Processor Scheduling and Deadlock-----Computer Operating System

1. Short answer questions

1. What are the main tasks of high-level scheduling and low-level scheduling? Why introduce intermediate scheduling

The main task of advanced scheduling: It is used to decide which jobs in the backup queue on external memory are transferred into the memory, allocate necessary resources to their creation processes, and then insert the newly created processes into the ready queue for execution.

The main task of low-level scheduling: It is used to decide which process in the ready queue should get the processor, and then the dispatcher performs the specific operation of allocating the processor to the process.

The main purpose of introducing intermediate scheduling is to improve the utilization of system resources and system throughput.

2. What are homework and JCB?

A job is a set of programs, data and job instructions, and is the basic unit of advanced scheduling.
JCB is a job control block, which represents the existence of a job and contains all the information required for management and scheduling.

tips:(对作业的控制是JCB和作业说明书一起的) 
	  
3.在什么情况下需要使用JCB?JCB通常包含了哪些内容?  
(1)作业进入系统。 
(2)包含系统对作业调度,管理的全部信息。

4. How to determine how many jobs and which jobs to accept in job scheduling?

Decide how many jobs to accept based on the system scale, running speed, job size and whether good system performance can be obtained
Decide which jobs to accept based on the scheduling algorithm

  1. Try to explain the main functions of low-level scheduling?

Low-level scheduling, also known as process scheduling, is used to determine which process in the ready queue gets the processor first, and allocates the processor to the selected process, and then puts it into execution.

6. Briefly describe the reasons for process scheduling? [Postgraduate entrance examination questions]

1. The process being executed has been completed or cannot continue to execute due to an event; [Running finished] [Blocked]
2. The process being executed has raised I Execution is suspended due to /O request; [Blocked]
3. Certain primitive operations such as P operations, blocking, and suspend primitives are executed during process communication or synchronization; [Blocked] 】
4. In preemptive scheduling, a process with a higher priority than the current process enters the ready queue; [preempted]
5. In the time slice rotation method, the time slice is finished; [Time slice is finished]

7. What principles should be followed in the preemptive scheduling algorithm?

①Time slice principle. Each process runs according to a time slice assigned by the system. When the time slice is used up or the process is blocked because it is waiting for an event to occur, the system stops the execution of the process and reschedules it. The time slice principle applies to time-sharing systems and most real-time information processing systems.
②Priority principle. Each process is assigned a scheduling priority. When a new urgent process arrives, or a process with a high priority changes from the blocking state to the ready state, if the priority of the process is higher than the priority of the current process , the OS stops the execution of the current process and allocates the processor to the high-priority process to execute it.
③Short process priority principle. When the running time of the process corresponding to the newly arrived job is significantly shorter than that of the process corresponding to the currently executing job, the system deprives the execution of the current process and allocates the processor to the new short process so that it can be executed first.
The preemptive scheduling method is suitable for time-sharing systems and most real-time systems.

8. What rules should be followed when choosing a scheduling algorithm?

Fairness, resource utilization, balance, enforcement

9.What is static priority? What is dynamic priority? What is the basis for prioritization?

(1) The static priority is determined when the process is created, and the dynamic priority changes with time and environmental changes.
(2) User requirements, process requirements for CPU IO and other resources, process type.

10. Try to compare the two scheduling algorithms: FCFS [First Come First Served] and SJF [Short Process First].

First-come, first-served service has a long turnaround time, which is not good for short processes. Interaction cannot be achieved. Emergency jobs cannot be processed but the process does not starve to death.
Prioritizing short processes requires knowing the job running time first, which is detrimental to long processes, does not consider the urgency of the process, and is prone to starvation.

11. In the round-robin scheduling algorithm based on time slices, how should the time slice size be determined?

The size of a time slice is slightly larger than the time required for a typical intersection.

12. Why is the multi-level feedback queue better able to meet the needs of all users?

Multi-level feedback queue algorithm Each queue can be set up with different scheduling algorithms, so that short processes are completed in the first queue, and long queues are also processed, and there will be no problem of not being processed for a long time.

13. Why does a real-time system require a system with strong processing capabilities?

In a real-time system, if there are many tasks to be completed in the same time period, the processor will not have time to process them, and the tasks will not be completed, resulting in catastrophic consequences.

  1. What types of real-time scheduling algorithms can be divided according to scheduling methods?

Preemptive and non-preemptive.

