Operating System Concepts 作業系統原理

Slides:



Advertisements
Similar presentations
1 I/O 设备访问方式和类型. 2 Overview n The two main jobs of a computer: l I/O (Input/Output) l processing n The control of devices connneted to the computer is.
Advertisements

Information Resource Management
存储基础知识 V1.1.
Chapter 3: Operating-System Structures操作系统结构
CHAPTER 9 虛擬記憶體管理 9.2 分頁需求 9.3 寫入時複製 9.4 分頁替換 9.5 欄的配置法則 9.6 輾轉現象
Foundations of Computer Science
Chapter 17 數位革命與全球電子市場 Global Marketing Warren J. Keegan Mark C. Green.
创新实验 课程说明 计算机学院 孙彤 计算机学院 张明.
操作系统结构.
CHAP 2 Computer-System Structures 计算机系统结构
Chapter 2: Computer-System Structures计算机系统结构
最新計算機概論 第3章 計算機組織.
天文望远镜集成建模研究 杨德华 南京天文光学技术研究所 30 NOV, 年中国虚拟天文台年会 广西师范大学 桂林
Operating System Process Management - 4 Monday, August 11, 2008.
Leftmost Longest Regular Expression Matching in Reconfigurable Logic
Operating System CPU Scheduing - 2 Monday, August 11, 2008.
CHT Project Progress Report
Operating System CPU Scheduing - 3 Monday, August 11, 2008.
CH.2 Introduction to Microprocessor-Based Control
Operating System Concepts 作業系統原理
Chapter 5 電腦元件 目標---- 研讀完本章後,你應該可以: 閱讀有關電腦的廣告以及了解它的專業用語(行話)。
第 4 章 記憶單元.
雲端運算虛擬主機技術的發展.
Operating System Concepts 作業系統原理 Chapter 3 行程觀念 (Process Concept)
網路技術管理進階班---區域網路的技術發展
操作系统课程的特点: 实践性强(从实践总结出原理)
電腦的種類 超級電腦 (supercomputer) 大型電腦 (Mainframe) 迷你電腦 ( Mini computer)
第一篇 Unix/Linux 操作介面 第 1 章 Unix/Linux 系統概論 第 2 章 開始使用 Unix/Linux
Applied Operating System Concepts
作 業 系 統 第三組 楊育翰 顏瑞霖.
Chapter 3 Case Studies.
5 Computer Organization (計算機組織).
SOLUTIONACCELERATORS Windows Vista Hardware Assessment 1
Operating System Concepts 作業系統原理 CHAPTER 2 系統結構 (System Structures)
Draft Amendment to STANDARD FOR Information Technology -Telecommunications and Information Exchange Between Systems - LAN/: R: Fast BSS.
Flash数据管理 Zhou da
Operating System Internals and Design principles
Computer Organization
Chapter 3 行程觀念 (Process Concept)
微程序控制器 刘鹏 Dept. ISEE Zhejiang University
创建型设计模式.
ICT RTOS Research Group 胡伟平,王剑
Ch 9: Input/Output System 输入/输出系统
SAP 架構及基本操作 SAP前端軟體安裝與登入 Logical View of the SAP System SAP登入 IDES
預官考試輔導 計算機概論提要 91年12月4日.
Chapter 4 多執行緒 (Multi Thread)
「寬頻匯流網路管理」教材 模組四: 第一章 網路管理架構
第1章 單晶片微電腦概論.
校園網路架構介紹與資源利用 主講人:趙志宏 圖書資訊館網路通訊組.
第4章(1) 空间数据库 —数据库理论基础 北京建筑工程学院 王文宇.
Operating System Principles 作業系統原理
資料結構 Data Structures Fall 2006, 95學年第一學期 Instructor : 陳宗正.
資料庫 靜宜大學資管系 楊子青.
高性能计算与天文技术联合实验室 智能与计算学部 天津大学
Real-Time System Software Group Lab 408 Wireless Networking and Embedded Systems Laboratory Virtualization, Parallelization, Service 實驗室主要是以系統軟體設計為主,
Operation System(OS).
中国科学技术大学计算机系 陈香兰 2013Fall 第七讲 存储器管理 中国科学技术大学计算机系 陈香兰 2013Fall.
虚 拟 仪 器 virtual instrument
中国科学技术大学计算机系 陈香兰 Fall 2013 第三讲 线程 中国科学技术大学计算机系 陈香兰 Fall 2013.
NASA雜談+電腦網路簡介 Prof. Michael Tsai 2015/03/02.
Process Description And Control
CHAPTER 6 Concurrency:deadlock And Starvation
SAP 架構及基本操作 SAP前端軟體安裝與登入 Logical View of the SAP System SAP登入 IDES
Operating System Software School of SCU
Race Conditions and Semaphore
SAP 架構及前端軟體安裝 Logical View of the SAP System SAP Frontend 7.1安裝 SAP登入
MGT 213 System Management Server的昨天,今天和明天
Introduction to Computer Security and Cryptography
Chapter 4 Multi-Threads (多執行緒).
第三章 计算机体系结构.
Presentation transcript:

