Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Linux process scheduling opportunity     - Linux command ls (Linux)

- Python dictionary applications get built-in method (Programming)

- Installation JDK1.7 under Ubuntu14.04 64-bit (Linux)

- Enterprise Hadoop cluster architecture - DNS installation (Server)

- Install and configure GO 1.2.1 under CentOS 6.5 (Linux)

- Gitblit adopted Ticket collaborative development model (Linux)

- Spacewalk Linux system configuration and installation (Linux)

- shell script: a key to install LAMP, LNMP script (Server)

- Gentoo: startx problem appears Failed to load module (Linux)

- Linux 0.12 kernel and modern kernels difference in memory management (Linux)

- Java data structures - order linear form of table ArrayList (Programming)

- OpenCV 3.0 + Python 2.7 installation and testing under Ubuntu 14.04 (Linux)

- Create the best introductory tutorial REST API (Linux)

- 8 Docker knowledge you may not know (Server)

- After installing Ubuntu 15.04, to do a few things (Linux)

- OpenJDK7 source compiler installation on CentOS 6.5 (Linux)

- CentOS7 installation performance monitoring system (Server)

- Use apt-p2p up a local Debian package cache (Server)

- How to set IonCube Loaders in Ubuntu (Linux)

- Four safety delete files under Linux tools (Linux)

 
         
  Linux process scheduling opportunity
     
  Add Date : 2018-11-21      
         
         
         
  Although the Linux process scheduler is particularly important, but it is merely a space exists in the kernel function of it, is not a mystery. Linux scheduler is called Schedule () function, the high frequency of this function is called by it to decide whether to switch to the process, and if you want to switch, then switch to which process and so on. Let's look at what you want to execute the scheduler, we call this situation a scheduling opportunity.

Linux scheduling opportunity are:

1, the process state transition moment: the process terminates, the process to sleep;

2,current time slice is run out (current-> count = 0) (current-> counter = 0);

3, the device driver

4, the process from interrupts, exceptions and system calls to return to the state when a user;

Timing 1, the process to be called sleep () or exit () functions such as state transition, these functions will take the initiative to call the scheduler process scheduling procedures;

Timing 2, since the process time slice is updated by the timer interrupt, and therefore, the timing of this case and 4 are the same.

Timing 3, when the device driver to perform long and repetitive tasks, direct calls to the scheduler. In each iteration cycle, the driver checks the value of all need_resched, if necessary, call the scheduler schedule () initiative to give up CPU.

Timing 4, as mentioned above, whether it is from the interrupt, exception or system call returns, eventually calling ret_from_sys_call (), this is detected by the flag scheduling function, if necessary, call the call the dispatcher. Why, then, the system call returns from the dispatcher to call it? This of course is from the viewpoint of efficiency. System call returns from kernel mode means that you want to leave and return to the user mode, and converting the state to take some time, therefore, before returning to user mode, the system is all done things in the kernel mode processing.

For the timing of the implementation of direct scheduling procedures, we do not discuss, because later we will describe the work process scheduler. Earlier we discussed the clock interrupt, know the important role of the clock interrupt, http: //Ubuntuone.cn/ Here we take a brief look at each clock interrupt occurs, the core work to be done, the first time to have the most frequent scheduling a general understanding, and then discuss in detail the specific work process scheduler.

Each clock interrupt (timer interrupt) occurs by three functions work together to complete the selection and switching processes, which are: schedule (), do_timer () and ret_form_sys_call (). Let's explain these three functions:

schedule (): process scheduling function, which does the selection process (scheduling);

do_timer (): let's call it a clock function, which is called the clock interrupt service routine, a major component of the clock interrupt service routine, the frequency of the function is called is the clock interrupt frequency that is 100 times per second ( referred to 100 Hz or 100Hz);

ret_from_sys_call (): Returns the system call function. When a system call or interrupt is completed, the function is called for to deal with some finishing touches, such as signal processing, and so on core tasks.

These three functions is how to coordinate the work?

We saw earlier, the clock interrupt is an interrupt service routine, which is a major component of the clock function do_timer (), by the completion of this function to update the system time, the update process time slice, etc., the process of the updated time slice counter as mainly based on the schedule.

Interrupt the clock returns to the calling function ret_from_sys_call (), We have already discussed this function, there is in this function the following lines:

cmpl $ 0, _need_resched

jne reschedule

......

restore_all:

RESTORE_ALL

reschedule:

call SYMBOL_NAME (schedule)

jmp ret_from_sys_call

These lines meaning is clear: detect need_resched flag. If this flag is non-zero, then call the scheduler to reschedule at the schedule () selection process. Scheduler schedule () will select the next process should run in the run queue according to specific criteria. When returning from the scheduler, if found to have scheduling flag is set, then they call the scheduler until dispatch flag is 0, then, when you return from the scheduler selected by the RESTORE_ALL recovery process environment, to return to the selected given process user space, so that get to run.

These are the most frequent clock interrupt scheduling opportunity. The main purpose of this discussion is to give the reader the opportunity to have a general understanding 4.

Finally, note that the system function call returns ret_from_sys_call () system call is from, exception and interrupt function usually returns to call functions, but does not have to call, for those who want to frequently interrupt response and request to be treated as soon as possible signal, http: //www.britepic.org/ to reduce system overhead, does not call ret_from_sys_call after processing () (because obviously, the return from the interrupt handler to user space must be interrupted that process, without having to re-select), and they are made to work as little as possible, because the frequency response is too high.

Linux and other UNIX scheduler scheduler different, especially in the "nice level" priority treatment and priority scheduling (priority high process to run first) is different from Linux using a round-robin scheduling (Round Robing ), but at the same time ensuring high-priority processes run both fast, time and length (both sooner and longer). The standard UNIX scheduler are used in a multi-stage process queue. Most implementations are used in the two priority queues: a standard queue and a real ( "real time") queue. Under normal circumstances, if the real time queue process is not blocked, they must be executed before the standard queue process, and each queue, "nice level" high process to be executed.

Overall, Linux scheduling sequence in the interactive process in terms of performance is very good, of course, this is at the expense of part of the "throughput" for the price.
     
         
         
         
  More:      
 
- SSH without password Definitive Guide (Linux)
- Install Visual Studio Code in Ubuntu (Linux)
- CentOS static IP network configuration (Linux)
- Linux (RHEL6 CENTOS6 OLE6) VNC-SERVER Installation and Configuration (Server)
- MongoDB study notes - polymerization (Database)
- Java Foundation - Variables and data types (Programming)
- JavaScript subarray Deduplication (Programming)
- 10 important Linux ps command combat (Linux)
- linux network security experience (Linux)
- MySQL binary packages install for RedHat Linux Enterprise 6.4 (Database)
- Oracle table space usage monitoring (Database)
- CentOS 6.6 running level (Linux)
- 3 tips Linux command (Linux)
- Debian (Wheezy) were installed wxPython GUI development (Linux)
- Apache2.4.7 make an error [exports.lo] Error 1 Solution (Server)
- Getting Started with Linux: Learn how to upgrade Docker in Ubuntu (Server)
- Postgres-X2 deployment steps (Database)
- Nginx introduced Dynamic Module Architecture (Server)
- Installation and Configuration Tomcat environment CentOS 6.6 (Server)
- C ++ inline functions (Programming)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.