15. What are the commonly used scheduling algorithms in real-time systems? Introduce them individually.

Earliest deadline: The earlier the deadline, the higher the priority. It can be preemptive or non-preemptive.
The lowest slack takes priority: the deadline minus the current time, minus the required time is the slack. The lower the slack, the higher the priority. If the slack is 0, the priority is the highest.

16. Which process scheduling algorithms are used in batch processing systems, time-sharing systems and real-time systems?

Batch processing system: first come first served, short processes first, priority scheduling.

tips: There is no round robin and multi-level feedback queue algorithm.
tips: High response ratio first is a priority scheduling algorithm. Time-sharing system: rotation only. Real-time systems: Round robin and priority scheduling algorithms.

17.What is deadlock? What are the causes and necessary conditions for deadlock? How to prevent deadlock? [Postgraduate entrance examination questions]

(1) Deadlock is when multiple processes hold resources needed by other processes but they are unable to obtain the required resources and are in a stalemate blocking state.
(2) Inalienable, request and hold, mutually exclusive access, loop waiting.
(3) Destroy the four conditions for deadlock.

18. Among the several methods to solve the deadlock problem, which method is easiest to implement? Which method provides the most efficient resource utilization?

Solving deadlocks can be summarized into four methods: preventing deadlocks, avoiding deadlocks, detecting deadlocks and releasing deadlocks.
Among them, preventing deadlock is the easiest to implement.
Avoid deadlocks to maximize resource utilization.

2. Calculation questions

19. [Postgraduate entrance examination questions]

19
Insert image description here

20. [Postgraduate entrance examination questions]

20
20
20

21. [Postgraduate entrance examination questions]

Insert image description here
Insert image description here

22.

Insert image description here
(1) Safe state
(2) Non-safe state
(3) Non-safe state
( 4) Non-safe state

3. Comprehensive application questions

23. [Postgraduate entrance examination questions]

Insert image description here
(1) Among the three methods given in the question, detecting deadlock allows more processes to move forward without waiting and has the greatest concurrency, because this method allows processes to apply for and allocate resources to the maximum extent, Until a deadlock occurs, the system resolves the deadlock.
(2) The banker algorithm allows processes to apply for resources freely, but when a process applies for resources, it will check whether the system is in a safe state. If so, it can be allocated immediately; if not, it will be rejected. Its concurrency is secondary to deadlock detection.
(3) The last step is resource pre-allocation, because this method requires the process to apply for all the resources it needs before running. This will cause many processes to be unable to start because they cannot apply for all resources, resulting in partial The resource process will also not release the occupied resources because it has not obtained all the resources, so this method will lead to a waste of resources. Therefore, the above three methods are ordered from large to small in order of concurrency: deadlock detection, banker's algorithm, and resource pre-allocation.

24. [Postgraduate entrance examination questions]

Insert image description here
(1) A deadlock will occur in the system. The reason is as follows: Suppose two accounts A and B have two transfer businesses, namely transfer from A to B and transfer from B to A. The following situation may occur when these two businesses are executed: one business locks account A and fails to lock account B and waits; the other business locks account B and fails to lock account A and is also waiting, which will cause the system to be in Deadlock status.
(2) In order to avoid deadlock, a two-stage locking method can be used, that is, a unique account number is set for each account. Before the business is executed, it must be obtained in order of the account size. For all account locks, after the business is completed, the accounts locked later will be unlocked first in the order of locking.

25. [Postgraduate entrance examination questions]

Insert image description here
<1>These two processes may cause deadlock at different advancement speeds. For example: process P1 first applies for resource R1, and after P1 obtains R1, process P1 applies for R2; after P2 obtains R2, P2 applies for resource R1. At this time, because R1 has been allocated, P2 is blocked. P1 and P2, the two processes formed a deadlock because they could not apply for the required resources. If the running order of the processes is changed, the two processes may not deadlock. Therefore, the reasons for deadlock can be attributed to two points: 1. Competition for resources, 2. Illegal process advancement sequence. Necessary conditions for deadlock: 1. Mutual exclusion conditions; 2. Request and hold conditions; 3. Non-preemption conditions, 4. Loop waiting conditions

<two>A deadlock will occur
Reason: When both p1 and p2 run the first step, they will block each other
Necessary Conditions: Mutual exclusion, request and hold, loop waiting, ineligible.

Guess you like

Origin blog.csdn.net/m0_46222433/article/details/129592108