My review of the operating system - processor scheduling

  The first two blog are talking about the operating system processes, including process status, PCB, process synchronization, communication, threads, etc. - my review of the operating system - processes (on)  , and  (next process - my OS review ) herein, this began to speak scheduling processor, including the processor scheduling algorithm deadlock. 

First, processor scheduling type

Processor scheduling program according to some algorithm processor assigned to a process, which is called processor scheduling. Overall, divided by level, there are three types:

(1) Job Scheduling (also known as advanced scheduling, long-range scheduling).

  The nature of the job scheduling is based on an algorithm to work on external memory into memory, and whom to create a process, allocated to the processor and executed. There are two concepts:

  1) Job (the Job)

  Overview of the operating system, we find out about the development process of the operating system, the single-batch system and a multi-batch system had a rough understanding of the concept of operations. Job is a broader concept than the program, it may include a plurality of programs and data, further comprising a manual operation, the processor to control the operation of the program in accordance with the job specification. In general, the batch system will have advanced scheduling.

  2) the job step (Job Step)

  The essence of the program is to work step. During the job, each step can be called a job step. Typical operation can be divided into three working steps: compilation of the job step -> Step continuous assembly operation - runs the job step>. Equivalent to the entire execution step in our program code.

 

(2) process scheduling (also known as low-level scheduling, dispatching short).

  The nature of the process of scheduling is based on an algorithm, processors allocated to the process. First, the process of scheduling will save the processor scene. Save the contents of the specified register to the program counter like the PCB. The process is then selected from the ready queue in accordance with an algorithm to process allocated to the processor. Finally, the restoration processor PCB information site designation process in the processor, the processor allocated to the process execution. It should be an additional look at three basic mechanisms and process scheduling in two scheduling methods:

  Three basic mechanism 1) Process Scheduling

  • Requeuer. All ready process in a certain way (such as priority) arranged in a queue to schedule the program finds.
  • Dispatcher. After taken out from the process ready queue, the processor context switch, the processor assigned to the process execution.
  • Context switching mechanism.

  (PS: There is an additional knowledge: every context switch typically takes a few milliseconds to have a simple way to reduce context switching time by a plurality of sets of registers in a set of registers for the system processor state used. a set of processors for use in application state. Thus, when a context switch only needs to change the pointer to the current register.)

  (PSS: system state in the CPU is the CPU executes an operating system, the user mode is executed in CPU normal applications.)

  2) two scheduling process scheduling mode

  • Non-preemptive (Nonpreemptive Mode). It means once the allocation process to a process unless it voluntarily withdraw, it will run forever.
  • Preemptive (Preemptive Mode). It means depending on certain conditions, to suspend the running processes, the processors allocated to another process. Condition variables corresponding to the semaphore mechanism.

 

(3) Intermediate scheduling

  Intermediate essence is to make scheduling process can not be run temporarily suspend, release the memory resources, and moved them to the external memory up to wait. What is external memory? External memory is the hard drive, disk and other storage devices.

 

Second, scheduling algorithm

When it comes to scheduling algorithm, then there are several operating efficiency measurement process need to know about the term, you will need to do when the problem:

  • Service time: The length of time the process requires a total occupancy processor.
  • Time started: point of time the process started.
  • Time to complete: process execution point of time is finished.
  • Turnaround time: Finish time - time of arrival.
  • Weighted turnaround time: Turnaround time / service time.
  • Arrival time: time point process enters the ready queue

(1) a first-come, first-served scheduling algorithm (FCFS).

  As the name suggests. It is first come first into memory or using the processing system. For job scheduling, the backup job queue is selected from one or more of the first to enter the job queue, which is transferred to memory. For the scheduling process is to choose to enter the latest process from the ready queue, whom allocated to the processor.

 

(2) short job (process) scheduling algorithm and (SJ (P) F)

  As the name suggests. It is in the process of selecting a job or when the first estimate service time per job, of course, choose the shortest priority access to the processor.

 

(3) high priority priority scheduling algorithm.

  Such an algorithm to process the addition of a property, that is the priority. The nature of this algorithm is that high-priority priority calls. Priority There are two types, one is static, that is, each process, priority jobs have been identified at the time of its creation, then do not change. Another dynamic that process, priority job can be changed. The most common practice is the process, jobs are waiting, the priority grow at a certain rate over time, so the longer the wait, the greater the likelihood of being called.

 

(4) based on time slice of round-robin scheduling method.

  This is the time-sharing scheduling algorithm used in the system. The principle is all ready queue process according to the principle of first come, first served queued. Every time the CPU allocated to the first team, allowed the implementation of a time slice is finished, the scheduler interrupts the process, and the process moves to ready the end of the queue, and then take a first team process, continue with the next time sheet. What time slice that is a very short range of CPU time, a few milliseconds to a few hundred milliseconds.

 

(5) multi-level feedback queue scheduling algorithm.

  This is a good moment recognized, the most widely used scheduling algorithm. The principle is not difficult. For example, a computer using multi-level feedback queue scheduling algorithm provided five ready queue. The first ready queue with the highest priority, time slice is 2ms. The second priority ready queue a second time slice is 4ms, the rest is the same queue, the priority in descending order, sequentially increasing the time slice. If a process enters the ready queue, first of all put it at the end of the first ready queue, turn it performs on the implementation of 2ms, the end of the time slice, if the process has not finished, put the process into the second-ready end of the queue. Only when the first queue of processes are completed execution time slice, will perform a second queue. So in order to perform, if the process is very long service time, it will be moved to the last one ready queue. In a final ready queue, round-robin scheduling process executes a method according to the time slice. Processor execution process, only when the high priority queue threads are executed, will perform low-priority queue. As shown (do not bother painted himself again, and take over directly from the book):

 

Third, the deadlock

What is a deadlock? That is the process of running multiple processes in deadlock because of one result of competition for resources.

(1), generate the necessary cause of a deadlock:

  1) mutually exclusive conditions. That period of time, a resource can only be occupied by one process. During this time, other processes can only wait.

  2) Request and holding conditions. The process has been maintained for at least one resource, but proposed a new resource request, the resource has already been occupied by other processes, this time requesting process blocked, but for other resources that they have available to keep hold.

      3) is not deprived conditions. Resources process has acquired, before not used, it can not be denied

  4) loop wait condition.

 

  

 Reference: "Computer Operating System (Tang Ziying)"

Reproduced in: https: //www.cnblogs.com/zrtqsk/p/4192091.html

Guess you like

Origin blog.csdn.net/weixin_33802505/article/details/93248559