1. Address transformation and finding FAT table size
The contents of a page table from 0 to 7 are 03; 07; 0B;11;1A;1D;20;22.
Please calculate the page size when it is 1K and 4K The logical address 134D corresponds to the physical address.
First, convert 134D to a binary number as 0001001101001101
1k is 2 raised to the 10th power. The tenth digit from back to front is 000100|1101001101
The binary number in front of the vertical bar is converted to decimal number 4, and the 4 block number corresponds to 1A. Then replace the binary number in front of the vertical line with the binary number of 1A 011010 and finally get 0110101101001101 converted to hexadecimal 6B4D
When the page size is 4k, 4k is 2 raised to the 12th power, counting 12 digits from back to front 0001|001101001101
The number before the vertical line is 1, and the block number corresponding to 1 is 07, then 0111. Finally, we get 0111001101001101, which is 734D.
Assume that the disk block size is 1K. For a 540M hard disk, how much storage space does the file allocation table FAT need to occupy? When the hard disk capacity is 1.2G, how much space does the FAT need to occupy?
540M/1K=540K, so there are 540K disk blocks in total, 512<540<1024
1024K is 2 raised to the 20th power, so each entry occupies 2.5 bytes, a total of 540
The final storage space occupied is 540*2.5=1350K
When the hard disk size is 1.2G, 1.2G/1K=1.2M, so a total of 1.2M disk blocks 1<1.2<2
2M is 2 raised to the 21st power. Each entry occupies 3 bytes. A total of 1.2M*3=3.6M
Variable partition management
On the basis of the following partition table, the process start addresses of the five processes PO, P1, P2, P3, and P4 are allocated sequentially according to the first adaptation and best adaptation algorithms. The sizes of the five processes are P0: 200k, P1: 15K, P2: 100K, P3: 80K, P4: 20K.
P0 | P1 | P2 | P3 | P4 | |
first adaptation | 500k | 10K | 320K | 25K | 200K |
best fit | 850k | 1065k | 10k | 320k | 200k |
by first partition
The process size of p0 is 200K, and only the fifth partition can be put down. Therefore, the starting address of P0 is 500K. At this time, the starting address of partition No. 5 becomes 700K and the size becomes 100K.
The process size of P1 is 15K, and partition 1 can be put down. Therefore, the starting address of P1 is 10K. At this time, the starting address of partition 1 becomes 25K, and the size becomes 85K.
The size of P2 is 100K. At this time, only No. 4 can be put down, so the starting address is 320K. At this time, the starting address of No. 4 is 420K and the size is 50K.
The size of P3 is 80K, and partition 1 can be put down, so the starting address is 25K. At this time, the starting address of partition 1 is 105K and the size is 5K.
The size of P4 is 20K and 2 partitions can be placed, so the starting address is 200K.
Best fit: Start with the smallest and find the first one that can fit
P0 is 200k. The first partition that can accommodate it is partition No. 6, so the starting address is 850k. At this time, the starting address of partition No. 6 is 1050k and the size is 20K.
P1 is 10K. From small to large, the first partition that can be installed is No. 6. The starting address is 1050K. At this time, the starting address of No. 6 is 1065k and the size is 5k.
P2 is 100k. The first partition that can be installed from small to large is partition 1. The starting address is 10K. At this time, the starting address of partition 1 is 110k and the size is 0k.
P3 is 80K. From small to large, the first partition that can be installed is No. 4. The starting address is 320k. At this time, No. 4 starts from 400k. Size 70k
P4 is 20k, which can be installed in partitions from small to large. The starting size is 200k.
Page replacement algorithm
During the address mapping process, if the page to be accessed is found to be not in the memory, a page fault interrupt will occur. When a page fault occurs, if there is no free page in the operating system's memory, the operating system must select a page in the memory and move it out of the memory to make room for the page to be transferred in. The rule used to select which page to eliminate is called Page replacement algorithm.
In a request paging system, there is a process with a length of 5 pages. If the system allocates 3 physical blocks for it
, and the page direction of this process is 2, 3 ,2,1,5,2,
5,3,2,5,2. Calculated respectively using FIFO (first in, first out), LRU (selecting the most recent and longest unused pages for elimination), and OPT (each selecting pages that will not be accessed for a long time in the future or will never be used in the future) algorithms. The number of page faults that occurred during program access
Disk scheduling algorithm
A certain disk has 8192 tracks, numbered 0~8191. After completing the request at track 1250, it is currently serving a request at track 3500. If the order of the request queue at this time is 1000, 4000, 3360, 5600, 1300, 6000, 1200, 2500. Answer the following questions:
(1) Use the FCFS (first come, first served) algorithm to complete the above request. Please write down the sequence of head movement and calculate the average seek length (2) Use the SSTF (shortest seek time first) algorithm to complete the above request. Please write the sequence of head movement and calculate the average seek length (3) Use SCAN (elevator) algorithm to complete the above request. Please write the sequence of head movement and calculate the average seek length
![1d348154d8234232bab827b8b320b4c8.png](https://img-blog.csdnimg.cn/1d348154d8234232bab827b8b320b4c8.png)
Processor Scheduling
banker's algorithm
![83c4e29f9cc4411985abbffca2345235.png](https://img-blog.csdnimg.cn/83c4e29f9cc4411985abbffca2345235.png)
Process synchronization and mutual exclusion