Answers to Test #2 1a. Utilization is execution time divided by the period, and sum this for all the tasks. U = 2/5 + 1/3 = 11/15, which is about 73.3% 1b. The hyperperiod is 15. Note that job A starts a new period at 0, 5, 10. Job B starts a new period at 0, 3, 6, 9, 12. In Rate-Monotonic, we must allocate time for the job that has the shortest period. In this case, it is Job B. Next, we will allocate time to job A. Time Job Job Interval A B Idle? ------------------------- 0-1 X 1-2 X 2-3 X 3-4 X 4-5 X 5-6 X 6-7 X 7-8 X 8-9 X 9-10 X 10-11 X 11-12 X 12-13 X 13-14 X 14-15 X 1c. If we increase the execution time of Job A from 2 to 3, the set of jobs is still schedulable without missing deadlines. We would allocate the following idle times to job A: 4-5, 8-9, 13-14. Only 14-15 would still be idle. 2. We round up the size of the requests to the next power of two bytes. 5 KB needs 8 KB of space. 25 KB needs 32 KB of space. The 128 KB of kernel memory is split up as follows: 128 = 64 + 64 = 32 + 32 + 64 = 16 + 16 + 32 + 64 = 8 + 8 + 16 + 32 + 64 So, the kernel memory looks like this: 0 8 16 32 64 128 ----------------------------------------------------------------- | | | | | | | A | 8 | 16 | B | 64 | | | | | | | ----------------------------------------------------------------- Therefore the base addresses are 0 for A and 32 KB for B. 3a. Best fit: The idea is to find a partition that matches our desired size exactly. If this is not possible, then find the smallest one larger than what we need. Fortunately, exact matches are possible here. Answer: B, H, C. 3b. First fit: Return the first partition we encounter that is at least as large as needed. Answer: A, B, C 3c. Worst fit: Find the largest available partition. Answer: F, E, A 4. When we use the (First-in-First-out) page replacement algorithm, it is occasionally possible that when we (increase) the available number of frames, we observe a corresponding (increase) in the number of (page faults). 5. It is likely that the last page that we request or allocate won't be filled. For example, a page size of 4 KB and we want 5 KB. We are given 8 KB, so 3 KB is unused but belongs to the process. 6a. After These pages referencing are in page Memory ------------------------ 2 2 3 2, 3 2 2, 3 1 2, 3, 1 5 3, 1, 5 2 1, 5, 2 4 5, 2, 4 6b. After These pages referencing are in page Memory ------------------------ 2 2 3 2, 3 2 2, 3 1 2, 3, 1 5 2, 5, 1 because 5 replaced 3 2 2, 5, 1 4 2, 5, 4 because 4 replaced 1 7a. Going up, we encounter 70, 90 Then we go down, and we encounter 30, 10 7b. From 40 we go to: 30 --> 10 --> 70 --> 90 8a. 4 GB virtual memory means we need 32 bit virtual address. The page size is 1 KB, so this means we need 10 bits for the page offset. Therefore, the number of bits for the page number is 32 - 10 = 22. 8b. 256 MB RAM means the physical address needs 28 bits. 28 - 10 = 18 8c. The number of virtual pages: 2^22 or about 4 million. 8d. Consider the hexadecimal and binary representation of 0xabcd1234, focusing on the bits allocated to the page offset: Hexadecimal: 0x a b c d 1 2 3 4 Binary: ... 0010 0011 0100 The last 10 bits need to be allowed to vary from: 00 0000 0000 to: 11 1111 1111 Min address: 0x a b c d 1 0 0 0 0000 0000 0000 Max address: 0x a b c d 1 3 f f 0011 1111 1111 9a. At t = 0, we execute job 2 from 0 to 30 At t = 30, we execute job 3 from 30 to 50 At t = 50, we execute job 4 from 50 to 60 At t = 60, we execute job 1 from 60 to 100 Time --> Job 0 10 20 30 40 50 60 70 80 90 100 ------------------------------------------------------------- 1 | R | R | R | R | R | R | X | X | X | X | 2 | X | X | X | | | | | | | | 3 | | | R | X | X | | | | | | 4 | | | | | R | X | | | | | ------------------------------------------------------------- load: 2 2 3 2 3 2 1 1 1 1 9b. done - arrive = Turnaround time. Job 1: 100 - 0 = 100 Job 2: 30 - 0 = 30 Job 3: 50 - 20 = 30 Job 4: 60 - 40 = 20 9c. The average of the loads given in part A is (2 + 2 + 3 + 2 + 3 + 2 + 1 + 1 + 1 + 1) / 10 = 1.8