Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Linux process scheduling opportunity     - Ubuntu batch scp to copy files without password (Linux)

- Python Flask environment to build (Linux)

- Getting Started with Linux: Learn how to upgrade Docker in Ubuntu (Server)

- The top command under Linux (Linux)

- MySQL Tutorial: Some optimized for I / O memory areas (Database)

- grub boot error resolution examples (Linux)

- CentOS7 Kubernetes used on container management (Server)

- Linux Services Comments (Linux)

- Linux System Getting Started Tutorial: How to automatically set the JAVA_HOME environment variable on Linux (Linux)

- Android Studio Personalization (Linux)

- HDFS Distributed File System Resource Manager Developer summary (Server)

- Encounter ORA-00600: internal error code, arguments: [4194] ORA-1552 (Database)

- Install VMware Tools in Debian (Linux)

- Make command tutorial (Linux)

- CentOS 6.3 compile and install LNMP environment (Server)

- Oracle inverted reverse function (Database)

- Detailed PHP code optimization [section] (explain reasons) (Programming)

- Linux virtual machine how to access the Internet in a virtual machine when using NAT mode (Linux)

- Linux System Getting Started Tutorial: How to find the maximum memory your system supports (Linux)

- innodb storage engine backup tool --Xtrabackup (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.
- Java Concurrency -volatile keywords (Programming)
- How to use the Linux terminal Git commands (Linux)
- Oracle11g CRS-0184 Problem Solving (Database)
- Android imitation UC browser scroll up and down functions (Programming)
- Use HttpClient remote interface testing (Programming)
- [Errno 4] IOError: [Errno ftp error] with yum appears as a workaround (Linux)
- Mac OS X 10.9 build Nginx + MySQL + php-fpm environment (Server)
- How to make Linux a non-root user uses less than 1024 ports (Linux)
- MySQL import large amounts of data (Database)
- MySQL related statements (CRUD) (SQLyog software) (Database)
- Install Redis 2.6 5.5 32 position CentOS error resolved (Linux)
- Linux --- process tracking (Linux)
- Java multi-threaded communications pipeline flow (Programming)
- Two strokes to improve development productivity Struts2 (Programming)
- RMAN backup file is much larger than the size of the database Cause Analysis (Database)
- MySQL configuration file my.cnf increase the log file parameter error (Database)
- Solve ORA-01012: not logged on (Database)
- Several Ceph performance optimization of new methods and ideas (2015 SH Ceph Day after flu reference) (Server)
- Ubuntu 12.04 configure NVIDIA CUDA 5.5 Record (Linux)
- How to configure HTTP Strict Transport Security (HSTS) (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.