Operating System Error-prone Questions

Operating System Error-prone Questions

  1. Suppose a hard disk consists of 5 discs (8 recording surfaces in total), the outer diameter of the effective recording area of ​​the disc is 30cm, the inner diameter is 10cm, the recording bit density is 250 bits/mm, and the track density is 16 tracks/mm. The track is divided into 16 sectors, and each sector is 512 bytes, so the formatted capacity of the hard disk is about () MB.

    Analysis
    Hard disk capacity is divided into two types: unformatted capacity and formatted capacity. The calculation formula is as follows:Unformatted capacity = number of planes x (number of tracks/plane) x inner circumference x maximum bit density
    Formatted capacity = number of sides x (number of tracks/side) x (number of sectors/track) x (number of bytes/sector)The number of sides of the hard disk given in the title is 8, the number of tracks on each side is (30-10)×10/2×16, the number of sectors per track is 16, and each sector is 512 bytes, so its formatted capacity is
    insert image description here
    To convert to MB, you need to divide by 1024*1024

  2. If the I/O interface and main memory of a computer system adopt unified addressing, the input and output operations are completed through (D) instructions.
    A. Control B. Interrupt C. Input and output D. Memory access

    Analysis
    There are two commonly used I/O interface addressing methods: one is withmemory unitUnified addressing, the second isindividually addressable.
    In the unified addressing mode with the memory unit, the relevant registers or storage components in the I/O interface are regarded as memory units, and are uniformly addressed with the storage units in the main memory. In this way, the memory address and the interface address are unified in a common address space, and the access to the I/O interface is the same as the access to the main memory unit, and the I/O interface can be accessed by the instruction to access the memory unit.
    The separate addressing of the I/O interface refers to assigning address codes to the relevant registers or storage components in the interface by setting a separate I/O address space, which needs to be accessed by setting special I/O instructions. The advantage of this addressing method is thatDoes not occupy the address space of main memory, the instruction to access the main memory is different from the instruction to access the interface, and it is easy to use and identify in the program.

  3. There are two producers in the production line M of an enterprise. Producer A continuously puts the semi-finished products processed in its process into the semi-finished product box, and producer B takes out the semi-finished product box from the semi-finished product box to continue processing. Assuming that the semi-finished product box can store n pieces of semi-finished products, using PV operation to realize the synchronization of producer A and producer B can set three semaphores S, S1 and S2, and the synchronization model is shown in the figure below.
    insert image description here
    The semaphore S is a mutually exclusive semaphore, and its initial value is (); the initial values ​​of S1 and S2 are (n, 0) respectively.
    A, 0 B, 1 C, n D, any integer

    Analysis
    Since the semaphore S is a mutually exclusive semaphore , it meansWhether the semi-finished box is currently used by a producer,soThe initial value is 1. amount of signalS1 means semi-finished box capacity, so its initial value is n. When producer A continuously puts the semi-finished products processed in its process into the semi-finished product box, it should first test whether there is space in the semi-finished product box, so producer A uses P(S1). signalS2 indicates whether there are semi-finished products in the semi-finished product box, the initial value is 0. When producer B takes out the semi-finished product box and continues processing, he should first test whether there is a semi-finished product in the semi-finished product box, so producer B uses P (S2).

  4. A file management system creates a bitmap on the disk to record the usage of the disk. If the word length of the system is 32 bits, and the physical blocks on the disk are sequentially numbered as 0, 1, 2, ..., then the usage of physical block No. 4096 is described in word (A) in the bit diagram: if the disk If the capacity is 200GB and the physical block size is 1MB, then the size of the bitmap is (6400) words.
    A, 129 B, 257 C, 513 D, 1025

    Analysis According to the meaning of the question, the word length
    in the system is32 bit, can record the usage of 32 physical blocks , so0~31 physical blockusage of the bitmap in theDescribed in the first word, the use of physical blocks 32~63 is described in the second word in the bitmap, ..., the use of physical blocks 4064~4095 is described in the 128th word in the bitmap, 4096~ The use of physical block No. 4127 is described in the 129th word in the bitmap. According to the meaning of the question, if the capacity of the disk is 200GB and the size of the physical block is 1MB, then the disk has 204800 physical blocks (ie 200X1024), and the size of the bitmap is 204800/32=6400 words.

  5. Assume that a time-sharing system adopts a simple time slice rotation method. When the number of users in the system is n and the time slice is q, the response time of the system to each user is T=(C) A, n B, q C, n
    * q D, n+q

    Analysis
    In the time-sharing system, the CPU time is divided into very short time slices and distributed to each end user in turn. When the number of users in the system is n and the time slice is q, then the response time of the system to each user It is equal to n*q.

  6. Issues that do not need to be considered when designing an operating system are (D)
    A. Management of hardware resources in computer systems
    B. Management of software resources in computer systems
    C. Interface between users and computers
    D. Realization of language compilers

    Analysis
    The operating system has two important functions:
    ① ThroughAsset ManagementTo improve the efficiency of the computer system, the operating system is the resource manager of the computer system, which contains a set of programs that manage the system's software/hardware resources.
    Improve human-machine interface, to provide users with a friendly working environment.

  7. Assuming that the address structure in the segment page storage management system is shown in the figure below, then system (D).
    insert image description here
    A. There can be a maximum of 2048 segments, and the size of each segment is 2048 pages. The page size is 2K
    B. There can be a maximum of 2048 segments. Each segment can have a maximum of 2048 pages, and the page size is 2K
    C. , There can be a maximum of 1024 segments, and the size of each segment is 1024 pages
    , and the page size is 4K

    Analysis
    The number of segment numbers is 210=1024, the maximum number of pages in a segment is 210=1024, and the page size is 212=4096 bytes.

  8. In single-processor systems, a first-come, first-served scheduling algorithm is used. There are 4 processes P1, P2, P3, and P4 in the system (assuming that the processes arrive in this order), among which P1 is in the running state, P2 is in the ready state, P3 and P4 are in the waiting state, and P3 is waiting for the printer, and P4 is waiting for the scanner. If P1 (time slice is up), then the states of P1, P2, P3 and P4 should be ().
    A, waiting, ready, waiting and waiting
    B, running, ready, running and waiting
    C, ready, running, waiting and waiting
    D, ready, ready, waiting and running

    Analysis
    First of all, the first-come-first-serve scheduling algorithm is used here, that is, the operation is arranged according to the order of application, and the application order has been assumed to be P1-P2-P3-P4 in the question stem.
    Secondly, the structure cannot be judged by a single space, so analyze it in combination with the option of the second space. Firstly two processes cannot run at the same time, so the "Released Scanner" option is ruled out. According to the original states of P1-P2-P3-P4 respectively (running, ready, waiting, waiting), so the next one that can be in the running state is eitherKeep running P1 unchanged, otherwise it should beP2 that has entered the ready state(According to the first-come-first-served scheduling principle), among the four options of the second space, only the option "released the printer" is matched. At this time, the states of P1-P2-P3-P4 are (ready, running, waiting, waiting) ). Based on this, let’s analyze the first space again. P1 changes from the running state to the ready state. The condition should be that the time slice arrives, so choose "time slice arrives".

  9. Assuming that the size of the disk block is the same as that of the buffer, the time for each multiple-choice disk block to be read into the buffer is 10us, the time for the buffer to be sent to the user area is 5us, and the processing time for the system for each disk block is 2us. If the user needs to read a Docl file with a size of 10 disk blocks from the disk into the buffer block by block and send it to the user area for processing, then the time it takes to use a single buffer is (C)us; to use a double buffer requires The time taken is (107) us.
    A, 100 B, 107 C, 152 D, 170

    When analyzing
    block device input, assume that the time to input a block of data from the disk into the buffer is T, the time to transfer the data in the buffer to the user's work area is M, and the time for system processing (calculation) is C, as shown in the figure (a) shown.
    insert image description here
    After the first piece of data is sent to the user work area, the buffer is free and the second piece of data can be sent. In this way, the processing C1 of the first block of data and the input T2 of the second block of data can be parallelized, as shown in figure (b), and so on. The system's processing time for each piece of data is: Max(C, T)+M. Because when T>C, the processing time is 10+5=15 for each piece of data in this question, and the processing time for Doc1 file is 15*10+2=152

The basic method of double buffering is to input data into buffer 1 when the device is input, and then turn to buffer 2 when it is full. At this point, the system can extract data from buffer 1 and send it to the user area, and finally the system will process the data, as shown in Figure (c).
insert image description here
Double buffering can realize the input T and extraction M of the data in the buffer, and the calculation C of the CPU, and the three work in parallel, as shown in figure (d). It can be seen from the figure that double buffering further accelerates the speed of I/O and improves the utilization rate of equipment. In double buffering, the time for the system to process a block of data can be roughly considered as Max(C, T). If C<T, the block device can be continuously input; if C>T, the system does not have to wait for the device input. The processing time for each piece of data in this question is 10, and the time it takes to use double buffering is 10*10+5+2=107.

Guess you like

Origin blog.csdn.net/qq_52108058/article/details/130782891