Final review of computer operating system principles

Chapter 1 Introduction to Operating Systems

1. What are the four characteristics of modern operating systems? (4 points)

Concurrency, shared, virtual, asynchronous
Concurrency: two or more events inthe same time intervalhappen.
Sharing: Multiple concurrently executing processes in memory use resources in the system together.

2. What are the four main functions of the operating system kernel? (4 points)

Memory management, process management, device management, file management

3. Why is the average turnaround time of a multiprogramming system longer than that of a singleprogramming system? (1 point)

There is CPU waiting time

4. What is an important performance indicator related to time-sharing systems and human-computer interaction? (1 point)

Response time

5. What are the two main indicators to measure whether a real-time system meets the time performance requirements? (2 minutes)

start time, end time

6. Which part of the program completes the function of converting the logical address of a file into the physical address of the file in external memory? (1 point)

disk driver

7. What are the main types of operations performed by instructions? (3 points)

between 1, processor and memory Instruction ordata transferoperation
2. Processor< Command or data transfer between a i=9> and I/O deviceOperations 3. Arithmetic operationsOperations andLogical operations, that is, modify the instruction execution sequence operationControl operation 4. Operation

Chapter 2 Process Description and Control

1. What three parts does the process consist of? Under what circumstances does an executing process become ready? What program should be called in the last step of blocking the process to reallocate the CPU?

Program, user data, process control block

CPU time slice exhausted

process scheduler

2. If two processes execute the following program concurrently, the initial value of x is 3. After each of the two processes executes the following code once, what are the possible values ​​of x?
load R1, x //Get the value of x into register R1
dec R1 //Decrease the value of R1 by 1
store x, R1 // Store the contents of R1 into x

1 or 2

3. Briefly describe the process of operating system booting.

After the execution of theBIOS program in the is loaded from external storage to memory, and finally the kernel begins execution. The kernel program in the external memory and load it into the memory. Then the loader program is executed. loader program is loaded into the memory, and then the Boot program is executed. Find the Boot programread-only memory ROM, the

4. What is the component that generates the external interrupt signal? Which component generates the interrupt vector? What operations are completed by the hardware after the interrupt response starts? What operations are completed by the operating system kernel after the interrupt response starts? What is stored in the interrupt vector table entry? If the starting address of the interrupt vector table is addr and the entry length is 8 bytes, what is the starting address of the nth entry in the interrupt vector table?

Hardware circuit outside CPU
Interrupt controller
Hardware: turn off interrupts, save program breakpoints, interrupt handler address—》pc Information related to the entry address of the interrupt or exception handling service program
Kernel: protect the scene, execute the interrupt service routine, restore the scene, enable interrupts, interrupt return

5.What is the function of the programmable interval timer? List several functions thatclock interrupt handler need to complete. How to ensure synchronization of RTC time and OS time?

Function: Generate clock interrupts at specified intervals, measure elapsed time, and trigger time-related operations.

Example:
1. Maintenance time and date;
2. Accounting for CPU usage;
3 , Decrement the alarm timer;
4. Decrement the remaining time of the current process within a time slice, and check whether it is 0 to prevent the process from running overtime.

Chapter 3 Process Synchronization and Process Communication

1. Is the synchronization mechanism implemented by the operating system or the application? Does the operating system or the application need to call a function that implements the synchronization operation?

Operating system or application;
Operating system or application;

2. Please write down the pseudo code of wait(s) and signal(s) operations in the record-type semaphore mechanism, and explain the type of semaphore.

Type semaphore=record
value:integer;
L:list of process;
end

Insert image description here

3. If the record semaphore mechanism is used to solve the producer-consumer synchronization problem, under what circumstances will the producer process be blocked? Which blocking queue will the blocked producer process be inserted into?

The buffer is full
The producer process blocks the queue

4. Please write down the code fragment before the reading process enters the shared data area to perform the read operation in the reader-writer problem.

wait(rmutex);
if readcount = 0 then wait(wmutex);
readcount++;
signal(rmutex);

5. What is the meaning of "give up and wait" among the four principles that the synchronization mechanism should follow? What are the benefits of waiting to realize the transfer of power?

Meaning: When the process cannot apply for access rights to shared resources, the processor should be released immediately
Benefits: To prevent the process from falling into a "busy waiting" state and wasting CPU resources

6. Is the semaphore a global variable or a local variable?

global variables

Chapter 4 Process Scheduling

1. Why does an operating system that supports multitasking need to implement process scheduling (CPU scheduling)?

Because the CPU is a shared resource

2. When what events occur does the operating system execute the process scheduler?

1. The process ends (including normal end and abnormal end)
2. Process blocking
3. Interrupt return
4. In a system that supports preemptive scheduling, a process with a higher priority than the currently running process arrives
5. The time slice of the currently running process runs out

