Tut-6 With Solution
Short Description
hey hey hey...
Description
KSU/CCIS
CSC227 Tutorial # 6 – Memory Management SUMMER - 2010
Question # 1: Assume that the main memory has the following 5 fixed partitions with the following sizes: 100KB, 500KB, 200KB, 300KB and 600KB (in order) a) Expalin the following allocation algorithms: First-fit, Best-fit and Worst-fit. b) How would each of the First-fit, Best-fit and Worst-fit algorithms place processes of 212KB, 417KB, 112KB and 426KB (in order)? c) Compute the total memory size that is not used for each algorithm. d) Which algorithm makes the efficient use of the memory?
Answer Q 1:
a) Form your book. b) Fisrt-fit 100K 500K 200k
212K 288K 112k 88K
300K
Best-fit 100K 500K 200K 300K
Worst-fit 100K 417K 83K 112K 88K 212K
500K 200K 300K
88K 600K
417K 183K
600K
426K 174K
417K 83K
112K 188K
600K
212K 388K
c) First-fit = 1700 – 741 = 959 Best-fit = 1700 – 1167 = 533 Worst-fit = 1700 – 741 = 959 d) Memeory Utilization Ratio: First-fit = 741 / 1700 = 43.5% Best-fit = 1167 / 1700 = 68.6% Worst-fit = 741 / 1700 = 43.5 % Best-fit has the most efficient use of the memory.
Question # 2: Assume that the MMU is using the multiple variable partition schemes. The memory size is 2560KB, from which the OS uses 400KB. You have the following processes: Process
Size
CPU burst
P1 P2 P3 P4 P5
600K 1000K 300K 700K 500K
10 5 20 8 15
Using the First-fit allocation technique and the multiprogramming system (FCFS), do the following (without using compaction) a) Load and execute the processes until P5 is loaded (do not terminate P5). b) Every time a program is loaded, compute the external fragmentation. c) Assuming P5 is now terminated and P6 requires 1000K, (the P3 and P4 are still in the memory) how would you compact best the memory so to enable P6 to be loaded?
Answer Q 2:
a) Solution b) Soultion Time = 0 OS 400K P1 600K
Time = 10 OS 400K #Free# 600K
Time = 16 OS 400K P4 700K
P2 1000K
P2 1000K
P5 500K
P3 300K
P3 300K
#Free# 260K EF = 0
#Free# 260K EF = 860K
#Free# 400K P3 300K #Free# 260K EF = 660K
c) Soutlion P5 trem OS 400K P4 700K
P5 trem OS 400K P4 700K
#Free# 900K
P3 300K
P3 300K #Free# 260K
#Free# 1160K
Can get most free space in less moves if you move P3 up.
Question # 3: Assume that we have the following jobs to be scheduled using FCFS algorithm with variable partition memory scheme:
Job J1 J2 J3 J4 J5 6
Size 50 KB 120 KB 70 KB 20 KB 105 KB 55 KB
CPU 13 3 9 3 8 13
Memory size is 256KB; Jobs are initially loaded in memory as follows: J1
50 KB
J2
120 KB
J3
70 KB 16 KB
Show how the memory will look after scheduling job 6 (assume no memory compaction is allowed) using both FCFS and Best-fit allocation technique.
Answer Q 3:
J1
50K
J4 20K #Free# 30K
J2
120K
J2
120K
J3
70K
J3
70K
#Free# 16K Time = 0
#Free# 16K Time = 13
J4
20K
J4
20K
J5
105K
J5
105K
#Free# 45K J3 70K
J6
55K
#Free# 16K Time = 16
#Free# 76K Time = 25
Question # 4: Assume that we have the following jobs to be executed on a time-sharing operating system (Quantum = 4 ms) with a total user memory of 256 KB.
Job No. 1 2 3 4 5 6 7 8
Arrival time (ms) 0 2 2 2 0 2 0 0
Memory size (KB) 120 70 50 100 40 120 60 30
CPU Time (ms) 8 4 12 12 4 4 8 8
Show how the memory will look after loading Job No 6 using the Best-fit allocation technique with no compaction.
Answer Q 4:
Question # 5: Consider a logical address space of 8 pages; each page is 2048 byte long, mapped onto a physical memory of 64 frames. a) What are the sizes of the logical and physical spaces? b) How many bits are there in the logical address and how many bits are there in the physical address? c) A 6284 bytes program is to be loaded in some of the available frames= {10, 8, 40, 25, 3, 15, 56, 18, 12, 35}. Show the contents of the program’s PMT. d) What is the size of the internal fragment? e) Convert the following logical addresses 2249, 5245 and 10512 to physical addresses.
Answer Q 5:
a) Physical space size = 64 * 2048 = 2 17 bytes. Logical space size = 8 * 2048 = 2 14 bytes b) Logical @ field is 14 bits long. Physical @ field is 17 bits long. c) Page size = 2048 bytes, so program is divided into 6284/2048 = 4 pages PMT Index Frame # 0 10 1 8 2 40 3 25 4 5 6 7
Valid/Invalid V V V V I I I I
FL { 3, 15, 56, 18, 12, 35} d) There is interanl fragment in page number 3, 4 pages * 2048 = 8192 bytes Program size is 6284 Internal fragment = 8192 – 6284 = 1908 bytes. (all in page number 3) e) 2249 16585 5245 83069 10512 Trap (page is invalid)
Question # 6: Consider a paged memory of 64 pages of 256 bytes each. a) What is the size of the logical space and the number of bits of a logical address? b) Assume that the free frame list is {29, 4, 18, 5, 22, 15, 7, 2} and two programs P1 (4 pages), P2 (2 pages) are waiting to be loaded. Perform the memory allocation of P1 and P2 and show their PMTs. c) Assume that PMT is kept in memory and two register associative memory. The access time to the memory is 480ns and the access to associative memory is 50ns. What is the effective access time to the memory if the hit ration in the associative memory is 50%? 90%? d) Under what condition is an associative memory effective?
Answer Q 6:
a) Logical space size = 64 * 256 = 2 6 * 28 = 214 bytes Logical @ field is 14 bits long. b)
PMT of P1 Index Frame# 0 29 1 4 2 18 3 5
PMT of P2 Index Frame#
V/I V V V V
0 1
22 15
V/I V V
FL { 7, 2 } c) Memory access time = 480 ns. Associative memory access time = 50 ns. Effective access time = (access time for associative memory + access time for memory) * hit probability + (access time for associative memory + 2 * access time for memory) * miss probability -
If hit ration 50%: EAT = (50 + 480) * 0.50 + ( 50 + 2 * 480) * 0.50 = 265 + 505 = 770 If hit ration 90%: EAT = (50 + 480) * 0.90 + ( 50 + 2 * 480) * 0.10 = 477 + 101 = 578
d) A higher hit probability make associative memory effective.
Question # 7: a)
Assume a page size of 1KB, the logical address space is 8KB and the physical address space is 16KB. Answer the following questions: i. What is the highest degree of parallelism? ii. What is the length in bits of the physical address field? iii. What is the length in bits of the logical address field? iv. What is the length of the Page Table?
b) Assume that the page size is 128 bytes; the current program size is 635 bytes and the physical space 2048 bytes. Before the program is loaded the free frame list is {10, 7, 2, 9, 12, 4, 8, 14}. Answer the following questions after loading t he above program in main memory: i. What is the internal fragment size? ii. What is the physical address of 128? iii. What is the physical address of 635? iv. What is the logical address of the 2-D physical address ?
Answer Q 7: a) v. vi. vii. viii.
16 programs. 4 10 14 16KB = 2 *2 = 2 14 bits 3 10 13 8KB = 2 *2 = 2 13 bits 3 2 = 8 pages.
v. vi. vii. viii.
5 7 * 128 + (128 – 128) = 896 12 * 128 + (635 – 512) = 1659 120
b)
Question # 8: Consider the following segment mapping table (SMT)
Segment 0 1 2 3 4
Base 219 2300 90 1327 1952
Length (limit) 600 14 100 580 96
What are the physical addresses of the following logical addresses? a) b) c) d) e) f)
Answer Q 8:
a) b) c) d) e) f)
219 + 430 = 649 2300 + 10 = 2310 Trap (500 >= 100) 1327 + 500 = 1827 Trap (122 >= 96) Trap (6 is an invalid entry)
Question # 9: Given a logical address field with the following format: 2 bits 16 bits Seg # Page # Answer the following questions: a. What is the number of segments? b. What is the maximum size of the segment? c. What is the size of a page? d. What is the maximum number of pages per segment?
Answer Q 9: a. b. c. d.
2
2 = 4 segments 16+8 24 2 = 2 8 2 16 2
8 bits Page Offset
Question # 10: Assume a hardware mechanism using a combined segmentation and paging. The user logical address space can have up to 8 segments of 64KB each. Each segment can have up to 64 pages of 1024 bytes each. Given a 4-segment user program P (S0: 4000 bytes, S1: 4000 bytes, S2: 4000 bytes, S3: 4000 bytes) and the free frame list is {12, 23, 32, 45, 57, 64, 72, 81, 99, 103, 120, 124, 108, 90, 85, 78, 67, 55, 46, 33, 25, 16, 8, 27, 38, 49, 51, 62} Translate the following 1-dimensional logical addresses 6452 and 12846 into 1-dimensional physical addresses after performing memory allocation.
Answer Q 10: 4000 / 1024 = 4 pages S0 need 4 pages {12, 23, 32, 45} S1 need 4 pages {57, 64, 72, 81} S2 need 4 pages {99, 103, 120, 124} S3 need 4 pages {108, 90, 85, 78} Logical address 6452 4000 < 6452 < 7999 € S1 • 6452 – 4000 = 2452 < S1, 2452> • Page number is (2452 / 1024 = 2) , address in page #2 is (2452 - 1024*2 = 404) • change to frame # = • Physical address = 72 * 1024 + 404 = 74132 • Logical address 12846 12000 < 12846 < 15999 € S3 • 12846 – 12000 = 846 • Page number is (846 / 1024 = 0), address in page #0 is (846 – 1024 * 0) • change to frame # = • Physical address = 108 * 1024 + 846 = 111438 •
View more...
Comments