Operating System Concepts 作業系統原理 Authors: Abraham Silberschatz, Peter Baer Galvin, Greg Gagne Chapter 1: Introduction Instructor : Min-Shiang Hwang (黃明祥) Office: I-420 Tel : 1864 E-mail : mshwang@asia.edu.tw Skype: minshiang Facebook:http://www.facebook.com/mshwang (mshwang@nchu.edu.tw)

Chapter 1: Introduction What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management Memory Management Storage Management Protection and Security Distributed Systems Special-Purpose Systems Computing Environments Open-Source Operating Systems

Objectives 使學生瞭解一個作業系統的組成及電腦系統基本結構 To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization 使學生瞭解一個作業系統的組成及電腦系統基本結構

What is an Operating System? 1.1 What Operating Systems Do What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware Operating system goals: Execute user programs and make solving user problems easier Make the computer system convenient to use Use the computer hardware in an efficient manner 作業系統 (Operating system) 是介於使用者與電腦硬體之間的管理軟體。 目的在於提供使用者—便利有效的執行程式環境。做為計算機系統資源的管理者,以有效的管理方式來使用硬體的原動力,提供使用者可執行程式的方便環境。

Four Components of a Computer System 一個電腦系統分成四個單元:硬體(Hardware)、作業系統(Operating System)、應用程式(Application Program)、使用者(User)。 編譯程式 組譯程式 本文編輯器 資料庫系統 CPU (Central Processing Unit)、 記憶體(Memory)、輸入/輸出裝置(I/O)

Computer System Structure Computer system can be divided into four components Hardware – provides basic computing resources CPU, memory, I/O devices Operating system Controls and coordinates use of hardware among various applications and users Application programs – define the ways in which the system resources are used to solve the computing problems of the users Word processors, compilers, web browsers, database systems, video games Users People, machines, other computers

1.1.1 User View of Operating Systems Mainframe view: to maximize “resource utilization”, to that all available CPU time, memory, and I/O are used efficiently, and that no individual user takes more than her fair share. 大型電腦的使用者認為 OS 應做資源使用的最大化 Workstation or Server view: to compromise between individual usability and resource utilization 兼顧使用方便性與有效的管理資源 PC view: OS is designed mostly for “ease of use”, with some attention paid to performance, and none paid to resource utilization 個人用電腦使用者認為 OS 應提供容易使用的介面

User View of Operating Systems Handheld view: mostly for individual usability, but performance per amount of battery life is important. 有使用電池及顯示螢幕大小的限制,因此OS 應只考 慮使用的方便性以及電池的壽命的問題。 Embedded system view: (嵌入式系統) have little or no user view. OS is designed to run without user intervention 根本不需要使用者介面 資源(軟硬體)容易使用(ease of use)、有效分享發揮資源(resource utilization)

1.1.2 System View of Operating System OS is a resource allocator - Manages all resources - Decides between conflicting requests for efficient and fair resource use 是資源分配者,會以有效率且公平的方式來管理與分配 系統資源。 OS is a control program Controls execution of programs to prevent errors and improper use of the computer 監督使用者程式的執行,避免程式發生錯誤或使用不當。 資源分配者(resource allocator) ; 控制程式(control program) - CPU時間、記憶體空間、檔案儲存空間、 I/O裝置

