Sunteți pe pagina 1din 30

OPERATING SYSTEM

1. What are the advantages of spooling? The spooling operation uses a disk as a very large buffer. Spooling is however capable of overlapping I/O operation for one ob with processor operations for another ob. !. What are the advantages and disadvantages of batch syste"? #dvantages of batch syste"$ %ove "uch of the work of the operator to the co"puter Increased perfor"ance since it was possible for ob to start as soon as the previous ob finished. &isadvantages of batch syste"$ Turn around ti"e can be large fro" user standpoint. &ifficult to debug progra". # ob could enter an infinite loop. # ob could corrupt the "onitor' thus affecting pending obs. &ue to lack of protection sche"e' one batch ob can affect pending obs. (. What are the features of "ulti)processor syste"s? 1. If one processor fails' then another processor should retrieve the interrupted process state so that e*ecution of the process can continue. !. The processors should support efficient conte*t switching operation. (. %ultiprocessor syste" supports large physical address space + large virtual address space. ,. The I-. "echanis" should be provided and i"ple"ented in hardware as it beco"es efficient and easy. ,. What are the difficulties in distributed OS? 1. !. (. ,. There are no current co""ercially successful e*a"ples. -rotocol overhead can do"inate co"putation costs. /ard to build well. -robably i"possible to build at the scale of the internet.

0. 1*plain the characteristics of suspended process? Suspended process is not i""ediately available for e*ecution. The process "ay or "ay not be waiting on an event. 2or preventing the e*ecution' process is suspended by OS' parent process' process itself and an agent. -rocess "ay not be re"oved fro" the suspended state until the agent orders the re"oval.

3. What are the reasons for process suspension? Swapping Ti"ing Interactive user re4uest -arent process re4uest Swapping: OS needs to release re4uired "ain "e"ory to bring in a process that is ready to e*ecute. Timing: -rocess "ay be suspended while waiting for the ne*t ti"e interval. Interactive user request: -rocess "ay be suspended for debugging purpose by user. Parent process request: To "odify the suspended process or to coordinate the activity of various descendants. 5. 1*plain whether following transitions between process states are possible or not. If possible' give the e*a"ple? 1. 6unning ) 6eady (. Waiting 7 6unning !.6unning 7 Waiting ,.6unning 7 Ter"inated

Ans: 1. 2or changing the state fro" running to ready is possible. 2or e*a"ple' when a process ti"e 4uantu" e*pires. !. 6unning 7 Waiting is also possible. When a process issues an I/O re4uest. (. Waiting 7 6unning is not possible. 2ro" waiting state' the process goes to the ready state then running. ,. 6unning 7 Ter"ination is possible' when a process ter"inates itself.

8. What are the drawbacks of se"aphore? They are essentially shared global variables. #ccess to se"aphores can co"e fro" anywhere in a progra". There is no control or guarantee of proper usage. There is no linguistic connection between the se"aphore and the data to which the se"aphore controls access. They serve two purposes' "utual e*clusion and scheduling constraints.

9. What are the drawbacks of "onitors? %a or weakness of "onitors is the absence of concurrency if a "onitor encapsulates the resources' since only one process can be active within a "onitor at a ti"e. There is the possibility of deadlocks in the case of nested "onitors calls. %onitor concept is its lack of i"ple"entation "ost co""only used progra""ing languages. %onitors cannot easily be added if they are not natively supported by the language.

1:. What are the drawbacks of software solutions? .o"plicated to progra". ;usy waiting is possible. It would be "ore efficient to block processes that are waiting. %akes difficult assu"ptions about the "e"ory syste".

11. What are the advantages of test + set instruction? It is si"ple and easy to verify. It is applicable to any nu"ber of processes. It can be used to support "ultiple critical section.

1!. What are the disadvantages of test + set instruction? ;usy waiting is possible. Starvation is also possible. There "ay be deadlock.

1(. .o"pare the long ter"' "iddle ter" and short ter" schedulers? Sr.no <ong ter" scheduler 1. !. (. ,. 0. It is ob scheduler. Speed is less than short ter" scheduler. It controls the degree of "ultiprogra""ing #bsent or "ini"al in ti"e sharing syste". It selects processes fro" pool and loads the" into "e"ory for e*ecution. -rocess state is >?ew to 6eady@ Select a good process' "i* of I/O bound and .-= bound. Short ter" scheduler It is .-= scheduler. Speed is very fast. <ess control over degree of "ultiprogra""ing %ini"al in ti"e sharing syste". It select fro" a"ong the processes that are ready to e*ecute. -rocess state is >6eady to 6unning@ Select a new process for a .-= 4uite fre4uently. %ediu" ter" scheduler It is swapping. Speed is in between both. 6educe the degree of "ultiprogra""ing Ti"e sharing syste" use "ediu" ter" scheduler. -rocess can be reintroduced into "e"ory and its e*ecution can be continued. )))) ))))

3. 5.