3. Regarding the time slice rotation scheduling algorithm, answer the questions. Compared with other scheduling algorithms, what special hardware support does the time slice round-robin scheduling algorithm require? When is the remaining time for the process to execute on the CPU initialized? What are the main operations required for process switching? What are the disadvantages of using shorter time slices?

Hardware: Programmable interval timer, programmable interrupt controller
The process is initialized during process scheduling
Main operations: Stack frame switching and CPU context switching
Disadvantages: increased system overhead and average turnaround time

4. If there are three processes p1, p2, and p3, the time to enter the system is 30ms, 40ms, and 50ms respectively, the required CPU service time is 5ms, 10ms, and 4ms respectively, and the priority levels are 3, 20, and 1 respectively (priority The smaller the number, the higher the priority). If the system starts process scheduling from 35ms and uses a non-preemptive priority scheduling algorithm, please explain the scheduling order of the three processes and calculate the average turnaround time of the three processes.
Please add image description

Chapter 5 Deadlock

Chapter 6 Memory Management

Insert image description here

(First of all, there is a problem with the question. The question says that 3 page frames are allocated to the process, but only 2 page frames of the process are given in the table. When accessing the logical unit 0x1F0A, you need to obtain the page frame of the page with page number 1. According to the LRU replacement algorithm required by the question, swap out the most recently unused page. The pages occupied by the process here are No. 0, No. 2 and the ungiven x number. No. 2 has just been accessed, but does not know the page. Change to number 0 or change to number There is something wrong with the condition of "allocate 3 page frames for this process", and there is no other guidance saying that page 0 should be swapped out, so we can only rely on guessing)

(1) 0x2356: The page number is 2, the intra-page offset is 0x356, the page frame number of page number 2 read out according to the page table is 0x102, and the physical address is calculated as follows:
0x1020x1000+0x356=0x102356
0x1F0A: The page number is 1, the offset within the page is 0xF0A, and page number 1 is found to be missing according to the page table (valid bit is 0), page 0 is swapped out according to the LRU replacement algorithm, and page 1 is loaded into the original page frame of page 0, so the physical address is calculated as follows: 0x6E
0x1000+0xF0A= 0x6EF0A

(2) First question: If the TLB hits, the time required to access the page frame is equal to 10ns, and the time required to access the memory to obtain data is 100ns, and the total time spent is 110ns
Second question : When accessing logical unit 0x1F0A, the CPU first retrieves the fast table (which takes 10 ns). The page table is not in the fast table. Then the page table is accessed (which takes 100 ns). If the page is not in the memory, a page missing exception occurs, and page missing exception processing is performed. (It takes 20ms). After loading the page into the page frame, it requests access to 0x1F0A again. First, the CPU retrieves the fast table (it takes 10ns). The page table is not in the fast table. Then it accesses the page table (it takes 100ns) and the page is in the memory. , the physical address is calculated based on the page frame number and the page offset, and the data is accessed (which takes 100ns), and the total time is (10ns+100ns+20ms+10ns+100ns+100ns=20.32ms)

Chapter 7 File System

In a certain file system, the directory entry structure is as shown on the right.
Insert image description here
There are 2 direct address items, 1 primary indirect address item, 1 secondary indirect address item, and 1 tertiary indirect address item in the i node. If the directory tree is as shown in the figure below, the i-node number, cluster number and sequence occupied by each file are as shown in the table below. Among them, dir and dir1 are directories, file1 and file2 are user files, the directory entry length is 32 bytes, and the disk block size is 4KB. Please answer the following questions.
Insert image description here

1. Write the contents of the directory file dir1.

The content of directory file dir1 isInsert image description here (2 points)

2. At least how many bytes of disk space do the directory files dir, dir1 and user file file1 occupy in total?

The file system allocates space for files in units of disk blocks. The directory files dir and dir1 each need to be allocated a disk block. The file file1 occupies three disk blocks 6, 8, and 10. Therefore, dir, dir1, and the user file file1 occupy a total of 5 disk blocks. Disk block, 5*4KB=20KB space. (2 minutes)

3. What data structures have changed after deleting file file2? Explain the specific content after the change.

After deleting file file2, the content of directory file dir1 becomes
Insert image description here
The i node occupied by file file2 is released.
The status of the four disk blocks 12, 13, 16, and 23 occupied by file file2 becomes idle. (3 points)

4. Briefly describe the process of accessing file file1 by name.

According to the file name dir1, find the i-node number 2 where dir1 is located in the dir directory file, obtain the disk block number of the directory file dir1 in i-node 2, and read the contents of dir1 from it. Retrieve the directory file dir1 with the file name file1 as the index, from which the i-node number 3 of file1 can be obtained. From the i-node No. 3, the disk block numbers 6, 8, and 10 where the file file1 is located can be obtained, from which the contents of file1 can be obtained. (3 points)

Chapter 8 I/O Device Management

Guess you like

Origin blog.csdn.net/weixin_52060913/article/details/131055098