1.1.3 Defining Operating System No universally accepted definition “Everything a vendor ships when you order an operating system” is good approximation But varies wildly “The one program running at all times on the computer” is the kernel. Everything else is either a system program (ships with the operating system) or an application program 一個在電腦內部隨時都在執行的程式(核心 Kernel)(系統程式 & AP) 對於OS 並沒有一個完整適合的定義,通常說 OS 是用來 Controlling 與 Allocating 系統資源。 OS 是一個 Kernel ( 核心程式),因為隨時須要有它的存在。 一個 OS 是使用者與硬體的介面,做為電腦系統資源的管理者 ,以有效的管理方式來使用硬體,提供使用者可執行程式的環 境。

1.2 Computer-System Organization 1.2.1 Computer-system operation (計算機系統的運作) One or more CPUs, device controllers connect through common bus providing access to shared memory Concurrent execution of CPUs and devices competing for memory cycles 近代電腦系統包含單一或多個CPU和一些裝置控制器。經由公用Bus(匯流排)存取共用記憶體。 監視器 磁碟控制器 USB控制器 圖形顯示卡

Computer-System Operation I/O devices and the CPU can execute concurrently Each device controller is in charge of a particular device type Each device controller has a local buffer CPU moves data from/to main memory to/from local buffers I/O is from the device to local buffer of controller Device controller informs CPU that it has finished its operation by causing an interrupt 每一種I/O device 有專屬的device controller 實際操作設備的使用程序。 device controller 需要專屬軟體來指揮它們,這些軟體叫做驅動程式(device driver)。驅動程式對controller 下命令指揮它們完成輸出入工作。 因此,OS 透過driver 來控制與指揮device controller 對週邊設備做實際的I/O 動作。Controller 利用「中斷(Interrupt)」告訴 OS 工作已完成。

Computer Startup bootstrap program (啟動程式) is loaded at power-up or reboot Typically stored in ROM or EPROM, generally known as firmware (軔體) Initializes all aspects of system Loads operating system kernel and starts execution 啟動OS 執行的最初程式稱為initial program 或bootstrap program 或IPL (Initial Program Loading),俗稱為開機程式。 啟動程式(bootstrap program)存於唯讀記憶體(ROM: Read-only Memory)或可消除式唯讀記憶體(EEPROM: Electrically Erasable Programmable ROM)[通常稱為韌體firmware]。 開機後OS 會偵測系統的週邊設備,逐一載入每一種設備的驅動程式(Driver)。 開機程式的作用是: (a) 設定系統初值或參數,包括CPU registers,device controllers,memory等等。(b) 從硬碟將作業系統核心載入記憶體。(c) 啟動OS 的執行。 啟動OS 後所執行的第一個process 稱為init,init 會產生許多幕後的login process 在那兒等候事件的發生,完成開機的程序。

The Concept of Interrupts The occurrence of an event is signaled by an interrupt from either hardware or software. Hardware may trigger an interrupt at any time by sending a signal to CPU. Software may trigger an interrupt by system call (monitor call) I/O device 產生的中斷訊號來告訴OS 現在I/O 工作已經完成,I/O devices 包括滑鼠與鍵盤。 Software interrupt 又稱為trap (陷阱),是經由system call 產生的中斷。常見的trap有:(a) divide-by-zero,(b) invalid memory access,(c) illegal instruction,(d) a request for OS service。

Common Functions of Interrupts Interrupt transfers control to the interrupt service routine generally, through the interrupt vector (中斷向量), which contains the addresses of all the service routines (中斷服務程式). Interrupt architecture must save the address of the interrupted instruction Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt A trap is a software-generated interrupt caused either by an error or a user request An operating system is interrupt driven OS 是中斷驅動,藉由interrupts 來產生相關的動作。中斷是當代計算機的重要結構設計。

Interrupt Handling The operating system preserves the state of the CPU by storing registers and the program counter Determines which type of interrupt has occurred: polling vectored interrupt system Separate segments of code determine what action should be taken for each type of interrupt 中斷發生時,硬體將被中斷程式的暫存器以及return address 儲存在一個固定位置上,以便將來能夠恢復原來的執行工作。 中斷的處理程序是:CPU 暫時終止目前的工作,立即移轉到固定的記憶體位置上,此位置含有interrupt vector,interrupt vector 儲存interrupt service routine的起始位址。CPU 根據這個位址去執行相關的服務工作。

