What is an Operating System?

s A program that acts as an intermediary between a user

of a computer and the computer hardware.

Operating System Goals
s Use the computer resources in an efficient manner. s Make the computer system convenient to use. s Maximize resource utilization. s OS is one program that is ALWAYS running on a

computer(the kernel).


Silberschatz, Galvin and Gagne © 2002

Computer System Components
1. Hardware – provides basic computing resources. 2. Operating System – controls and coordinates the use of the resources. 3. Applications Programs – define the ways in which the system resources are used to solve the computing problems of the users. 4. Users


Silberschatz, Galvin and Gagne © 2002

Mainframe Systems
s Batch Systems s Multiprogrammed System s Time-Sharing System

Batch Systems
s Job – the program,data and control info. s Similar kind of jobs were BATCHED together and run as a

group to speed up the processing. s CPU is often idle,coz card reader is much slower than the CPU.


Silberschatz, Galvin and Gagne © 2002

Galvin and Gagne © 2002 . s In a non-multiprogramming environment.4 Silberschatz. s OS keeps several jobs in memory simultaneously.Once this job has to wait for some task. 1.and begins executing one of them.OS sits idle if one job has to wait for some task.Multiprogrammed System s CPU utilization is increased by organizing the jobs so that the CPU always has one to execute.OS switches to another job.

s Allow multiple users to share the computer simultaneously.5 Silberschatz. Galvin and Gagne © 2002 .CPU switches to the next job. 1.Time-Sharing Systems s Time-sharing is a logical extension of multiprogramming. s CPU executes multiple jobs by switching amongst them. Each user is given the impression that he is the sole user of the system. s Each job is executed for a fixed time-slice and after the completion of the time-slice.

communication usually takes place through the shared memory. Galvin and Gagne © 2002 .  Increased reliability – If one of the 10 processors fail. s Advantages of Parallel Systems:  Increased throughput – When N processors work together.Multiprocessor System s Multiprocessor systems have more than one CPU. 1. the speed up is huge. other 9 processors should be able to share the work without halting the system.  Although this speed up ratio is not N times due to sharing of data.  Economical – Multiprocessor save money than multiple singleprocessor systems coz they share memory and peripherals.6 Silberschatz. s Also known as Tightly-coupled Systems or Parallel Systems. s All the processors share memory and a clock.

even after failure of one processor. s Job Scheduling – If multiple jobs are ready to be brought into memory. the system has to choose amongst them. Making this decision is CPU scheduling. Galvin and Gagne © 2002 . s Fault Tolerant Systems – Systems designed for graceful degradation are called fault tolerant systems. Making this decision is job scheduling. is called graceful degradation.s Graceful Degradation – The ability to continue providing the service. 1. s CPU Scheduling – If there are several jobs ready to run at the same time. but there is not enough room for all.7 Silberschatz. the system has to choose amongst them.

s All systems are peers. s s s s master and others act act as slaves. s Advantage – N processes can be run simultaneously if there are N processors. s Disadvantage – One processor may be sitting idle while the other may be overloaded. Advantage – All the slave processors are given the work equally.there is no master-slave relationship.Sharing of memory and other data structures might cause delay sometimes. Galvin and Gagne © 2002 1.Symmetric Multiprocessor s Each of the N processors run an Asymmetric Multiprocessor s One of the N processor acts as a identical copy of the OS. Disadvantage . Master processor assigns a specific task to each of the slave processors. Used for large systems. Silberschatz.8 .

Also known as Loosely-coupled Systems. countries.floor or a building. 1. The computation is distributed among several physical processors connected in a network. such as high-speed buses or telephone lines.Distributed Systems s Distributed Systems are multiple single-processor system s s s s connected through a network. Processors communicate with one another through various communications lines.9 Silberschatz. cities. s Small Area Network exists in a range of several feet. s Wide Area Network (WAN) exists between buildings. eg-used for Bluetooth device. Networks s Local Area Network (LAN) exists in a room. Galvin and Gagne © 2002 . Each processor has its own local memory.

Distributed System s Client-Server System s Peer-to-Peer System General Structure of Client-Server 1.10 Silberschatz. Galvin and Gagne © 2002 .

Galvin and Gagne © 2002 . 1.Peer-to-Peer System s All systems are peers.11 Silberschatz. s All N single processors can run separate tasks.there is no master-slave relationship.