1,. 1*plain the co"parison between 2.2S and 6ound 6obin >66@ "ethod? Sr.no. 1. !. (. ,. 0. 3. 2.2S 2.2S decision "ade is non pree"ptive. It has "ini"u" overhead. 6esponse ti"e "ay be high. It is troubleso"e for ti"e sharing syste". The workload is si"ply processed in the order of arrival. ?o starvation in 2.2S. 6ound 6obin 66 decision "ade is pree"ptive. It has low overhead. -rovides good response ti"e for short processes. It is "ainly designed for ti"e sharing syste". It is si"ilar like 2.2S but uses ti"e 4uantu". ?O starvation in 66.

10. .onsider following process' with the .-= burst ti"e given in "illiseconds. -rocess -1 -! -( -, -0 ;urst ti"e 1: 1 ! 1 0 -riority ( 1 ( , !

-rocesses are arrived in p1' p!' p(' p,' p0 order of all at ti"e :. 1. &raw Aantt charts to show e*ecution using 2.2S' SB2' nonpree"ptive priority >s"all priority nu"ber i"plies higher priority@ and 66 >4uantu" C 1@ scheduling. !. #lso calculate turn around ti"e for each scheduling algorith"s. (. What is the waiting ti"e of each process for each one of the above scheduling algorith"? Ans: 1 Gantt c!art a "#"S

P1 0 10

P2 11

P3 13

P4 14

P5 19

$ S%" P2 0 19 1 P4 2 P3 4 P5 9 P1 19

c Nonpreemptive priorit& P2 0 1 P5 6 P1 16 P3 18 P4 19

' RR (quantum ) 1 -1 0 1 -! -( -, -0 -1 -( -0 -1 -0 -1 2 3 4 5 6 7 8 9 10 -0 -1 -0 -1 -1 -1 -1 -1 11 12 13 14 15 16 17 18 19

* Turn aroun' time ) $urst time + waiting time a ,or "#"S C >1:D11D1(D1,D19@/0 C 35/0 C 1(., $ ,or S%" C >1D!D,D9D19@ / 0 C(0 / 0 C5 c ,or nonpreemptive priorit& C >1D3D13D18D19@ / 0 C 3: / 0 C1! ' ,or RR C >19D!D5D,D1,@ / 0 C ,3 / 0 C 9.! - waiting time a ,or "#"S -rocess -1 -! -( -, -0 Waiting ti"e : 1: 11 1( 1,

$ ,or S%" -rocess -1 -! -( -, -0 c ,or nonpreemptive priorit& -rocess -1 -! -( -, -0 ' "or RR met!o' -rocess -1 -! -( -, -0 Waiting ti"e 9 1 0 ( 9 Waiting ti"e 3 : 13 18 1 Waiting ti"e 9 : ! 1 ,

13. 2or the following e*a"ple calculate average turnaround ti"e and average waiting ti"e for the following algorith"s. 1. 2.2S !. -ree"ptive SB2 (. 6ound robin >1 ti"e unit@ -rocess -1 -! -( -, Ans: 1. ,or "#"S a@ Gantt c!art$ P1 8 #rrival ti"e : 1 ! ( ;urst ti"e 8 , 9 0

P2 12

P3 21

P4 26

$ waiting time: -rocess -1 -! -( -, c@ Average waiting time C >:D5D1:D18@ / , C (0 / , C 8.50 ' Turn aroun' time: $urst time + waiting time -rocess -1 -! -( -, Turn around ti"e 8D:C8 ,D5C11 9D1:C19 0D18C!( Waiting ti"e : 5 1: 18

e@ average turn aroun' time C >8D11D19D!(@ /, C31/, C 10.!0 !. ,or preemptive S%" a@ Gantt c!art: P1 0 1 p! 5 p, 10 p1 17 p( 26

b /aiting time$ -rocess -1 -! -( -, c@ Average waiting time C >9D:D10D!@/, C !3/, C 3.0 Waiting ti"e 9 : 10 !

d@ Turn aroun' time$ -rocess -1 -! -( -, e@ Average turnaroun' time C >15D,D!,D5@/, C0!/, C1( (@ Roun' Ro$in (1 unit time a Gantt c!art:
P1 p2 p3 p4 p1 p2 p3 p4 p1 p2 p3 p4 p1 p2 p3 p4 p1 p3 p4 p1 p3 p1 p3 p1 p3 p3

Turn around ti"e 8D9C15 ,D:C, 9D10C!, 0D!C5

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

b@ /aiting time$ -rocess -1 -! -( -, c@ Average waiting time C >13D9D10D11@ / , C 01/, C 1!.50 d turnaroun' time: -rocess -1 -! -( -, Turnaround ti"e 8D13C!, ,D9C1( 9D10C!, 0D11C13 Waiting ti"e 13 9 10 11

e@ Average turnaroun' time C >!,D1(D!,D13@ / , C 55/, C 19.!0 15. 2or the process listed below' draw a Aantt chart using priority scheduling. # larger priority nu"ber has higher priority. a@ -ree"ptive b@ ?onpree"ptive

-rocess -1 -! -( -,

#rrival ti"e :.: (.: (.: 3.:

;urst ti"e 3 0 ( 0

-riority , ! 3 (

#ns a@ pree"ptive priority$ Aantt chart P1 0 3 p3 6 p1 9 p4 14 p2 19

b@ ?onpree"ptive priority$ Aantt chart$ P1 0 6 p3 9 p4 14 p2 19

18. What are the disadvantages of deadlock avoidance? 1. The "a*i"u" resource re4uire"ent for each process "ust be stated in advance. !. There "ust be a fi*ed nu"ber of resources to allocate and a fi*ed nu"ber of processes. (. The processes under consideration "ust be independent. 19. State the weakness of bankerEs algorith"? 1. It re4uires that there be a fi*ed nu"ber of resources to allocate. !. The algorith" re4uires that users state their "a*i"u" needs >re4uest@ in advance. (. ?u"ber of users "ust re"ain fi*ed. ,. The algorith" re4uires that the bankers grant all re4uests with in a finite ti"e. 0. #lgorith" re4uires that process returns all resource within a finite ti"e. !:. What are the advantages + disadvantages of deadlock prevention? #&F#?T#A1S$ 1 no pree"ption necessary !. Works well for processes that perfor" a single burst of activity. (. ?eeds no run)ti"e co"putation. ,. feasible to enforce via co"pile ti"e check.

&isadvantages$ 1. !. (. ,.
#lgorith" 2.2S -olicy type ?on pree"ptive -ree"ptive

Inefficient. delays process initiation sub ect to cyclic restart disallows incre"ental resource re4uest
=sed in ;atch #dvantages 1.easy to i"ple"ent !.%ini"u" overhead 1.provides fair .-= allocation !.provides reasonable response ti"es to interactive users 1.ensures fast co"pletion of i"portant obs 1."ini"iGes average waiting ti"e !.SB2 algorith" is opti"al &isadvantages 1.unpredicable turnaround ti"e !.average waiting is "ore 1.re4uires selection of good ti"e slice.

!1. 1*plain the co"parison of scheduling algorith"?

66

Interactive

-riority

?on pree"ptive

;atch

SB2

?on pree"ptive

;atch

%ultilevel 4ueues

pree"ptive or non pree"ptive

;atch/interactive 1.fe*ible !.gives fair treat"ent to .-= bound obs

1.indefinite postpone"ent of so"e obs !.faces starvation proble" 1.indefinite postpone"ent of so"e obs !.cannot be i"ple"ented at the level of short ter" scheduling (.difficulty is knowing the length of the ne*t .-= re4uest 1.overhead incurred by "onitoring of 4ueues

!!. What are advantages and disadvantages of deadlock detection? #dvantages$ 1. never delays process initiation !. 2acilitates online handling. &isadvantages$ 1. Inherent pree"ption losses.

!(. what are the advantages and disadvantages of deadlock avoidance?

#dvantages$ 1. no pree"ption necessary &isadvantages$ 1. 2uture resource re4uire"ents "ust be known !. -rocesses can be blocked for long periods. !,. Aive the process resource usage and availability' draw the resource allocation graph?

.urrent -rocess allocation 61 -1 -! -( -, ! ( 1 :

Outstanding re4uest 6! : 1 ( 1

#vailable resource 6( : : : 1

61 6! 6( 61 6! 6( 1 : : : 1 : : 1 : : 1 : : : :

#ns$ 6esource)allocation graph$

......

.....

( ,

!0. 1*plain logical verses physical address space?

<ogical address is generated by .-=. -hysical address is the address of "ain "e"ory and it is loaded into the "e"ory address register. .o"pile)ti"e and load)ti"e address)binding "ethods generate sa"e logical address and physical addresses. 1*ecution)ti"e address)binding sche"e results in different logical and physical addresses. Aenerally logical address is referred as a virtual address. <ogical address space)set of all logical addresses generated by progra" is a logical address space. -hysical address space is a set of all physical addresses corresponding to these logical addresses. %e"ory "anage"ent unit "apping at run)ti"e fro" virtual to physical addresses is done by a hardware device. This hardware device is %%=. 6elocation register is also called base register. Falue of the relocation register is added to every address generated by a user process at the ti"e it is sent to "e"ory. =ser progra" never sees the real physical addresses.

!3. 1*plain the advantages and disadvantages of contiguous "e"ory allocation? #dvantages$ 1. si"ple to i"ple"ent !. does not re4uire e*pertise to understand and use such a syste" &isadvantages$ 1. "e"ory is not fully utiliGed !. poor utiliGation of processors (. userEs process > ob@ being li"ited to the siGe of available "ain "e"ory !5. Write the advantages and disadvantages of paging? #dvantages$ 1. paging eli"inates frag"entation !. support higher degree of "ultiprogra""ing (. paging increases "e"ory and processor utiliGation ,. .o"paction overhead re4uired for the re locatable partition sche"e is also eli"inated. &isadvantages$ 1. page address "apping hardware usually increases the cost of the co"puter !. "e"ory "ust be used to store the various tables like page table' "e"ory "ap table etc (. so"e "e"ory will still be unused if the nu"ber of available block is not sufficient for the address spaces of the obs to be run

!8.given "e"ory partitions of 1::H' 0::H' !::H' (::H and 3::H >in order@ how would each of the first fit' best fit and worst fit algorith"s place processes of !1!H' ,15H' 11!H and ,!3H >in order@ ? which algorith" "akes the "ost efficient use of "e"ory. #ns$ 1. first fit$
%e"ory -artitions

100K

500K

200K

300K

600K

-rocesses

212K

417K

112K

426K

?o "e"ory partitions

!.worst fit$
%e"ory -artitions

100K

500K

200K

300K

600K

-rocesses

212K

417K

112K

426K
?o "e"ory partitions

(.best fit$
%e"ory -artitions

100K

500K

200K

300K

600K

-rocesses

212K

417K

112K

426K

!9. Write the advantages and disadvantages of paging? #dvantages$ 1. seg"entation eli"inates frag"entation !. it provides virtual "e"ory (. allows dyna"ic seg"ent growth ,. seg"entation assists dyna"ic linking 0. seg"entation is visible &isadvantages$ 1. "a*i"u" siGe of a seg"ent is li"ited by the siGe of "ain "e"ory !. difficulty to "anage variable siGe seg"ents on secondary storage (:. 1*plain advantages and disadvantages of seg"entation with paging? #dvantages .o"bine all advantages of paging and seg"entation. &isadvantages$ 1. it increases hardware cost !. it increases processor overhead (. &angers of thrashing (1. Write the difference between seg"entation and paging? Sr.no Seg"entation -aging 1. !. (. ,. 0. 3. 5. 8. -rogra" is divided into variable siGe seg"ents. =ser >or co"piler@ is responsible for dividing the progra" into seg"ents. Seg"entation is slower than paging. Seg"entation is visible to the user. Seg"entation eli"inates internal frag"entation Seg"entation suffers fro" e*ternal frag"entation -rocessor uses page nu"ber' offset to calculate absolute address OS "aintain a list of free holes in "ain "e"ory -rogra" is divided into fi*ed siGe page. &ivision into pages is perfor"ed by the operating syste". -aging is faster than seg"entation. -aging is invisible to the user. -aging suffers fro" internal frag"entation There is no e*ternal frag"entation -rocessor uses seg"ent nu"ber' offset to calculate absolute address OS "ust "aintain a free fra"e list.

(!. 1*plain the advantages and disadvantages of de"and paging? #dvantages$ 1. large virtual "e"ory !. "ore efficient use of "e"ory (. =nconstrained "ultiprogra""ing. There is no li"it on degree of "ultiprogra""ing. &isadvantages$

1. ?u"ber of tables and a"ount of processor over head for handling page interrupts are greater than in the case of the si"ple paged "anage"ent techni4ue. !. &ue to the lack of an e*plicit constraint on obs address space siGe. ((. .onsider the following snapshot of a syste" #llocation processe s -: -1 -! -( -, # : 1 1 : : ; : : ( 3 : . 1 : 0 ( 1 & ! : , ! , # : 1 ! : : %a* ; : 5 ( 3 3 . 1 0 0 0 0 & ! : 3 ! 3 # 1 #vailable ; 0 . ! & :

#nswer the following 4uestions using the bankerEs algorith". a@. what is the content of the "atri* need? b@ is the syste" is a safe state? c@ if the re4uest fro" process p1 arrives for >:','!':@ can the re4uest be granted i""ediately? #ns$ a@ .ontent of the needed "atri* is -rocess -: -1 -! -( -, # : : 1 : : ; : 5 : : 3 . : 0 : ! , & : : ! : !

b@ Syste" is in safe state because resources available >1'0'!':@' c@ 6e4uest fro" process p1 can be granted i""ediately. 6e4uest is >:','!':@ and available resource is >1'0'!':@. (,. -aging syste" consists of physical "e"ory !!, bytes' pages of logical address space is !03. -age siGe of !1: bytes' how "any bits are in a logical address? #ns$ <ogical address space C !03 C !8 -age siGe C !1: bytes So' total logical address space C!8 I !1: C !18 bytes

2or !18 byte address space 7 18 bit address is re4uired (0. 1*plain the co"parison of de"and paging with seg"entation? Sr.no 1 !. (. ,. 0. 3. Seg"entation Seg"ents "ay of different siGe Seg"ents can be shared. It allows dyna"ic growth of seg"ents. Seg"ent "ap table indicates the address of each seg"ent in "e"ory. Seg"ents are allocated to the progra" while co"pilation. -rovides virtual "e"ory. &e"and paging -ages are of sa"e siGe. -ages can not be shared. -age siGe is fi*ed. -age "ap table keeps track of pages in "e"ory. -ages are loaded in "e"ory on de"and. #lso provides virtual "e"ory.

(3. On a syste" using si"ple seg"entation' co"pute the physical address for each of the logical addresses' logical address is given in the following seg"ent table. If the address generates a seg"ent fault' indicates so. Seg"ent : 1 ! ( a@ :' 99 b@ !' 58 #ns$ ;ase ((: 853 111 ,98 d@ ('!!! <ength 1!, !11 99 (:! e@ :'111

c@ 1'!30

a@ :' 99 Offset C 99 Seg"ent length C 1!, Seg"ent C : Offset 99 is less than seg"ent length 1!,. Starting location of seg"ent : is start fro" ((:. -hysical address C offset D seg"ent base C 99 D ((: C ,!9 b@ !' 58 Seg"ent C ! Offset C 58 Seg"ent length C 99 Offset 58 is less than seg"ent length 99. Starting location of seg"ent ! is 111. -hysical address C offset D seg"ent base C 111 D 58 C 189

c@ 1'!30 Seg"ent C 1 Offset C !30 Seg"ent length C !11 Offset !30 is greater than seg"ent length !11. This address results in a seg"ent fault. d@ (' !!! Seg"ent C ( Offset C !!! Seg"ent length C (:! Offset !!! is less than seg"ent length (:!. Starting location of seg"ent ( is ,98. -hysical address C offset D seg"ent base C ,98 D !!! C 5!: e@ :'111 Seg"ent C : Offset C 111 Seg"ent length C 1!, Offset 111 is less than seg"ent length 1!,. Starting location of seg"ent : is ((:. -hysical address C offset D seg"ent base C ((: D 111 C ,,1 (5. Syste" using a paging and seg"entation' the virtual address space consists of up to 8 seg"ents where each seg"ent can be up to ! !9 byte long. The hardware pages each seg"ent into !03 bytes pages. /ow "any bits in the virtual address specify the 1@ Seg"ent nu"ber? !@ -age nu"ber ? (@ Offset within page? ,@ 1ntire virtual address? #ns$ 1@ seg"ent nu"ber$ virtual address space consists up to 8 seg"ents. So 8 C !( Since ( bits are needed to specify seg"ent nu"ber. !@ -age nu"ber$ /ardware pages each seg"ent into !03 byte pages. So !03 C !8 byte page SiGe of seg"ent is !!9 bytes. Since !!9 / !8 C !!9)8 C !!1 C !1 pages Since !1 bits are re4uired to specify the page nu"ber. (@ Offset within the page$ for !8 byte page' 8 bits are needed.

,@ 1ntire virtual address$ C seg"ent nu"ber D page nu"ber D offset C ( D !1 D 8 C (!. (8@ 1*plain the advantages and disadvantages of tree structured directory? #dvantages$ 1. It allows users to create their own subdirectory. !. =ser can access the files of other users. (. It allows users to define their own search paths. &isadvantages$ 1. Special syste" calls are re4uired to create + delete directories. !. It prohibits the sharing of files and directories. (. -ath to the file is longer than the two level directories. (9@ 1*plain the characteristics' advantages' and disadvantages of contiguous file allocation? .haracteristics$ 1. It supports variable siGe portions. !. -re)allocation is re4uired. (. It re4uires only single entry for a file. ,. #llocation fre4uency is only once. #dvantages$ 1. It supports variable siGe portion. !. 1asy to retrieve single block. (. #ccessing a file is easy. ,. It provides good perfor"ance. &isadvantages$ 1. It suffers fro" e*ternal frag"entation. !. -re)allocation is re4uired. ,:@ 1*plain the characteristics' advantages' and disadvantages of linked allocation? .haracteristics$ 1. It supports fi*ed siGe portions. !. -re)allocation is possible. (. 2ile allocation table siGe is one entry for a file. ,. #llocation fre4uency is low to high. #dvantages$ 1. There is no e*ternal frag"entation. !. It is never necessary to co"pact disk space. (. -re)allocation is not re4uired.

&isadvantages$ 1. 2iles are accessed only se4uentially. !. Space re4uired for pointers. (. 6eliability is not good. ,. .an not support direct access. ,1@ 1*plain the advantages' and disadvantages of inde*ed allocation? #dvantages$ 1. It supports se4uential and direct access. !. ?o e*ternal frag"entation. (. 2aster than other two "ethods. ,. It supports fi*ed and variable siGe blocks. &isadvantages$ 1. Inde*ed allocation does suffer wasted space. !. -ointer overhead is generally greater. ,!@ 1*plain the co"parison between contiguous + linked file allocation "ethod? -ara"eter .ontiguous <inked 1. pre)allocation !.fi*ed or variable siGe portion (.2#T siGe ,. ti"e to allocate 0. allocation fre4uency 3. frag"entation 5. file access ?ecessary Fariable One entry %ediu" Once Suffer fro" e*ternal frag"entation 6ando"ly -ossible 2i*ed blocks One entry <ong <ow or high &oes not suffer fro" e*ternal frag"entation. Se4uentially

,(@ The operating syste" contains ( resources' the nu"ber of instance of each resource type are 5'5'1:. The current resource allocation state is as shown below. .urrent allocation %a*i"u" need -roces 61 6! 6( 61 6! 6( s -1 ! ! ( ( 3 8 -! -( ! 1 : ! ( , , ( ( , ( ,

1. is the current allocation in a safe state?

!. can the re4uest "ade by process p1 >1 1 :@ be granted? #ns$ 1@ first find the available resource in the syste". #vailable$ C ?u"ber of instance ) su" of allocation .urrent allocation -rocess 61 6! 6( -1 ! ! ( -! -( ! 1 0 : ! , ( , 1:

#vailable C >5 5 1:@ 7 >0 , 1:@ #vailable resource C >! ( :@ .ontent of need "atri* is ?eed -rocess 61 6! -1 1 , -! -( ! ! ( !

6( 0 : :

Safe se4uence J p(' p!' p1K The syste" is in safe state. !@ process p1 re4uest >1 1 :@' this re4uest is less than need. ?eed for process p1 is >1 , 0@. #vailable resource is > !' (' :@ and re4uest is >1 1 :@. 6e4uest J available > 1 1 :@ J >! ( :@ after allocating >1 1 :@ to process p1 the need beco"es as follows. ?eed -rocess -1 -! -( 61 : ! ! 6! ( ( ! 6( 0 : :

#nd available resources is >1 ! :@. ?eed of any process is never satisfied after granting the process p1 re4uest >1 1 :@. So the syste" will be blocked. Therefore re4uest of process p1 >1 1 :@ is cannot be granted. ,,@ consider the following snapshot #llocation %a* #vailable -rocess 61 6! 61 6! 61 6! -1 -! -( -, 1 : 1 ! ! 1 : : , 1 1 ( ! ! ( ! 1 1

Whether the syste" is safe state or unsafe? #ns$ first calculated need ?eed C "a* 7 allocation ?eed -rocess 61 6! -1 ( : -! 1 1 -( : ( -, 1 ! Syste" is in safe state with safe se4uence J p!' p,' p1' p(K Syste" will co"plete its operation in this se4uence. ,0@ .onsider the snapshot. #llocation -rocess -1 -! 61 5 1 6! ! ( 61 9 ! %a* 6! 0 3 61 ! #vailable 6! 1

-( -,

1 (

1 :

! 0

! :

1@ .alculate content of need "atri*. !@ Syste" is safe or unsafe.

#ns$

1@ need C "a* 7 allocation ?eed

-rocess -1 -! -( -,

61 ! 1 1 !

6! ( ( 1 :

!@ Syste" is unsafe state. 6esources are not available for processes p1 and p! to co"plete their operation. ,3. What is "eant by L/ard real syste"s and soft real syste"s? /ard real syste"s guarantee that critical tasks co"plete on ti"e. In soft real syste" a critical task get priority over tasks and re"ains that priority until it co"plete. ,5. What are the "ain differences between operating syste"s for "ainfra"e co"puters and personal co"puters? Aenerally' operating syste"s for batch syste"s have si"pler re4uire"ents than personal co"puters. ;atch syste"s do not have to be concerned with interacting with a user as "uch as personal co"puter. #s a result' an operating syste" for a -. "ust be concerned with response ti"e for an interactive user. ;atch syste"s do not have such re4uire"ents. # pure batch syste" also "ay have not to handle ti"e sharing' whereas an operating syste" "ust switch rapidly between different obs. ,8. What is the "ain advantage of the layered approach to syste" design? What are the disadvantages of using the layered approach? #s in all cases of "odular design' designing an operating syste" in a "odular way has several advantages. The syste" is easier to debug and "odify because changes affect only li"ited sections of the

syste" rather than touching all sections of the operating syste". Infor"ation is kept only where it is needed and is accessible only within a defined restricted area' so any bugs affecting that data "ust be li"ited to a specific "odule or layer. ,9. What are the three "ain purposes of an operating syste"? 1@ To provide an environ"ent for a co"puter user to e*ecute progra"s on co"puter hardware in a convenient and efficient "anner. !@ To allocate the separate resources of the co"puter as needed to solve this proble" given. The allocation process should be as fair and efficient as possible. (@ #s a control progra" it serves ! "a or functions$ I. Supervision of the e*ecution of user progra"s to prevent errors and i"proper use of the co"puter II. %anage"ent of the operation and control of I/O devices. 0:. What is the "ain advantage of "ultiprogra""ing? %ultiprogra""ing "akes efficient use of the .-= by overlapping the de"ands for the .-= and I/O devices fro" various users. It atte"pts to increase .-= utiliGation by always having so"ething for the .-= to e*ecute. 01. Why are distributed syste"s desirable? &istributed syste"s can provide resources' sharing' co"putation speeding' increased reliability' and the ability to co""unicate with re"ote sites. 0!. What is the "ain difficulty that a progra""er "ust overco"e in writing an operating syste" for a real)ti"e environ"ent? The "ain difficulty is keeping the operating syste" within the fi*ed ti"e constraints of a real)ti"e syste". If the syste" does not co"plete a task in a certain ti"e fra"e' it "ay cause a breakdown of the entire syste" it is running. Therefore when writing an operating syste" in a real)ti"e syste"' the writer "ust be sure that his scheduling sche"es donEt allow response ti"e to e*ceed the ti"e constraint. 0(. <ist the advantages of Interprocess "essages? 1. -rocesses need not define a co"ple* protocol for co""unication. !. -rocess does not need to guess the siGe of shared data area re4uired for Interprocess co""unication. (. The OS takes responsibility to block the process e*ecuting a receiver when no "essage e*ist for it. ,. The process "ay e*ist in different co"puter syste"s. 0,. <ist the features of process scheduling in "ultiprogra""ing scheduler? 2eatures$

1@ # single list of process control blocks is "aintained in the syste". !@ -rocess control blocks in the list are organiGed in the order of reducing priorities. (@ The process control blocks of newly created process is entered in the list in accordance with its priority. ,@ The process control block is re"oved fro" the list when it ter"inates. 0@ The scheduler scans the process control block list and schedules the first ready process. 00. 1*plain the features of process scheduling in ti"e sharing syste"? 2eatures$ 1@ -rocess priority does not depend on the nature of the processes. !@ -rocesses are scheduled in the round robin "anner. (@ # running process is pre)e"pted when its ti"e slice elapses. ,@ -rocesses "ay be swapped out of "e"ory. 03. What infor"ation is saved and restored during a conte*t switch? .onte*t switch re4uires saving the state of the old process and loading the saved state for the new process. -rocess state "ini"ally includes current contents of registers' progra" counter' stack pointer' file descriptors' etc. 05. <ist the features of independent process? # process is independent if it cannot affect or be affected by other processes e*ecuting in the syste". This type of processes has following features$ Its state is not shared in any way be any other process. Its e*ecution is deter"inistic' i.e. the results of e*ecution depend only on the input values. Its e*ecution is reproducible i.e. the results of e*ecution will always be the sa"e for the sa"e input. Its e*ecution can be stopped and restarted without any negative effect. 08. <ist the characteristics of cooperating process? .ooperating processes can affect or be affected by other processes e*ecuting in the syste". They are characteriGed by$ Their states are shared by other processes Its e*ecution is not deter"inistic' i.e. the results of e*ecution depend on relative e*ecution se4uence and can not be predicted in advance Its e*ecution is irreproducible' i.e. the results of e*ecution are not always the sa"e for the sa"e input. 09. What advantage is there in having different ti"e)4uantu" siGes on different levels of a "ultilevel 4ueuing syste"? -rocesses that need "ore fre4uent servicing' for instance' interactive processes such as editors' can be in 4ueuing with a s"all ti"e 4uantu".

-rocesses switch no need for fre4uent servicing can be in 4ueue with a larger 4uantu"' re4uiring fewer conte*t switches to co"plete the processing' and thus "aking "ore efficient use of the co"puter. 3:. 1*plain the difference in degree to which the following scheduling algorith" discri"inate in favour of short processes? 1. 2.2S !. 66 (. %ultilevel feedback 4ueue. 2.2S$ discri"inates against short obs since any short obs arriving after long obs will have a longer waiting ti"e. 66$ treats all obs e4ually so that short obs will be able to leave the syste" faster since they will finish first. %2M$ work si"ilar to the 66 algorith" 7 they discri"inate favourably toward short ob. 31. # .-= scheduling algorith" deter"ines an order for the e*ecution of its scheduled processes. Aiven n processes to be scheduled on one processor' how "any possible different schedules are there? Aive a for"ula in ter"s of n? nN >n factorial C n I n )1I n 7 !OOO.I!I1@. 3!. &efine the difference between pree"ptive and non pree"ptive scheduling? -ree"ptive scheduling allows a process to be interrupted in the "iddle of its e*ecution' taking the .-= away and allocating it to another process. ?onpree"ptive scheduling ensures that a process relin4uishes control of the .-= only when it finishes with its current .-= burst. 3(. What is the difference between a pree"ptive scheduler and a ti"e)sliced one? 2or a pree"ptive scheduler' process with highest priority runs first. =nless there is a process with a higher priority is waiting' the current process runs until co"pletion. Ti"e slice is .-= based. It divides .-= ti"e into e4ual ti"e slots and each process gets one ti"e slot to run. 3,. Is a nonpree"ptive scheduling algorith" a good choice for an interactive syste"? ?o. once the process gains control of the .-= it returns control until it blocks or it ter"inates. # process could e*ecute for an e*tended period of ti"e doing unaccepted response ti"e. 30. What is a Aantt chart? # two di"ensional chart that plots the activity of a unit on the P)a*is versus the ti"e on the Q)a*is. The chart 4uickly represents how the activities of the units are serialiGed.

33. What is starvation proble" in .-= scheduling? # pheno"enon in "any resources allocation strategies in which so"e set of processes are perpetually ignored because of their priority is not as high as that of other processes. 35. .an the OS detect process starvation? If so' how? If not' what can it do to avoid it? ?oR the best the OS can do is verify that a process has been blocked for a very long ti"e 7 which need not denote starvation. /owever' it is also the one thing that the OS can do to prevent starvation$ have an aging policy that eventually gives very high priority to obs that have been blocked a long ti"e' so that obs that need fewer resources and "ight otherwise pass head will be denied the resources they need until the OS has accu"ulated enough free resources to fulfilled the re4uest of the high)priority ob. 38. What is a spin 7 lock? When a process is in its critical section' any other process that tries to enter its critical section "ust loop continuously in the entry code of critical section until the first one gets out. 39. What is an alternative to spin locking? -ut the process in a wait 4ueue' so it doesnEt waste .-= cycles and allow it to sleep until the block is released. 5:. What is a race condition? # condition in which the behaviour of two or "ore processes depends on the relative rate at which each process e*ecute its progra"s. # race condition can cause a pair of processes to violate a critical section or deadlock. 51. &efine a condition variable? # structure that "ay appear within a "onitor' global to all procedure within the "onitor that can have its value "anipulates by the wait' signal and 4ueue operation. 5!. <ist three e*a"ples of deadlocks that are not related to a co"puter syste" environ"ent? Two cars crossing a single)lane bridge fro" opposite directions. # person going down a ladder while another person is cli"bing up the ladder. Two trains traveling towards each other on the sa"e track. Two carpenters who "ust pound nails. There is a single ha""er and a single bucket of nails. &eadlock occurs if one carpenter has the ha""er and the other carpenter has the nails. &istinguish between internal and e*ternal frag"entation?

5(.

Internal frag"entation is the area in a region or a page that is not used by the process it is allocated to. The space is wasted until the process ter"inates. 1*ternal frag"entation occurs when there is enough free space to satisfy a re4uest for "e"ory' but none of the free holes between processes in "e"ory is large enough to satisfy the re4uest. ?a"e the difference between logical and physical addresses? # logical address does not refer to an actual e*isting address R rather' it refers to an abstract address in an abstract address space. .ontrast this with physical address that refers to an actual physical address in "e"ory. # logical address is generated by the .-= and is transferred into a physical address by the "e"ory "anage"ent unit >%%=@. Therefore' physical addresses are generated by the %%=. Why page siGe always power of !? 6ecalling that paging is i"ple"ented by breaking up an address into a page and offset nu"ber. It is "ost efficient to break the address to calculate the page nu"ber and offset. ;ecause each bit position represents a power of !' splitting an address between bits results in a page siGe that is a power of !. 53. .onsider a logical address space of eight pages of 1:!, words each' "apped onto a physical "e"ory of (! fra"es? a@ /ow "any bits are there in the logical address? b@ /ow "any bits are there in the physical address? a@ <ogical address$ 1( bits. b@ -hysical address$ 10 bits. =nder what circu"stance do page faults occur? &escribe the actions taken by the operating syste" when a page fault occurs? # page fault occurs when an access to a page that has not been brought into "ain "e"ory takes place. The operating syste" verifies the "e"ory access' aborting the progra" if it is invalid. If it is valid' a free fra"e is located and I/O is re4uested to read the needed page into a free fra"e. =pon co"pletion of I/O' the process table and page table are updated and the instruction is restarted. 58. #ssu"e that you have a page)reference string for a process with " fra"es >initially all e"pty@. The page)reference string has length pR n distinct page nu"bers occur in it. #nswer these 4uestions for any page replace"ent algorith"$ a@ What is a lower bound on the nu"ber of page fault? b@ What is an upper bound on the nu"ber of page faults? 55. 50. 5,.

#ns$

#ns$

a@ n b@ p #n operating syste" supports a paged virtual "e"ory' using a central processor with a cycle ti"e of 1 "icrosecond. It costs an additional 1 "icrosecond to access a page other than the current one. -ages have 1::: words' and the paging device is a dru" that rotates at (::: revolutions per "inute and transfers 1 "illion words per second. The following statistical "easure"ents were obtained fro" the syste". 1 percent of all instructions e*ecuted accessed another page other than the current page. Of the instructions that accessed another page' 8: percent accessed a page already in "e"ory. When a new page was re4uired' the replaced page was "odified 0: percent of the ti"e. .alculate the effective instruction ti"e on this syste"' assu"ing that the syste" is running one process only and that the processor is idle during dru" transfers. #ns$ 1ffective access ti"e C :.99 I >1sec D :.::8 I >!sec@ D:.::! I >1::::sec D 1::: sec@ D :.::1 I >1::::sec D 1:::sec@@ C >:.99D:.:13D!!.:D11.:@ sec C (, sec 8:. .onsider a syste" that supports the strategies of contiguous' linked' and inde*ed allocation. What criteria should be used in deciding which strategy is best utiliGed for a particular file? .ontiguous$ if file is usually accessed se4uentially' if file is relatively s"all. <inked$ if file is large and usually accessed se4uentially. Inde*ed$ if file is large and usually accessed rando"ly. 59.

81. 1*plain the purpose of the LO-1?S and L.<OS1S operation =?IQ? 1@ The O-1? operation infor"s the syste" that the na"ed file is about to beco"e active. !@ The .<OS1 operation infor"s the syste" that the na"ed file is no longer in active use by the user who issued the close operation. 8!. .onsider a syste" that supports 0::: users. Suppose that you want to allow ,99: of these users to be able to access one file. a@ /ow would you specify this protection sche"e in =?IQ? b@ .ould you suggest another protection sche"e that can be used "ore effectively for this purpose? #ns$ a@ there are two "ethods for achieving this$

.reate an access control list with the na"es of all ,99: users. -ut these ,99: users in one group and set the group access accordingly. This sche"e cannot always be i"ple"ented since user groups are restricted by the syste".

b@ The universal access to files applies to all users unless their na"e appears in the access)control list with different access per"ission. With this sche"e you si"ply put the na"es of the re"aining ten users in the access control list but with no access privileges allowed.

S-ar putea să vă placă și