700 likes | 986 Views
Advanced Operating Systems. Mehdi Naghavi naghavi@iust.ac.ir Winter 1385. Course motivation and goals. Programming computer hardware directly is difficult Operating systems provide a layer between applications and computer hardware (VM)
E N D
Advanced Operating Systems Mehdi Naghavi naghavi@iust.ac.ir Winter 1385
Course motivation and goals • Programming computer hardware directly is difficult • Operating systems provide a layer between applications and computer hardware (VM) • Understanding operating system concepts is essential to many advanced programming tasks
Class outline • Introduction and Overview • Processes and threads • Operating system structures • Memory management • Scheduling • Input/Output • File Systems • Security
Textbook • Andrew S. Tanenbaum. “Operating Systems design and implementation”, 3nd ed., Prentice Hall, 2006. • Abraham Silberschatz, Galvin, and Gagne. “Operating Systems Concepts”, 7nd ed., John Wiley and Sons, 2005 • William Stallings. “Operating Systems”, 4nd ed., Prentice Hall, 2001. • Andrew S. Tanenbaum. “Modern Operating Systems”, 2nd ed., Prentice Hall, 2001. • Andrew S. Tanenbaum. “Distributed Operating Systems”, Prentice Hall.
Mobile Phones, pagers and other similar devices OFF during class Collegians must be Presence in classroom Contact naghavi@iust.ac.ir naghavi@aut.ac.ir Points
Operating Systems Introduction to Operating Systems Mehdi Naghavi naghavi@aut.ac.ir Winter 1385
Overview: • What is an operating system? • Operating systems history • The zoo of modern operating systems • Review of computer hardware • Operating system concepts • System calls • Operating system structure • User interface to the operating system • Anatomy of a system call
IBSYS (IBM 7090) OS/360 (IBM 360) TSS/360 (360 mod 67) Michigan Terminal System CP/CMS & VM 370 MULTICS (GE 645) Alto (Xerox PARC) Pilot (Xerox STAR) CP/M IRIX Solaris MVS VxWorks MACH Apollo DOMAIN Unix (System V & BSD) Apple Mac (v. 1– v. 9) MS-DOS Windows NT, 2000, XP Novell Netware Linux FreeBSD PalmOS PocketPC VxWorks Samples of Operating Systems
What is an Operating System? • An Operating System is a program that acts as an intermediary/interface between a user of a computer and the computer hardware. • 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
The Operating System controls the machine Debugger Compiler User OS Kernel Video Game Hard ware Application App. Editor Operating System … Terminal emulator Hardware Browser
Static View of System Components … User 1 User 2 User 3 User 4 User n Compiler Editor Database Calculator WP Operating System Hardware
End User Programmer Operating- System Designer Layers of a Computer System Application Programs Utilities Operating-System Computer Hardware
History of Operating Systems • First generation: 1945 – 1955 • Vacuum tubes, Plug boards • Second generation: 1955 – 1965 • Transistors, Batch systems • Third generation: 1965 – 1980 • Integrated circuits, Multiprogramming • Fourth generation: 1980 – present • Large scale integration, Personal computers • Next generation: ??? • Systems connected by high-speed networks? • Wide area resource management?
First generation: direct input • Run one job at a time • Enter it into the computer (might require rewiring!) • Run it • Record the results • Problem: lots of wasted computer time! • Computer was idle during first and last steps • Computers were very expensive! • Goal: make better use of an expensive commodity: computer time
Second generation: batch systems • Bring cards to 1401 • Read cards onto input tape • Put input tape on 7094 • Perform the computation, writing results to output tape • Put output tape on 1401, which prints output
$END $RUN $LOAD $FORTRAN $JOB, 10,6610802, JANE DOE Structure of a typical 2nd generation job Data forprogram FORTRANprogram
Third generation: multiprogramming • Multiple jobs in memory • Protected from one another • Operating system protected from each job as well • Resources (time, hardware) split between jobs • Still not interactive • User submits job • Computer runs it • User gets results minutes (hours, days) later Job 3 Job 2 Memorypartitions Job 1 Operatingsystem
CPU Multi tasking • Resource utilization • Multiprogramming, multitasking, and multiple users. • Time sharing. • Response time. Operating System Main Memory Job 1 Task 1 Task 2 Job 2 Job 3
Timesharing • Multiprogramming allowed several jobs to be active at one time • Initially used for batch systems • Cheaper hardware terminals → interactive use • Computer use got much cheaper and easier • No more “priesthood” • Quick turnaround meant quick fixes for problems
Types of modern operating systems • Mainframe operating systems: MVS • Server operating systems: FreeBSD, Solaris • Multiprocessor operating systems: Cellular IRIX • Personal computer operating systems: XP, Linux • PDA operating systems: PalmOS, PocketPC • Real-time/embedded operating systems: VxWorks, QNX • Smart card operating systems • Some operating systems can fit into more than one category
Computer Hardware Review • Computer block diagram • Components of a simple personal computer • CPU internals • Memory • Storage pyramid • Disk drive structure • Anatomy of a device request • Structure of a large Pentium system
Keyboard Mouse Scanner Modem Input Unit Computer CPU Monitor Printer Modem Output Unit Control Unit ALU Registers Bank Cache Memory Memory Main Memory RAM ROM Secondary Memory HD FD CD Flash TertiaryMemory Tape
ComputerComponents: Top-Level View • MAR - Memory Address Register • address for next read or write • MBR - Memory Buffer Register • data to be written into memory • receives data read from memory • I/OAR - I/O Address • specifies a particular I/O device • I/OBR - I/O Buffer • exchange of data between an I/O module and the processor
Components of a simple personal computer Outsideworld Videocontroller Hard drivecontroller USBcontroller Networkcontroller CPU Computer internals(inside the “box”) Memory
CPU internals Executeunit Fetchunit Decodeunit Holding buffer Executeunit Fetchunit Decodeunit Executeunit Fetchunit Decodeunit Executeunit (a) A three-stagePipelined CPU (b) ASuperscalar CPU
Memory Address Address 0x0002ffff 0x0002ffff User 2 programand data User 2 data 0x0002d000 Limit2 0x0002b000 0x0002bfff User 1 data Base2 0x00029000 Limit 0x00027fff User 1 programand data Limit1 0x00024fff User program 0x00023000 Base Base1 0x00023000 0x0001dfff 0x0001dfff Operatingsystem Operatingsystem • Single base/limit pair: set for each process • Two base/limit registers: one for program, one for data 0x00000000 0x00000000
Registers Cache (SRAM) Main memory (DRAM) Magnetic disk Magnetic tape Storage pyramid Capacity Access latency < 1 KB 1 ns Better 1 MB 2–5 ns 1 GB 50 ns 200 GB 5 ms > 1 TB 50 sec • Goal: really large memory with very low latency • Latencies are smaller at the top of the hierarchy • Capacities are larger at the bottom of the hierarchy • Solution: move data between levels to create illusion of large memory with low latency Better
Disk drive structure head • Data stored on surfaces • Up to two surfaces per platter • One or more platters per disk • Data in concentric tracks • Tracks broken into sectors • 256B-1KB per sector • Cylinder: corresponding tracks on all surfaces • Data read and written by heads • Actuator moves heads • Heads move in unison sector platter track cylinder surfaces spindle actuator
Anatomy of a device request Instructionn 3 2 Instructionn+1 1: Interrupt CPU 5 Interruptcontroller Diskcontroller Operatingsystem 1 6 4 3: Return Interrupt handler • Left: sequence as seen by hardware • Request sent to controller, then to disk • Disk responds, signals disk controller which tells interrupt controller • Interrupt controller notifies CPU • Right: interrupt handling (software point of view) 2: Process interrupt
Operating system Components • Process Management • Memory Management • File Management • I/O Management • Process Scheduler • Inter Process Communication • Network Unit • Command Interpreter • Security Management
Modern Operating System Structure Application Application Application Shared Runtime Libraries user-mode supervisor-mode System Call Interface memory manager task manager file manager network manager Device Driver Components OS Kernel Hardware
Processes • Process: program in execution • Address space (memory) the program can use • State (registers, including program counter & stack pointer) • OS keeps track of all processes in a process table • Processes can create other processes • Process tree tracks these relationships • A is the root of the tree • A created three child processes: B, C, and D • C created two child processes: E and F • D created one child process: G A B C D E F G
Memory image of a Unix process • Processes have three segments • Text: program code • Data: program data • Statically declared variables • Areas allocated by malloc() or new (heap) • Stack • Automatic variables • Procedure call information • Address space growth • Text: doesn’t grow • Data: grows “up” • Stack: grows “down” 0x7fffffff Stack Data Data Text 0x00000000
Synchronization and deadlock (b) An Actual deadlock (a) A Potential deadlock
Hierarchical file systems File system for a university department
Mounting • Before mounting, • files on floppy are inaccessible • After mounting floppy on b, • files on floppy are part of file hierarchy
Inter-process communication • Processes may want to exchange information with each other • Many ways to do this, including • Network • Pipe (special file): A writes into pipe, and B reads from it Process Process A B Pipe Two processes connected by a pipe
Types of OS structures • Monolithic system • Layered system • Virtual machine • Exokernel • Client/Server
Monolithic system Mainprocedure ServiceProcedures UtilityProcedures Simple structuring model for a monolithic system
Applications User space Kernel space System call interface Kernel MM PS IPC FS … I/O Net Monolithic system… MM = Memory Manager PS = Processor Scheduler IPC = Inter Process Communication FS = File System I/O = Input/Output manager Net = Network manager
User Layer 5 User Application Layer 4 User space I/O Management Hardware Kernel space Layer 3 Message Interpreter Layer 2 Memory Management Layer 1 Process Scheduling Layer 0 Layered system Structure of the THE operating system
Virtual machine App1 App2 App3 System calls Linux Windows NT FreeBSD I/O instructions CMS (VMW) CMS(VMW) CMS (VMW) Calls to simulate I/O VM/370 “Real” I/O instructions Bare hardware • First widely used in VM/370 with CMS (Conversational Monitor System) • Available today in VMware • Allows users to run any x86-based OS on top of Linux or NT • “Guest” OS can crash without harming underlying OS • Only virtual machine fails—rest of underlying OS is fine • “Guest” OS can even use raw hardware • Virtual machine keeps things separated