s Types of clustered systems: Asymmetric clustering Symmetric clustering Asymmetric Clustering  One machine is in standby mode Symmetric Clustering  All machines run applications while the other is running the applications.  Disadvantage – Difficult to share the load.Clustered Systems s Clustered Systems are multiple single-processor system connected through a network with shared storage.12 and monitor each other too.  Advantage – Very easy to recover from machine failure. Galvin and Gagne © 2002 . 1.  Advantage – No machine is idle.  If the running machine fails.the standby mode machine becomes active. Silberschatz.If any machine fails.its load is shared amongst all others.  Disadvantage – One machine is ALWAYS in standby mode.

industrial control system etc. medical imaging systems. Galvin and Gagne © 2002 . 1.13 Silberschatz. s Used in controlling scientific experiments.Real-Time Systems s Well-defined rigid time constraints are placed on the operation of the processor. s Real-Time systems: 3 Hard real-time 3 Soft real-time.

1. Secondary storage limited or absent.Hard Real-Time Systems  Hard real time systems Soft Real-Time Systems  Failure to meet the time deadline     guarantees that the job will be done on time.Industrial control.  Soft real-time tasks are given higher priority than.  Example . If the time deadline is not met. data stored in read-only memory (ROM).14 Silberschatz.etc does not lead to catastrophes. Example – Rocket launch. Galvin and Gagne © 2002 .it may lead to catastrophes. All delays in the system are bounded.

1.Handheld Systems s Personal Digital Assistants (PDAs) s Cellular telephones s Issues: 3 Limited memory 3 Slow processors 3 Small display screens. Galvin and Gagne © 2002 .15 Silberschatz.

Galvin and Gagne © 2002 .16 Silberschatz.Computer-System Architecture 1.

17 Silberschatz. CPU moves data from/to main memory to/from local buffers I/O is from the device to local buffer of controller. Each device controller has a local buffer. Device controller informs CPU that it has finished its operation by causing an interrupt. Galvin and Gagne © 2002 . 1.Device Controller s Each device controller is in charge of a particular device s s s s type.

1.and then waits for some event to occur.BootStrap Program s Stored in Read only memory(ROM) s Initializes all aspects of computer from CPU registers.to device controllers and memory. s Loads the OS into main memory and starts executing it. Galvin and Gagne © 2002 . s OS then starts executing the first process. eg “init”.18 Silberschatz.

