Summary of operating system final review knowledge points

Table of contents

Chapter 1 Introduction to Operating System

Chapter 2 Process Description and Control/Threads

Chapter 3 Concurrency Control - Mutual Exclusion and Synchronization

Chapter 4 Deadlock Handling

Chapter 5 Memory Management

Chapter 6 Processor Scheduling

Chapter 7 I/O Device Management


Chapter 1 Introduction to Operating System

1. Definition of operating system

OS is a set of programs that control and manage computer hardware and software resources , reasonably schedule various jobs , and facilitate users to use computers. That is, it provides services for user programs and is the interface between users and hardware systems.

2. The role of the operating system

OS is the core of the computer system. It is responsible for managing the software and hardware resources of the entire computer system, formulating allocation strategies for various resources, scheduling user programs running in the system, and coordinating user needs for resources, so that the entire computer system can work efficiently and orderly.

3. Common classifications of operating systems

①Batch processing operating system: single-channel batch processing (automatic, sequential and single-channel), multi-channel batch processing (parallel on the macro level, serial on the micro level, high resource utilization and high system throughput; long user response time and drone interaction capability)

② Time-sharing operating system: time slice rotation; simultaneous, interactive, independent and timeliness

③Real-time operating system: respond to events within a pre-defined time; timely and reliable

④Network OS Distributed OS and Embedded OS

4. The definition of multi-programming technology, the reason and purpose of introducing multi-programming technology

Multiprogramming technology allows multiple programs to enter memory at the same time and allows them to run alternately on the CPU. When a program is suspended due to an I/O request, the CPU immediately switches to running other programs, making full use of resources and doubling work efficiency.

Introduce multiprogramming technology to further improve resource utilization and system throughput, and give full play to the parallelism of computer system components

5. The relationship between the operating system and hardware, other system software, and users

The operating system is the first layer of software covering the hardware, which directly manages the hardware and software resources of the computer and provides users with a good interface;

The operating system is a special system software. Other system software runs on the basis of the operating system and can obtain a large number of services provided by the operating system. That is to say, the operating system is the interface between other system software and hardware;

In addition to operating system support, general users also need to use a large number of other system software and application software to make their work more convenient and efficient.

6. The definition of multiprogramming technology and the benefits brought by the introduction of this technology in OS

Multi-programming technology refers to storing multiple jobs in the memory, and automatically scheduling another job in the memory to run when the operation is completed or an error occurs. The main advantages of multiprogramming are as follows:
(1) High resource utilization. Since multiple programs are loaded into the memory, they share resources and keep system resources busy, so that various resources can be fully utilized.
(2) The throughput of the system is large. Since the CPU and other system resources remain "busy" and switch only when the job is complete or cannot continue, the system overhead is small, so the throughput is high.

7. The main driving force for the formation and development of batch processing systems and time-sharing systems

(1) The main driving force for the formation and development of batch processing systems: continuous improvement of system resource utilization and system throughput: the application of offline input/output technology and automatic transition of jobs greatly improves the speed of I/O and the degree of parallel work between I/O devices and CPU, reducing the idle time of the host CPU; the application of multi-programming technology further improves the utilization of CPU, memory and I/O devices and the throughput of the system.

(2) The main driving force for the formation and development of the time-sharing system is to better meet the needs of users: the time-sharing use of the CPU shortens the average turnaround time of jobs; the provision of human-computer interaction capabilities enables users to directly control their own jobs; the sharing of hosts enables multiple users to use the same computer at the same time to process their jobs independently and without interfering with each other.

8. The key issues in realizing the time-sharing system

The key issue in realizing the time-sharing system is to enable the user to interact with his own job, that is, the system can receive and process the command in time after the user inputs a command on his own terminal to request the system service, and returns the result to the user within a time delay acceptable to the user. It is relatively easy to receive commands and return output results in a timely manner. Generally, you only need to configure a multi-channel card in the system and configure a buffer for each terminal to temporarily store the commands entered by the user and the output results.

9. The principle of division of time slices

The time slice is the time allocated by the CPU to each program, that is, the time the process is allowed to run, so that each program appears to be running at the same time. If the process is still running when the time slice ends, the CPU will be taken away and assigned to another process. If the process blocks or ends before the time slice ends, the CPU switches immediately. Without causing a waste of CPU resources.

10. From the three aspects of interactivity, timeliness and reliability, compare time-sharing system and real-time system.

① timeliness. The real-time requirements of the real-time information processing system are similar to those of the time-sharing system, which are determined by the waiting time acceptable to humans; while the timeliness of the real-time control system is determined by the start deadline or completion deadline required by the control object. Generally, it is on the level of seconds to milliseconds, and some are even lower than 100 microseconds.

