Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CS149 Operating Systems Agustin Araya 1 What Are the Major Pieces of Functionality of an OS? ... • Running programs ==> Process management • Managing main memory ==> Memory management • Manipulating files (... hard disk) ==> Storage management 2 (Cont.) • Dealing with I/O devices (e.g., printers, keyboard...) ==> Managing I/O systems • Providing security • Dealing with distributed systems 3 What is an Operating System? • A program that acts as an intermediary between a user of a computer and the computer hardware 4 Operating System Goals 1 To execute user programs and make it easy for the user to solve problems (with the help of a computer) ...another way of saying it: make the computer system convenient to use 2 To use the computer hardware in an efficient manner 5 A Look Behind the Scene... | 6 A Look Behind the Scene... | 7 A Look Behind the Scene... OS | 8 What Do We Mean by a Computer System? • We just said that a goal of an OS is to make computer systems easy to use... • But what is a computer system? 9 (Cont.) • A computer system consists of four major components... • Hardware • provides basic computing resources • e.g.: CPU, memory, I/O devices • Operating system • controls and coordinates use of hardware among various applications and users 10 (Cont.) • System and Application programs ...define the ways in which the system resources are used to solve the computing problems of the users ...e.g.: word processors, compilers, web browsers, database systems, video games • Users • e.g.: people, machines, other computers 11 The Four Components of a Computer System 12 13 Important design issue: what to put in the OS and what to leave as system program 14 Unix systems: small OS... Microsoft's OSs: very large OS... 15 Operating System Definitions • 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 16 E.g.: several Operating System Definitions programs need to run. They • OS is a resource allocator compete for the • manages all resources CPU, for memory • 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 17 (Cont.) • No universally accepted definition of what an OS is composed of • “Everything a vendor ships when you order an operating system” is a good approximation • but varies wildly • Another definition: The OS is “the one program running at all times on the computer” (the kernel) • everything else is either a system program (ships with the operating system) or an application program 18 What should be part of the kernel? Should the kernel be as small as possible (a microkernel)? 19 Different Situations • A user using a personal computer (PC)... • A user using a mainframe • by means of a terminal • other users are simultaneously connected • A user using a workstation, more powerful than a PC • connected to servers • some resources are shared (e.g., print servers) • A user using a PDA (personal digital assistant) 20 Different Situations • A user using a personal computer (PC)... • A user using a mainframe which are the OS goals for each situation? • by means of a terminal • other users are simultaneously connected • A user using a workstation, more powerful than a PC • connected to servers • some resources are shared (e.g., print servers) • A user using a PDA (personal digital assistant) 21 Different Situations • A user using a personal computer (PC)... • A user using a mainframe ease of use (+resource utilization) • by means of a terminal • other users are simultaneously connected • A user using a workstation, more powerful than a PC • connected to servers • some resources are shared (e.g., print servers) • A user using a PDA (personal digital assistant) 22 Different Situations • A user using a personal computer (PC)... • A user using a mainframe • by means of a terminal S maximize resource utilization • other users are simultaneously connected • A user using a workstation, more powerful than a PC • connected to servers • some resources are shared (e.g., print servers) • A user using a PDA (personal digital assistant) 23 Different Situations S • A user using a personal computer (PC)... • A user using a mainframe • by means of a terminal • other users are simultaneously connected ease of use anda PC • A user using a workstation, more powerful than resource • connected to servers utilization • some resources are shared (e.g., print servers) • A user using a PDA (personal digital assistant) 24 Different Situations S • A user using a personal computer (PC)... • A user using a mainframe • by means of a terminal • other users are simultaneously connected • A user using a workstation, more powerful than a PC • connected to servers • some resources are shared (e.g., print servers) ease of use, battery • A user using a PDA (personal digital assistant) performance 25 (Cont.) ==> Different situations lead to different OS goals 26 Computer System Organization • Background knowledge for understanding OSs... • Review of some basic concepts in computer organization 27 Computer System Organization (the h/w components) 28 The OS is a program that manages these components Computer System Organization (the h/w components) 29 Computer System Organization From an OS point (the h/w components) of view, we are interested in an abstract view of these components 30 Computer System Organization device controllers (hardware) 31 The OS interacts Computer System Organization with the controllers, rather than with the devices themselves 32 Computer System Organization execute concurrently 33 (Cont.) • Computers have evolved toward increasing concurrency • because it leads to higher resource utilization 34 Computer System Organization Bus 35 Computer System Organization shared memory 36 Interactions of the I/O Devices with CPU (Processor), Memory, and OS • Suppose a program requests to read (or write) data from (to) a file • How is the information transferred from the file (in hard disk) to the appropriate addresses of the memory allocated to the program (or vice versa)? • The OS will perform key steps of this process... Note: In this context, interactions with I/O devices refer to interactions with I/O device controllers 37 OS Responsibilities with Respect to I/O Devices • If the user (who activated the program) can only read the file, but not write on it ...the OS needs to ensure the program can only use the appropriate functionality of the I/O device • The OS does not allow the program to directly access the device ...rather, it provides appropriate commands (abstractions) ...and corresponding routines for executing those commands on the I/O device 38 (Cont.) • The OS must give commands to the I/O devices to perform the desired operations • At the same time, the OS needs to deal with the interrupts triggered by the I/O devices ...it is through interrupts that those devices communicate with the OS ...e.g., to indicate that an operation terminated or that an error occurred • Finally, the transfer of data between the device and memory must take place... 39 How the OS Gives Commands to I/O Devices. Different Approaches 1 By means of memory-mapped I/O ...certain parts of the address space have been assigned to I/O devices (rather than to memory) ...so, if such an address is put in the bus, the corresponding device controller records it and passes it to the device as a command In other words, commands to the I/O devices are given by reading and writing on those addresses... 40 (Cont.) 2 Or, by means of specific I/O instructions in the processor • (see next slide) 41 Communication Between the Processor and the I/O Device • Example: a basic printer that prints only one character at a time • The status register of the printer has: • a ‘done’ bit: set to 1 when the printer has printed a character • an ‘error’ bit: set to 1 to indicate there is a problem with the printer • e.g.: no paper... 42 (Cont.) • The data register of the printer contains the character to be printed • Before passing the next character to be printed the processor must check (poll) the status register... 43 (Cont.) • Polling: “periodically checking status bits to see if it is time for the next I/O operation” • But polling has a problem • what is it? ... ...the processor wastes time checking the status • What is the alternative approach to polling? ... ...interrupts... 44 Interrupt Mechanism • Varies with different computers, but the basic functionality is similar • Events requiring immediate attention from the processor are indicated by means of an interrupt • Example: an I/O interrupt... ...the device controller informs the CPU that it has finished its operation by sending a signal through the bus 45 (Cont.) • The CPU must pay immediate attention to the interrupt • The processors' fetch-execute cycle checks to see if an "interrupt flag" has been set • For different interrupts, the CPU must do something different • This is achieved by the CPU activating the appropriate interrupt service routine (see next slide) 46 How the CPU reacts to the interrupt? • An interrupt vector (a table...) containing the addresses of each of those service routines is used • it is stored in memory (e.g., in the first 100 locations) • When an interrupt is sent, an appropriate index into the interrupt vector is given with it • ...in this way the address of the corresponding service routine is obtained • and the service routine is activated 47 (Cont.) • After servicing the interrupt the CPU should continue doing what it was doing earlier... • Hence, it must save the address of the instruction the CPU was executing when interrupted 48 Coming back to the example of the simple printer (Now using interrupts) • ...the printer that prints one character at a time... • First, the CPU sends the character to be printed to the printer • Second, the printer prints it • Third, the printer sends an I/O interrupt to the CPU • Fourth, the CPU activates the interrupt service routine to handle the interrupt... 49 A More Detailed Analysis • Device controllers play a role in transferring data between I/O devices and memory • The device controller (a piece of h/w) has: • special-purpose registers and • buffer storage • ...and it is in charge of transferring data between the I/O device and its own buffer • The OS interacts with the device controller by means of a device driver (a piece of software) 50 (Cont.) • The I/O operation starts with the device driver putting appropriate info’ in the device controller’s registers • Depending on the info’ the controller moves the data from the device (e.g., a hard disk) to its own buffer (or vice versa) • By means of an interrupt, the device controller informs the device driver that the operation ended • If the operation was a read, the OS would then proceed to transfer the data from the controller’s buffer to memory 51 (Cont.) Issue: • This approach based on interrupts could produce too much overhead if the amount of data to be transferred is large • That is, the CPU becomes too directly involved in the I/O transference Alternative approach: • ‘direct memory access’... (see next slide) 52 Direct Memory Access • The device controller itself transfers the data between its own buffer and memory! • the CPU does not intervene • The data is transferred in blocks (rather than in bytes) • when the transfer has concluded, the device controller sends an interrupt to the device driver • In this way, far fewer interrupts are generated and the CPU can do other things 53 Simplified Interactions data transfers CPU I/O request interrupt Memory direct memory access Device 54 Hierarchy of Storage Devices • Fast storage is expensive and volatile • Slow storage is cheap and non-volatile • CPU registers • Cache memory (memory buffer within the CPU) • Main Memory (Memory/Random access mem.) • Magnetic disk • Magnetic tapes 55 Hierarchy of Storage Devices S • Fast storage is expensive and volatile • Slow storage is cheap and non-volatile • CPU registers • Cache memory (memory buffer within the CPU) • Main Memory (Memory/Random access mem.) • Magnetic disk • Magnetic tapes less expensive 56 Hierarchy of Storage Devices S • Fast storage is expensive and volatile • Slow storage is cheap and non-volatile • CPU registers volatile • Cache memory (memory buffer within the CPU) • Main Memory (Memory/Random access mem.) • Magnetic disk • Magnetic tapes 57 Hierarchy of Storage Devices S • Fast storage is expensive and volatile • Slow storage is cheap and non-volatile • CPU registers • Cache memory (memory buffer within the CPU)volatile • Main Memory (Memory/Random access mem.) • Magnetic disk • Magnetic tapes nonvolatile 58 Other Basic Concepts S • The instruction-execution cycle... • etc 59 So far... S • We have been talking about the basic components of a computer and their interactions • Now we will say a word about how those components can be put together ==> Computer architecture 60 Computer Architecture S • Single processor • Multi-processor • increased throughput • increased reliability 61 (Cont.) S • Symmetric multi-processing • all processors are the same, with the same responsibilities • Asymmetric multi-processing • there is a master processor • the rest of the processors perform specific tasks, and follow the orders of the master 62 Summary. Important Concepts • • • • • Operating system goals Components of a Computer System What is an OS Different kinds of Computer Systems (personal computer, mainframe, handheld...) • Computer System organization • Interactions of the I/O Devices with CPU (Processor), Memory, and OS 63 Summary. Important Concepts • • • • Interrupt Mechanism Direct Memory Access Hierarchy of Storage Devices Computer architecture: single- and multiprocessing 64