Exercise Set Three
Chapter 8 Problem 8.3: Given memory partitions of 100K, 500K, 200K, 300K and 600K (in order), how would each of the First-fit, Best-fit and Worst-fit algorithms place processes of 212K, 417K, 112K and 426K (in order) ? Which algorithm makes the most efficient use of memory? Answer:
In this example, Best-fit turns out to be the best. Problem 8.6: Why is that, on a system with paging, a process cannot access memory it does not own? How could the operating system allow access to other memory? Why should it or should it not? Answer: An address on a paging system is a logical page number and an offset. The physical page is found by searching a table based on the logical page number to produce a physical page number. Because the operating system controls the contents of this table, it can limit a process to accessing only those physical pages allocated to the process. There is no way for a process to refer to a page it does not own because the page will not be in the page table. To allow such access, an operating system simply needs to allow entries for non-process memory to be added to the process' page table. This is useful when two or more processes need to exchange data - they just read and write to the same physical address ( which may be at varying logical addresses ) . This makes for very efficient interprocess communication. Problem 8.9: Consider a paging system
with the page table stored in memory.
Answer:
Problem 8.12: Consider the following segment
table:
What are the physical addresses for the following logical addresses?
Answer:
Chapter 9 Problem : When do page faults occur? Describe the actions taken by the operating system when a page fault occurs. Answer: A page fault occurs when an access to a page that has not been brought into main memory takes place. The operating system verifies the memory access, aborting the program if it is invalid. If it is valid a free frame is located and I/O requested to read the needed page into the free frame. Upon completion of I/O, the process table and page table are updated and the instruction is restarted. Problem 9.5: Suppose we have a demand-paged
memory. The page table is held in registers. It takes 8 milliseconds to service
a page fault if an empty page is available or the replaced page is not modified,
and 20 milliseconds if the replaces page is modified. Memory access time
is 100 nanoseconds. Answer: 0.2micro seconds = (1-P) * 0.1 microseconds +(0.3P) *8milliseconds +(0.7P) * 20 milliseconds 0.1 = -0.1P +2400 P + 14000 P
a. for j:=1 to 100 do b. for i:=1 to 100 do Answer:
Problem 9.13: A page-replacement algorithm
should minimize the number of page faults. We can do this minimization
by distributing heavily used pages evenly over all of memory, rather than
having them compete for a small number of page frames. We can associate
with each page frame a counter of the number of pages that are associated
with that frame. Then, to replace a page, we search for the page frame
with the smallest counter.
Answer:
Problem 9.14: Consider a demand-paging
system with a paging disk that has an average access and transfer time of
20 milliseconds. Addresses are translated through a page table in main
memory, with an access time of 1 microsecond per memory access. Thus, each
memory reference through the page table takes two accesses. To improve
this time, we have added an associative memory that reduces access time
to one memory reference, if the page-table entry is in the associative memory.
Answer:
Problem : Give an example of an application in which
data in a file should be accessed in the following order:
Answer :
Chapter 12. Problem 12.2 : Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive is currently serving a request at cylinder 142, and the previous request was at cylinder 125. The queue of pending requests, in FIFO order, is Starting from the current head position, what is the total distance (in cylinders) that the disk arm moves to satisfy all the pending requests, for each of the following disk scheduling algorithms?86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130. Answer : a.
b.
c.
d.
e.
|
Chapter 13
Problem 13.3: Consider the following I/O scenarios on a single-user PC.
For each of these I/O scenarios, would you design the operating system to use buffering, spooling, caching, or a combination? Would you use polled I/O, or interrupt-driven I/O? Give reasons for your choices.
Answer:
Problem 13.6: Describe the three circumstances under which blocking I/O should be used. Describe three circumstances under which nonblocking I/O should be used. Why not just implement nonblocking I/O and have processed busy-wait until their devices are ready?
Answer:
Generally.blocking I/O is appropriate when the process will only be waiting for one specific event. Examples include a disk, tape, or keyboard read by an application program. Non-blocking I/O is useful when I/O may come from more than one source and the order of the I/O arrival is not predetermined. Examples include network daemons listening to more than one network socket, window managers that accept mouse movement as well as keyboard input, and I/O management programs, such as a copy command that copies data between I/O devices. In the last case, the program would optimize its performance by buffering the input and output and using non-blocking I/O to keep both devices fully occupied.
Non-blocking I/O is more complicated for programmers, because of the asynchronous rendezvous that is needed when an I/O occurs. Also, bust waiting is less efficient than interrupt-driven I/O so the overall system performance would decrease.