② Interactivity. Although the real-time information processing system is also interactive, the interaction between the user and the system is limited to accessing some specific special service programs in the system. It does not provide services such as data processing and resource sharing to end users like a time-sharing system.

③Reliability. Although the time-sharing system also requires the system to be reliable, in contrast, the real-time system requires the system to have a high degree of reliability. Because any error may bring huge economic losses, even unpredictable catastrophic consequences, so in real-time systems, multi-level fault tolerance measures are often taken to ensure system security and data security.

11. Characteristics of the operating system

(1) concurrent

Two or more events occur within the same time interval.

(The difference is different from parallelism: parallelism means that the operating system has the characteristics of performing calculations or operations at the same time, and performing two or more tasks at the same time.)

(2) Sharing

① Mutually exclusive sharing: Only one process is allowed to use it for a period of time, and other jobs are allowed to use it only after the current job is released.

② Simultaneous sharing: system resources allow simultaneous (macroscopic) access by multiple processes in a period of time, and alternate access on a microscopic level

(3) virtual

Transform a physical entity into several logically corresponding functions through a certain technology.

(4) asynchronous

In a multiprogramming environment, multiple programs are executed concurrently, but due to limited resources, the execution of the process is not consistent to the end, but moves forward at an unpredictable speed.

12. Advantages of microkernel structure

 The microkernel structure is based on the client/server architecture and adopts the structure of object-oriented technology.

①Flexibility. The microkernel is short and lean, providing only the most basic and necessary services.

② Openness. The functions of the operating system except the kernel can be built on the kernel in the form of a server. Based on this structural framework, system developers can easily design, develop, and integrate their own new systems.

③ scalability. It is very easy to implement, install, and debug a system using a microkernel operating system. Users can rewrite unsatisfactory services they already have

Chapter 2 Process Description and Control /Threads

1. The basic state of the process

① Create state. The state of the process when it was just created and has not yet entered the ready state.

② Ready state. The process gets all the resources except the processor , it only needs to get the processor to run, and if multiple processes are in the ready state, they are placed in the ready queue.

③Running state. The process gets the processor to run. Only one process can run on a single processor at a time

④ blocking state. The state that the process is waiting for a resource and suspending operation, such as waiting for a resource or waiting for input and output to complete, if there are multiple blocked processes, store them in the blocking queue.

⑤ end state. The process is disappearing from the system and may end normally or passively. The system needs to put the process into an end state to reclaim related resources.

2. Process state transition diagram

①Ready state→running state: the process in the ready state is scheduled by the processor, obtains processor resources, and can run

②Running state→ready state: In a non-preemptive operating system, the time slice is used up; in a preemptive operating system, a process with a higher priority enters, and it will preempt the processor, causing the original process to return to the ready state

③Running state→blocking state: the running process needs other resources, it will enter the blocking state

④Blocking state→ready state: After the previously required resources are obtained, it will re-enter the ready state

3. Definition of process hang

Swap a process in the ready or blocked state from memory to external memory

4. The cause of the hang

5. The primitives used for process control in the operating system, the role of these primitives

①create primitive: create a new process

② cancel the original language: terminate the process

③ Blocking primitive block: change the process from running state to blocking state

④Wake up primitive: remove the process from the waiting queue and set its state to ready state

6. The structure of the process

A process is an independent operating unit and the basic unit for resource allocation and scheduling by the operating system. It generally includes three parts: a process control block, a program segment, and a data segment.

7. Definition of process control block

PCB is a part of the process entity, the only sign of the existence of the process, and the most important record-type data structure in the operating system

8. The composition of the process control block

① Process identifier

②Processing and Status

③Process scheduling information

④ process control information

9. The role of PCB

The role of the PCB is to make a program that cannot run independently in a multi-program environment become a basic unit that can run independently and can be executed concurrently with other processes.

10. What types of information should a classic PCB have?

Processor status information; process scheduling information; process control information

11. The main steps to create a new process

① Assign a unique process identification number to the new process and apply for a blank PCB  .

Allocate resources for the process , and allocate the necessary memory space for the program and data of the new process and the user stack. If the resources are insufficient (such as memory space), it is not that the creation fails, but it is in a blocked state, waiting for memory resources.

③Initializing the PCB mainly includes initialization flag information, initialization processor status information, initialization processor control information, and setting process priority.

Insert the new process into the ready queue, waiting to be scheduled to run .

1 2. The difference between a process and a program

(1) Process is a dynamic concept, while program is a static concept. A program is an ordered collection of instructions without execution meaning, while a process emphasizes the process of execution.

(2) The process has parallel characteristics (independence, asynchrony), but the program does not.

(3) Different processes can contain the same program, and the same program can also generate multiple processes during execution

