Documente Academic
Documente Profesional
Documente Cultură
Memory management, address translation, and virtual memory Operating system management of I/O File systems Security & protection Distributed systems (as time permits)
Overview: Chapter 1
What is an operating system, anyway? Operating systems history The zoo of modern operating systems Review of computer hardware Operating system concepts Operating system structure
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.
Abstracts and standardizes the interface to the user across different types of hardware
Virtual machine hides the messy details which must be performed Each program gets time with the resource Each program gets space on the resource Use hardware efficiently Give maximum performance to each user
Brief History
First Generation of computers had no OS: single-user. All coding done directly in machine language, memory resident code (no other resources to manage) Second Generation has basic OS: batch processing. Read input (tape/cards), process, output to tape or print Third Generation improved life: multiprogramming! Careful partitioning of memory space (4-12KB), drums and disks added for reading cards and spooling outputs (Simultaneous Peripherals Operations On-Line) Time-sharing created several virtual machines
History (cont)
Fourth Generation: PCs and workstations. Cheaper, faster, more user-friendly (Thank Macs for interfaces!) UNIX precursor MULTICS (MULTIplexed Information and Computing Services) was the first modern OS. Bell+MIT+GE (MULTICS --> units --> Unix) Berkeley improved on it: paging, virtual memory, file systems, signals (interrupts), networking!
Vacuum tubes Plug boards Transistors Batch systems Integrated circuits Multiprogramming Large scale integration Personal computers Systems connected by high-speed networks? Wide area resource management?
Enter it into the computer (might require rewiring!) Run it Record the results Computer was idle during first and last steps Computers were very expensive!
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
Spooling
Original batch systems used tape drives Later batch systems used disks for buffering
Operator read cards onto disk attached to the computer Computer read jobs from disk Computer wrote job results to disk Operator directed that job results be printed from disk
Computer overlapped I/O of one job with execution of another Better utilization of the expensive CPU Still only one job active at any given time
IBM System/360: combine business and scientific computers into one machine Computer will grow with client(memory, processor speed, number of I/O devices etc.) Forerunner of 370, 4300, 3080 and 3090 Use of integrated circuits provided major price/performance advantage over 2nd generation OS/360 had to meet conflicting needs which resulted in enormous and complex operating system Introduced multiprogramming to make most efficient use of CPU
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
Timesharing
Initially used for batch systems Cheaper hardware terminals -> interactive use No more priesthood Quick turnaround meant quick fixes for problems
Fourth Generation
PCs and workstations. Cheaper, faster, more userfriendly (Thank Macs for interfaces!) UNIX precursor MULTICS (MULTIplexed Information and Computing Services) was the first modern OS. Bell+MIT+GE (MULTICS --> units --> Unix) Berkeley improved on it: paging, virtual memory, file systems, signals (interrupts), networking!
Desktop Systems
Personal computers computer system dedicated to a single user. I/O devices keyboards, mice, display screens, small printers. User convenience and responsiveness. Can adopt technology developed for larger operating systems. Often individuals have sole use of computer and do not need advanced CPU utilization of protection features. May run several different types of operating systems (Windows, MacOS, UNIX, Linux)
Parallel Systems
Multiprocessor systems with more than on CPU in close communication. Tightly coupled system processors share memory and a clock; communication usually takes place through the shared memory. Advantages of parallel system:
Increased throughput with more processors Economical share peripherals, mass storage, power etc. as opposed to individual PCs Increased reliability
failure of one processor will slow down but not halt the system other processors pick up the slack
Each processor runs and 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 allocates work to slave processors. More common in extremely large systems
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. Advantages of distributed systems.
Resource sharing Computation speed up load sharing Reliability Communications between processors and processes
Local area networks (LAN) or Wide area networks (WAN) May be either client-server or peer-to-peer systems.
Clustered Systems
Differs from parallel systems in that they are composed of two or more individual systems coupled together Clustering allows two or more systems to share storage. Provides high reliability. Asymmetric clustering (passive standby): one server runs the application while other servers are in hot standby mode Symmetric clustering(active secondary): all hosts are running the application, monitoring each other
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:
Secondary storage limited or absent, data stored in short term memory, or readonly memory (ROM) Not supported by general-purpose operating systems. Limited utility in industrial control of robotics Useful in applications (multimedia, virtual reality) requiring advanced operating-system features.
Soft real-time
Handheld Systems
Personal Digital Assistants (PDAs) Cellular telephones Issues:
Limited memory (512KB to 8MB) requires efficient management Slow processors Small display screens.
Networking
Networked OSs are connected through a network, but user needs to know the name/type/location of everything Distributed OSs (e.g., Amoeba, Mach, Locus) provide transparency to user, yielding one huge virtual machine! Specialized OSs are built for specific purposes: routing engines (Networking), lisp machines (AI), time constrained applications (Real-Time), Internet (WWW servers), massively parallel uses (supercomputers), etc All these are coming together, hard to identify boundaries anymore.
Microsoft World
Excellent marketing, some good products OSs started with DOS (Disk OS), no nothing, just very simple commands! Windows 3.1 was a huge jump (based on decadesold technology initially developed at Xerox then Macs) Windows 95 (released in 96) improved tremendously the state-of-the-affairs for MS, but still unreliable Windows NT approaches Unix distributions, with more user-friendly interface.
Unix World
Created at AT&T, re-written/improved by Berkeley ATT had majority control and good support (reliable OS) OSF (Open SW Foundation, now Open Group) is a consortium of several companies to standardize UNIX Different subgroups (syscalls, shells, RT, etc) Standardization is with respect to interfaces and not implementation of primitives. Impln is left to the implr Modern applications are time constrained (tel, video, etc) Real-Time playing an increasingly important role
Components of a simple PC
Outside world
Video controller
USB controller
Network controller
CPU Memory
CPU internals
Execute unit
Fetch unit Fetch unit Decode unit Execute unit Fetch unit
Decode unit
Buffer
Decode unit
Pipelined CPU
Superscalar CPU
Storage pyramid
Capacity < 1 KB 1 MB 256 MB 40 GB
Better
Access latency Registers Cache (SRAM) Main memory (DRAM) Magnetic disk Magnetic tape 1 ns 25 ns 50 ns 5 ms 50 sec
Better
> 1 TB
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
head sector
Up to two surfaces per platter One or more platters per disk Tracks broken into sectors
surfaces
Memory
Address
0x2ffff 0x2b000 0x27fff
Operating system
0 0
Operating system
Single base/limit pair: set for each process Two base/limit registers: one for program, one for data
1: Interrupt
Disk controller 4
3: Return
Request sent to controller, then to disk Disk responds, signals disk controller which tells interrupt controller Interrupt controller notifies CPU
OS Structure
Interface can be done at USER any level (depends on level of security of OS) OS Interface with the lower Dev Drivers level layer gets translated Machine dependent language Hardware used for accessing hardware Main advantage of direct resource access is efficiency Main advantage of indirect access is portability Completely layered OS? Why or why not?
OS Functions
Controls and manages resources (disks, memory, CPU, ); sends/receives control commands and data Allows multiprogramming (several programs at the same time in the same resource) Carries out communication between processes (inter and intra processor) Manages interrupt handlers for HW and SW interrupts Provides protection and security to processes Prioritizes requests and manages multiple resources in a single machine (eg multiprocessors or CPU IO reqs)
OS Functions
processes (creation, deletion, suspension, comm, synch) main memory (usage, alloc/de-alloc, which processes get it) 2ary storage (disk scheduling, alloc/de-alloc, swapping, files) IO interfaces and devices (eg, keyboard, caching, memory) protection (authorization, file and memory protection, etc) InterProcess Communication (intra- and inter-machines) Command interpretation (shells to Xlate user to OS). Typically includes the user interface that the OS uses.
OS Structure
USER OS
Hardware at the bottom layer Dev Drivers Accessing the lower layer thru Hardware the higher layers Typical DOS DOS programs can access HW Unix has controllers and dev drivers (DD) controlling devices USER system calls are the interface System Programs between user and OS (DDs) Kernel Functions libraries and system programs Dev Drivers invoke sys_calls
Hardware Typical Unix
OS Structure
Interface can be done at any level (depends on security) Machine dependent language used for accessing HW Main advantage of direct resource access is efficiency (less layers means less overhead, ie, better performance Main advantage of indirect access (syscall) is portability Modular approaches (ind access) have less flexibility, since appls only access HW thru libraries and sys_calls Layering means that one level is defined in terms of the level below (level 0 is the HW, level n is the user appls)
Modular Approach
Create well-defined interfaces between any two layers Create well-defined properties of each layer Attempt to decrease the number of layers to improve efficiency and performance The final goal is to make the OS flexible and efficient Create the layers such that each user perceives the machine as belonging solely to himself or herself This is the concept of a virtual machine, which allows each user to avoid thinking about others processes
Many of these should be familiar to Unix users Processes (and trees of processes) Deadlock File systems & directory trees Pipes Well cover all of these in more depth later on, but its useful to have some basic definitions now
Processes
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
Statically declared variables Areas allocated by malloc() or new Automatic variables Procedure call information
Stack
Data Data
Text 0
Deadlock
Potential deadlock
Actual deadlock
bin
cse
grads
amer4
classes stuff
research stuff
Interprocess communication
Processes 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
System calls
Access a file Create a process Others Program passes relevant information to OS OS performs the service if
The OS is able to do so The service is permitted for this program at this time Dont want programs reading data into other programs memory!
Language
System calls are the interface between user and OS Access to the resources is done through priviledged instructions (for protection) User applications cannot execute in kernel mode User applications user libraries that invoke sys_calls System procedures are executed to access resources, via priviledged instructions (called from sys_calls) This way, no process can influence other executions, on purpose or by accident: resource protection Example: accounting, priority information
Language (cont)
specification of deadlines, priorities, periodicity of processes specification of precedence constraints and/or synchronization among processes
Language (cont)
Examples of libraries are language constructs to carry out formatted printing Examples of sys_calls are primitives to create a process For example, the reading of 10 bytes of a file:
The user does fscanf, the kernel requests a block of bytes from the device driver (DD), which talks to the controller of the disk to obtain a block of data. The block is transfered into a buffer, in the kernel address space. The kernel then picks the 10 bytes and copies them into the user-specified location. This way, the kernel accesses kernel and user space, but the user only accesses user space!
System call:
read(fd,buffer,length)
Program pushes arguments, calls library Library sets up trap, calls OS OS handles system call Control returns to library Library returns to user program
Dispatch
User code
System Programs
System programs do not interact directly with running user programs, but define a better environmnt for the development of application programs. Sys programs include: compilers, file manipulation and modification, editors, linker/loaders, etc An important one is the command interpreter (or shell), which parses user input, interprets it, and executes it Shells can either execute the command, or invoke other system programs or system calls to do it. Trade-offs: performance, increasing/updating # of commands
Description
Open a file for reading and/or writing Close an open file Read data from a file into a buffer Write data from a buffer into a file Move the current pointer for a file Get a files status information (in buffer) Create a new directory Remove a directory (must be empty) Create a new entry (name2) that points to the same object as name1 Remove name as a link to an object (deletes the object if name was the only link to it)
Description
Create a child process identical to the parent Wait for a child to terminate Replace a process core image Terminate process execution and return status Change the working directory Change a files protection bits Send a signal to a process Get the elapsed time since 1 Jan 1970
A simple shell
while (TRUE) { /* repeat forever */ type_prompt( ); /* display prompt */ read_command (command, parameters) /* input from terminal */ if (fork() != 0) { /* fork off child process */ /* Parent code */ waitpid( -1, &status, 0); /* wait for child to exit */ } else { /* Child code */ execve (command, parameters, 0); /* execute command */ } }
Monolithic OS structure
Main procedure
Service routines
Utility routines
Virtual machines
App1 System calls I/O instructions Calls to simulate I/O Real I/O instructions App2 Linux VMware App3 Windows NT VMware Linux Bare hardware FreeBSD VMware
Allows users to run any x86-based OS on top of Linux or NT Only virtual machine failsrest of underlying OS is fine Virtual machine keeps things separated
Microkernels (client-server)
Client process Client process Process server Terminal server
File server
Memory server
Microkernel