19 Silberschatz. 3 An interrupt or 3 A Trap s A trap is a software-generated interrupt caused by: 3 Either an error(division by zero.invalid memory access). 1.Interrupts s Interrupts are triggered by: 3 Software 3 Hardware s Hardware interrupts are caused by device controller. (others use polling) s Events are signaled to the CPU through. 3 Specific request from the user to the OS to perform some specific task. Galvin and Gagne © 2002 .exec()) Interrupt Driven Systems s Most modern computers are interrupt-driven. s Software triggers an interrupt by executing a system call (eg- fork().

Silberschatz. s The OS preserves the state of the CPU by storing registers and the program counter. Galvin and Gagne © 2002 1.in turn.20 . This table of pointers is maintained as an array and called interrupt vector.Interrupt Handling s Interrupt Service Routine(ISR) is a function that is used to handle the interrupt. s Interrupt mechanism: 3 Generic Routine – A generic routine is invoked whenever an interrupt happens and that routine.would call the specific ISR.this table is indexed and we get the address of the ISR. 3 Pointer Table – when an interrupt occurs.

Two I/O Methods Synchronous Asynchronous 1.21 Silberschatz. Galvin and Gagne © 2002 .

s Ways to keep CPU waiting 3 Wait() instruction idles the CPU until the next interrupt. control returns to user Synchronous I/O s After I/O starts. 3 Device-status table contains entry for each I/O device indicating its type.CPU is: Interrupted – After the interrupt. 3 Wait loop hello: jmp hello s At most one I/O request is outstanding at a time.Asynchronous I/O s After I/O starts. address. 1. and state. CPU keeps polling all the devices to see if I/O is complete or not. 3 When I/O is complete.CPU has to check all the devices to infer which one caused the interrupt. 3 Multiple I/O requests can be handled. no simultaneous I/O processing.22 Silberschatz. program without waiting for I/O completion. control returns to user program only upon I/O completion. Galvin and Gagne © 2002 .

This might slow down the CPU execution. Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention. rather than the one interrupt per byte. CPU can perform any other job. Galvin and Gagne © 2002 . Cycle Stealing – DMA steals memory cycles from the CPU.23 Silberschatz. Only on interrupt is generated per block. 1.Direct Memory Access Structure(DMA) s Used for high-speed I/O devices able to transmit s s s s information at close to memory speeds.

24 Silberschatz.Moving-Head Disk Mechanism 1. Galvin and Gagne © 2002 .

Galvin and Gagne © 2002 . s SEEK TIME – Time to move the disk arm to the desired cylinder. 1.25 Silberschatz.Storage Structure s Main memory and cache and registers are the only storage that CPU can access directly. s LATENCY – Time to move to the desired sector.

s If one program is doing I/O and the other is being executed by the processor.its called programmed I/O. it were not loaded every time the machine was switched-on. Galvin and Gagne © 2002 . s If the device is not ready for I/O read/write operation. They were called so coz OS were always present in memory.CPU has to wait for it to be ready. s Early operating Systems were called Resident monitors.26 Silberschatz. 1. its called spooling. 3 If the CPU keeps checking the control bits of the device to see if the device is ready.a part of user memory is kept for I/O.s Memory Mapped I/O 3 No separate memory for I/O. 3 Same instructions for I/O and memory access. 3 If the device interrupts the CPU once it is ready.it is called interrupt driven.

27 Silberschatz.Storage Hierarchy.As we go down Increase in access time Decrease in cost Registers. Galvin and Gagne © 2002 .cache and main memory are volatile 1.

This is called cache coherency.in addition to sharing memory. s If multiple CPUs are there.they also maintain their local cache. Galvin and Gagne © 2002 .28 Silberschatz. 1.Caching s Use of high-speed memory to hold recently-accessed data. So if changes are made in one cache they should immediately reflected in all other caches sharing that data. Cache lies between main memory and secondary storage device. s Caching introduces another level in storage hierarchy. The data that is stored in cache is consistent with the data that is stored in main memory and hard disk.

system starts in monitor mode. and errant users from one another. Whenever an interrupt occurs. Dual mode of operation provides us with the means for protecting the OS from errant users. 2.29 Silberschatz. Instructions executed in monitor mode are called privileged instructions. Monitor mode (also kernel mode or system mode or privileged mode) – execution done on behalf of operating system.Execution of privileged instructions is not allowed in user mode. Galvin and Gagne © 2002 . A mode bit is there in hardware to indicate the current mode: monitor(0) and user (1) 1. At boot time.the control is given from the user mode to the monitor mode. User mode – execution done on behalf of a user.Dual-Mode Operation s Two modes of operations are there: s s s s s 1.

s Thus user cannot issue I/O commands directly.30 Silberschatz.all I/O instructions are defined as privileged instructions. Galvin and Gagne © 2002 . 1.Protection s I/O Protection s Memory Protection s CPU Protection I/O Protection s To prevent user from performing illegal I/O.it is done through the OS.

31 Silberschatz.Use of A System Call to Perform I/O 1. Galvin and Gagne © 2002 .

3 Limit register – contains the size of the range s Base and Limit registers are loaded using privileged instructions.Memory Protection s In order to have memory protection.32 Silberschatz. 1.two registers are added: 3 Base register – holds the smallest legal physical memory address. Galvin and Gagne © 2002 .

Galvin and Gagne © 2002 .33 Silberschatz.Use of A Base and Limit Register 1.

Hardware Address Protection/ Memory Protection 1. Galvin and Gagne © 2002 .34 Silberschatz.

1. s Timer commonly used to implement time-sharing systems. 3 When timer reaches the value 0. s Load-timer is a privileged instruction.35 Silberschatz.CPU Protection s We must also prevent a user program to be stuck in an infinite loop or never returning control to the OS. To accomplish this goal we have a timer. Galvin and Gagne © 2002 . an interrupt occurs. s Timer – interrupts after specified period to ensure operating system maintains control. 3 Before the control is to be given back to the user mode. 3 Timer is decremented every clock tick.the timer is set again.

3/89.90 03..//7088  .9398950 .03/.. /0.

:80/9039077:59 !&0058543 .425090 !&8 39077:590/ 19079039077:59 !& .0894 8001.430..0..894.90/0..08943107 .. 8.90/0.

30_  ..3..9 .3/.42509047349 507.93$890243.0598   $-078. 8.

90247.9:70  &80/147 8500/.088$97:..70.

 7.03943 !&.381078-4.841/.0$90.994 2.9..90/507-4.-09497.3/.0598   $-078.349074- 34339077:5980307.820247.9079..9 .30_  .48094 202478500/8 0.943.:943 507...08174290!& %829 84/4390!&00.39043039077:59 507-90 ..93$890243..1742-:11078947.382931472. /0.08.439740797.3 890.9.32024794:9!&3907.0.3.35071472.0/70.

3 0.3/.382 507../80.3.0598   $-078.30_  ...4.9 .93$890243.

3.3/.09.0$97:.7090438947.93$890243....3 .3/7089078.9:70 .9!&..0.9 $% %209424.3/.9 .30_  .088/70.729490/0870/.$947.3/07 % %209424.320247.0598   $-078.090/8..09490/0870/80.947 507...


7. 4805.9020247147.

7941:807202478059147. .5.

203897:.9438147. $.

/147.3/20247....088 190/0. .0834970.


390..7904507.0.894.0/39077:59/7.9147994-0 70.220/./ 98.0/5747.039077:59890!&43../ 98..943 !&.094800190/0..08 70./ 190/0..43974-984190/0.09870.03 190!&0058.

28/43..85708039320247 90703494.30./0/ 0.93$89028070.889...0/ 43 14305747.07920902.74507..0/84.4 $070. .0/#08/0392439478 %0070.

0598   $-078.3/9049078-0300..08847 98 .93$890243.30_  .9 .3..3/.. .0/85443 507.:90/-90574.

$947.803.7.088920 0...70.320247.4. 804/43 3...489 #089078 .30_  .93$890243.0.70.3/. .90 507..3/2.803..0598   $-078.

.0 $41.39..320247.33974/:.09084:/220/.3/.40703...0/...9...30_  . 4907..0/0.3/80..9 . .7.709070 3.0.7//8 .0598   $-078..9.739.349070.0 12:950!&8.702.9.308..0880//.907010. %0/.9889470/32..43889039 990/.842..3/..9.039 .008-090032.3907 ./03430.90/ 90..93$890243. 507. %88.038947.43/.78947.08.3 &8041 8500/20247944/70..9/..08..088.//943948..

0/57.709070  &80724/0 00.339077:594.84073024/0478890224/04757.00/ 3897:.9438 0.93$890243.03174290:80724/09490 24394724/0 :.3/:807  507.9090.70943/.7/./08:899020.07.:943/43043-0.:78 90.943800.:.943 %424/08414507.00/24/0  00.40/3:80724/0 24/0-9 890703..3814757490.3/077. 4/0 507.39:80781742430.:807  4394724/0 .1414507.94388349.0598   $-078.30_  .:90/324394724/0.:943/43043-0.:9434157..:7703924/0243947 .24/0414507.141.943574.3.34907 3897:.439748.9388902 9-449920 8890289..9438.3/..00/3897:.39:8078 .70.9 .798324394724/0 030.9390 $1742 077..

943 .!7490.

943 !&!7490.943 0247!7490.943 . !7490.

943 %4570. !7490.039:8071742507147230..


3897:.857.334988:0.00/3897:..9438 %:8:807.70/0130/ .9438.

93$890243..0598   $-078..422.3.9 .9 98/430974:90 $ 507.3/8/70.30_  . .3/.


3/...3. 507.30_  .93$890243.0598   $-078.9 .

00/3897:..9 .0598   $-078.439.58.20247.0247!7490.93$890243..70..02024757490.943 947089078./0/:8357.38908041907.//7088 29708907 .80708907 4/89082.//0/ .3/..9438 507.3/297089078.3.30 .80.0890.30_  .704.943 347/0794.

.0598   $-078.3/.80.3/29#08907 507.30_  .93$890243.&8041..9 .3.


0247!7490.30_  ..3/..3.0598   $-078.93$890243.943 507.9 .

00/3897:. 03920770.9490:80724/0 9092078809 .439749490 $ %4.294-089:.943 507.57.339077:594.38.039.30_  .43974894-0.9 .4.0890.!&!7490.4258984.84570.42243:80/942502039920 8.3...03-.07.39.9388902 2../ 92078..07709:733..0598   $-078..7020390/0.73889028 4.9207 %207 39077:598.1907850.10/5074/94038:704507..:8075747.943 02:89.:78 0147090.93$890243.3 %207.:0 ..3/.0..43974 %2078/0.0.33139044547 30.9..3.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer: Get 4 months of Scribd and The New York Times for just $1.87 per week!

Master Your Semester with a Special Offer from Scribd & The New York Times