Beruflich Dokumente
Kultur Dokumente
An interface between users and hardware - an environment "architecture Allows convenient usage; hides the tedious stuff
These are the pieces of the system Process Management Main Memory Management File Management I/O System Management Secondary Management Networking Protection System Command-Interpreter System
PROCESS MANAGEMENT A process is a program in execution: (A program is passive, a process active.) A process has resources (CPU time, files) and attributes that must be managed. Management of processes includes:
Process Scheduling (priority, time management, . . . ) Creation/termination Block/Unblock (suspension/resumption ) Synchronization Communication Deadlock handling Debugging
MAIN MEMORY MANAGEMENT Allocation/de-allocation for processes, files, I/O. Maintenance of several processes at a time Keep track of who's using what memory Movement of process memory to/from secondary storage. FILE MANAGEMENT A file is a collection of related information defined by its creator. Commonly, files represent programs (both source and object forms) and data. The operating system is responsible for the following activities in connections with file management: File creation and deletion. Directory creation and deletion. Support of primitives for manipulating files and directories. Mapping files onto secondary storage. File backup on stable (nonvolatile) storage media.
5
SYSTEM STRUCTURES
System Components
I/O MANAGEMENT Buffer caching system Generic device driver code Drivers for each device - translate read/write requests into disk position commands.
SECONDARY STORAGE MANAGEMENT Disks, tapes, optical, ... Free space management ( paging/swapping )
NETWORKING Communication system between distributed processors. Getting information about files/processes/etc. on a remote machine. Can use either a message passing or a shared memory model. PROTECTION Of files, memory, CPU, etc. Means controlling of access Depends on the attributes of the file and user SYSTEM PROGRAMS Command Interpreters interface, etc.) -- Program that accepts control statements (shell, GUI
Compilers/linkers
Communications (ftp, telnet, etc.)
Recap
OS functions
Coordinator
Service provider
The CPU is wasted if a job waits for I/O. This leads to:
Multiprogramming ( dynamic switching ). While one job waits for a resource, the CPU can find another job to run. It means that several jobs are ready to run and only need the CPU in order to continue.
All of this leads to: memory management resource scheduling deadlock protection which are the subject of the rest of this course.
Characteristics
Time Sharing - multiprogramming environment that's also interactive. Multiprocessing - Tightly coupled systems that communicate via shared memory. Used for scientific applications. Used for speed improvement by putting together a number of off-the-shelf processors.
Distributed Systems - Loosely coupled systems that communicate via message passing. Advantages include resource sharing, speed up, reliability, communication.
Real Time Systems - Rapid response time is main characteristic. Used in control of applications where rapid response to a stimulus is essential.
10
Initialize kernel data structures Initialize the state of all hardware devices Creates a number of processes to start operation (e.g. getty in UNIX, the Windowing system in NT, e.g.)
11
OS executes an infinite loop (UNIX) OS performs some system management & profiling OS halts the processor and enter in low-power mode (notebooks) Interrupts from hardware devices Exceptions from user programs System calls from user programs User mode: Restricted execution mode (applications) Supervisor mode: Unrestricted access to everything (OS)
OS wakes up on:
12
Control Flow in an OS
main() From boot Interrupt
Initialization
System call
Exception
RTI
Return to user mode
13
Characteristics
Interrupt transfers control to the interrupt service routine generally, through the interrupt vector, 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.
14
On Interrupts
Hardware calls the operating system at a pre-specified location Operating system saves state of the user program Operating system identifies the device and cause of interrupt Responds to the interrupt Operating system restores state of the user program (if applicable) or some other user program Execute an RTI instruction to return to the user program User program continues exactly at the same point it was interrupted. Key Fact: None of this is visible to the user program
15
On Exceptions
Hardware calls the operating system at a pre-specified location Operating system identifies the cause of the exception (e.g. divide by 0) If user program has exception handling specified, then OS adjust the user program state so that it calls its handler Execute an RTI instruction to return to the user program If user program did not have a specified handler, then OS kills it and runs some other user program, as available Key Fact: Effects of exceptions are visible to user programs and cause abnormal execution flow
16
On System Calls
User program executes a trap instruction (system call) Hardware calls the operating system at a pre-specified location Operating system identifies the required service and parameters (e.g. open(filename, O_RDONLY)) Operating system executes the required service Operating system sets a register to contain the result of call Execute an RTI instruction to return to the user program User program receives the result and continues Key Fact: To the user program, it appears as a function call executed under program control
17
User Applications Command Interpreter Window System Middleware Operating System (process/device/memory management, file systems, interprocess communication, ) Instruction Execution & Interrupt Processing I/O Devices Memory
18
Summary
An OS is just a program:
It has a main() function, which gets called only once (during boot) Like any program, it consumes resources (such as memory), can do silly things (like generating an exception), etc.
19