HW3.Solutions - 9.2 Discuss the hardware support required...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 9.2 Discuss the hardware support required to support demand paging. Answer: For every memory access operation, the page table needs to be consulted to check whether the corresponding page is resident or not and whether the program has read or write privileges for accessing the page. These checks would have to be performed in hardware. A TLB could serve as a cache and improve the performance of the lookup operation. 9.3 What is the copy-on—write feature and under what circumstances is it beneficial to use this feature? What is the hardware support required to implement this feature? Answer: When two processes are accessing the same set of program values (for instance, the code segment of the source binary), then it is useful to map the corresponding pages into the virtual address spaces of the two programs in a write-protected manner. When a write does indeed take place, then a copy must be made to allow the two programs to individually access the different copies without interfering with each other. The hardware support required to implement is simply the fol- lowing: on each memory access, the page table needs to be consulted to check whether the page is write-protected. If it is indeed write-protected, a trap would occur and the operating system could resolve the issue. 9.4 A certain computer provides its users with a virtual-memory space of 232 bytes. The computer has 218 bytes of physical memory. The virtual memory is implemented by paging, and the page size is 4096 bytes. A user process generates the virtual address 11123456. Explain how the system establishes the corresponding physical location. Distinguish between software and hardware operations. Answer: The virtual address in binary form is 0001 0001 0001 0010 0011 0100 0101 0110 Since the page size is 212, the page table size is 22']. Therefore the low- order 12 bits “0100 0101 0110” are used as the displacement into the page, while the remaining 20 bits “0001 0001 0001 0010 0011” are used as the displacement in the page table. 9.6 Assume that you are monitoring the rate at which the pointer in the clock algorithm (which indicates the candidate page for replacement) moves. What can you say about the system if you notice the following behavior: a. pointer is moving fast b. pointer is moving slow Answer: If the pointer is moving fast, then the program is accessing a large number of pages simultaneously. It is most likely that during the period between the point at which the bit corresponding to a page is cleared and it is checked again, the page is accessed again and therefore cannot be replaced. This results in more scanning of the pages before a victim page is found. If the pointer is moving slow, then the virtual memory system is finding candidate pages for replacement extremely efficiently, indicating that many of the resident pages are not being ac- cessed. 9.10 Consider a demand-paging system with the following time-measured utilizations: CPU utilization 20% Paging disk 97.7% Other I/ 0 devices 5% Which (if any) of the following will (probably) improve CPU utilization? Explain your answer. Install a faster CPU. 9‘5“ Install a bigger paging disk. Increase the degree of multiprogramming. E1 e Decrease the degree of multiprogramming 51-" Install more main memory [-h Install a faster hard disk or multiple controllers with multiple hard disks. g. Add prepaging to the page fetch algorithms h. Increase the page size. Answer: The system obviously is spending most of its time paging, indicating over-allocation of memory If the level of multiprogramming is reduced resident processes would page fault less frequently and the CPU utilization would improve. Another way to improve performance would be to get more physical memory or a faster paging drum. a. Get a faster CPU—No. b. Get a bigger paging drum—No. c. Increase the degree of multiprogramming—No. d. Decrease the degree of multiprogramming—Yes. 9.15 9.17 Install more main memory—Likely to improve CPU utilization as more pages can remain resident and not require paging to or from the disks. Install a faster hard disk, or multiple controllers with multiple hard disks—Also an improvement, for as the disk bottleneck is removed by faster response and more throughput to the disks, the CPU will get more data more quickly. Add prepaging to the page fetch algorithms— Again, the CPU will get more data faster, so it will be more in use. This is only the case if the paging action is amenable to prefetching (i.e., some of the access is sequential). Increase the page size—Increasing the page size will result in fewer page faults if data is being accessed sequentially. If data access is more or less random, more paging action could ensue because fewer pages can be kept in memory and more data is transferred per page fault. So this change is as likely to decrease utilization as it is to increase it. What is the cause of thrashing? How does the system detect thrashing? Once it detects thrashing, what can the system do to eliminate this problem? Answer: Thrashing is caused by underallocation of the minimum num- ber of pages required by a process, forcing it to continuously page fault. The system can detect thrashing by evaluating the level of CPU utiliza- tion as compared to the level of multiprogramming. It can be eliminated by reducing the level of multiprogramming. Consider the parameter A used to define the working-set window in the working-set model. What is the effect of setting A to a small value on the page fault frequency and the number of active (non-suspended) processes currently executing in the system? What is the effect when A is set to a very high value? Answer: When A is set to a small value, then the set of resident pages for a process might be underestimated allowing a process to be scheduled even though all of its required pages are not resident. This could result in a large number of page faults. When A is set to a large value, then a process’s resident set is overestimated and this might prevent many processes from being scheduled even though their required pages are resident. However, once a process is scheduled, it is unlikely to generate page faults since its resident set has been overestimated. 10.1 Consider a file system where a file can be deleted and its disk space reclaimed while links to that file still exist. What problems may occur if a new file is created in the same storage area or with the same absolute path name? How can these problems be avoided? Answer: Let F1 be the old file and F2 be the new file. A user wishing to access F1 through an existing link will actually access F2. Note that the access protection for file F1 is used rather than the one associated with F2. 10.2 The open-file table is used to maintain information about files that are currently open, Should the operating system maintain a separate table for each user or just maintain one table that contains references to files that are being accessed by all users at the current time? If the same file is being accessed by two different programs or users, should there be separate entries in the open file table? Answer: By keeping a central open-file table, the operating system can perform the following operation that would be infeasible other- wise. Consider a file that is currently being accessed by one or more processes. If the file is deleted, then it should not be removed from the disk until all processes accessing the file have closed it. This check could be performed only if there is centralized accounting of number of processes accessing the file. On the other hand, if two processes are accessing the file, then separate state needs to be maintained to keep track of the current location of which parts of the file are being accessed by the two processes. This requires the operating system to maintain separate entries for the two processes. 10.9 Some systems provide file sharing by maintaining a single copy of a file; other systems maintain several copies, one for each of the users sharing the file, Discuss the relative merits of each approach. Answer: 1With a single copy, several concurrent updates to a file may result in user obtaining incorrect information, and the file being left in an incorrect state. 1With multiple copies, there is storage waste and the various copies may not be consistent with respect to each other. 11.2 What are the advantages of the variation of linked allocation that uses 11.3 11.4 a FAT to chain together the blocks of a file? Answer: The advantage is that while accessing a block that is stored at the middle of a file, its location can be determined by chasing the pointers stored in the PAT as opposed to accessing all of the individual blocks of the file in a sequential manner to find the pointer to the target block. Typically, most of the FAT can be cached in memory and therefore the pointers can be determined with just memory accesses instead of having to access the disk blocks. Consider a system where free space is kept in a free-space list. a. Suppose that the pointer to the free-space list is lost. Can the system reconstruct the free-space list? Explain your answer. b. Consider a file system similar to the one used by UNIX with indexed allocation. How many disk I/O operations might be required to read the contents of a small local file at [cl/WC? Assume that none of the disk blocks is currently being cached. c. Suggest a scheme to ensure that the pointer is never lost as a result of memory failure. Answer: a. In order to reconstruct the free list, it would be necessary to perform “garbage collection.” This would entail searching the entire directory structure to determine which pages are already allocated to jobs. Those remaining unallocated pages could be relinked as the free-space list. b. The free-space list pointer could be stored on the disk, perhaps in several places. C. Some file systems allow disk storage to be allocated at different levels of granularity. For instance, a file system could allocate 4 KB of disk space as a single 4-KB block or as eight 512-byte blocks. How could we take advantage of this flexibility to improve performance? What modifications would have to be made to the free-space management scheme in order to support this feature? Answer: Such a scheme would decrease internal fragmentation. If a file is 5K3, then it could be allocated a 4K3 block and two contiguous 512-byte blocks. In addition to maintaining a bitmap of free blocks, one would also have to maintain extra state regarding which of the subblocks are currently being used inside a block. The allocator would then have to examine this extra state to allocate subblocks and coallesce the subblocks to obtain the larger block when all of the subblocks become free. 11.6 Consider a file system on a disk that has both logical and physical block sizes of 512 bytes. Assume that the information about each file is al- ready in memory For each of the three allocation strategies (contiguous, linked, and indexed), answer these questions: a. How is the logical-to-physical address mapping accomplished in this system? (For the indexed allocation, assume that a file is always less than 512 blocks long.) If we are currently at logical block 10 (the last block accessed was block 10) and want to access logical block 4, how many physical blocks must be read from the disk? Answer: Let Z be the starting file address (block number). a. Contiguous. Divide the logical address by 512 with X and Y the resulting quotient and remainder respectively. 1‘ Add X to Z to obtain the physical block number. Y is the displacement into that block. 21 Linked. Divide the logical physical address by 511 with X and Y the resulting quotient and remainder respectively. 1. Chase down the linked list (getting X + 1 blocks). Y + 1 is the displacement into the last physical block. 2‘ 4 Indexed. Divide the logical address by 512 with X and Y the resulting quotient and remainder respectively. 1‘ Get the index block into memory. Physical block address is contained in the index block at location X. Y is the dis- placement into the desired physical block. 22 11.10 Explain why logging metadata updates ensures recovery of a file sys- tem after a file system crash. Answer: For a file system to be recoverable after a crash, it must be consistent or must be able to be made consistent. Therefore, we have to prove that logging metadata updates keeps the file system in a consistent or able-to-be-consistent state. For a file system to become inconsistent, the metadata must be written incompletely or in the wrong order to the file system data structures. With metadata logging, the writes are made to a sequential log. The complete transaction is written there before it is moved to the file system structures. If the system crashes during file system data updates, the updates can be completed based on the information in the log. Thus, logging ensures that file system changes are made completely (either before or after a crash). The order of the changes are guaranteed to be correct because of the sequential writes to the log. If a change was made incompletely to the log, it is discarded, with no changes made to the file system structures. Therefore, the structures are either consistent or can be trivially made consistent via metadata logging replay. ...
View Full Document

Page1 / 7

HW3.Solutions - 9.2 Discuss the hardware support required...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online