Analysis of process scheduling for Linux,windows and Unix __linux

Source: Internet
Author: User

v/:* {behavior:url (#default #vml);} o/:* {behavior:url (#default #vml);} w/:* {Behavior:url (#default #vml);. Shape { Behavior:url (#default #vml); Normal 0 7.8 lb 0 2 false false en-US zh-cn x-none/* Style definitions/table. msonormaltable {mso-style-name: plain form; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; Mso-style-parent: ""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; Mso-pagination:widow-orphan; font-size:10.0pt; Font-family: "Times New Roman", "Serif";}

absrtact : This paper takes Linux, Unix, Windows operating system as an example to analyze its process scheduling strategy in order to have a deeper understanding of process scheduling process.

Keywords : process scheduling priority time slice rotary real-time process time-sharing technology

Introduction : In the batch processing system or time-sharing system, the number of user processes is generally more than the number of processors, which will cause them to compete with each other processor. In addition, the system process also requires the use of a processor. This requires the process scheduler to dynamically assign the processor to a process in the ready queue to perform a certain strategy.

the specific features of process scheduling can be summed up in the following points:

as the preparation of process scheduling, the Process Management module must record the performance and status characteristics of each process in the process of the PCB table. Moreover, according to the status characteristics and resource requirements of each process, the process Management module also arranged the PCB table of each process into the corresponding queue and carried out dynamic queue transfer. The process scheduling module is used to master the performance and state characteristics of all the processes in the system, and select a process to occupy the processor from the ready queue at the right time.

the process of selecting a possession processor

The main function of process scheduling is to select the process in a ready state by a certain strategy, so that it gets the processor execution. According to different system design purposes, there are a variety of selection strategies, such as static priority scheduling method with less overhead, suitable for the rotation method (Round Rolin) and multilevel reciprocal feed (Round Robin with MULTIP1E feedback) of time-sharing system. These selection strategies determine the performance of the scheduling algorithm.

to process Context switches

-the context of a process includes the state of the process, the values of variables and data structures, the value of machine registers, and PCB and related programs, data, and so on. Execution of a process is performed in the context of the process. When a process is being executed for some reason to relinquish the processor, the system has to do process context switching so that another process can be executed. When context-switching is performed, first check to see if context switching is allowed (in some cases, context switching is not allowed, such as when the system is executing a primitive that does not allow interrupts). The system then retains enough information about the process being toggled to successfully resume execution of the process when it is later switched back to the process. After the system retains the CPU site, the scheduler selects a new ready-state process and assembles the context of the process so that the CPU's control is in the hands of the selected process.

 

Unix Process Scheduling

A process is an entity that is active in the execution system of a program. In UNIX systems, processes are defined as the execution of images. An image is a computer's execution environment, which includes the values of various registers and memory, the status of open files, and current directories, and so on. Part of the process image: registers, Process Control blocks proc structure and user structure, process data area PPDA (controlled by text structure), data segment and stack segment (including user stack and core stack). For an image of a process, the proc structure, the Process page table, the text structure are resident memory, and the user structure, body segment, data segment is a very resident memory part. They form a whole in the user's virtual space and swap in and out together.

In the UNIX operating system, the program, whether executed at the user level or at the kernel level, appears on the site of a process where all the user programs run in their own process locale. When these user processes request kernel services through system calls, the kernel code that implements the system call continues to execute on the site of the request process, which makes it easy for the kernel to access all state and other address spaces of the process. It also provides a way to record the current state of the kernel execution on behalf of a user program. For example, if you need to suspend the execution of a system call to wait for the I/O operation to complete, the kernel's state of system call processing is guaranteed to exist in the process.

Because all the activities of the system, whether at the user level or at the kernel level, occur on the site of a process, all UNIX cores schedule only the processes that need to be performed. When a traditional time-sharing scheduling strategy is used, processes executed at the user level are not executed in time. You can switch to another process that is executing in the kernel only if the current kernel process is explicitly allowed.

UNIX core idea of process scheduling


Process state transition diagram

process scheduling mechanism asking quantity

In traditional UNIX. Process priority settings are done through nice and set priority, but unfortunately, both speed system calls cannot use the highest priority process immediately because of the cyclic scheduling (time slice scheduling) mechanism. When the process of the smell of the film after use. Let the CPU go regardless of the scrambling level. In addition, because it is a non preemptive kernel, a high-priority process cannot immediately interrupt a currently running process to obtain CPU resources. This requires the process to preempt the CPU immediately, and the real-time application that completes once runs is not enough.

The UNIX system is a multi-user time-sharing system, and its time-sharing is realized by the frequent scheduling of the user process, and the scheduling program of the system is divided into two parts, the processor scheduler (Swtch) and the Process commutation program (SCHED). What I'm dealing with here is the processor scheduler. The processor scheduler is invoked in the following situations: (1) If a process has reached a point that it cannot exceed, then it will call "sleep" and "sleep" calls "Swtch"; (2) a process running in a nuclear mindset that tests the variable "Runrun" before it is transferred to the user state and, if its value is not 0, means that the higher priority process is ready to run. At this point the nuclear mentality process will also invoke "Swtch". The UNIX process scheduling strategy is based on the dynamic priority number, and the setting of the priority number has the following characteristics:

Swtch are called by trap, sleep, expand, exit, stop, and Xalloc. It is a very special process that is divided into three operative paragraphs, involving 3 nuclear mentality processes.

① the first stage belongs to the part of the current process, and if the current process is not process 0, the call to the Savu procedure saves the environment variable of the current process to U. U-rsav. Call the Retu procedure to restore the environment variables of process 0.

② the second stage belongs to process 0, first clearing the Runrun flag, which indicates that a process with a higher priority than the current process is ready to run. Swtch finds the highest priority process through the Do loop (the priority of the process is recalculated). If a ready process is found that satisfies the condition, it is removed from the ready queue and the priority of the process is set to the current priority curpri.

③ the third stage belongs to the selected process. The process has become the current process starting to run, depending on whether the SSWAP flag of the process is set, calling the Aretu process from U. The environment variables (R5 and R6) for the recovery process in U-ssav.

When the

    program discovers that a process takes precedence over the current running process, it sets the flag and checks if the flag is set before the interrupt is dropped into the handler, and if it is set, calls the Swtch () program for scheduling, and Every 1

in the clock interrupt processing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.