1 3. The execution mode of the process

user mode; kernel mode

14. Compare processes and threads in terms of scheduling, concurrency, resource ownership, independence, system overhead, and support for multiprocessors

1) Scheduling. In an operating system that introduces threads, a thread is the basic unit of independent scheduling, and a process is the basic unit that owns resources; thread switching in the same process will not cause process switching. Switching threads in different processes, such as switching from a thread in one process to a thread in another process, will cause a process switch.

2) Concurrency. In operating systems that introduce threads. Not only processes can be executed concurrently, but also multiple threads can be executed concurrently, so that the operating system has better concurrency. The throughput of the system is improved.

3) Own resources. Whether it is a traditional operating system or an operating system without threads, a process is the basic unit that owns resources; while a thread does not own system resources (only a few essential resources), but a thread can access the system resources that belong to the process.

4) System overhead. Since the system must allocate or reclaim resources, such as memory space, IO devices, etc., when creating or canceling a process, the overhead paid by the operating system is much greater than the overhead when creating or canceling a thread; while thread switching only needs to save and set a small amount of register content, the overhead is very small. Since multiple threads in the same process have the same address space, the realization of synchronization and communication between them becomes easier. And without the intervention of the operating system.

15 , the definition of user-level thread ULT

A user-level thread refers to a thread that does not depend on the operating system core and is controlled by the application process using the thread library to provide functions for creating, synchronizing, scheduling, and managing threads.

16. The definition of kernel support thread KLT

Kernel-level threads refer to threads that depend on the kernel and are created and revoked by the operating system kernel.

17. The relationship between threads and processes

①A process can have multiple threads, but at least one thread; and a thread can only be active in the address space of one process.

②Resources are allocated to processes, and all threads of the same process share all resources of the process.

③The CPU is allocated to the thread, that is, the thread is actually running on the processor.

④Threads need to cooperate and synchronize during the execution process, and the threads of different processes need to use message communication to achieve synchronization.

Chapter 3 Concurrency Control - Mutual Exclusion and Synchronization

1. Basic principles to be followed in the use of critical resources

Access to critical resources must be mutually exclusive

2. Definition of critical section

The code that accesses critical resources in the process.

3. The principles that a process should follow when accessing the critical section

1) Give in when free. When the critical section is free, a process that requests to enter the critical section can be allowed to enter the critical section immediately.

2) Wait if busy. When an existing process enters the critical section, other processes trying to enter the critical section must wait.

3) Bounded waiting. The process that requests access should be guaranteed to enter the critical section within a limited time.

4) Give up the right to wait. When the process cannot enter the critical section, the processor should be released immediately to prevent the process from busy waiting.

4. Interrupt processing

Turn off interrupts : After the CPU responds to interrupts, it must first protect the on-site status of the program. During the protection process, the CPU cannot respond to higher-priority interrupt requests. If a higher priority program is responded to, the low priority program will not be saved completely, and after the interrupt is processed, it will not be able to return to the state before the interrupt.

Save the breakpoint : In order to ensure that the interrupt service program can return to the original program correctly after execution, the program breakpoint (the value of the program counter PC) must be saved

Find the entry address of the interrupt service program : the essence is to take out the entry address of the interrupt service program and send it to the program counter PC. Acquisition of the entry address: query the "interrupt vector table" to find the storage location of the corresponding interrupt handler in the memory

Enter the interrupt service routine and start executing the interrupt service routine

Protect the scene and mask word : The first thing after entering the interrupt service routine is to protect the scene and mask word, mainly to save the program status word PSWR and the contents of some general registers

⑤Enable interrupt : Allow to respond to higher-level interrupts If a high-level interrupt arrives at this time, you can execute the high-level interrupt, because the site information of the interrupted program has been saved, and responding to the high-level interrupt will not cause the site information of the interrupted program to be restored. Incomplete

Interrupt service program processing : Execute the interrupt service program, which is also the purpose of the interrupt

Interrupt off : After executing the interrupt service program, before the end of the program, the scene needs to be restored, and this operation cannot be interrupted

Restore the scene : the interrupt service program restores the previously saved values ​​of the relevant registers to their original state

⑨Open interrupt : The interrupt service routine is about to end, reopen the interrupt, and allow to respond to other interrupts

Return to the breakpoint to continue execution : the last instruction of the interrupt service routine is usually an interrupt return instruction, making it return to the program breakpoint so that the original program can continue to execute

 5.  How to ensure that the processes have mutually exclusive access to critical resources?

   give in if idle; wait if busy; bounded wait; wait if busy

6. How to solve mutual exclusion with hardware method (including two methods)

