Académique Documents
Professionnel Documents
Culture Documents
An Operating System exploits the hardware resources of one or more processors to provide a set of services to system users. An Operating System also manages secondary memory and input/output devices on behalf of its users.
PC
MAR MBR
1 2
Interrupts
A mechanism by which other modules (I/O, memory) may interrupt the normal sequencing of the processor Interrupts help to improve processor utilization. Classes of interrupts:
Program: generated by some condition that occurs as a result of an instruction execution, such as arithmetic overflow, division by zero, attempt to execute an illegal machine instruction, and reference outside a users allowed memory space. Timer: Generated by a timer within the processor. This allows the operating system to perform certain functions regularly. I/O: Generated by an I/O controller, to signal normal completion of an operation or to signal a variety of error conditions. H/W failure: Generated by a failure, such as power, etc.
5
An Example
A processor has two programs P1 and P2 to execute: P1 is simply reading data from memory and writing the data into the disk. P2 is doing only calculations. Processor may begin P1 first, issue a write command to the external device, and then proceed with P2.
Two cases: Writing to disk initiated by P1 might finish before P2 completes calculations. P2 completes calculations before the disk writing initiated by P1 finishes.
What are the consequences of these two cases?
6
Memory Hierarchy
Registers
Cache
Main Memory
Magnetic tape
Cache
a portion of the main memory that can be used as a buffer temporarily holds data that are to br read out to disk Caches improve the performance in two ways: Disk writes are clustered. instead of having many small transfers of data, few large transfers are possible. some data meant for write-out (from disk) may be directly accessed from the cache very fast.
Objectives of an O.S.
Convenience of use of the computer
Application Programs
End user
Utilities
Programmer
Operating System
Computer Hardware
OS System Designer
10
Operating System Services Program Development variety of services and utilities such as
Editors and debuggers. They are usually referred to as application program
development tools.
Access to I/O devices Each I/O device has its own set of
Instructions and control signals. O.S. hides these details to provide a common interface to the user/programmer.
11
Operating System Services Controlled access to files- nature of I/O device (disk drive, tape
drive) and structure of the data stored in the files in the storage medium. In the case of multiple users accessing the processor concurrently, proper protection mechanisms have to be used. System access- For shared or public systems, the O.S. controls access to the system as a whole and to specific system resources. Access system provides protection of resources, and data from unauthorised users, and resolves resource conflicts Error detection and response Variety of errors may occur in computer system. Responses may range from program termination, retrial of the same operation, or reporting error to the application. Accounting collecting usage statistics, CPU usages, monitor performance, etc.
12
Serial Processing
From 1940s to mid-1950s Programmer interacted with the hardware Programs in machine code were loaded via the input device (card reader) In case of any error, they were indicated with lights
Associated problems:
Scheduling: Hardcopy sigh-up sheet for reserving time User could reserve for 45 mins and finish in 30 mins => wastage of time User may not be able to finish in scheduled time
13
14
2 s
19 s --------40 s
TOTAL
16
An example of Multiprogramming
P1 Run Wait Run Wait
P2
Wait
Run
Wait
Run
Wait
P3
Wait
Run
Wait
Run
Wait
P1, P2, P3
Run
Run
Run
Wait
Run
Run
Run
Wait
Any Advantage?
17
Scheduling
Uniprogramming Processor use 20% Multiprogramming 40%
Memory use
Disk use Printer use Elapsed time Throughput Mean response time
33%
33% 33% 30 min 6 jobs/hr 18 min
67%
67% 67% 15 min 12 jobs/hr 10 min
Time-Sharing Systems
For some jobs, e.g., for transaction processing jobs, it is desirable that users may interact directly with the computer
Processor time is shared among multiple users through time sharing multiple users simultaneously access the system through terminals, with the O.S. interleaving the execution of each user program in time quanta. For n users actively requesting service at one time (for instance, all editing files), each user will only see on the average 1/n of the effective computer capacity (approx.) Given the slow human reaction time, response time is similar to that on a dedicated machine
19
20
Processes Memory management Information protection and security Scheduling and resource management System structure
21
Processes
A process is
22
Parts of a Process
Components of a process An executable program Associated data required by the program (variable, work space, buffer, etc.) Execution context: internal data used by O.S. to supervise a process = process state.
Process list
Program code context
Main memory
Program code context
data
data
24
Priority : Priority level relative to other processes Program counter : Address of the next instruction of the program to be executed. Memory pointers: pointers to the program code and data associated with the process, and any shared memory blocks Context data: Data in the registers in the processor during process execution. I/O status information: outstanding I/O requests, I/O devices allocated to the process, a list of files is use by the process, etc. Accounting information: amount of processor time, etc.
25
Differential responsiveness: O.S. should make allocation and scheduling decisions to meet total set of requirements, and in a dynamic manner. E.g., if a process is waiting for an I/O device, O.S. may schedule that process as soon as the device is free. Efficiency: Maximize throughput, minimize response time, and accommodate as many concurrent users as possible.
26
Virtual Memory
A facility that allows programs to address memory from a logical viewpoint Disregards the amount of physical memory actually available Meets the requirements of multiple user processes to reside simultaneously in main memory without any interference (Demand) Paging system and Page faults
27
File A
File B
File C
10
20
30
28
29
UNIX Architecture
Kernel Shell
Application Programs UNIX commands and libraries System call interface bash H/W Kernel wc vi who
Utilities
30
Libraries
scheduler
Device drivers
Hardware control
Kernel level Hardware level
Hardware
31
Multi-user System Multiprogramming/Multitasking system Uses Time Sharing Access rights for Files and Processes Uses File and Process hierarchies
32
33
34
35
/misc
/mnt /net /opt
/proc
/root /sbin
/tmp
/usr /var
etc
usr usr
tom
harry
37
Regular files : they contain normal data, for example text files, executable files or programs, input for or output from a program and so on. Directories: files that are lists of other files. Special files: Devices treated as files, used for input and output. They exist in /dev. Links: a system to make a file or directory visible in multiple parts of the system's file tree. (Domain) sockets: a special file type, similar to TCP/IP sockets, providing inter-process networking protected by the file system's access control. Named pipes: act more or less like sockets and form a way for processes to communicate with each other, without using network socket semantics.
38
Permissions of a file
Read Write execute
39
psdg/Documents> ls l total 8 -rw-rw-r-- 1 psdg faculty 31744 Feb 21 17:56 samplefile1.doc lrw-rw-r-- 1 psdg faculty 41472 Feb 21 17:56 samplefile2 drwxrwxr-x 2 psdg faculty 4096 Feb 25 11:50 os-course/ crw-rw-r-- 1 psdg faculty 41472 Feb 21 17:56 /dev/tty00
Symbol d Meaning Regular file Directory
l
c s p
Link
Special file Socket Named pipe
40
User Accounts
41