Silberschatz, Galvin and Gagne Operating System Concepts Bare Machine (early 1950s) Structure Large machines run from console Single user system Programmer/User as operator Paper tape or punched cards Early Software Assemblers, compilers, linkers, loaders Libraries of common subroutines Device drivers Inefficient use of expensive resources Low CPU utilization Significant amount of setup time Solutions Add a card reader Hire an operator
Silberschatz, Galvin and Gagne Operating System Concepts Simple Batch Systems Reduce setup time by batching similar jobs Automatic job sequencing - automatically transfers control from one job to another - first rudimentary OS Resident monitor Initial control in monitor Control transfers to job Job transfers control back to monitor (or chaos ensues) Use control cards to Separate jobs Specify job types, e.g., FORTRAN Separate code from data
Silberschatz, Galvin and Gagne Operating System Concepts Memory Layout for a Simple Batch System
Silberschatz, Galvin and Gagne Operating System Concepts Offline Operation Do card reading and printing offline Jobs copied from cards to tape Tape loads to CPU, and results output to tape Tape content printed Advantages CPU constrained only by tape speed No changes to existing code Multiple card readers and printers per CPU
Silberschatz, Galvin and Gagne Operating System Concepts Offline Operation Layout
Silberschatz, Galvin and Gagne Operating System Concepts Spooling Overlap I/O of one job with computation of another job. While executing one job, the OS: Reads next job from card reader into a storage area on the disk (job queue). Outputs printout of previous job from disk to printer. Job pool – data structure that allows the OS to select which job to run next in order to increase CPU utilization Critical change of hardware Allows CPU to swap between IO control and job Implemented with interrupts
Silberschatz, Galvin and Gagne Operating System Concepts Spooling
Silberschatz, Galvin and Gagne Operating System Concepts Two I/O Methods Synchronous Asynchronous
Silberschatz, Galvin and Gagne Operating System Concepts Synchronous IO After I/O starts, control returns to user program only upon I/O completion. Wait instruction idles the CPU until the next interrupt At most one I/O request is outstanding at a time, no simultaneous I/O processing. More common in real time systems Asynchronous IO 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 IO device interrupts on completion I/O devices and the CPU can execute concurrently.
Silberschatz, Galvin and Gagne Operating System Concepts Asynchronous IO Request User process requests IO service Device-status table contains entry for each I/O device indicating its type, address, and state If device is idle the IO starts If the device is busy, the request is queued (double buffering)
Silberschatz, Galvin and Gagne Operating System Concepts Asynchronous IO Each device controller has a local buffer. CPU moves data from/to memory to/from local buffers Device controller informs CPU that it has finished its operation by causing an interrupt. On interrupt the OS indexes into I/O device table to determine device status and do service Feed more data from this request Start next request on queue Note device idle
Silberschatz, Galvin and Gagne Operating System Concepts Multiprogrammed Batch Systems Several jobs are kept in main memory at the same time, and the CPU is multiplexed among them.
Silberschatz, Galvin and Gagne Operating System Concepts OS Features Needed for Multiprogramming I/O routine supplied by the system. Memory management – the system must allocate the memory to several jobs. CPU scheduling – the system must choose among several jobs ready to run. Allocation of devices.
Silberschatz, Galvin and Gagne Operating System Concepts Time-Sharing Interactive Computing Multi-programming plus … Multi-user On-line communication between the user and the system is provided; when the operating system finishes the execution of one command, it seeks the next “control statement” from the user’s keyboard. On-line file system must be available for users to access data and code Jobs may be swapped in and out of memory to the disk.
Silberschatz, Galvin and Gagne Operating System Concepts Dual-Mode Operation Provide hardware support to differentiate between at least two modes of operations. 1.User mode – execution done on behalf of a user. 2.Monitor mode (also kernel mode or system mode) – execution done on behalf of operating system. 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 When executing in monitor mode, the operating system has unrestricted access to both monitor and user’s memory. Privileged instructions can be issued only in monitor mode. monitoruser Interrupt/fault set user mode
Silberschatz, Galvin and Gagne Operating System Concepts CPU Protection Timer – interrupts computer after specified period to ensure operating system maintains control. Timer is decremented every clock tick. When timer reaches the value 0, an interrupt occurs. Timer commonly used to implement time sharing. Timer also used to compute the current time. Load-timer is a privileged instruction. Setting the interrupt vector is privileged
Silberschatz, Galvin and Gagne Operating System Concepts Memory Protection 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. The load instructions for the base and limit registers are privileged instructions.
Silberschatz, Galvin and Gagne Operating System Concepts Use of A Base and Limit Register
Silberschatz, Galvin and Gagne Operating System Concepts I/O Protection All I/O instructions are privileged instructions.
Silberschatz, Galvin and Gagne Operating System Concepts Personal Computers Computer system dedicated to a single user. I/O devices – keyboards, mice, display screens, small printers. Goals: User convenience and responsiveness. Can adopt technology developed for larger operating systems Individuals have sole use of computer - only multi- programming. May run several different types of operating systems (Windows, MacOS, UNIX, Linux)
Silberschatz, Galvin and Gagne Operating System Concepts Multiprocessor Systems Multiprocessor systems with more than one CPU in close communication. Tightly coupled system – processors share memory and a clock; communication usually takes place through the shared memory.
Silberschatz, Galvin and Gagne Operating System Concepts Multiprocessor Systems Symmetric multiprocessing (SMP) Each CPU runs an identical copy of the operating system. Many processes can run at once without performance deterioration. Most modern operating systems support SMP Asymmetric multiprocessing Each processor is assigned a specific task; master processor schedules and allocated work to slave processors. More common in extremely large systems Advantages of multiprocessor systems: Increased throughput Economical Increased reliability Graceful degradation Fail-soft systems
Silberschatz, Galvin and Gagne Operating System Concepts Distributed Systems Distribute the computation among several physical processors. Loosely coupled system – each processor has its own local memory; processors communicate with one another through various communications lines, such as high- speed buses or telephone lines. May be either client-server or peer-to-peer systems.
Silberschatz, Galvin and Gagne Operating System Concepts Distributed Systems (cont) Requires networking infrastructure. Local area networks (LAN) or Wide area networks (WAN) Advantages of distributed systems. Resources Sharing Computation speed up – load sharing Reliability Communications
Silberschatz, Galvin and Gagne Operating System Concepts Real-Time Systems 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. Well-defined fixed-time constraints. Hard real-time: guaranteed task completion Secondary storage limited or absent, data stored in short term memory, or read-only memory (ROM) Conflicts with time-sharing systems, not supported by general- purpose operating systems. Soft real-time: absolute task priority Limited utility in industrial control of robotics Useful in applications (multimedia, virtual reality) requiring advanced operating-system features.
Silberschatz, Galvin and Gagne Operating System Concepts Handheld Systems Personal Digital Assistants (PDAs) Cellular telephones Issues: Limited memory Slow processors Small display screens.
Silberschatz, Galvin and Gagne Operating System Concepts Migration of Operating-System Concepts and Features