①Interrupt masking: CPU process switching is completed through interrupts, so shielding interrupts can allow the currently running process to execute smoothly, prevent other processes from entering the critical section, and then ensure the realization of mutual exclusion. The typical steps are: turn off interrupt → critical section → open interrupt.

This method is simple and efficient, but only applies to the kernel process of the operating system, not to the user process; the execution efficiency of the processor decreases; if the interrupt is not enabled after the interrupt is turned off, the system may terminate.

②Hardware instruction: TestAndSet instruction: This instruction is an atomic operation (the execution process is not allowed to be interrupted), and is used to set the read specified flag to true; Swap instruction: Used to exchange the contents of two bytes

7. What is "busy-wait" and its disadvantages

"Busy waiting" refers to the waiting of "not giving up the right", that is, when the process cannot continue to execute due to the occurrence of a certain event, it still occupies the CPU and waits for the completion of the event by continuously executing loop test instructions.

The main disadvantage of "busy waiting" is that it wastes CPU time, and it may also cause unexpected consequences.

For example, consider a system that adopts a high-priority priority scheduling principle. At present, there are two processes A and B sharing a certain critical resource. A has a higher priority and B has a lower priority, and B is already in the critical area. If A wants to enter its own critical area, neither A nor B can continue to move forward and fall into a "dead wait" state.

8. How to use semaphores to solve mutual exclusion problems «

Mutual exclusion means that different processes perform PV operations on the same semaphore; solving mutual exclusion means that only one process is allowed to access critical resources per unit time

Processes P1 and P2 are executed concurrently, and both have their own critical sections, but the system requires that only one process enters its own critical section at a time, so the initial value of the semaphore S is set to 1 (the number of available resources is 1), and the critical section is placed between the P and V operations to realize mutually exclusive access to critical resources by two processes:

If there is no process in the critical area, any process enters to execute the P operation, lock S-- to 0, and then enter; if there is a process in the critical area, S is 0 at this time, and if you want to execute the P operation, you will block yourself until the process in the critical area exits, thus achieving mutual exclusion.

9. P, V operation of semaphore

P operation (wait(s), value--), means that the process applies for a resource of this type;

V operation (signal(s), value++), indicating that the process releases a resource;

10. Composition of the monitor

①The name of the tube

②Description of shared structure data localized inside the monitor

③ A set of procedures (or functions) that operate on the data structure

④ A statement that sets the initial value for the shared data that is local to the monitor

11. Characteristics of the monitor

① Local variables in the monitor can only be accessed by processes limited to the monitor; and vice versa, that is, processes local to the monitor can only access variables in the monitor.

② Any process can only enter the monitor by calling the process entry provided by the monitor. For the above example, the external process can only apply for a resource through the take_away() process.

③ At any time, at most one process can be executed in the monitor, so as to realize mutual exclusion of processes. A monitor is a component of a programming language, and its implementation requires the support of a compiler

12. Message Passing Primitives

Send primitives and Receive primitives: Appear in pairs, generally combined as blocking sending, blocking receiving; non-blocking sending, blocking receiving; non-blocking sending, non-blocking receiving

Chapter 4 Deadlock Handling

1. Definition of deadlock

Deadlock refers to a deadlock (waiting for each other) caused by multiple processes competing for resources. Without external forces, these processes cannot continue to move forward.

2. Four necessary conditions for deadlock

Mutual exclusion : only one process occupies resources in the same time interval

Inalienable : The resources obtained by the process can only be released by itself, and cannot be forcibly occupied by other processes

③Request and hold : A process that already owns a resource makes a new resource request, but the resource is already occupied by another process, the process is blocked, but the obtained resource is still held

④Circular waiting : There is a circular waiting chain of process resources, and the resources obtained by each process in the chain are simultaneously requested by the next process

3. The root cause of the deadlock

①Competition for system resources: Since the inalienable resources cannot meet the needs of multiple processes to run, these processes are deadlocked in the competition for inalienable resources, resulting in a deadlock.

② Illegal process advancement: When two processes P1 and P2 occupy resources 1 and 2 respectively, if P1 applies for resource 2 and P2 applies for resource 1 again, the two processes will be deadlocked due to lack of resources, that is, the improper order of requesting and releasing resources during process running will also lead to deadlock.

4. Three ways to solve deadlock

①Deadlock prevention: set conditions to destroy one or more of the four conditions generated by deadlock

②Deadlock avoidance: in the process of dynamic allocation of resources, adopt a certain strategy to prevent the system from entering an unsafe state

③Deadlock detection and release: During the running process of the process, if the running deadlock occurs, the deadlock is detected by the detection mechanism, and measures such as depriving resources and canceling the process are taken to free the system from the deadlock

