Download Homework 2 for Operating Systems Design | CS 423 and more Assignments Operating Systems in PDF only on Docsity!
You are to complete this homework individually (not in groups). You will use
Compass to submit your solutions. Submit a copy of this homework file
(Homework2.doc) with your answers clearly marked in the Solution line of each
problem. NOTE: Submission will be turned off right at 4:59pm since solutions
will be posted at that time. Make sure you submit by then, or you will not get
credit.
For all problems, choose the most correct answer
- In order to prevent deadlocks, let a system adopt the policy of forcing processes to request resources in ascending order of request type rank. In particular, when a process is requesting a resource of a certain type, the process cannot be holding other higher ranked resources. Consider four resource types with the following profile in this system: Resource Type Rank Number of Instances RT1 4 2 RT2 7 4 RT3 8 3 RT4 10 2 Let the following sequence of resource requests be processed by the system (note that REQ(A, B, k) represents the request of k resources of type B by process A and REL(A, B, k) represents process A releasing k resources of type B): REQ(P4, RT2, 3) REQ(P3, RT3, 2) REQ(P2, RT4, 1) REL(P4, RT2, 3) REQ(P4, RT1, 2) REL(P2, RT4, 1) REL(P3, RT3, 2) REQ(P3, RT2, 3) REQ(P2, RT3, 2) REQ(P1, RT4, 2)
Note that all of the above request and release operations can be processed without any violation of the deadlock-prevention policy of the system. For each of the following sequences of request/release operations, examine if it can or cannot be processed without violating the deadlock-prevention scheme above. Identify the sequence that is allowed by the scheme and consequently can be processed without leading to system deadlock? (a) REQ(P2, RT4, 2), REL(P1, RT4, 2), REQ(P4, RT4, 2), REQ(P1, RT1, 2) (b) REL(P2, RT3, 2), REQ(P4, RT4, 2), REQ(P2, RT4, 2), REQ(P1, RT1, 2) (c) REL(P3, RT2, 3), REQ(P2, RT4, 2), REQ(P4, RT2, 2), REQ(P1, RT3, 2) (d) REQ(P4, RT3, 3), REL(P3, RT2, 3), REQ(P3, RT3, 3), REQ(P2, RT1, 2) (e) REQ(P3, RT3, 2), REL(P4, RT1, 2), REQ(P4, RT4, 2), REQ(P2, RT2, 3) Solution: ______________
- Consider a memory-management system based on segmentation. Let the logical address space of each process contain up to four segments with the maximum length of a segment limited to 4MB. Let the following table indicate the segment layout for a process in the system (note that hexadecimal representation is used for addresses, for example 0x5c2bb62e refers to 0101 1100 0010 1011 1011 0110 0010 1110): Segment Length Base Address 1MB 0xab465d9c 3MB 0x5c2bb62e 2MB 0xac2e2bb 512KB 0x2eb62b5c Translate the following four logical address based on the above segment table: 0x62ad36, 0xc96a3d, 0x12a3d5 and 0x9a24c5. With respect to this address translation, identify the TRUE statement from among the following? (a) Logical address 0x62ad36 translates to physical address 0xac50d9ec. (b) Logical address 0x62ad36 causes a segmentation fault. (c) Logical address 0x12a3d5 causes a segmentation fault. (d) Logical address 0x9a24c5 translates to physical address 0x5c45daf3.
- Consider a disk that is scheduled using a variant of the Elevator policy. In this policy, the disk head scans from the first cylinder to the last repeatedly, processing I/O requests along the way. Note that as the disk head completes a scan and reaches the last cylinder, it moves back to the first cylinder (without processing any requests) and starts the next scan. Also, each scan is terminated whenever there are no I/O requests in the disk queue at higher-numbered cylinders (with respect to the cylinder the disk head is in), but there are I/O requests in the disk queue in lower-numbered cylinders. In such a case, the head moves back to the lowest-numbered cylinder among the requests in the disk queue. Finally, note that if there are no pending I/O requests, the disk head does not move and waits for new requests to arrive before it resumes scanning. Let the disk have an average rotational latency of 0.5 time units and transfer time of 0. time units per sector. The seek time for processing a request is 0, if the request is in the same cylinder that the disk head is currently in. Otherwise, let the seek time be 1+(k- 1)*0.1 time units, where k is the number of cylinders travelled. Let the following table represent a stream of I/O requests for the disk: Request Arrival Time Cylinder Number of Sectors R1 t 66 5 R2 t+1 59 2 R3 t+2 37 2 R4 t+3 87 1 R5 t+7 16 2 R6 t+8 8 1 R7 t+15 48 5 R8 t+24 49 1 Assume that the disk head is at cylinder 45 at time t, and no other requests arrive until all of the above requests are processed. Determine the schedule of processing for the above stream of requests. Based on the processing schedule, identify the TRUE statement among the following, with respect to the relative order of processing the various requests. (a) R8 is the last request processed.
(b) R4 is the last request processed. (c) R5 is the last request processed. (d) R6 is processed before R7. (e) R6 is processed before R4. Solution: ___________
- Suppose a pollution-monitoring system generates a service request exactly once a second. These requests are queued in a single queue and serviced by several processors. Because the processors are of various ages, they run at different rates. Consider five possible collections of processors: (A) Three processors, which take 2, 3, and 4 seconds, respectively, to service one request. (B) Three processors, which take 2, 3, and 6 seconds, respectively, to service one request. (C) Four processors, which take 3, 4, 5, and 6 seconds, respectively, to service one request. (D) Four processors, which take 3, 4, 4, and 5 seconds, respectively, to service one request. (E) Six processors, which take 4, 5, 6, 7, 8, and 9 seconds, respectively, to service one request. There are three things that might happen in such a system: 1. There is a limit to the length to which the queue grows, and the processors are idle a positive fraction of the time. 2. There is a limit to the length to which the queue grows, but after some time the processors are never idle. 3. The queue grows indefinitely. For each of (A)-(E), determine which of cases (1)-(3) holds. Then, identify the true statement in the list below. (a) In case (B), the behavior is (1): the queue is bounded and the processors are sometimes idle. (b) In case (E), the behavior is (1): the queue is bounded and the processors are sometimes idle. (c) In case (E), the behavior is (3): the queue grows without bound. (d) In case (C), the behavior is (2): the queue is bounded, but the processors are never idle. (e) In case (E), the behavior is (2): the queue is bounded, but the processors are never idle. Solution: __________
(e) REQ(P8, R8) Solution: _____________
- Consider two disk configurations C1 and C2. In C1, a disk A is mirrored by another disk A'. Read operations can access either A or A', while write operations need to modify both A and A'. In particular, serial writes are performed in order to avoid simultaneous corruption of both mirrors, thus protecting against permanent data loss. In C2, disk A is mirrored by two other disks A' and A'', for added protection. Read operations can access any of the three disks while write operations modify all three disks. However, for the sake of higher performance, the write operations are performed in parallel. Let the average read operation on a disk take 5 ms and the average write operation take 10 ms. Consider a sequence of I/O operations consisting of 90 read operations and 10 write operations. Estimate the expected time for processing this sequence of operations in the two configurations. Identify the TRUE statement below, based on the estimate. (a) Configuration C1 is slower than configuration C2 by about 200 ms, with respect to the sequence of operations. (b) It takes about 650 ms to process the sequence of operations in configuration C2. (c) Configuration C2 is faster than configuration C1 by about 100 ms, with respect to the sequence of operations. (d) It takes about 750 ms to process the sequence of operations in configuration C2. (e) It takes about 1100 ms to process the sequence of operations in configuration C1. Solution: __________
- Consider a disk with average rotational latency of 0.5 time units and transfer time of 0. time units per sector. The seek time for processing a request is 0, if the request is in the same cylinder that the disk head is currently in. Otherwise, let the seek time be 1+(k-1)*0.1 time units, where k is the number of cylinders travelled. Let the following table represent a stream of I/O requests for the disk: Request Arrival Time Cylinder Number of Sectors R1 t 51 2
R2 t+2 25 5 R3 t+4 62 2 R4 t+8 46 1 R5 t+17 35 5 R6 t+18 75 1 R7 t+20 14 2 Let the disk be scheduled using the Shortest Seek First (SSF) policy. Assume that the disk head is at cylinder 30 at time t, and no other requests enter the disk queue until all of the above requests are processed. Determine the schedule of processing for the above stream of requests. Based on the processing schedule, compute the wait times and turnaround times for all the requests. Note that the wait time of a request is the difference between the time at which the disk starts processing the request and the arrival time of the request; the turnaround time of a request is the difference between the time at which the disk completes processing the request and the arrival time of the request. Identify the TRUE statement among the following, with respect to the wait times and turnaround times of these requests. (a) R3 has the largest turnaround time. (b) R6 has the largest wait time. (c) R4 has a smaller turnaround time than R5. (d) R4 has a smaller wait time than R5. (e) R2 has a smaller turnaround time than R5. Solution: __________
- Suppose a disk has size 2GB, and blocks are of size 1KB. If all block numbers are stored as 4-byte integers, how large must a main-memory file-allocation table (FAT) be? (a) 64 KB (b) 16 MB (c) 8 MB (d) 4 MB (e) 8 KB