Interrupt Timeline 硬體可以在任何時間藉由送給 CPU 一個信號觸發中斷。軟體可以藉由執行一項特殊的系統呼叫(system call,也叫做 monitor call) 觸發中斷。 Process: 行程、處理 CPU 與I/O 可同時進行,CPU 啟動I/O 動作,I/O 完成後會發出中斷給CPU。

1.2.2 Storage Structure Main memory – only large storage media that the CPU can access directly Secondary storage – extension of main memory that provides large nonvolatile storage capacity Magnetic disks – rigid metal or glass platters covered with magnetic recording material Disk surface is logically divided into tracks, which are subdivided into sectors The disk controller determines the logical interaction between the device and the computer 任何要被執行的程式都必須儲存在可複寫記憶體,稱之為主記憶體 又叫做隨機存取記憶體 (Random-Access Memory或RAM)。以動態隨機存取記憶體(DRAM: Dynamic RAM)的半導體技術製作而成。 load 指令從主記憶體搬移一個字元組(Byte)到 CPU 內部的暫存器,而 store 指令則是搬移暫存器的內容到主記憶體。 大部份電腦系統提供輔助記憶體 ( secondary storage) 做為主記憶體的延伸。輔助記憶體的主要要求是能夠永久保存大量的資料。

Magnetic Disk

Storage Hierarchy Storage systems organized in hierarchy Speed Cost Volatility Caching – copying information into faster storage system; main memory can be viewed as a last cache for secondary storage 不同儲存系統間的主要差別是︰速度、價格、大小和揮發性(Volatile)。揮發性:Power Off Data Lose 裝置快取記憶體(Cache)可以改善因為兩種元件之間的存取時間或傳輸速率差別所造成的性能差別。 Cache 又稱為buffer memory 是一種成本高且速度快的儲存設備。CPU 欲讀取資料會先檢查資料是否在cache,若是稱之為hit,可立即取出使用;否則稱之為no hit,必須到記憶體取出資料同時更新cache 的內容。

Storage-Device Hierarchy Capacity 容量 Cost 價格 Speed 速度 Volatile ------------- Nonvolatile 慢 低 大

Electronic Disk 電子磁碟(electronic disk) 被設計成同時具有volatile 與nonvolatile storages,這是由一個很大的DRAM array 及一個隱藏的硬碟所組成的。通常資料只儲存於DRAM,當停電或關機時,資料才被儲存於硬碟上。 Flash memory 也是屬於電子磁碟,常用於digital camera 與PDA中,存取速度比DRAM 慢,但不耗電可保存資料。 NVRAM (Non-Volatile RAM)是DRAM 加上電池組,是nonvolatile,速度比DRAM快。

How a Modern Computer Works 1.2.3 I/O Structure How a Modern Computer Works 指令執行週期 執行的執行緒 指令與資料 每一種裝置控制器負責特定週邊設備的輸出入工作,每一個裝置控制器有自己的local buffer 及一些暫存器,負責處理I/O 與local buffer之間的資料搬動。 (用在處理 小量資料) DMA: Direct Memory Access (Device與記憶體直接存取) Device SCSI: Small Computer Systems Interface (用在處理大量資料) Device Driver 所有的I/O 是由CPU 啟動的。CPU 根據I/O 的類別呼叫相關的device driver,由device driver 將訊息與參數載入於device controller 的registers中,並對controller下達輸出入命令,由device controller 對週邊設備做實際I/O 動作。I/O 完成後由device controller 發出interrupt 訊號告訴CPU。

Direct Memory Access Structure Used for high-speed I/O devices able to transmit information at close to memory speeds Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention Only one interrupt is generated per block, rather than the one interrupt per byte DMA 是一種專門為high speed devices 做輸出入的設備。它的作業程序是:首先由CPU 預設好I/O 所需要的buffer、pointer 與counter 後,由CPU啟動DMA controller,讓DMA 自行去做記憶體與buffer 之間的大量資料讀寫的工作,而不用CPU 的干預。每當讀寫完一筆資料後,才由DMA controller 發出中斷告訴CPU 工作已完成,接著再由CPU 重新設定buffer、pointer 與counter,繼續啟動DMA 做後續的輸出入工作。