5. Static resource allocation strategy

 Destroy the request and hold conditions, adopt static allocation, and apply for all the resources needed by the process at one time when the process is in the ready state. If all resources are applied for, the process will run immediately, and all resources will only be owned by the current process during the running period, and will not be requested by other processes.

6. Methods to prevent deadlock

Adopt static resource allocation strategy;

Adopt an on-demand resource allocation strategy

7. What is a safe state

The safe state is that at a certain moment, the system can allocate the required resources for each process in a certain order or sequence (eg: P1, P2, ..Pn), until each process can obtain the maximum resource demand, and ensure that all processes are completed sequentially. At this time, the sequence is called a safe sequence. As long as a safe sequence can be found, the system is in a safe state; if there is no safe sequence in the system, the system is in an unsafe state.

8. How to tell if the system is in a safe state «

​Example : Is T0 a safe state? If so, please give a safe sequence

 

9. The basic idea of ​​the banker's algorithm

Core idea: Before the process runs, declare the maximum demand for various resources. When the process continues to apply for resources during execution, first test whether the sum of the number of resources occupied by the process and the number of resources requested this time exceeds the maximum demand declared by the process. If it exceeds, refuse to allocate resources; if it does not exceed, then test whether the existing resources of the system can meet the maximum amount of resources that the process still needs; if it can meet, allocate resources according to the current application amount; otherwise, the allocation will also be postponed.

10. Resource allocation graph and its simplification

In the resource allocation graph, find a process that is neither blocked nor isolated (that is, find a directed edge connected to it, and the number of applications for resources corresponding to the directed edge is less than or equal to the number of idle resources in the system). If all the edges connected to the process meet the conditions, the process can continue to run until it is completed, and then release all the resources it occupies. Eliminate all its request edges and allocation edges, making it an isolated node. To judge whether a resource has space, apply its resource quantity minus its out-degree in the resource allocation graph. After a series of simplifications according to the above method, if all the edges in the graph can be eliminated, the graph is said to be completely simplified.

Chapter 5 Memory Management

1. Definition of virtual memory

Virtual storage is a storage system that only loads part of a job into memory to run it. Specifically, it refers to a storage system that has the function of request transfer and replacement, and can logically expand the memory capacity.

2. Key technologies for realizing virtual memory

The realization of virtual memory is based on the storage management methods of discrete allocation, such as request paging , request segmentation and request segment page three storage management methods; at the same time, dynamic relocation is required, that is, relocation technology and relocation registers.

3. Switch technology

Swapping technology is to move a part or all of a program and data that is not used temporarily from the memory to the external memory to free up the necessary memory space; or read the specified program or data from the external memory to the corresponding memory, and transfer the control to it

Swap out - move the process in the waiting (blocked) state from memory to external memory to free up memory space

Swapping in—moves a process that is ready to compete for the CPU from external storage to main memory

4. Definition of logical address and physical address

① Logical address: After the source code is compiled, the address used in the target program is the logical address. Each target module starts addressing from unit 0, and its corresponding address range is the logical address space; different processes can have the same logical address and can be mapped to different locations of the main memory

②Physical address: the collection of physical units in the memory, the final address of address translation, the process execution instructions and access data must be accessed from the main memory through the physical address

5. Definition of relocation

Address translation that converts the logical address used in the address space to the physical address in the memory space, also called address mapping

According to the time and means of address translation, relocation is divided into static relocation and dynamic relocation.

6. Three zoning methods

① Fixed partition method: It divides the user memory into several fixed-size areas, and each area only loads one job

②Dynamic partition method: Dynamic partition allocation does not pre-divide memory. When a process is loaded into memory, partitions are dynamically established according to the size of the process, so that the size of the partition is just right for the needs of the process.

③ Relocatable partition method:

7. What is Patchwork

In order to make reasonable use of scattered and smaller free areas, merge all the fragments into a continuous area, that is, move the contents of some allocated areas, so that all job partitions are connected together, and leave the free area at the other end

8. Recovery and allocation of storage space in the first-fit algorithm, best-fit algorithm, and worst-fit algorithm

① Adaptation for the first time: free partitions are linked in the order of increasing address. When a job arrives, it is searched sequentially from this table to find the first free partition of the required size. The remaining empty partitions remain. If there is no eligible partition from the beginning to the end, the allocation will fail.

②Best Adaptation: Free partitions form a partition chain in the form of increasing capacity. When a job arrives, the first free partition that meets the requirements is retrieved from the table and assigned to it. This method has the smallest fragmentation, and if the remaining free partition is too small, the entire partition will be allocated to it.

③Worst adaptation: free partitions are linked in order of decreasing capacity. When a job arrives, the first free partition that can meet the requirements is retrieved from the table, that is, the largest partition is selected. This method has the largest fragmentation, but the remaining free partitions can be used again.

