Operating System Chapter 7 Homework

Multiple choice

  1. Which of the following statements is correct ()?
    A. Limited by hardware or operating system support, there are situations where the space at the end of the memory cannot be accessed
    B. The physical address refers to the actual address, and the relative address is an address relative to the reference (start) address
    C. The address space depends on the computer architecture and the length of the address encoding
    D. The address space can be infinite
    E. When the program is running, the relative address needs to be converted to a physical address to determine the actual location of the required content

  2. Regarding the relocation statement, which of the following is correct ()?
    A. The purpose of relocation is to determine the real address of the required content when the program is running, so that the required content can be obtained
    B. When the actual address can be determined in advance, static relocation can be used to directly convert all relative addresses to actual addresses in advance
    C. There are two commonly used methods of relocation: static relocation and dynamic relocation
    D. Dynamic relocation is to convert the relative address when the program instruction is actually executed

Subjective questions

  1. It is known that the memory status at a certain time is as follows, the shaded part represents the free and unallocated space, and the physical address of the corresponding junction is marked on the left.
    If the next adaptation algorithm is used for allocation, then for the job sequence P1 (length 3K), P2 (Length 10K), P3 (length 15K), P4 (length 10K), draw the final distribution.
    Insert picture description here

answer:
Insert picture description here

  1. The main memory of a computer is addressed in bytes, the logical address and physical address are both 32 bits, and the page table entry size is 4 bytes. please answer the following question.

(1) If the paging storage management method of the first-level page table is used, the logical address structure is:
Insert picture description here
How many bytes is the page size? How many bytes does the page table occupy?

(2) If the paging storage management mode of the secondary page table is used, the logical address structure is:
Insert picture description here
set the logical address as LA, and please give the corresponding page directory number and the expression of the page table index respectively.

(3) Using the paging storage management method in (1), the starting logical address of a code segment is 0000 8000H, its length is 8 KB, and it is loaded into the continuous main memory space starting from the physical address 0090 0000H. The page table is stored continuously from the physical address starting from the main memory 0020 0000H, as shown in the figure below (the address size increases from bottom to top). Please calculate the physical address of the two page table entries corresponding to the code segment, the page frame number in the two page table entries, and the starting physical address of code page 2.
Insert picture description here

Answer: [This question is addressing by byte]
(1) Because the offset in the page is 12 bits, the page size is 2 12 = 4 KB, and the
number of page table entries is 2 32 /4K = 2 20 , And since the page table entry size is 4 bytes, the maximum size of the first level page table is 2 20 × 4 B=4 MB.
(2) The page catalog number can be expressed as: (((unsigned int)(LA))>>22)&0x3FF. (Squeeze out the page table index and the offset within the page)
[((unsigned int)(LA))>>22 means that the data in LA is treated as an unsigned number, and the number is bitwise Right shift operation, right shift 22 bits. Complement the 22& (and) 0, but retain the 10 bits of the page directory number (11, 1111, 1111 = 3FF), that is, do a bitwise AND (&) operation between the result and 0x3FF.
Page table index can be expressed as: (((unsigned int)(LA))>>12)&0x3FF. (Squeeze out the offset in the page)
(3) The logical address of code page 1 is 0000 8000H, indicating that it is located at the eighth page, corresponding to the eighth page table entry in the page table, so the eighth page The physical address of the entry = the start address of the page table + (8 × the number of bytes of the page entry), that is, 0020 0000H + (8 × 4) = 0020 0020H.
[Because (3) adopts the paging storage management method in (1), so the page frame number is the page number, which has 20 digits, and when converted to hexadecimal, it has 5 digits. Then intercept the first five digits of the physical address. It is the page frame number; and the offset within the page has 12 digits, and it has 3 digits when converted to hexadecimal; the page size is 4 KB=2 12, Converted to hexadecimal system is 0001 0000 0000 0000 = 1000H, so 0090 0000H + 0000 1000H = 0090 1000H; 】
From this, you can get the answer as shown in the figure below.
Insert picture description here

Guess you like

Origin blog.csdn.net/Jessieeeeeee/article/details/109222972