You are on page 1of 25

Operating System

(ECS-501)

Unit- I Introduction 1.1 Operating System: An operating system is a program that manages the computer hardware. It a so pro!ides a "asis #or app ication programs and acts as an intermediary "etween the computer user and the computer hardware. Components of Computer System:

$he hardwarethe central processing unit (C U!" the memory" and the input#output (I#O! de$ices%pro!ides the "asic computing resources #or the system. $he application program de#ine the ways in which these resources are used to so !e users& computing pro" ems. $he operating system contro s and coordinates the use o# the hardware among the !arious app ication programs #or the !arious users.

Operating System

(ECS-501)

Operating system can %e e&plored from two $iew points: A. 'ser (iew ). System !iew

'. User (iew: *esigned most y #or ease o# use. some attention paid to per#ormance. +one paid to resource utili)ation

*. System (iew: Operating system as a resource allocator (C,' time- memory space- #i e-storage spaceI.O de!ices- and so on.) Control program (manages the e/ecution o# user programs to pre!ent errors and improper use o# the computer.) 1.+ Classification of Operating System: '. *atch Systems:

,&ecuting a series of no interacti$e similar types of -o%s all at one time. $he term originated in the days when users entered programs on punch cards. $hey wou d gi!e a "atch o# these programmed cards to the system operator- who wou d #eed them into the computer.

*atch -o%s can %e stored up during wor.ing hours and then e&ecuted during the e$ening or whene$er the computer is idle. )atch processing is particu ar y use#u #or operations that re0uire the computer or a periphera de!ice #or an e/tended period o# time. Once a "atch 1o" "egins- it continues unti it is done or unti an error occurs. +ote that "atch processing imp ies that there is no interaction with the user whi e the program is "eing e/ecuted.

Operating System

(ECS-501)

*. /ulti rogrammed System: In 2u tiprogramming- se!era programs are run at the same time on a uniprocessor in an interlea$ed manner. Since there is on y one processor - there can %e no true simultaneous e&ecution of different programs. $o the user it appears that a programs are e/ecuting at the same time. If the machine has the capa%ility of causing an interrupt after a specified time inter$al- then the operating system wi e&ecute each program for a gi$en length of time- regain contro - and then e/ecute another program #or a gi!en ength o# time- and so on. In the a%sence of this mechanism - the operating system has no choice %ut to %egin to e&ecute a program with the e&pectation - "ut not the certainty- that the program wi e!entua y return contro to the operating system.

Operating System

(ECS-501)

C. 0ime Sharing System: 3e#ers to the concurrent use o# a computer "y more than one user -- users share the computer&s time. Time sharing is synonymous with multi-user. It is a so ca ed interacti!e system. A time-sharing system is one that a ows mu tip e users to share time on a sing e computer. 1. /ultitas.ing Operating System: 2u titas4ing operating system is a time sharing system that a so supports mu tip e process per user. In mu titas4ing- on y one C,' is in!o !ed- "ut it switches from one program to another so 2uic.ly that it gi$es the appearance of e&ecuting all of the programs at the same time. Each user is gi!en a time slice o# C,' time (e.g.- each user is ser!ed e!ery 0.1 s "y the computer). $he computer wor4s so #ast that each user seems to "e the so e user o# the computer. One e/amp e o# a time-sharing system is the "an4&s "an4card system- which a ows hundreds o# peop e to access the same program on the main#rame at the same time. A time-sharing system that a ows di##erent users to independent y run di##erent programs at the same time is a so ca ed a mu ti-user system.

,. /ulti rocessor System ( arallel System or 0ightly Coupled Systems!:

Operating System

(ECS-501)

Such systems ha!e two or more processors in c ose communication within the same computer system- sharing the computer "us and sometimes the c oc4- memory- and periphera de!ices. 'd$antages: i. Increased throughput: )y increasing the num"er o# processors- we e/pect to get more wor4 done in ess time. ii. ,conomy of scale: Sa!e more money than mu tip e sing e processor system. iii. Increased relia%ility: $he #ai ure o# one processor wi not ha t the systemon y s ow it down. $he mu tip e-processor systems in use today are o# two types. i. symmetric multiprocessing (S/ !: each processor runs an identica copy o# the O.S. and these copies communicate with one another as needed (no master s a!e re ationship e/ists "etween processors). ii. 'symmetric multiprocessing ('S/ !: each processor is assigned a speci#ic tas4. A master processor contro s the system5 the other processors either oo4 to the master #or instruction or ha!e prede#ined tas4s.

3. 1istri%uted System: In a distri"uted system- so#tware and data may"e distri"uted around the systemprograms and #i es may"e stored on di##erent storage de!ices which are ocated in di##erent geographica ocations and may"e accessed #rom di##erent computer termina s. $hese systems ha!e their own oca memory. $hey do not ha!e shared memory. Client Ser$er System: i. ii. Centra i6ed systems act as ser$er systems to satis#y re0uest generated "y c ient system. Ser!er systems may "e computer ser$er systems (on y re0uest) or file ser$er systems (#i e read- write- create etc.)

Operating System

(ECS-501)

Client Ser$er system eer to eer System: i. ,rocessor communicates with one another through !arious communication ines such as high speed "uses or te ephone ines. ii. ,eer to peer system may "e tight y coup ed (do not share memory or c oc4- ha!e oca memory to communicate) or oose y coup ed (shara" e).

4. Clustered system: 7i4e mu tiprocessor systems- c ustered systems gather together mu tip e C,'s to accomp ish computationa wor4. C ustered systems di##er #rom mu tiprocessor systems5 in mu tiprocessor system- two or more C,'s are tied together within a sing e system through "us- sharing memory- I.O and c oc4- whi e in distri"uted system two or more indi!idua system are tied together sharing the memory space through 7A+. C ustered computers share storage and are c ose y in4 !ia 7A+ networ4ing. C ustering is usua y used to pro!ide high-a$aila%ility. A ayer o# c uster so#tware runs on the c uster nodes. Each node can monitor one or more o# the others (o!er the 7A+). I# the monitored machine #ai s- the monitoring machine can ta4e ownership o# its storage and restart the app ications that were running on the #ai ed machine. $he users and c ients o# the app ications see on y a "rie# interruption o# ser!ice. 1istri%uted 5oc. manager (15/! pro!ides access contro and oc4ing to the #i es to ensure no con# icting operations occurs. C ustering can "e structured asymmetrica y or symmetrica y. i. In asymmetric clustering" one machine is in hot-stand%y mode whi e the other is running the app ications. $he hot-stand"y host machine does nothing "ut

Operating System

(ECS-501)

monitor the acti!e ser!er. I# that ser!er #ai s- the hot-stand"y host "ecomes the acti!e ser!er. ii. In symmetric mode" two or more hosts are running app ications- and are monitoring each other. 6. 7eal 0ime System: A system is said to "e rea -time i# the tota correctness o# an operation depends not on y upon its ogica correctness- "ut a so upon the time in which it is per#ormed. O3 A rea -time system is a so#tware system where the correct #unctioning o# the system depends on the resu ts produced "y the system and the time at which these resu ts are produced. A rea -time operating system (3$OS) is an operating system (OS) intended to ser!e rea time app ication re0uests 0ypes of 7eal 0ime Systems 1. hard real-time system A hard rea -time system is a system whose operation is incorrect i# resu ts are not produced according to the timing speci#ication.

8ard rea -time systems are used when it is imperati!e that an e!ent is reacted to within a strict dead ine. Such strong guarantees are re0uired o# systems #or which not reacting in a certain inter!a o# time wou d cause great oss in some mannerespecia y damaging the surroundings physica y or threatening human i!es (a though the strict de#inition is simp y that missing the dead ine constitutes #ai ure o# the system). 9or e/amp e- a car engine contro system is a hard rea time system "ecause a de ayed signa may cause engine #ai ure or damage. . 8ard rea -time systems are typica y #ound interacting at a ow e!e with physica hardware. In these systems secondary storage are either imited or a"sent.OS is stored on 3O2 (3ead On y 2emory).

Operating System
soft real-time system

(ECS-501)

A so#t rea time system is a system whose operation is degraded i# resu ts are not produced according to the speci#ied timing re0uirements 7ate comp etion o# 1o"s is undesira" e "ut not #ata . System per#ormance degrades as more : more 1o"s miss dead ines. 7i!e audio-!ideo systems are usua y so#t rea -time5 !io ation o# constraints resu ts in degraded 0ua ity- "ut the system can continue to operate

,&amples of 70OS; <+=- 3$7I+'= and (/>or4s

I. 6and 6eld System; It inc udes ,*A (,ersona *igita Assistants) such as ,a m-,i ots or ce u ar te ephones with connecti!ity to a networ4 such as internet. $he de!e opers o# hand he d systems ha!e some imitations i4e less memory" less processor" small screen display and limited power %ac.up. 8. ,m%edded system: an em%edded system is one in which OS is em%eds on the system itself. $hey are !ery #ast. $hey are app ication speci#ic. $hey are used in washing machine- ce phones-contro systems.

9. :etwor. operating system ' networ.ing operating system (:OS!" also referred to as the 1ialoguer" is the software that runs on a ser$er and ena%les the ser$er to manage data" users"

Operating System

(ECS-501)

groups" security" applications" and other networ.ing functions. $he networ4 operating system is designed to a ow shared #i e and printer access among mu tip e computers in a networ4- typica y a oca area networ4 (7A+)- a pri!ate networ4 or to other networ4s. $he most popu ar networ4 operating systems are 2icroso#t >indows Ser!er ?00@- 2icroso#t >indows Ser!er ?00A- '+I=- 7inu/- 2ac OS =and +o!e +et>are. :etwor. Operating Systems are %ased on a client#ser$er architecture in which a ser$er ena%les multiple clients to share resources. $he +etwor4 Operating System can a so do the #o owing; Centra y manage networ4 resources- such as programs- data and de!ices. Secure access to a networ4. A ow remote users to connect to a networ4. A ow users to connect to other networ4s i4e the Internet. )ac4 up data and ma4e sure it&s a ways a!ai a" e. A ow #or simp e additions o# c ients and resources. 2onitor the status and #unctiona ity o# networ4 e ements. *istri"ute programs and so#tware updates to c ients. Ensure e##icient use o# a ser!er&s capa"i ities.

1.; 3unctions of Operating System:

/anagement of the processor; the operating system is responsi" e #or managing a ocation o# the processor "etween the di##erent programmes using a scheduling

Operating System

10

(ECS-501)

algorithm. $he type o# schedu er is tota y dependent on the operating system- according to the desired o"1ecti!e.

/anagement of the random access memory; the operating system is responsi" e #or managing the memory space a ocated to each app ication and- where re e!ant- to each user. I# there is insu##icient physica memory- the operating system can create a memory 6one on the hard dri!e- 4nown as B$irtual memoryB. $he !irtua memory ets you run app ications re0uiring more memory than there is a!ai a" e 3A2 on the system. 8owe!er- this memory is a great dea s ower.

/anagement of input#output; the operating system a ows uni#ication and contro o# access o# programmes to materia resources !ia dri!ers (a so 4nown as periphera administrators or input.output administrators).

/anagement of e&ecution of applications; the operating system is responsi" e #or smooth e/ecution o# app ications "y a ocating the resources re0uired #or them to operate. $his means an app ication that is not responding correct y can "e B4i edB.

/anagement of authori)ations; the operating system is responsi" e #or security re ating to e/ecution o# programmes "y guaranteeing that the resources are used on y "y programmes and users with the re e!ant authori6ations.

3ile management; the operating system manages reading and writing in the #i e system and the user and app ication #i e access authori6ations.

Information management; the operating system pro!ides a certain num"er o# indicators that can "e used to diagnose the correct operation o# the machine.

1.< Operating System Structure: '. Simple Structure :

Operating System

11

(ECS-501)

In this- the most #unctiona ities are pro!ided in east space so it was not di!ided into modu es care#u y. ,&ample: /S-1OS System Structure 2S-*OS C written to pro!ide the most #unctiona ity in the east space +ot di!ided into modu es A though 2S-*OS has some structure- its inter#aces and e!e s o# #unctiona ity are not we separate.

Operating System
*. 5ayered Structure:

12

(ECS-501)

$he operating system is di!ided into a num"er o# ayers ( e!e s)- each "ui t on top o# ower ayers. $he %ottom layer (layer =!" is the hardware5 the highest (layer :! is the user interface. An OS ayer is an imp ementation o# an a"stract o"1ect that is the encapsu ation o# data and operations that can manipu ate those data. $hese operations (routines) can "e in!o4ed "y higher- e!e ayers. $he ayer itse # can in!o4e operations on ower- e!e ayers. 7ayered approach pro!ides modu arity. >ith modu arity- ayers are se ected such that each ayer uses #unctions (operations) and ser!ices o# on y ower- e!e ayers. Each ayer is imp emented "y using on y those operations that are pro!ided ower e!e ayers. $he ma1or di##icu ty is appropriate de#inition o# !arious ayers.

Layered Operating System.

Operating System

13

(ECS-501)

,&ample: U:I> System Structure '+I= C imited "y hardware #unctiona ity- the origina '+I= operating system had imited structuring. $he '+I= OS consists o# two separa" e parts. o Systems programs C use 4erne supported system ca s to pro!ide use#u #unctions such as compi ation and #i e manipu ation. o $he 4erne Consists o# e!erything "e ow the system-ca inter#ace and a"o!e the physica hardware ,ro!ides the #i e system- C,' schedu ing- memory management- and other operating-system #unctions5 a arge num"er o# #unctions #or one e!e .

9ernel:

Operating System

14

(ECS-501)

Derne is the core part o# the operating system. $his 4erne is in the inner ayer o# OS ayers and direct y interacts with the hardware. It is responsi" e #or per#orming !arious #unctions re ated to the hardware such as main memory management- process management- I.O management and secondary storage management. >hen a computer "oots up- it goes through some initia i6ation #unctions- such as chec4ing memory. It then oads the 4erne and switches contro to it. $he 4erne then starts up a the processes needed to communicate with the user and the rest o# the en!ironment (e.g. the 7A+) $he 4erne is a ways oaded into memory- and 4erne #unctions a ways run- hand ing processesmemory- and de!ices. $he traditiona structure o# a 4erne is a layered system- such as 'ni/. In this- a ayers are part o# the 4erne - and each ayer can ta 4 to on y a #ew other ayers. App ication programs and uti ities i!e a"o!e the 4erne .

0ypes of 9ernel: 1. /onolithic .ernel: In a mono ithic 4erne - a OS ser!ices such as process managementmemory management- #i e management- storage management : I.O management run a ong with the main 4erne thread- thus a so residing in the same memory area. 'd$antage:
1. Easier to design 2. 2ore e##icient due to the use o# shared 4erne memory . Disadvantage:

Operating System
1. 7arge 4erne si6e ?. 7ac4 o# e/tensi"i ity

15

(ECS-501)

@. 'nre ia" e; as a "ug anywhere in the 4erne can "ring down the who e system.

+. /icro .ernel structure Derne using micro.ernel approach. 3emo!e a non-essential components from the .ernel : imp ementing them as system : user e!e programs (sma er 4erne s). 2ain #unction o# micro4erne is to pro!ide a communication #aci ity %etween a client program ? the $arious ser$ices that are a so running in user space. )ene#its; o Easier to e/tend a micro4erne o Easier to port the operating system to new architectures o 2ore re ia" e ( ess code is running in 4erne mode) o 2ore secure *isad!antages; o ,er#ormance (System ca s can re0uire a ot o# protection mode changes) o E/pensi!e to re imp ement e!erything with a new mode

1.@ Operating System Components:

Operating System

16

(ECS-501)

*ue to the comp e/ nature o# the modern operating systems- it is partitioned into sma er component. Each component per#orms a we -de#ined #unction w ith we -de#ined inputs and outputs. 2any modern operating systems ha!e the #o owing components. ,rocess 2anagement 2ain 2emory 2anagement 9i e 2anagement I.O System 2anagement Secondary 2anagement +etwor4ing ,rotection System Command-Interpreter System

'. rocess /anagement A process is a program in e/ecution. 9or e/amp e A "atch 1o" is a process A time-shared user program is a process A system tas4 (e.g. spoo ing output to printer) is a process. 3emem"er a program itse # is not a process rather it is a passi!e entity. A process needs certain resources- inc uding C,' time- memory- #i es- and I.O de!icesto accomp ish its tas4. $hese resources are either gi!en to the process when it is created or when it is running. >hen the process comp etes- the OS rec aims a the resources. $he operating system is responsi" e #or the #o owing acti!ities in connection with process management. ,rocess creation and de etion. ,rocess suspension and resumption. ,ro!ision o# mechanisms #or; o ,rocess synchroni6ation o ,rocess communication *. /ain

Operating System
/emory /anagement

17

(ECS-501)

2emory is a arge array o# words or "ytes- each with its own address. It is a repository o# 0uic4 y accessi" e data shared "y the C,' and I.O de!ices. 2ain memory is a !o ati e storage de!ice. It oses its contents in the case o# system #ai ure. $he operating system is responsi" e #or the #o owing acti!ities in connections with memory management; Deep trac4 o# which parts o# memory are current y "eing used and "y whom. *ecide which processes to oad when memory space "ecomes a!ai a" e. A ocate and dea ocate memory space as needed.

C. 3ile /anagement:

2ost !isi" e component o# OS. Computers can store in#ormation on se!era di##erent types o# physica media (e.g. magnetic tapemagnetic dis4- C* etc). 9or con!enient use o# the computer system- the OS pro!ides a uni#orm ogica !iew o# in#ormation storage. A #i e a ogica storage unit- which a"stract away the physica properties o# its storage de!ice. A #i e is a co ection o# re ated in#ormation de#ined "y its creator. Common y- #i es represent programs ("oth source and o"1ect #orms) and data. $he operating system is responsi" e #or the #o owing acti!ities in connections with #i e management; 9i e creation and de etion. *irectory creation and de etion.

Operating System

18

(ECS-501)

Support o# primiti!es #or manipu ating #i es and directories. 2apping #i es onto secondary storage. 9i e "ac4up on sta" e (non!o ati e) storage media.

1. I#O System /anagement 'sed to manage I.O de!ices and I.O operations. $he I.O system consists o#; A "u##er-caching system A genera de!ice-dri!er inter#ace *ri!ers #or speci#ic hardware de!ices

,. Secondary Storage management Since main memory (primary storage) is !o ati e and too sma to accommodate a data and programs permanent y- the computer system must pro!ide secondary storage to "ac4 up main memory. 2ost modern computer systems use dis4s as the princip e on- ine storage medium- #or "oth programs and data. $he operating system is responsi" e #or the #o owing acti!ities in connection with dis4 management; 9ree space management Storage a ocation *is4 schedu ing 3. :etwor.ing (1istri%uted Systems! A distributed system is a co ection processors that do not share memory or a c oc4. Each processor has its own oca memory. $he processors in the system are connected through a communication networ4.

Operating System

19

(ECS-501)

Communication ta4es p ace using a protocol. A distri"uted system pro!ides user access to !arious system resources. Access to a shared resource a ows; Computation speed-up Increased data a!ai a"i ity Enhanced re ia"i ity

4. rotection System Protection re#ers to a mechanism #or contro ing access "y programs- processes- or users to "oth system and user resources. $he protection mechanism must; *istinguish "etween authori6ed and unauthori6ed usage. Speci#y the contro s to "e imposed. ,ro!ide a means o# en#orcement.

6. Command-Interpreter System 2any commands are gi!en to the operating system "y contro statements which dea with; ,rocess creation and management I.O hand ing Secondary-storage management 2ain-memory management 9i e-system access ,rotection +etwor4ing $he program that reads and interprets contro statements is ca ed !arious y; Command- ine interpreter She (in '+I=)

Operating System

20

(ECS-501)

Its #unction is to get and e/ecute the ne/t command statement.

1.A Operating System Ser$ices: rogram e&ecution C system capa"i ity to oad a program into memory and to run it. I#O operations C since user programs cannot e/ecute I.O operations direct y- the operating system must pro!ide some means to per#orm I.O. 3ile-system manipulation C program capa"i ity to read- write- create- and de ete #i es. Communications C e/change o# in#ormation "etween processes e/ecuting either on the same computer or on di##erent systems tied together "y a networ4. Imp emented !ia shared memory or message passing. ,rror detection C ensure correct computing "y detecting errors in the C,' and memory hardware- in I.O de!ices- or in user programs.

'dditional functions e/ist not #or he ping the user- "ut rather #or ensuring e##icient system operations. 7esource allocation C a ocating resources to mu tip e users or mu tip e 1o"s running at the same time. 'ccounting C 4eep trac4 o# and record which users use how much and what 4inds o# computer resources #or account "i ing or #or accumu ating usage statistics. rotection C ensuring that a access to system resources is contro ed

1.B System Calls System ca s pro!ide the inter#ace "etween a process and the operating system. $hese ca s are genera y a!ai a" e as assem" y anguage instructions . Some systems a so a ow to ma4e system ca s #rom a high e!e anguage- such as C.$hey are used to a ow user e!e processes to re0uest ser!ices o# the OS.'ser programs communicate with an OS : re0uests ser!ices #rom it "y ma4ing system ca s.each system ca has a i"rary procedure that the user program ca s.

Operating System

21

(ECS-501)

0ypes of System Calls :


0he $arious types of system calls are as gi$en :

Operating System

22

(ECS-501)

Operating System

23

(ECS-501)

Operating System
1.C System rograms:

24

(ECS-501)

System programs pro!ide a con!enient en!ironment #or program de!e opment and e/ecution. Some o# them are simp y user inter#aces to system ca s.

Types of system programs :

Operating System < 1;

25

(ECS-501)

Dhat is the distinction %etween .ernel mode and user mode in operating system.
Answer:. Certain instructions cou d "e e/ecuted on y when the C,' is in 4erne mode.

Simi ar y- hardware de!ices cou d "e accessed on y when the program is e/ecuting in 4erne mode. Contro o!er when interrupts cou d "e ena" ed or disa" ed is a so possi" e on y when the C,' is in 4erne mode. Conse0uent y- the C,' has !ery imited capa"i ity when e/ecuting in user mode-