Silberschatz, Galvin and Gagne 2002 2.1 Operating System Concepts Bare Machine (early 1950s)...

27
Silberschatz, Galvin and Gagne 2002 2.1 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

Transcript of Silberschatz, Galvin and Gagne 2002 2.1 Operating System Concepts Bare Machine (early 1950s)...

Page 1: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.1Operating 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

Page 2: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.2Operating 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

Page 3: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.3Operating System Concepts

Memory Layout for a Simple Batch System

Page 4: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.4Operating 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

Page 5: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.5Operating System Concepts

Offline Operation Layout

Page 6: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.6Operating 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

Page 7: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.7Operating System Concepts

Spooling

Page 8: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.8Operating System Concepts

Two I/O Methods

Synchronous Asynchronous

Page 9: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.9Operating 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.

Page 10: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.10Operating 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)

Page 11: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.11Operating 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

Page 12: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.12Operating System Concepts

Multiprogrammed Batch Systems

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

Page 13: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.13Operating 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.

Page 14: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.14Operating 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.

Page 15: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.15Operating 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.

monitor user

Interrupt/fault

set user mode

Page 16: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.16Operating 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

Page 17: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.17Operating 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.

Page 18: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.18Operating System Concepts

Use of A Base and Limit Register

Page 19: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.19Operating System Concepts

I/O Protection

All I/O instructions are privileged instructions.

Page 20: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.20Operating 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)

Page 21: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.21Operating 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.

Page 22: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.22Operating 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

Page 23: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.23Operating 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.

Page 24: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.24Operating 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

Page 25: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.25Operating 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.

Page 26: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.26Operating System Concepts

Handheld Systems

Personal Digital Assistants (PDAs) Cellular telephones Issues:

Limited memory Slow processors Small display screens.

Page 27: Silberschatz, Galvin and Gagne  2002 2.1 Operating System Concepts Bare Machine (early 1950s) Structure  Large machines run from console  Single user.

Silberschatz, Galvin and Gagne 20022.27Operating System Concepts

Migration of Operating-System Concepts and Features