Work Sheet 7 1.What is binding? ### Binding is a mapping from one address space to another. Classically, the binding of instructions and data to memory addresses can be done in Compile time, or Excution time. 2.What are overlays? ### Overlay is to keep in memory only those instructions and data that are needed at any given time. When other instructions are needed, they are loaded into space that was occupied previously by instructions that are no longer needed. 3.List two ways to classify jobs by memory requirements. ### Static Loading or Dynamic Loading; Static Linking or Dynamic Linking. 4.What is swapping? ### Swapping is a method to improve the memory space uilitation. A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution. 5.Do problems 8.1, 8.2, 8.5, 8.8 and 8.10 of S&G. 8.1 ### An address generated by the CPU is commonly referred to as a logical address, whereas an address seen by the memory unit is commonly referred to as a physical address. In the complile-time and load-time address-binding schemes they are the same, but in the execution-time address-binding scheme they are different. 8.2 ### External fragmentation exists when enough total memory space exists to satisfy a request, but it is not contiguous; storage is fragmented into a large number of small holes; Internal fragmentation is the memory that is internal to a partition, but is not being used. It occurs when fixed size partitions are too large. 8.5 ### ---------- First fit: ---------- Allocation: 212K is put in 500K partition 417K is put in 600K partition 112K is put in 200K partition 426K must wait; Partition Utilization: 100K is empty 500K holds 212K 200K holds 112K 300K is empty 600K holds 417K Utilization rate=44% ---------- Best fit: ---------- Allocation: 212K is put in 300K partition 417K is put in 500K partition 112K is put in 200K partition 426K is put in 600K partition Partition Utilization: 100K is empty 500K holds 417K 200K holds 112K 300K holds 212K 600K holds 426K Utilization rate=69% --------- Worse fit: --------- Allocation: 212K is put in 600K partition 417K is put in 500K partition 112K is put in 600K partition 426K must wait Partition Utilization: 100K is empty 500K holds 417K 200K is empty 300K is empty 600K holds 212K+112K Utilization rate=44% Best fit algorithm makes the most efficient use of memory. 8.8 ### For the logical address: 3 bits for the pages and 10 bits for the words. Total is 13 bits; For the phiscal address: 5 bits for the frames and 10 bits for the words. Total is 15 bits. 8.10 ### a. We must first access memory for the page table and frame number, and then access the desired byte in memory. Thus, a page reference takes 400ns; b. We have following formula: 75%*200+25%*400=250ns. This the effective memory reference time. Work Sheet 8 1.What is the system manager's main problem in using fixed partition? ### A process needs either more or less memory. Since the partition is fixed This results poor memory utilization. Thus, the main problem is its low utilization rate of the memory. 2.What are internal and external fragmentation? ###Please see worksheet 7. 3.List common allocation methods. Which is the poorest? What was rationale for even considering it? ### Common allocation methods include first-fit, best-fit and worse-fit; Worse-fit is the poorest; The worse-fit may produce less external fragmentation. 4.What is swapping? ###Please see Worksheet 7 5.Do problems 8.3, 8.5, 8.11, 8.12, 8.16 and 8.17 of S&G. ### 8.3 ### a.First-fit. Place job in first storage hole on free storage place list in which it will fit; b.Best-fit.Place job in the smallest possible hole in which it will fit; c.Worst-fit.Place job in the largest possible hole in which it will fit. 8.5 ###Please see Worksheet 7 8.11 ### The effect of allowing two entries in a page table to point to the same page frame in memory let some pages in memory shared by two entries or more. If we need to copy a large amount of memory from one place to another, we needn't copy the memory itself, only need copy the entries in the page table. If updating some bytes in the one page along one entry, it maybe voilate the page that another entry points to and make it invalid . 8.12 ### Both paging and segmentation have their advantages and disadvantages. We can merge paging and segmentation toward a mixture of paging and segmentation and improve on each. 8.16 ### a.0,430 219+430=649 b.1,10 2300+10=2310 c.2,500 Because 500>100, then 500-100=400.We have 1327+400=1747 d.3,400 1327+400=1747 e.4,112 113> length 96. It is an invalid address. 8.17 ### a. In Figure 8.28, we can see the logical address space of a process is divided into two partitions: LDT and GDT. The select register points to the appropriate entry in the LDT or GDT. The base and limit information about the segment in question are used to generate a linear address. First, the limit is used to check for address validity. If the address is not valid, a memory fault is generated, resulting in a trap to the operating system. If it is valid, then the value of the offset is added to the value of the base, resulting in a 32-bit linear address. This address is then translated into a physical address. b. It can improve the efficiency of physical-memory use and check the data valid. c. One disadvantage is that its complicated hardware makes the cost very high. Work Sheet 9 1.What is virtual memory? ### Virtual memory is the separation of user logical memory from physical memory. A set of techniques and hardware allows the execution of processes that may not be completely in physical memory. 2.What is demand paging? List advantages of demand paging ### Demand paging is that, when we want execute a process, we don't swap the entire process into memory. That is, we never swap a page into memory unless the page will be needed. Lets more process into the memory; Fixed size page is easy to manage; Handle and overall use of swap space. 3.What is a page fault? ### When the process tries to use a page that was not in physical memory, it is called page fault. 4.How do you compute the effective access time of a demand page system? ### Let p be the probability of a page fault, ma is the memory access time. Then effective access time=(1-p)*ma+p*p*page fault time. 5.Do problems 9.2, 9.3, 9.5 and 9.8 ### 9.2 ### a. the lower bound is n; b. the upper bound is p; 9.3 ### The page size is 4096(2**12), so 12 bits are required to specify the offset within the page, leaving 20 bits to specify the page number. Given address 11123456, which is in binary 00|000|000|101|010|011|011|101|100|000|000. The 20 most significant bits "00|000|000|101|010|011|011" speccify the page number, and the 12 least gihnificant bits "101|100|000|000" specify the offset within the page. The page number is used as the index into the page table, and the final physical address is the frame number (from the page table) combined with the offset. 9.5 ### Suppose the page-fault rate is R. 1ns=10e-9; 1millis=10e-3. Then, the effective access time is : (1-R)*0.0000001+R*70%*0.02+R*30%*0.008<=0.0000002. Thus, R<=6.7*10e-6. 9.8 ### Suppose find a page in drum need rotate half revolution. The time =50%*60/3000=0.01s Transfer a page need time = 1000/10e-6=0.001s; qmicrosecond=10e-6second. The effective instruction time: 99%*10e-6 + 1%*80%*2*10e-6 + 1%*20%*50%*(0.01+0.001) + 1%*20%*50%*(0.01+0.001*2) = 2.4*10e-5 seconds