Operating System Overview Tarek Abdelzaher Lawrence Angrave Vikram Adve Copyright ©: Nahrstedt, Angrave, Abdelzaher
Today’s Objectives By the end of the hour you should be able to: Copyright ©: Nahrstedt, Angrave, Abdelzaher Today’s Objectives By the end of the hour you should be able to: Explain the main purpose of operating systems and describe milestones of OS evolution Explain fundamental machine concepts such as: Instruction processing, Memory hierarchy, Interrupts, and I/O Explain fundamental OS concepts such as: System calls, processes, synchronization, Files Explain the POSIX standard (UNIX specification)
Copyright ©: Nahrstedt, Angrave, Abdelzaher Today’s Applications Application Software Browser Second Life Yahoo Chat Client Pop Mail Hardware Network
Application Requirements Copyright ©: Nahrstedt, Angrave, Abdelzaher Application Requirements Application Software Browser Second Life Yahoo Chat Client Pop Mail Store Read/write Display Print Send/receive Hardware Network
Application Requirements Copyright ©: Nahrstedt, Angrave, Abdelzaher Application Requirements Application Software Browser Second Life Yahoo Chat Client Pop Mail Store Read/write Display Print Store Read/write Display Print Send/receive Send/receive Hardware Network
Application Requirements Copyright ©: Nahrstedt, Angrave, Abdelzaher Application Requirements Application Software Browser Second Life Yahoo Chat Client Pop Mail Store Read/write Display Print Print Store Store Send/receive Read/write Display Print Display Send/receive Send/receive Read/write Hardware Network
Application Requirements Copyright ©: Nahrstedt, Angrave, Abdelzaher Application Requirements Application Software Browser Second Life Yahoo Chat Client Pop Mail Read/write Store Display Print Store Print Store Store Send/receive Send/receive Read/write Display Print Display Send/receive Send/receive Display Read/write Read/write Print Hardware Network
Delegate Common Functions? Copyright ©: Nahrstedt, Angrave, Abdelzaher Delegate Common Functions? Application Software Browser Second Life Yahoo Chat Client Pop Mail Read/write Store Display Print Store Print Store Store Send/receive Send/receive Read/write Display Print Display Send/receive Send/receive Display Read/write Read/write Print Hardware Network
Delegate Common Functions to an Operating System Copyright ©: Nahrstedt, Angrave, Abdelzaher Delegate Common Functions to an Operating System Application Software Web Server Second Life Yahoo Chat Pop Mail Operating System Read/Write Standard Output Device Control File System Communication Hardware Network
OS Exports a Virtual Machine Interface Copyright ©: Nahrstedt, Angrave, Abdelzaher OS Exports a Virtual Machine Interface Application Software Web Server Second Life Yahoo Chat Pop Mail Standard Operating System Interface (Virtual Machine) Operating System Read/Write Standard Output Device Control File System Communication Hardware Network
Increase Portability = Minimize Machine-Specific Code Copyright ©: Nahrstedt, Angrave, Abdelzaher Increase Portability = Minimize Machine-Specific Code Application Software Web Server Second Life Yahoo Chat Pop Mail Standard Operating System Interface (Virtual Machine) Operating System (machine independent part) Read/Write Standard Output Device Control File System Communication Machine specific part Hardware Network
Increase Portability = Minimize Machine-Specific Code Copyright ©: Nahrstedt, Angrave, Abdelzaher Increase Portability = Minimize Machine-Specific Code Application Software Web Server Second Life Yahoo Chat Pop Mail Standard Operating System Interface (Virtual Machine) Operating System (machine independent part) Portable Read/Write Standard Output Device Control File System Communication Machine specific part Hardware Network
OS Runs on Multiple Platforms while Presenting same Interface Copyright ©: Nahrstedt, Angrave, Abdelzaher OS Runs on Multiple Platforms while Presenting same Interface Application Software Web Server Second Life Yahoo Chat Pop Mail Standard Operating System Interface (Virtual Machine) Operating System (machine independent part) Portable Read/Write Standard Output Device Control File System Communication
OS Runs on Multiple Platforms while Presenting same Interface Copyright ©: Nahrstedt, Angrave, Abdelzaher OS Runs on Multiple Platforms while Presenting same Interface Application Software Web Server Second Life Yahoo Chat Pop Mail Standard Operating System Interface (Virtual Machine) Operating System (machine independent part) Portable Read/Write Standard Output Device Control File System Communication Machine specific part Hardware Network
POSIX – The UNIX Interface Standard Copyright ©: Nahrstedt, Angrave, Abdelzaher POSIX – The UNIX Interface Standard Application Software Web Server Second Life Yahoo Chat Pop Mail The POSIX Standard Specifies UNIX Interface Operating System (machine independent part) Portable Read/Write Standard Output Device Control File System Communication Machine specific part Hardware Network
A peek into Unix Application Libraries User space/level Copyright ©: Nahrstedt, Angrave, Abdelzaher A peek into Unix Application Libraries User space/level Kernel space/level Portable OS Layer Machine-dependent layer User/kernel modes are supported by hardware Some systems do not have clear user-kernel boundary
Unix: Application Application (E.g., emacs) Libraries Copyright ©: Nahrstedt, Angrave, Abdelzaher Unix: Application Application (E.g., emacs) Written by programmer Compiled by programmer Uses function calls Libraries Portable OS Layer Machine-dependent layer
Unix: Libraries Application Libraries (e.g., stdio.h) Copyright ©: Nahrstedt, Angrave, Abdelzaher Unix: Libraries Application Provided pre-compiled Defined in headers Input to linker (compiler) Invoked like functions Libraries (e.g., stdio.h) Portable OS Layer Machine-dependent layer
Typical Unix OS Structure Copyright ©: Nahrstedt, Angrave, Abdelzaher Typical Unix OS Structure Application Libraries Machine-dependent layer Portable OS Layer system calls (read, open..) All “high-level” code
Typical Unix OS Structure Copyright ©: Nahrstedt, Angrave, Abdelzaher Typical Unix OS Structure Application Bootstrap System initialization Interrupt and exception I/O device driver Memory management Kernel/user mode switching Processor management Libraries Portable OS Layer Machine-dependent layer
Summary: What is an Operating System? Copyright ©: Nahrstedt, Angrave, Abdelzaher Summary: What is an Operating System? It is an extended machine Hides the messy details which must be performed Presents user with a virtual machine, easier to use It is a resource manager Each program gets time with the resource Each program gets space on the resource
History of Operating Systems Copyright ©: Nahrstedt, Angrave, Abdelzaher History of Operating Systems Early systems bring cards to 1401 read cards to tape put tape on 7094 which does computing put tape on 1401 which prints output Batch Multiprogramming Time sharing Personal
History of Operating Systems Copyright ©: Nahrstedt, Angrave, Abdelzaher History of Operating Systems Structure of a typical job – 2nd generation
History of Operating Systems Copyright ©: Nahrstedt, Angrave, Abdelzaher History of Operating Systems Multiprogramming/timesharing system three jobs in memory – 3rd generation
History of Operating Systems Copyright ©: Nahrstedt, Angrave, Abdelzaher History of Operating Systems Memory Management Process Management Multiprogramming/timesharing system three jobs in memory – 3rd generation
History of Computer Generations Copyright ©: Nahrstedt, Angrave, Abdelzaher History of Computer Generations First generation 1945 – 1955 vacuum tubes, plug boards Second generation 1955 - 1965 transistors, batch systems Third generation 1965 – 1980 ICs and multiprogramming Fourth generation 1980 – present personal computers
Computer Hardware Review Copyright ©: Nahrstedt, Angrave, Abdelzaher Computer Hardware Review Bus Components of a simple personal computer
Computer Hardware Review Copyright ©: Nahrstedt, Angrave, Abdelzaher Computer Hardware Review CPU Bus Components of a simple personal computer
Copyright ©: Nahrstedt, Angrave, Abdelzaher CPU Fetch instruction from code memory Fetch operands from data memory Perform operation (and store result) Go to next instruction
Copyright ©: Nahrstedt, Angrave, Abdelzaher CPU Registers Fetch instruction from code memory Fetch operands from data memory Perform operation (and store result) Go to next instruction Note: CPU must maintain certain state Current instructions to fetch (program counter) Location of code memory segment Location of data memory segment
Copyright ©: Nahrstedt, Angrave, Abdelzaher CPU Register Examples Hold instruction operands Point to start of Code segment Data segment Stack segment Point to current position of Instruction pointer Stack pointer
Code Layout for Process Copyright ©: Nahrstedt, Angrave, Abdelzaher Code Layout for Process Processes have three segments: text, data, stack
Copyright ©: Nahrstedt, Angrave, Abdelzaher Memory Hierarchy Typical memory hierarchy numbers shown are rough approximations (old generation of computers)
Computer Hardware Review Copyright ©: Nahrstedt, Angrave, Abdelzaher Computer Hardware Review CPU Memory Bus Components of a simple personal computer
Computer Hardware Review Copyright ©: Nahrstedt, Angrave, Abdelzaher Computer Hardware Review CPU Memory I/O Devices Bus Components of a simple personal computer
Computer Hardware Review Example I/O Device: Disk Copyright ©: Nahrstedt, Angrave, Abdelzaher Computer Hardware Review Example I/O Device: Disk Structure of a disk drive
Example of modern architecture Copyright ©: Nahrstedt, Angrave, Abdelzaher Example of modern architecture Graphics Processor MPEG Comp. Digital Video Copper Fibre Channel Network Interface Fibre Channel Network Interface IEEE 1394 Discrete IO IO CPU+Multi- Level Cache PCI Bus 0a PCI Bus 1a Shared Memory Ethernet RS-485 PCI Bus 0b PCI Bus 1b System Controller Power PC clocked @ 1000 MHz 64 Bit Wide Memory Bus 256 MB DDR SDRAM Clocked @ 125 MHz 64 Bit PCI-X Clocked @ 100 MHz 32 Bit PCI Clocked @ 66 MHz Clocked @ 33 MHz PCI to PCI Bridge PCI-X to PCI Bridge Port 1 Port 2 Inactive
Interrupts CPU hardware has the interrupt report line that the CPU senses after executing each instruction Why interrupts? Real life analogy for interrupts An alarm sets off when the food/laundry is ready You can do other things in between and handle the event once notified
Operating System Review: Processes Copyright ©: Nahrstedt, Angrave, Abdelzaher Operating System Review: Processes A process tree A created two child processes, B and C B created three child processes, D, E, and F
Copyright ©: Nahrstedt, Angrave, Abdelzaher Context Switching How would you switch CPU execution from one process to another?
Semaphores (synchronization) Copyright ©: Nahrstedt, Angrave, Abdelzaher Semaphores (synchronization) Control access to shared resources (like shared data structures) Prevent race conditions, synchronize access to shared resources. Needed for concurrent programming (we will discuss a lot about this topic)
Copyright ©: Nahrstedt, Angrave, Abdelzaher Why Synchronization? Processes and threads can be preempted at arbitrary times, which may generate problems. Example: What is the execution outcome of the following two threads (initially x=0)? Thread 1: Read X Add 1 Write X Thread 2: Read X Add 1 Write X 42
Copyright ©: Nahrstedt, Angrave, Abdelzaher Why Synchronization? Example: What is the execution outcome of the following two threads (initially x=0)? Depending on the execution order of thread 1 and 2, the outcome can be x=1 or x=2. Thread 1: Read X Add 1 Write X Thread 2: Read X Add 1 Write X 43
Inter-process Communication Copyright ©: Nahrstedt, Angrave, Abdelzaher Inter-process Communication Two processes connected by a pipe