Hardware Reference
In-Depth Information
23. On a certain computer, a program can create as many files as it needs, and all files may
grow dynamically during execution without giving the operating system any advance
information about their ultimate size. Do you think that files are stored in consecutive
sectors? Explain.
24. Studies of different file systems have shown that more than half the files are a few KB
or smaller, with the vast majority of files less than something like 8 KB. On the other
hand, the largest 10 percent of all files usually occupies about 95 percent of the entire
disk space in use. From this data, what conclusion can you draw about disk block size?
25. Consider the following method by which an operating system might implement sema-
phore instructions. Whenever the CPU is about to do an up or down on a semaphore
(an integer variable in memory), it first sets the CPU priority or mask bits in such a
way as to disable all interrupts. Then it fetches the semaphore, modifies it, and
branches accordingly. Finally, it enables interrupts again. Does this method work if
a. There is a single CPU that switches between processes every 100 msec?
b. Two CPUs share a common memory in which the semaphore is located?
26. The description of semaphores in Sec. 6.3.3 states: ''Usually sleeping processes are
strung together in a queue to keep track of them.'' What advantage is gained by using a
queue for waiting processes as opposed to waking a random sleeping processes when
an up is performed?
27. The Nevercrash Operating System Company has been receiving complaints from some
of its customers about its latest release, which includes semaphore operations. They
feel it is immoral for processes to block (they call it ''sleeping on the job''). Since it is
company policy to give the customers what they want, it has been proposed to add a
third operation, peek , to supplement up and down . peek simply examines the sema-
phore without changing it or blocking the process. In this way, programs that feel it is
immoral to block can first inspect the semaphore to see if it is safe to do a down . Will
this idea work if three or more processes use the semaphore? If two processes use the
semaphore?
28. Make a table showing which of the processes P1, P2, and P3 are running and which are
blocked as a function of time from 0 to 1000 msec. All three processes perform up and
down instructions on the same semaphore. When two processes are blocked and an up
is done, the process with the lower number is restarted, that is, P1 gets preference over
P2 and P3, and so on. Initially, all three are running and the semaphore is 1.
At t = 100 P1 does a down
At t = 200 P1 does a down
At t = 300 P2 does an up
At t = 400 P3 does a down
At t = 500 P1 does a down
At t = 600 P2 does an up
At t = 700 P2 does a down
At t = 800 P1 does an up
At t = 900 P1 does an up
29. In an airline reservation system, it is necessary to ensure that while one process is busy
using a file, no other process can also use it. Otherwise, two different processes,
Search WWH ::




Custom Search