1 Agustin Araya CS149 Operating Systems
2... Running programs ==> Process management Managing main memory ==> Memory management Manipulating files (... hard disk) ==> Storage management What Are the Major Pieces of Functionality of an OS?
3 Dealing with I/O devices (e.g., printers, keyboard...) ==> Managing I/O systems Providing security Dealing with distributed systems (Cont.)
4 What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware
5 Operating System Goals 1To 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 2To use the computer hardware in an efficient manner
6 A Look Behind the Scene... |
7 |
8 | OS
9 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?
10 (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
11 (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
12 The Four Components of a Computer System
13
14 Important design issue: what to put in the OS and what to leave as system program
15 Unix systems: small OS... Microsoft's OSs: very large OS...
16 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
17 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 Operating System Definitions E.g.: several programs need to run. They compete for the CPU, for memory
18 (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
19 What should be part of the kernel? Should the kernel be as small as possible (a micro- kernel)?
20 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) Different Situations
21 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) Different Situations which are the OS goals for each situation?
22 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) Different Situations ease of use (+resource utilization)
23 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) Different Situations maximize resource utilization S
24 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) Different Situations ease of use and resource utilization S
25 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) Different Situations ease of use, battery performance S
26 ==> Different situations lead to different OS goals (Cont.)
27 Background knowledge for understanding OSs... Review of some basic concepts in computer organization Computer System Organization
28 Computer System Organization (the h/w components)
29 Computer System Organization (the h/w components) The OS is a program that manages these components
30 Computer System Organization (the h/w components) From an OS point of view, we are interested in an abstract view of these components
31 Computer System Organization device controllers (hardware)
32 Computer System Organization The OS interacts with the controllers, rather than with the devices themselves
33 Computer System Organization execute concurrently
34 (Cont.) Computers have evolved toward increasing concurrency because it leads to higher resource utilization
35 Computer System Organization Bus
36 Computer System Organization shared memory
37 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 Interactions of the I/O Devices with CPU (Processor), Memory, and OS
38 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 OS Responsibilities with Respect to I/O Devices
39 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... (Cont.)
40 1By 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... How the OS Gives Commands to I/O Devices. Different Approaches
41 2Or, by means of specific I/O instructions in the processor (see next slide) (Cont.)
42 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... Communication Between the Processor and the I/O Device
43 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... (Cont.)
44 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... (Cont.)
45 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
46 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) (Cont.)
47 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 How the CPU reacts to the interrupt?
48 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 (Cont.)
49...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... Coming back to the example of the simple printer (Now using interrupts)
50 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) A More Detailed Analysis
51 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 (Cont.)
52 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) (Cont.)
53 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 Direct Memory Access
54 Simplified Interactions CPUMemory Device I/O request interrupt direct memory access data transfers
55 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 Hierarchy of Storage Devices
56 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 Hierarchy of Storage Devices less expensive S
57 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 Hierarchy of Storage Devices volatile S
58 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 Hierarchy of Storage Devices volatile non- volatile S
59 The instruction-execution cycle... etc Other Basic Concepts S
60 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 So far... S
61 Single processor Multi-processor increased throughput increased reliability Computer Architecture S
62 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 (Cont.) S
63 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
64 Summary. Important Concepts Interrupt Mechanism Direct Memory Access Hierarchy of Storage Devices Computer architecture: single- and multi- processing