9. Definition of pages

 Divide the logical address space of a process into equal-sized parts, each called a page

10. How to divide the page size?

The size of the page should also be moderate, generally an integer power of 2 (518B~8KB). If the page is too small, the process will have too many pages, causing the page table to be too long to occupy a large amount of memory and increase the overhead of hardware address translation; if the page is too large, it will increase the fragmentation in the page and reduce the utilization of memory.

11. Definition of physical block

Divide the memory space into several storage blocks of the same size as the page, which are physical blocks or page frames

12. What is a page table? What is the function of page table? page table structure?

  In order to know where the pages of each process are stored in memory, the operating system creates a page table for each process, one process corresponds to a table, each page of the process corresponds to a page table entry (page number + block number), and records the correspondence between the process page and the actual stored memory block

13. What is a pure paging system

The pure paging system means that when scheduling a job, all its pages must be loaded into the physical block of the memory at one time. When the physical block is insufficient, the job must wait until there are enough physical blocks, and then the system schedules another job.

14. Logical address structure in paging storage management system

 15.  Address translation process in request paging system

 16.  What is segmented storage management

It divides the address space of the process into several segments according to its own logical relationship. Each segment can define a relatively complete set of logical information. Each segment is addressed from 0 (the segment name can be programmed by the programmer); memory is allocated in units of segments. Each segment occupies a continuous space in the memory, but it can be non-adjacent (discrete allocation)

17. Definition of segment

A segment is a collection of logical information. Each segment has its own name and length addressing starting from 0, and a segment number is often used instead of the segment name

18. How to divide the size of the segment

The size of the segment is determined by the length of the corresponding logical information group, so the length of each segment can be different

19. Segment table structure

Each process has a segment table that maps logical space and memory space. Each segment table entry corresponds to a segment of the process, and records the length of the segment and the starting position of the segment in memory.

20. Logical Address Structure in Segmented Systems

21. The difference between paging and segmented memory management

1) A page is a physical unit of information, and paging is due to the needs of system management rather than user needs, in order to achieve discrete allocation and improve memory utilization; segment is a logical unit of information, and the main purpose of segmentation is to better meet user needs and be visible to users.

2) The size of the page is fixed by the system; while the length of the segment is not fixed, it depends on the program written by the user.

3) The paged job address space is one-dimensional, that is, a single linear address space; while the segmented job address space is two-dimensional, to identify an address, the segment number must be given in addition to the given segment address

4) In a process, there is only one segment table, but there may be multiple page tables.

5) Segmentation is easier to share and protect information than paging.

6) Both single-level page table and segmented access to a logical address require two memory accesses.

23. How to deal with segment interruption

In the request segmentation system, whenever the segment to be accessed by the process has not been transferred into the memory, a segment interrupt mechanism will generate a segment interrupt signal, and then the operating system will transfer the required segment into the memory through the segment interrupt handler. Like the page fault interrupt mechanism, the fault segment interrupt mechanism generates and handles interrupts during the execution of an instruction, and multiple fault segment interrupts may be generated during the execution of an instruction. Unlike a page, a segment has an indefinite length, so the handling of segment-missing interrupts is much more complicated than that of page-missing interrupts.

24. What is segment page storage management

Segment page storage management is a combination of page and segment management methods, segmented by program, and then paged within the segment. That is, the user program is logically divided into several segments, each segment is divided into several pages, and the memory is divided into blocks of corresponding sizes

25. Segment table and page table structure in segment page storage management

Each segment in the process corresponds to a segment table entry, and each segment table entry consists of a segment number, a page table length, and a page table storage block number (page table start address). Each segment table entry is of equal length and the segment number is implied.

Each page corresponds to a page table entry, and each page table entry consists of a page number and a memory block number where the page is stored. Each page table entry is of equal length, and the page number is implied.

 26.  Page replacement algorithm (requires mastering the English abbreviation of the algorithm)

① Optimal Replacement OPT: Select pages that will never be used after being eliminated, or pages that will not be accessed for the longest time, so as to ensure the lowest page fault rate. But the operating system cannot predict which page will be accessed next, so in fact OPT cannot be realized

②First-in-first-out FIFO: Eliminate the pages that enter the memory the earliest (or the ones that stay in the memory for the longest time), sort the pages according to the order they are loaded into the memory, and select the head page when replacing

③ LRU that has not been used for the longest time: Each time the page that has not been used for the most recent time is eliminated, the access field in the page table item can be used to record the time that the page has elapsed since the last visit, and the page with the largest value among the existing pages is selected for elimination.

④ Clock replacement CLOCK27. 

 27. What is jitter

