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

- CentOS 7 Docker build private warehouse registry (Linux)

- Run two MySQL service on one server (Database)

- Linux --- manual release system cache (Linux)

- Installation Atom text editor on Mint Ubuntu / Linux (Linux)

- DDOS Attacks and Prevention (Linux)

- Linux, MySQL root privilege escalation another method (Linux)

- Linux network cut package is not fully defragment (Linux)

- Standardized UNIX command-line tool (Linux)

- How to install MySQL on Linux Dock (Database)

- Transplant spider to MySQL 5.6 (Database)

- Linux Network Statistics Tools / Command (Linux)

- Linux user login and IP restrictions (Linux)

- HA-Federation-HDFS + Yarn cluster deployment (Server)

- RAID configuration and management under linux (Server)

- Why do you need close contact Rust 1.0 (Programming)

- Ubuntu users to install Xtreme Download Manager (Linux)

- iOS development -Launch Image and Launchscreen (Programming)

- Linux monitoring tools introduced series --smem (Server)

- MariaDB 10.0.X, the dynamic column support JSON format to obtain data (Database)

  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





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.
- Linux System Getting Started Tutorial: Linux file permissions brief description (Linux)
- Oracle Database High-Risk Vulnerability Warning (Database)
- Sleuth Kit: used to analyze a disk image and restore files open source forensics tools (Linux)
- Win7 + Ubuntu Kylin + CentOS 6.5 installed three systems (Linux)
- Database start listening TNS-12537, TNS-12560 error (Database)
- jQuery plugin dynamic label generation (Linux)
- Performance issues under CentOS 6.5 VLAN devices (Linux)
- How to statistical data of various size Redis (Database)
- Jump table (skiplist) of code (Programming)
- Binary search and modification (Programming)
- Use IF NOT EXISTS create a data table (Database)
- Linux file compression and file system packaged with instructions (Linux)
- Linux Network Programming - raw socket instance: MAC Address Scanner (Programming)
- How to upgrade to Ubuntu 14.04 Linux Kernel 4.4.1 LTS (Linux)
- CentOS Linux firewall configuration and Close (Linux)
- Teach you to diagnose problems with strace (Linux)
- How ONLYOFFICE collaborative editing document on Linux (Linux)
- CentOS 6 adds disk quota limit (Linux)
- Unix system security configuration (Linux)
- Graphic Git (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.