COMP 2432 Operating Systems Tutorial 8 Solution
1. Contiguous Memory Allocation.
The total size is 5000K. The available space is 200+400+600+300 = 1500K. So used space is 3500K.
First-fit sequence:
Copyright By PowCoder代写 加微信 powcoder
Allocation of 280K to second hole, 180K to first hole, 320K to third hole, request of 400K not satisfied, 120K to second part of second hole, 160K to second part of third hole.
320 600 160
Utilization = (3500+180+280+120+320+160)/5000 = 91.2%.
Best-fit sequence:
Allocation of 280K to fourth hole, 180K to first hole, 320K to second hole, 400K to third hole, 120K to second part of third hole, request of 160K not satisfied.
Utilization = (3500+180+320+400+120+280)/5000 = 96.0%.
Worst-fit sequence:
Allocation of 280K to third hole, 180K to second hole, 320K to second part of third hole, request of 400K not satisfied, 120K to fourth hole, 160K to second part of second hole.
Utilization = (3500+180+160+280+320+120)/5000 = 91.2%.
Unsatisfied requests of 400K, 160K and 400K for FF, BF and WF respectively. Best-fit performs the best and the other two perform the worst.
Using compaction, the unused space is 440K for FF and WF and 200K for BF. Those holes could be merged into a single large hole in all cases, and that is sufficient to admit the unsatisfied requests.
2. More Contiguous Memory Allocation.
The total size is 1000K. The available space is 100+180+120 = 400K. So used space is 600K.
First-fit sequence:
31 24 34 11 18 27
Utilization = 98.3%.
Best-fit sequence:
27 18 79 2411 Utilization = 96.4%.
Worst-fit sequence:
75 11 24 27 18
Utilization = 96.5%.
Unsatisfied requests of 27K, 46K and 27+18K for FF, BF and WF respectively. First-fit performs the best and best-fit performs the worst.
Using compaction, the unused space is 17K for FF. The two holes could be merged into a hole of size 17K, which is not sufficient to admit the unsatisfied request of 27K.
Using compaction, the unused space is 36K for BF. The three holes could be merged into a larger hole of size 36K, which is still not sufficient to admit the unsatisfied request of 46K.
Using compaction, the unused space is 35K for WF. The three holes could be merged into a larger hole of size 35K, which is sufficient to admit either one of the unsatisfied requests of 27K and 18K, but not both.
With compaction, there are unsatisfied requests of 27K, 46K and 18K for FF, BF and WF respectively. Worst- fit now performs the best and best-fit still performs the worst.
180 400160
280 600 320
3. Paging.
(a) The logical address space covers 32MB. Since 32M = 225, the length of logical address is 25 bits.
(b) The physical memory has a size of 256KB. Since 256K = 218, the length of physical address is 18 bits.
(c) The page size is 512 bytes. Since 512 = 29, the length of offset is 9 bits.
(d) Now, m = 25, n = 16, so the length of page number is mn = 259 = 16 bits.
(e) Number of frames = 256K / 512 = 512. You could also find that the length of frame number is 9 bits (since 512 = 29), which could also be found as the difference between the length of the physical address and the length of the offset.
4. Page Table and Memory Frame.
The page table for process P is shown below.
Logical memory
Physical memory
Page table
24 E 35 C 42 A
3D 310 4E 424
memory frame
For the logical address 0010011000011, p = 001, d = 0011000011. Thus, f = 001011 (frame 11 or 001011 in binary for page 1 with 6 bits for frame number). The physical address would be 0010110011000011.
Since there are 6 bits for the frame number, there are 64 frames in the main memory. Each frame has a size of 1KB, same as the size of a page. Therefore the main memory is of 64KB.
5. Segmentation.
(a) 219+430 = 649 (b) error/invalid
(c) 90+30 = 120
(d) 1327+400 = 1727 (e) error/invalid
6. Segmentation with Sharing.
Memory used: 90 to 189, 219 to 818, 1327 to 1906, 1952 to 2047, 2300 to 2313, 3800 to 4095. So there are 6 holes (0 to 89, 190 to 218 etc) to be allocated for 3 segments for P2 (you should better draw three diagrams to show the memory allocation for the three segments with FF, BF, WF algorithms as in Questions 1 and 2).
First-fit allocates the segments S0 and S3 to 6th hole and S1 to 3rd hole. S2 is shared with P1. Best-fit allocates the segments S0 and S3 to 6th hole and S1 to 3rd hole. S2 is shared with P1. Worst-fit allocates the segments S0 and S1 to 6th hole and S3 to 3rd hole. S2 is shared with P1.
Segment table for P2
Base address Length
2314 2314 781 819 3095 483 90 90 90 100 3095 3095 819 425
Log address Alg for P2 (0, 430) (1, 200)
(3, 400) (4, 112)
Physical address for P2
FF BF WF 2744 2744 2744 1019 1019 3295
3495 3495 1219
error/invalid error/invalid
error/invalid
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com