For the page that has just been swapped out, it will be swapped into memory immediately, and the page just swapped in will be swapped out of memory immediately. This frequent page swapping behavior is called jitter

The main reason for jitter is that there are too few physical blocks allocated to the process, and the number of pages frequently accessed by the process is higher than the number of available physical blocks, which causes the process to spend more time on swapping than the execution time, and the process is in a state of jitter

28. Definition of page fault rate

Number of page faults/number of process accesses

29. Address translation process in segmented memory system

Get the segment number and offset according to the logical address, compare the segment number S with the segment table length M, if S>=M is ​​out of bounds, otherwise continue;

Query the segment table, the address of the segment table entry corresponding to S = the start address of the segment table F + the segment number S * the length of the segment table M, so as to take out the segment length C, if C <= offset W, then the boundary is interrupted, otherwise continue;

Get the physical address E=b+W, access the memory;

Chapter 6 Processor Scheduling

1. Tasks for advanced scheduling, intermediate scheduling, and low-level scheduling 

 2.  What are the factors that cause process scheduling?

(1) The executing process terminates normally or abnormally.

(2) The executing process is blocked for some reason.

(3) In systems that introduce time slices, time slices run out.

(4) In the preemptive scheduling method, the priority of a process in the ready queue becomes higher than that of the currently executing process, or a process with higher priority enters the ready queue.

3. All process scheduling algorithms of P159

(1) First come, first served FCFS: Each time the process that first enters the queue is selected from the ready queue, the processor is assigned to it, and it is put into operation, and the processor is not released until it is completed or blocked for some reason.

FCFS is an inalienable algorithm with a simple algorithm but low efficiency; it is beneficial to long jobs, but unfavorable to short jobs (compared to SPF and high response ratio). If a long job arrives at the system first, many short jobs behind will wait for a long time, so it cannot be used as the main scheduling strategy for time-sharing systems and real-time systems; it is good for CPU-busy jobs, but not for I/O-busy jobs.

(2) Short jobs first SJF: Select one or several processes with the shortest estimated running time from the ready queue, assign processors to them, and execute them immediately, and release the processors until they are completed or blocked by an event.

① The algorithm is unfavorable to long jobs, and the turnaround time of long jobs in the SJF scheduling algorithm will increase. If a long job enters the backup queue of the system, since the scheduler always prioritizes scheduling short jobs, the long job will not be scheduled for a long time, and "starvation" may occur.

② The urgency of the job is not considered, so there is no guarantee that the urgent job will be processed in time.

③ The length of the job is only determined according to the estimated execution time provided by the user, and the user may shorten the estimated running time of his job intentionally or unintentionally, and the algorithm may not be able to truly achieve short job priority scheduling.

④ The average waiting time and average turnaround time of the SJF scheduling algorithm are the least.

(3) High response ratio priority HRRN: first calculate the response ratio of each job in the backup job queue, and select the job with the highest response ratio and put it into operation.

Response ratio = (waiting time + requested service time) / requested service time

① When the waiting time of the job is the same, the shorter the service time is, the higher the response ratio is, which is beneficial to the short job.

②When the service time is required to be the same, the response ratio of the job is determined by its waiting time. The longer the waiting time, the higher the response ratio. Therefore, the algorithm realizes first-come-first-served.

③ For long jobs, the response ratio of the job can increase with the increase of the waiting time. When the waiting time is long enough, the response ratio can be raised to a high level, and a processor can also be obtained. Therefore, the starvation state is overcome and long-term jobs are taken into account.

(4) Priority scheduling: Select the process with the highest priority from the ready queue. According to whether the new higher priority process can preempt the executing process, it can be divided into non-preemptive priority scheduling algorithm and preemptive priority scheduling algorithm.

(5) Time slice rotation: The process scheduler always selects the first process in the ready queue to execute according to the order of arrival time, that is, the principle of first come, first served, but only runs one time slice. After using a time slice, even if the process has not completed its execution, it must release (deprived) the processor to the next ready process, and the deprived process returns to the end of the ready queue and requeues, waiting to run again.

① If the time slice is large enough so that all processes can be executed in one time slice, then degenerate into the FCFS algorithm.

②If the time slice is small, the processor switches frequently, the overhead increases, and the process usage time decreases.

(6) Multi-level feedback queue FB: The multi-level feedback queue scheduling algorithm is the synthesis and development of the time slice round-robin scheduling algorithm and the priority scheduling algorithm. By dynamically adjusting the process priority and time slice size, the multi-level feedback queue scheduling algorithm can take into account various system goals.

4. What are the preemptive scheduling algorithms? What are non-preemptive scheduling?

①Preemption: time slice rotation; multi-level feedback queue; short job priority; priority scheduling

