960 likes | 983 Views
Explore the basic organization, structure, and operations of computer systems with a focus on operating systems. Dive into components like process, memory, and storage management, as well as protection and security measures.
E N D
OPERATING SYSTEM CONCEPTS 操作系统概念 张 柏 礼 bailey_zhang@sohu.com 东南大学计算机学院
课程介绍 • 教材:《操作系统概念(第七版 影印版)》 • Operating System Concepts(Seventh Edition) • 【原出版社】John Wiley & Sons,Incl. • 【作者】(美)Abraham Silberschatz(西尔伯查茨) & Peter Baer Galvin & Greg Gagne • 【丛书名】国外优秀信息科学与技术系列教学用书 • 【出版社】高等教育出版社 • 【出版日期】2007-3
课程介绍 • 参考书 • 1、计算机操作系统 • 汤子瀛等 西安电子科技大学出版社 • 2、现代操作系统教程 • 滕至阳 高等教育出版社(光盘) • 3、Modern Operation Systems • Andrew S. Tanenbaum 机械工业出版社
课程介绍 • 学时:64学时 • 考核方式 • 闭卷考试 • 成绩评定: • 期末考试成绩 • 期中考试成绩 • 平时成绩(课堂、实验、作业、出勤等) • 答疑 • 计算机楼232(周一、周三、周五) • bailey_zhang@sohu.com
Chapter 1: Introduction • Objectives • To provide coverage of basic computer system organization • To provide a grand tour of the major operating systems components
Chapter 1: Introduction • 1.1 What Operating Systems Do • 1.2 Computer-System Organization • 1.3 Computer-System Architecture • 1.4 Operating-System Structure • 1.5 Operating-System Operations • 1.6 Process Management • 1.7 Memory Management • 1.8 Storage Management • 1.9 Protection and Security • 1.10 Distributed Systems • 1.11 Special-Purpose Systems • 1.12 Computing Environments
1.1 What Operating Systems Do • Computer system can be divided into four components • 1. Hardware • CPU, memory, I/O devices • provides basic computing resources • 2. Operating system • Controls and coordinates the use of hardware among various applications and users • Like a government, provides an environment within which other programs can do useful work
1.1 What Operating Systems Do • 3. Application programs • are used to solve users’ problems • Word processors, compilers, web browsers, database systems, video games • 4. Users • People, other computers, machines/devices
1.1 What Operating Systems Do • Operating System’s Role • User View • PC Users: an operating system is a program that provides an easy-to-use interface for using the hardware • Convenience is more important • Mainframe/Minicomputer Users: an operating system is a program that helps maximize the system resource utilization • Efficiency / utilization is more important • Workstation Users: an operating system is a program designed to compromise(权衡) between individual usability and resource utilization
1.1 What Operating Systems Do • System View • OS is a resource allocator / resource manager • Resources:CPU time,memory space,I/O device,file,etc. • allocates and reclaims the system resources to and from user programs • Resolve conflicting requests for resources • Operate computer system efficiently and fairly. • OS is a control program • Controls execution of programs to prevent errors and improper use of the computer
1.1 What Operating Systems Do • Operating System Definition • Definition 1 • One program running at all times on the computer(i.e., the kernel) • Everything else is either a system program (ships with the operating system) or an application program
1.1 What Operating Systems Do • Definition 2 • A program that acts as an intermediary (中介)between the application programs and the computer hardware. • Executes user programs and make user problems easy to solve. • Makes the computer system convenient to use. • Use the computer hardware in an efficient manner.
Chapter 1: Introduction • 1.1 What Operating Systems Do • 1.2 Computer-System Organization • 1.3 Computer-System Architecture • 1.4 Operating-System Structure • 1.5 Operating-System Operations • 1.6 Process Management • 1.7 Memory Management • 1.8 Storage Management • 1.9 Protection and Security • 1.10 Distributed Systems • 1.11 Special-Purpose Systems • 1.12 Computing Environments
1.2 Computer-System Organization • A modern general-purpose computer system • Consisted of one or more CPUs and a number of device controllers • Connected through a common bus that provides access to shared memory
1.2 Computer-System Organization • Computer-system operation • Concurrent operation • CPU • fetches a instruction and executes it. • moves data from/to main memory to/from local buffers of device control • Each device controller • is in charge of a particular device type. • has a local buffer • I/O operation moves data from/to the device to/from local buffers of control • informs CPU that it has finished its operation by causing an interrupt.
1.2 Computer-System Organization • The CPU and I/O device controllers can execute concurrently competing for memory cycles • A memory controller is provided to synchronize access to the memory
1.2 Computer-System Organization • Initial operation • Bootstrap/initial program • is typically stored in ROM or EPROM, generally known as firmware(固件) • Is loaded at power-up or reboot • Initializes all aspects of system • Loads operating system kernel into memory • The operating system starts executing the first process and waits for some event to occur
1.2 Computer-System Organization • Interrupt • An operating system is interrupt driven • The occurrence of the event is usually signaled by an interrupt • The interrupt is triggered by either hardware or software (system call) • Interrupt must save the address of the interrupted instruction • Interrupt transfers control to the interrupt service routine through the interruptvector • After the interrupt is completed, the CPU resumes the interrupted computation
1.2 Computer-System Organization • Interrupt Time Line For a Single Process Doing Output
1.2 Computer-System Organization • Storage Structure • Main memory (RAM) • Be 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
1.2 Computer-System Organization • The main differences among the various storage systems lies in • Speed • size • Volatility(易失性) • Cost
1.2 Computer-System Organization • I/O Structure • Synchronous I/O • After I/O starts, control does not return to the user program until I/O completion. • How to wait for I/O completion: • Wait instruction idles the CPU until the next interrupt. • Wait loop • Asynchronous I/O • After I/O starts, control returns to user program without waiting for I/O completion
1.2 Computer-System Organization • DMA (direct memory access) • 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
1.2 Computer-System Organization How a Modern Computer Works
Chapter 1: Introduction • 1.1 What Operating Systems Do • 1.2 Computer-System Organization • 1.3 Computer-System Architecture • 1.4 Operating-System Structure • 1.5 Operating-System Operations • 1.6 Process Management • 1.7 Memory Management • 1.8 Storage Management • 1.9 Protection and Security • 1.10 Distributed Systems • 1.11 Special-Purpose Systems • 1.12 Computing Environments
1.3 Computer-System Architecture • Single-processor system • Most systems use a single general-purpose processor • The systems range from PDAs through mainframes • Executing a general-purpose instruction sets • Almost all system have other special-purpose processors • Disk, keyboard and graphics controllers • Executing a limited instruction set and can not run user process
1.3 Computer-System Architecture • Multi-processor system • Have two or more general-purpose processors, sharing the computer bus and sometimes the clock, memory, and peripheral devices • Also known as parallel systems, tightly-coupled systems(强耦合系统) • growing in use and importance • Advantages include • Increased throughput(吞吐量) • Economy of scale(经济性) • Increased reliability –fault tolerance(可靠性-容错能力) • Two types • Asymmetric Multiprocessing—master/slave • Symmetric Multiprocessing (SMP)
1.3 Computer-System Architecture Symmetric Multiprocessing Architecture A Dual-Core Design
1.3 Computer-System Architecture • Clustered system • Gather multiple individual machines via a LAN or a faster interconnect to accomplish work • Advantages is like multiprocessor systems • High reliability / availability • Increased throughput • Asymmetric clustering • One is in hot-standby mode, and monitoring others • Others are running the applications • Symmetric clustering • multiple nodes are running applications, and are monitoring each other
Chapter 1: Introduction • 1.1 What Operating Systems Do • 1.2 Computer-System Organization • 1.3 Computer-System Architecture • 1.4 Operating-System Structure • 1.5 Operating-System Operations • 1.6 Process Management • 1.7 Memory Management • 1.8 Storage Management • 1.9 Protection and Security • 1.10 Distributed Systems • 1.11 Special-Purpose Systems • 1.12 Computing Environments
1.4 Operating-System Structure • Modern Operating Systems’ commonalities(共性) • Operating systems vary greatly in their makeup for being organized along different lines • But exist many commonalities, the important aspects include: • Multiprogramming(多道) • Time sharing (分时多任务)
1.4 Operating-System Structure • Multiprogramming • Single user/program cannot keep CPU and I/O devices busy at all times • Such as DOS • Multiprogramming organizes multiple jobs (code and data) so CPU always has one to execute • A subset of total jobs in system is kept in memory
1.4 Operating-System Structure • One job is selected and run via job scheduling • When the running job has to wait (for I/O operation to complete, for example), OS switches to another job • As long as at least one job needs to execute, the CPU is never idle • Multiprogramming is needed for system efficiency • it increases the system resources utilization (for example CPU, memory, and peripheral devices). • Is very suitable for batch computer system
1.4 Operating-System Structure • Time sharing(Multitasking) • is logical extension of Multiprogramming • Multiprogramming systems don’t need to provide for users a well interaction with the computer system • Interactive computer system • Provides direct communication between user and the system • The user gives instructions to the system directly, using an input device such as a keyboard or a mouse • waits for immediately results on an output device, Response time should be short, typically less than one second
1.4 Operating-System Structure • Time sharing operating system • Provide each user/job with a short time in turn • Allows many users share the computer simultaneously • The CPU execute multiple jobs by switching rapidly • The switches occur so frequently that users can interact with each job (give instructions and get response )while it is running • Gives users the impression: the entire computer system is dedicated to his use.
1.4 Operating-System Structure • New problems/concepts are presented • A time-shared operating system provide each user with a time slice. Each user has at least one program in memory process (chapter3) • If several jobs ready to run at the same time CPU scheduling (chapter5) • If processes don’t fit in memory, swapping(chapter8)moves them in and out to run • Virtual memory (chapter9) allows execution of processes not completely in memory
Chapter 1: Introduction • 1.1 What Operating Systems Do • 1.2 Computer-System Organization • 1.3 Computer-System Architecture • 1.4 Operating-System Structure • 1.5 Operating-System Operations • 1.6 Process Management • 1.7 Memory Management • 1.8 Storage Management • 1.9 Protection and Security • 1.10 Distributed Systems • 1.11 Special-Purpose Systems • 1.12 Computing Environments
1.5 Operating-System Operations • Interrupt • Modern operating system is interrupt driven • An operating system is waiting for something to happen • Events is usually signaled by an hardware interrupt or a trap • A trapis a software-generated interrupt caused either by an error or a user request • Errors:division by zero or invalid memory access • a user request : request for operating system service (system call) • A interrupt service routine is provided for dealing with interrupt
1.5 Operating-System Operations • Dual-modeoperation • allows OS to protect itself and other system components • The hardware and software are shared by the OS and users • an incorrect program cannot cause other programs to execute incorrectly • infinite loop • modifying the data/code of other programs or the operating system
1.5 Operating-System Operations • User modeand kernel mode • User mode • execution done on behalf of a user • Kernel mode • also Monitor mode or system mode or privileged mode • execution done on behalf of operating system. • Mode bitprovided by hardware • monitor (0) or user (1). • Provides ability to distinguish when system is running user code or kernel code
1.5 Operating-System Operations • Some instructions designated as privileged instructions, only executable in monitor mode • System call changes mode to kernel, and resets mode to user
1.5 Operating-System Operations • Timer • to prevent a user program from • Getting stuck infinite loop not calling system services and never returning control to OS • Be set to interrupt the computer after a specific period • Period may be fixed (ex. 1/60 second) or variable (ex. from 1ms to 1s) • A variable timer is generally implemented by fixed-rate clock and a counter • The OS sets the counter • Every the clock ticks, the counter is decremented • When counter reaches 0, an interrupt occurs
1.5 Operating-System Operations • Use timer to prevent a user program from running too long • Before passing control to the user, the OS initialize acounter with the amount of time that a program (the user program) is allowed to run • If the timer interrupts, the control transfers back to the OS, which may treat the interrupt as a fatal error or may give the program more time • As long as the counter is positive, control is returned to the user program • If the counter is negative, the OS terminate program that exceeds allowed time
Chapter 1: Introduction • 1.1 What Operating Systems Do • 1.2 Computer-System Organization • 1.3 Computer-System Architecture • 1.4 Operating-System Structure • 1.5 Operating-System Operations • 1.6 Process Management • 1.7 Memory Management • 1.8 Storage Management • 1.9 Protection and Security • 1.10 Distributed Systems • 1.11 Special-Purpose Systems • 1.12 Computing Environments
1.6 Process Management • Process • is a program in execution • Is a job in memory or a time-share program • A process needs certain resources to accomplish its task • The resources include • CPU time, memory, I/O device, files, • Initialization data • argc, argv,such as input file name • These resources are • either given when process is created • or allocated when process is running • These resources are • reclaimed by the OS when the process terminates
1.6 Process Management • Process and program • Program is a passive entity • A file stored on disk • process is an active entity • single-threaded process has one program counter specifying the next instruction to execute • A multi-threaded process has multiple program counters, each pointing to the next instruction to execute for a given thread. • Although two process may be associated with the same program, but they are two separate execution sequences
1.6 Process Management • Process is a unit of work within the system • A system consists of a collection of processes • Some are operating system processes (those execute system code) • Rest are user processes (those execute user code) • All those processes can potentially run concurrently on one or more CPUs
1.6 Process Management • 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
Chapter 1: Introduction • 1.1 What Operating Systems Do • 1.2 Computer-System Organization • 1.3 Computer-System Architecture • 1.4 Operating-System Structure • 1.5 Operating-System Operations • 1.6 Process Management • 1.7 Memory Management • 1.8 Storage Management • 1.9 Protection and Security • 1.10 Distributed Systems • 1.11 Special-Purpose Systems • 1.12 Computing Environments