CS 217 - Operating Systems - PowerPoint PPT Presentation

cs 217 operating systems n.
Skip this Video
Loading SlideShow in 5 Seconds..
CS 217 - Operating Systems PowerPoint Presentation
Download Presentation
CS 217 - Operating Systems

play fullscreen
1 / 69
CS 217 - Operating Systems
Download Presentation
Download Presentation

CS 217 - Operating Systems

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. CS 217 - Operating Systems Introduction and Overview Lecture 02 Somia Razzaq NFC-IET Slides adopted from Silbershatz, Galvin and Gagne, VU

  2. Introduction • What Operating Systems Do • Different Kind of Systems and OS History • Computer-System Organization • Computer-System Architecture • Operating-System Structure • Operating-System Operations • Process Management • Memory Management • Storage Management • Protection and Security • Distributed Systems • Special-Purpose Systems • Computing Environments • Open-Source Operating Systems

  3. What is an Operating System? • A program that acts as an intermediary between a user of a computer and the computer hardware • Operating system goals: • Execute user programs and make solving user problems easier • Make the computer system convenient to use • Use the computer hardware in an efficient manner

  4. Single User Systems • Personal computers – computer system dedicated to a single user. • Interactive • User convenience and responsiveness. • Individuals usually have sole use of computer and do not need advanced protection features. • May run several different types of operating systems (Windows, MacOS, UNIX, Linux)

  5. Batch Systems • First rudimentary system. • User  operator • Reduce setup time by batching similar jobs • Automatic job sequencing – automatically transfers control from one job to another. • Resident monitor : • initial control in monitor • control transfers to job • when job completes control transfers back to monitor

  6. Memory Layout

  7. Multiprogrammed Systems Several jobs are kept in main memory at the same time, and the CPU is multiplexed among them.

  8. CPU I/O Burst Burst P1 P2 P1 P2 Multiprogrammed Systems Example: Two processes P1 and P2 with CPU and I/O bursts of one time unit each …

  9. OS Features Needed for Multiprogramming • SPOOLing (Simultaneous Peripheral Operation On-Line) • Memory management • CPU scheduling

  10. Time-sharing Systems • An interactive system with multiprogramming • A job is swapped in and out of memory to the disk if needed. • On-line file system must be available for users to access data and code.

  11. Real-time Systems • Well-defined fixed-time constraints. • Often used as a control device in a dedicated application such as controlling scientific experiments, medical imaging systems, industrial control systems, and some display systems. • Real-Time systems may be either hard or soft real-time.

  12. Real-time Systems … • Hard real-time systems: • Secondary storage limited or absent, data stored in short term memory, or read-only memory (ROM) • No virtual memory—time cannot be “wasted” on translation of logical to physical addresses • OS code structured for efficiency • Plane landing systems, processcontrol in nuclear power plants, respirators, etc • Soft real-time systems • Output should be produced within the given time constraints but if it is not, the result is not life threatening • Useful in applications (multimedia, virtual reality) requiring advanced operating-system features

  13. History

  14. History (…continued)

  15. Fathers of Operating System • There are two people considered the pioneers of Operating Systems • E.W. Dijkstra • P.B. Hansen

  16. Computer System Structure • Computer system can be divided into four components • Hardware – provides basic computing resources • CPU, memory, I/O devices • Operating system • Controls and coordinates use of hardware among various applications and users • Application programs – define the ways in which the system resources are used to solve the computing problems of the users • Word processors, compilers, web browsers, database systems, video games • Users • People, machines, other computers

  17. Four Components of a Computer System

  18. Operating System Definition • 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

  19. Operating System Definition (Cont.) • No universally accepted definition • “Everything a vendor ships when you order an operating system” is good approximation • But varies widely • “The one program running at all times on the computer” is the kernel. Everything else is either a system program (ships with the operating system) or an application program

  20. Computer Startup • bootstrap programis loaded at power-up or reboot • Typically stored in ROM or EPROM, generally known as firmware • Initializes all aspects of system • Loads operating system kernel and starts execution

  21. Computer System Organization • Computer-system operation • One or more CPUs, device controllers connect through common bus providing access to shared memory • Concurrent execution of CPUs and devices competing for memory cycles

  22. Computer-System Operation • I/O device controllers and the CPU can execute concurrently • Each device controller is in charge of a particular device type • Each device controller has a local buffer • CPU moves data from/to main memory to/from local buffers • I/O is from the device to local buffer of controller • Device controller informs CPU that it has finished its operation by causing an interrupt

  23. Interrupts, Traps and Signals • The occurrence of an event is usually signaled by an interrupt either by h/w or a s/w program • Hardware interrupt may occur at any time by sending a signal to CPU via system bus • Software interrupt may be triggered via a system call • A process can generate a trap, for example, by dividing a number by zero • A user or a process may generate a signal (an interrupt to a process) Answer the Phone

  24. Common Functions of Interrupts • Interrupt transfers control to the interrupt service routine generally, through the interruptvector, which contains the addresses of all the service routines • Interrupt architecture must save the address of the interrupted instruction • Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt • A trap is a software-generated interrupt caused either by an error or a user request • An operating system is interrupt driven

  25. Interrupt Handling • The operating system preserves the state of the CPU by storing registers and the program counter • Determines which type of interrupt has occurred • Separate segments of code determine what action should be taken for each type of interrupt

  26. Interrupt Timeline

  27. I/O Structure • Synchronous -- after I/O starts, control returns to user program only upon I/O completion: Wait loop: • Idles the CPU until the next interrupt • Contention for memory access • At most one I/O request is outstanding at a time, no simultaneous I/O processing • Asynchronous -- after I/O starts, control returns to user program without waiting for I/O completion • System call – request to the operating system to allow user to wait for I/O completion • Device-status table contains entry for each I/O device indicating its type, address, and state • Operating system indexes into I/O device table to determine device status and to modify table entry to include interrupt

  28. Two Methods of I/O

  29. Device Status Table

  30. Direct Memory Access Structure • 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 to tell the device driver of operation completion, rather than the one interrupt per byte • While the device controller performs these operations, the CPU is available for other jobs

  31. Storage Structure • Main memory – 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 CPU

  32. Storage Hierarchy • Storage systems organized in hierarchy • Speed • Cost • Volatility • Caching – copying information into faster storage system; main memory can be viewed as a last cache for secondary storage

  33. Storage-Device Hierarchy

  34. Caching • Important principle, performed at many levels in a computer (in hardware, operating system, software) • Information in use copied from slower to faster storage temporarily • Faster storage (cache) checked first to determine if information is there • If it is, information used directly from the cache (fast) • If not, data copied to cache and used there • Cache smaller than storage being cached • Cache management important design problem • Cache size and replacement policy

  35. Computer-System Architecture • Most systems use a single general-purpose processor (PDAs through mainframes) • Most systems have special-purpose processors as well • Multiprocessors systems growing in use and importance • Also known as parallel systems, tightly-coupled systems • Advantages include • Increased throughput • Economy of scale • Increased reliability – graceful degradation or fault tolerance • Two types • Asymmetric Multiprocessing – Master-Slave architecture • Symmetric Multiprocessing – All processors work as peers

  36. Asymmetric Multiprocessing • Master-Slave relationship • Each processor is assigned a specific task • A master processor works as the controller – schedules and allocates work to other processors • Other processor (slaves) either look to the master for instructions or have predefined tasks

  37. Symmetric Multiprocessing • Peer to peer relationship • Each processor performs all tasks • Each processor has its own registers and local cache • All share memory • N processes can run simultaneously if there are N CPUs • I/O needs a careful control for data to reach appropriate processor • Load balancing and performance tuning needs to be handled

  38. Symmetric Multiprocessing Architecture

  39. Difference between Symmetric and Asymmetric multiprocessing may result from either hardware or software. • Special hardware may be used or • Special software may be written to allow only one master and multiple slaves • Example: • Sun’s OS ver 4 (SunOS) allows Asymmetric • Sun’s OS ver 5 (Solaris) allows Symmetric multiprocessing on same hardware

  40. A Dual-Core Design • More efficient: on chip vs. between chips communication • Requires less power • More suited for database and web-servers • Other designs might use a shared cache or a combination of local and shared caches • Multi-core CPUs appear to the OS as N standard processors

  41. Clustered Systems • Like multiprocessor systems, but multiple systems working together • Objective: High availability service • Usually sharing storage via a storage-area network (SAN) • Closely linked usually via a LAN • Provides a high-availability service which survives failures • Asymmetric clustering has one machine in hot-standby mode • Symmetric clustering has multiple nodes running applications, monitoring each other • Some clusters are for high-performance computing (HPC) • Applications must be written to use parallelization • Distributed Lock Manager: a function to ensure no conflicts on shared data access

  42. Operating System Structure • Operating System provides an environment within which programs are executed • Multiprogramming needed for efficiency • Single user cannot keep CPU and I/O devices busy at all times • Multiprogramming organizes jobs (code and data) so CPU always has one to execute • A subset of total jobs in system is kept in memory • One job selected and run via job scheduling • When it has to wait (for I/O for example), OS switches to another job • Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing • Response time should be < 1 second • Each user has at least one program executing in memory process • If several jobs ready to run at the same time  CPU scheduling • If processes don’t fit in memory, swapping moves them in and out to run • Virtual memory allows execution of processes not completely in memory

  43. Memory Layout for Multiprogrammed System OS keeps several jobs in memory Job Pool: contain all processes awaiting allocation of main memory

  44. Hardware Protection • Dual-Mode Operation • I/O Protection • Memory Protection • CPU Protection

  45. Dual-Mode Operation • Sharing system resources requires operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly. • Provide hardware support to differentiate between at least two modes of operations. • User mode – execution done on behalf of a user • Monitor mode (also kernel mode or system mode) – execution done on behalf of operating system

  46. Transition from User to Kernel Mode • Mode bit added to computer hardware to indicate the current mode: monitor (0) or user (1). • When an interrupt or fault occurs hardware switches to monitor mode • Privileged instructions can be issued only in monitor mode

  47. I/O Protection • All I/O instructions are privileged instructions • Must ensure that a user program could never gain control of the computer in monitor mode (i.e., a user program that, as part of its execution, stores a new address in the interrupt vector).

  48. Use of A System Call to Perform I/O

  49. Memory Protection • Must provide memory protection outside the address space of a process. • In order to have memory protection, add two registers that determine the range of legal addresses a program may access: • Base register – holds the smallest legal physical memory address. • Limit register – contains the size of the range • Memory outside the defined range is protected.