②Non-preemptive: short job priority; high response ratio priority; priority scheduling

5. Advantages of high response ratio priority scheduling algorithm

① When the waiting time of the job is the same, the shorter the service time is, the higher the response ratio is, which is beneficial to the short job.

③ For long jobs, the response ratio of the job can increase with the increase of the waiting time. When the waiting time is long enough, the response ratio can be raised to a high level, and a processor can also be obtained. Therefore, the starvation state is overcome and long-term jobs are taken into account.

6. Turnaround time, weighted turnaround time

①Turnaround time: the time consumed from job submission to job completion. Including the sum of the time spent waiting for jobs, queuing in the ready queue to run on the processor, and performing input/output operations.

Turnaround time T = job completion time - job submission time

③ Weighted turnaround time: The weighted turnaround time refers to the ratio of the job turnaround time to the actual running time of the job.

Job's weighted turnaround time w=job's turnaround time T/actual running time Ts

Chapter 7 I/O Device Management

1. Device independence

The equipment used in user programming has nothing to do with the actual equipment used. When the user program performs input/output, it does not need to consider specific input/output devices, but can use a general method to perform input/output.

2. Device logical name, device physical name

3. The functions that the message buffer queue communication mechanism should have

(1) Form a message. The sending process sets the sending area a in its own work area and fills in the message body and related control information.

(2) Send a message. Copy the message from send area a to the message buffer and insert it into the message queue of the target process.

(3) Receive messages. The target process finds the first message buffer from its own message queue and copies the message content therein to the receiving area b of the process.

(4) Mutual exclusion and synchronization. Mutual exclusion means to ensure that only one process operates on the message queue within a period of time; synchronization means to coordinate between the receiving process and the sending process. For this purpose, a semaphore for mutual exclusion and synchronization should be set in the PCB of the receiving process.

4. Definition and classification of I/O channels

(1) The I/O channel is a processor specially responsible for input and output. It can recognize and execute a series of channel instructions. On the basis of the DMA method, further reduce CPU intervention, that is, reduce the intervention of reading and writing of a data block to the reading and writing of a group of data blocks and related control management, and further improve the utilization rate of the CPU.

(2) ①Byte multi-channel: It is suitable for connecting low-speed or medium-speed I/O devices such as printers and terminals. This channel works interleaved in units of bytes: when a byte is transmitted for one device, it is immediately transferred to transmit a byte for another device.

②Array selection channel: It is suitable for connecting high-speed devices such as disks and tapes. This kind of channel works in "group mode" and transmits a batch of data at a time with a high transmission rate, but it can only serve one device at a time. Whenever an I/O request is processed, another device is selected and served for it. It can be seen that the channel utilization is very low

③Array multi-channel: This channel combines the characteristics of byte multi-channel time-sharing work and high transmission rate of selected channels. Its essence is: use multi-channel programming technology for channel programs, so that devices connected to channels can work in parallel.

5. Reasons for introducing buffer technology in equipment management

① Alleviate the contradiction between the speed mismatch between CPU and I/O device

②Reduce the interrupt frequency of the CPU and relax the restrictions on interrupt response

③ Improve parallelism between CPU and I/O devices

6. Classification of buffer technology

①Single buffering: Therefore, the single buffering strategy is adopted, and the average time spent on processing a piece of data is Max(C, T)+M

②Double buffering: using double buffering strategy, the average time-consuming Max(M+C, T) to process a piece of data

③Circular buffer

④ buffer pool

7. Disk scheduling algorithm

Assume a sequence of disk accesses: 98, 183, 37, 122, 14, 124, 65, 67. Read-write head starting position: 53

①First-in-first-out FCFS: The process is very simple to handle, but the average seek length will be very long, which is suitable for situations where there are not many access requests

②Shortest time priority: If the initial position of the magnetic head is known, the process closest to the position of the magnetic head will be processed first, and then the process closest to the current track will be processed after the processing is completed, until all the processes are processed. The advantage of this algorithm is that the average seek length will be greatly reduced, and the disadvantage is that the services that are far away from the initial head cannot be processed for a long time, resulting in a "starvation" phenomenon.

③Scanning strategy: The head only scans in one direction, and completes all unfinished requests during the scan until the head reaches the last track of the disk in this direction or the track where the last request in this direction is located.

④Circular scanning strategy: Change the scanning path of the magnetic head on the basis of the disk scanning algorithm: after scanning to the innermost layer, continue scanning from the outermost layer inward, that is, the scanning direction is the same.

Operating system end-of-term review application questions_SUNLYUER's Blog-CSDN Blog

Guess you like

Origin blog.csdn.net/weixin_46516647/article/details/125321624