Answer the following questions clearly but concisely. What is multiprogramming? 1.

Transcription

Answer the following questions clearly but concisely. What is multiprogramming? 1.
Answer the following questions clearly but concisely.
1.
Whatismultiprogramming?
2.
WhatisthekernelofanOS?
3.
Whatisthekeydifferencebetweenatrapandaninterrupt?
4.
Whatisthepurposeofsystemcalls,andhowdosystemcallsrelatetotheOS
andtotheconceptofdual‐modeoperations?
5.
NamefivemajoractivitiesofanOSwithrespecttoprocessmanagement.
6.
Canaprocessgodirectlyfromreadytoblocked?Explain.
7.
Can a process go directly from blocked to running? Explain.
8.
Whatarethetwoseparateandpotentiallyindependentcharacteristics
embodiedintheconceptofprocess?
9.
Whatresourcesaretypicallysharedbyallofthethreadsofaprocess?
10. What is the biggest advantage of implementing threads in user space? What is the
biggest disadvantage?
11. In a system with threads, is there one stack per thread or one stack per process
when user-level threads are used? What about when kernel-level threads are
used? Explain.
12. Can two threads in the same process synchronize using a kernel semaphore if
they are implemented by the kernel? What if they are implemented in user space?
Discuss your answers.
13. Whatisusuallythecriticalperformancerequirementinaninteractive
operatingsystem?
14. Whatarethemedium‐termscheduleranditsmaindifferencefromlong‐
termscheduler?
15. Whatisthedifferencebetweenturnaroundtimeandresponsetime?
16. Whatisthedifferencebetweenpreemptiveandnonpreemptivescheduling?
17. Describetheround‐robinschedulingtechnique.
18. Whichtypeofprocessisgenerallyfavoredbyamultilevelfeedbackqueuing
scheduler–aprocessor‐boundprocessoranI/O‐boundprocess?Briefly
explainwhy.
19. Five jobs are waiting to be run. Their expected run times are 9, 6, 3, 5, and X. In
what order should they be run to minimize average response time? (Your answer
will depend on X.)
20. Whatoperationscanbeperformedonasemaphore?
21. A computer has six tape drivers, with n processes competing for them. Each
process may need two drives. For which values of n is the system deadlock free?
Explain your answer.
22. A system has p processes each needing a maximum of m identical resources and
a total of r resources available. What condition must hold to make the system
deadlock free?
23. Two collaborating processes run concurrently in a computer system.
Assumingthateachofthe10instructionsa‐jisatomic,listallthedifferent
possiblepairsofoutcomes(forxandy)thatcanbeproducedbythiscode
fragment. Show each sequence and outcome. The shared variables x and y
bothareinitializedto0,andthebinarysemaphoremutexhasinitialvalue1.
Process1
a) x = 1
b) wait(mutex)
c) y = y + x
d) x = 2
e) signal(mutex)
Process2
f) x = x + 2
g) wait(mutex)
h) y = y - 1
i) x = x - y
j) signal(mutex)
24. Suppose that there are two types of philosophers in the dinning
philosophersproblem.Onetypealwayspicksuphisleftforkfirst(a“lefty”),
andtheothertypealwayspicksuphisrightforkfirst(a“righty”).Provethe
following:
a. Anyseatingarrangementofleftiesandrightieswithatleastoneofeach
avoidsadeadlock.
b. Anyseatingarrangementofleftiesandrightieswithatleastoneofeach
preventsstarvation.
25. Writeabounded‐buffermonitorinwhichthe(int)buffersareembedded
withinthemonitoritself.
26. ConsiderasystemconsistingofprocessesP1,P2,...,Pn,eachofwhichhasa
unique priority number. Write a monitor that allocates three identical line
printers to these processes, using the priority numbers for deciding the
orderofallocation.
Hint:Youmayusethefollowingstructureforyoursolution:
monitor printers {
…; //anything you want to add
void request_printer(int proc_number){…} //you need to implement
void release_printer(){…} //you need to implement
}
Notes: (1) You may consider the monitor is used to provide a synchronization
mechanismforprocessestogetaccesstotheprintersunderthegivenconstraint.
(2) When a process is awakened, the condition has to be checked before it is
allowed to access a printer. If the condition is not satisfied, the awakened
processwillbeblockedagain.(3)Youmayassumethatthereisaglobalfunction
for sorting sort() and also others like allocate_printer() and
deallocate_printer()availableforusewhenneeded.
27. Howcanthehold‐and‐waitconditionbeprevented?
28. Explainthedistinctionbetweenarealaddressandavirtualaddress.
29. Whatisthedifferencebetweenapageandaframe?
30. Consider a system in which memory consists of the following hole sizes in
memoryorder:10KB,4KB,20KB,18KB,7KB,9KB,12KB,and15KB.Which
holeistakenforsuccessivesegmentrequestsof
(a)12KB
(b)10KB
(c)9KB
forfirstfit?Nowrepeatthequestionforbestfit,worstfit,andnextfit.
31. Acomputerwitha32‐bitaddressusesatwo‐levelpagetable.Virtual
addressesaresplitintoa9‐bittop‐levelpagetablefield,an11‐bitsecond‐
levelpagetablefield,andanoffset.Howlargearethepagesandhowmany
pagesarethereintheaddressspace?
32. Suppose that a machine has 38-bit virtual addresses and 32-bit physical
addresses.
(a) What is the main advantage of a multilevel page table over a single-level one?
(b) With a two-level page table. 16KB pages, and 4-byte entries, how many bits
should be allocated for the top-level page table field and how many for the
next-level page table field? Explain.
33. Suppose that a 32-bit virtual address is broken up into four fields, a, b, c, and d.
The first three are used for a three-level page table system. The fourth field, d, is
the offset. Does the number of pages depend on the sizes of all four fields? If not,
which ones matter and which ones do not?
34. It has been observed that the number of instructions executed between page faults
is directly proportional to the number of page frames allocated to a program. If
the available memory is doubled, the mean interval between page faults is also
doubled. Suppose that a normal instruction takes 1 microsec, but if a page fault
occurs, it takes 2 msec to handle the fault. If a program takes 60 sec to run, during
which time it gets 15,000 page faults, how long would it take to run if twice as
much memory were available?
35. Can you think of any situations where supporting virtual memory would be a bad
idea and what would be gained by not having to support virtual memory?
Explain.
36. A system uses four physical memory frames and the following reference
stringoversix pages:1,2,3,4,2,1,4,6,2,1,2,3,5,6.Assumingmemory
starts empty, how many page faults will occur and what will be the final
contentsofmemoryundertheFIFOpagereplacementpolicy?
37. Isbusywaitingalwayslessefficient(intermsofusingprocessortime)thana
blockingwait?Explain.
38. Provide the detailed steps involved in performing an output operation in a
systemthatusespolling.
39. Whataretheadvantagesofusingdirectories?
40. Listandbrieflydefinethreefileallocationmethods.

Similar documents