Caching Important principle, performed at many levels in a computer (in hardware, operating system, software) Information in use copied from slower to faster storage temporarily Faster storage (cache) checked first to determine if information is there If it is, information used directly from the cache (fast) If not, data copied to cache and used there Cache smaller than storage being cached Cache management important design problem Cache size and replacement policy

1.3 Computer-System Architecture (電腦系統架構) 1.3.1 Single-Processor Systems (單一處理器系統) - Most systems use a single general-purpose processor (PDAs through mainframes) - Most systems have special-purpose processors as well 僅有一個一般處理器執行使用者的處理行程之系統。

1.3.2 Multiprocessor Systems (多處理器系統) Multiprocessors systems growing in use and importance Also known as parallel systems, tightly-coupled systems Advantages include Increased throughput Economy of scale Increased reliability – graceful degradation or fault tolerance Two types Asymmetric Multiprocessing Symmetric Multiprocessing 擁有一個以上的處理器,共同使用匯流排、時脈、記憶體、周邊裝置。 使用多處理器系統有三個優點:1. 增加產量 2.經濟度量(共用周邊設備) 3. 增加可信度(容錯性: Fault Tolerant)。

Symmetric Multiprocessing Architecture 目前有兩種類別:1. 非對稱多元處理(asymmetric multiprocessing)-主處理器會指定每個處理器不同之任務,有主從關係 2.對稱多元處理(symmetric multiprocessing, SMP)-每個處理器執行相同之任務,沒有主從關係。

A Dual-Core Design (雙核心設計) 單一晶片 雙核心設計比二元處理器還有效率(內部通信)及省電。

1.3.3 Clustered Systems (集成式系統) Like multiprocessor systems, but multiple systems working together Usually sharing storage via a storage-area network (SAN) Provides a high-availability service which survives failures Asymmetric clustering has one machine in hot-standby mode Symmetric clustering has multiple nodes running applications, monitoring each other Some clusters are for high-performance computing (HPC) Applications must be written to use parallelization 集成式電腦分享儲存裝置,經由區域網路、無線寬頻網路彼此相連,可提供高的取得率(high-availability) 。 非對稱集成系統(asymmetric clustering)- 一台機器處於熱待機狀態(hot-standby mode)為一監督工作的伺服器, 其他機器則執行應用程式。 對稱集成系統(symmetric clustering)- 所有機器均執行應用程式並互相監督。

1.4 Operating System Structure (作業系統架構) Multiprogramming needed for efficiency Single user cannot keep CPU and I/O devices busy at all times Multiprogramming organizes jobs (code and data) so CPU always has one to execute A subset of total jobs in system is kept in memory One job selected and run via job scheduling (工作排班) When it has to wait (for I/O for example), OS switches to another job Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing Response time should be < 1 second Each user has at least one program executing in memory process If several jobs ready to run at the same time  CPU scheduling If processes don’t fit in memory, swapping moves them in and out to run Virtual memory allows execution of processes not completely in memory

Memory Layout for Multiprogrammed System 作業系統提供執行程式的環境,工作排班的最重要觀念就是多元程式規劃的能力。多元程式規劃 (multiprogramming)的目的就是讓CPU始終有工作做,以增加CPU的使用率。 作業系統在同一時間存放數項工作在記憶體中,這一組工作是工作池(job pool)中所有工作的部份集合,作業系統把工作池中的一項工作挑出來並且開始執行。 Time Sharing(分時)或Multitasking(多工)是常用的多元程式規劃技術。

1.5 Operating-System Operations (作業系統的運作) Interrupt driven by hardware Software error or request creates exception or trap Division by zero, request for operating system service Other process problems include infinite loop, processes modifying each other or the operating system 現代作業系統是中斷驅動式 (interrupt driven),如果沒有行程要執行,沒有I/O裝置要服務和沒有使用者需要回應,則作業系統將安靜進入等待事件發生;事件通常都是由於中斷或陷阱(Trap)的發生(如被0除)而被通知。 因為作業系統和使用者共用電腦系統中硬體和軟體的資源,在共用的情況下,一個程式中的錯誤(如Infinite Loop)可能會使許多工作受到不利影響。 一個設計正確的作業系統必須保證一個不正確的 (或蓄意破壞的)程式不會造成其他程式不正確的執行。

1.5.1 Dual-mode Operation (雙模式運作) Dual-mode operation allows OS to protect itself and other system components User mode and kernel mode Mode bit provided by hardware Provides ability to distinguish when system is running user code or kernel code Some instructions designated as privileged, only executable in kernel mode System call changes mode to kernel, return from call resets it to user 為了確保作業系統正常操作,一定要能夠區別作業系統程式碼和使用者定義程式碼的操作。 使用者模式 (user mode)和核心模式 (kernel mode或 supervisor mode,也稱為系統模式,system mode或特權模式,privileged mode)。 在系統啟動時,硬體必須由核心模式開始。然後載入作業系統,接者在使用者模式開始執行使用者應用程式。每當一個插斷或中斷(Interrupt)發生時,硬體從使用者模式轉換到核心模式,作業系統得到電腦的控制權時,電腦就是在核心模式中。使用者程式再將控制權交給一個使用者程式之前, 轉換到使用者模式。

Transition from User to Kernel Mode 1.5.2 Timer (計時器) Timer to prevent infinite loop / process hogging resources Set interrupt after specific period Operating system decrements counter When counter zero generate an interrupt Set up before scheduling process to regain control or terminate program that exceeds allotted time 必須保證作業系統維持控制;必須防止使用者程式陷入一個無窮迴路之中,而永遠不把控制權交還給作業系統。為達成此目的,可以使用一個計時器(timer) Transition from User to Kernel Mode

計時器設定在某段時間之後中斷電腦。其週期可以是固定的 (例如,1/60秒)或可變的(例如,從1毫秒到1秒)。 用計時器來防止使用者程式執行太久。簡單的技巧是用程式允許的時間量設定計數器之初值。例如,具有 7分鐘時間限制的程式設定計數器初值為420。每過 1秒鐘,計時器就會發出中斷且計數器值減 1。只要計數器值為正,控制權仍回到使用者程式。當計數器值擴成負值時,作業系統因為程式超過其時間限制而終止執行。

1.6 Process Management (行程管理) A process is a program in execution. It is a unit of work within the system. Program is a passive entity, process is an active entity. Process needs resources to accomplish its task CPU, memory, I/O, files Initialization data Process termination requires reclaim of any reusable resources Single-threaded process has one program counter specifying location of next instruction to execute Process executes instructions sequentially, one at a time, until completion Multi-threaded process has one program counter per thread Typically system has many processes, some user, some operating system running concurrently on one or more CPUs Concurrency by multiplexing the CPUs among the processes / threads 行程(process)可以視為執行中的程式,行程需要某些特定的資源,包括 CPU時間、記憶體、檔案和I/O裝置等,以完成其工作。這些資源在行程產生或執行時就會配置給它,除了實體資源和邏輯資源的配置之外,有些起始資料 (輸入)也可能會隨著行程的產生而產生。

Process Management Activities The operating system is responsible for the following activities in connection with process management: Creating and deleting both user and system processes Suspending and resuming processes Providing mechanisms for process synchronization Providing mechanisms for process communication Providing mechanisms for deadlock handling 行程管理方面,作業系統必須提供下列的功能: 在CPU上的行程及執行緒排班 使用者和系統行程的產生與刪除 行程的暫停和恢復 提供行程同步機制(process synchronization) 提供行程通信機制(process communication)

1.7 Memory Management (主記憶體管理) All data in memory before and after processing All instructions in memory in order to execute Memory management determines what is in memory when Optimizing CPU utilization and computer response to users Memory management activities Keeping track of which parts of memory are currently being used and by whom Deciding which processes (or parts thereof) and data to move into and out of memory Allocating and deallocating memory space as needed 程式執行時,主記憶體必須映對到絕對位址並且載入主記憶體之中。 程式執行時,藉由產生程式指令和資料的絕對位址,才能從記憶體存取。程式結束時,它釋放出記憶體為可用狀態,以及載入下一個程式並且執行它。 記憶體管理方面,作業系統必須具有下列的功能: 記錄正在使用的記憶體部份以及是誰在使用 在記憶體空間可用時決定載入的行程 在需要時配置和回收記憶體空間

1.8 Storage Management (儲存體管理) OS provides uniform, logical view of information storage Abstracts physical properties to logical storage unit - file Each medium is controlled by device (i.e., disk drive, tape drive) Varying properties include access speed, capacity, data-transfer rate, access method (sequential or random) 作業系統提供資訊儲存一個一致性的邏輯觀點,目的是為了讓使用者能更方便的使用電腦系統。 作業系統摘取儲存裝置的實體特性並將之定義成邏輯儲存 單元,也就是檔案

1.8.1 File-System Management (檔案系統管理) Files usually organized into directories Access control on most systems to determine who can access what OS activities include Creating and deleting files and directories Primitives to manipulate files and dirs Mapping files onto secondary storage Backup files onto stable (non-volatile) storage media 檔案的建立與刪除 檔案的目錄建立與刪除 處理(操作)檔案和目錄 檔案與輔助記憶體的對映(Mapping) 穩定(非揮發性non-volatile)儲存裝置上的檔案備份

1.8.2 Mass-Storage Management (大量儲存體管理) Usually disks used to store data that does not fit in main memory or data that must be kept for a “long” period of time Proper management is of central importance Entire speed of computer operation hinges on disk subsystem and its algorithms OS activities Free-space management (可用空間管理) Storage allocation (記憶體配置) Disk scheduling (磁碟排班) Some storage need not be fast Tertiary storage includes optical storage, magnetic tape Still must be managed Varies between WORM (write-once, read-many-times) and RW (read-write)

Performance of Various Levels of Storage 1.8.3 Caching (快取記憶體) Movement between levels of storage hierarchy can be explicit or implicit Performance of Various Levels of Storage

Migration of Integer A from Disk to Register Multitasking environments must be careful to use most recent value, no matter where it is stored in the storage hierarchy Multiprocessor environment must provide cache coherency in hardware such that all CPUs have the most recent value in their cache Distributed environment situation even more complex Several copies of a datum can exist Various solutions covered in Chapter 17 作業系統 硬體功能

1.8.4 I/O Subsystem (I/O 系統) One purpose of OS is to hide peculiarities (特質) of hardware devices from the user I/O subsystem responsible for Memory management of I/O including buffering (storing data temporarily while it is being transferred), caching (storing parts of data in faster storage for performance), spooling (the overlapping of output of one job with input of other jobs) (記憶體管理構成要素包括緩衝(buffering)、快取和連線同時週邊作業。) General device-driver interface (通用裝置驅動程式(Driver)介面) Drivers for specific hardware devices (特定硬體裝置驅動程式)

1.9 Protection and Security (保護與安全) Protection – any mechanism for controlling access of processes or users to resources defined by the OS Security – defense of the system against internal and external attacks Huge range, including denial-of-service, worms, viruses, identity theft, theft of service Systems generally first distinguish among users, to determine who can do what User identities (user IDs, security IDs) include name and associated number, one per user User ID then associated with all files, processes of that user to determine access control Group identifier (group ID) allows set of users to be defined and controls managed, then also associated with each process, file Privilege escalation allows user to change to effective ID with more rights 電腦系統有許多使用者並且允許同時執行多個行程,則存取資料必須井然有序。 為了這個目的,必須提供一些功能以確保檔案、記憶體區段、CPU和其它的資源只能經由作業系統所認可並授權的行程適當地操作。

1.10 Distributed Systems Distributed systems depend on networking for their functionality. Loosely coupled system – each processor has its own local memory; processors communicate with one another through various communications lines, such as high-speed buses or telephone lines. Advantages of distributed systems. - Resources Sharing - Computation speed up – load sharing - Reliability - Communications Requires networking infrastructure. Using Local area networks (LAN) or Wide area networks (WAN) or Metropolitan area networks (MAN) LAN 要求傳輸之速度快且錯誤率低,速度從1Mbps 到1Gbps,通常Ethernet 是10BaseT (10Mbps) 以及100BaseT (100Mbps)。WAN通常透過電話系統連結,典型的是T1 (1.544Mbps),T3 (28T1、45Mbps)。

1.11 Special-Purpose Systems (特殊用途系統) 1.11.1 即時嵌入系統(Real-time Embedded System) 嵌入式計算機是現存最普遍形式的計算機。這些裝置到處都可發現,從汽車引擎和製造用機器人到VCRs 和微波爐。監督和管理硬體裝置。 嵌入式系統通常大部份執行即時作業系統(real-time operating systems)。即時系統是使用在使用者對於處理器的操作或資料的傳送在時間要求上很嚴謹,因此它通常是用在專門應用範圍中的控制裝置。 感應器將資料傳送給電腦。電腦必須將資料加以分析,而且可能控制調整以便修正感應器輸入。 控制科學實驗、醫學影像系統、工業控制系統,以及一些顯示系統都屬於即時系統的例子。其它還有自動引擎燃料噴射系統、家用器具控制器,以及武器系統也是即時系統。

1.11.2 多媒體系統(Multimedia System) 大多數的作業系統被設計成處理傳統的資料,像是文字檔、程式、處理文字文件和試算表。 多媒體:MP3、DVD、視訊會議等。 1.11.3 手持系統(Handheld System) 手持系統包括了個人數位助理 (Personal digital assistants, PDAs),例如掌上型電腦與行動電話和許多使用特殊用途嵌入式作業系統。 手持系統和應用的發展者面臨到許多挑戰,大部份的限制都是因為這些裝置尺寸限制。

1.12 Computing Environments (計算環境) 1.12.1 Traditional computer (傳統計算Centralized System集中式) Blurring over time Office environment PCs connected to a network, terminals attached to mainframe or minicomputers providing batch and timesharing Now portals allowing networked and remote systems access to same resources Home networks Used to be single system, then modems Now firewalled, networked 系統不是整批式(Batch)就是交談式(Interactive)。整批式系統以預定方式輸入(從檔案或其它資料來源),處理了大多數的工作,交談式系統等候來自使用者的輸入。為了將計算資源的使用最佳化,多個使用者共用系統的時間。分時系統對這些系統使用了計時器和排班演算法以便快速地經過中央處理器循環程序給予每個使用者資源的分享。(Compiler vs. Interpreter)

Computing Environments (Cont) 1.12.2 Client-Server Computing (客戶-伺服器系統) Dumb terminals supplanted by smart PCs Many systems now servers, responding to requests generated by clients Compute-server (計算伺服器系統) provides an interface to client to request services (i.e. database) File-server (檔案伺服器系統) provides interface for clients to store and retrieve files

1.12.3 Peer-to-Peer Computing (對等式運算) Another model of distributed system P2P does not distinguish clients and servers Instead all nodes are considered peers May each act as client, server or both Node must join P2P network Registers its service with central lookup service on network, or Broadcast request for service and respond to requests for service via discovery protocol Examples include Napster and Gnutella 當節點參與網路,以集中式分佈服務在網路註冊它的服務。任何節點需要服務,首先接觸這個集中式分佈服務,來決定那一個節點提供服務,剩下來的通信在客戶端和服務提供者之間發生。 表現像客戶端的點,必須首先發現那一個節點提供需求服務,藉由播送服務的需求,給網路上所有其它的節點。節點提供回應需求的服務,為了支持這個方法,必須提供搜尋協定,讓點發現在網路上其它點所提供的服務。

1.12.4 Web-Based Computing (網頁為基礎的計算) Web has become ubiquitous PCs most prevalent devices More devices becoming networked to allow web access New category of devices to manage web traffic among similar servers: load balancers Use of operating systems like Windows 95, client-side, have evolved into Linux and Windows XP, which can be clients and servers 雲端作業系統Chrome 網頁客戶端(Windows 95,98)伺服器(Windows XP, Linux)。

1.13 Open-Source Operating Systems Operating systems made available in source-code format rather than just binary closed-source. Counter to the copy protection and Digital Rights Management (DRM) movement. Started by Free Software Foundation (FSF), which has “copyleft” GNU Public License (GPL). Examples include GNU/Linux, BSD UNIX (including core of Mac OS X), and Sun Solaris.