Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Linux process scheduling opportunity     - SecureCRT 7.0 Log Ubuntu 12.04 server via SSH service under Vmware (Server)

- CentOS install Memcached (Server)

- Linux Getting Started tutorial: build your own Vim (Linux)

- Linux Network Programming --IP packet format Detailed (Programming)

- CentOS7 compile and install Tengine + PHP + MariaDB notes (Server)

- To install Jetty server configuration in detail (Server)

- CentOS 6.2 install git error Perl5 (Linux)

- RedHat6.4 installation tutorial --- Minimal Edition (Linux)

- Oracle can not change the tablespace to backup mode in non-archive mode (Database)

- SUSE Linux install Oracle 10g and problem solving (Linux)

- cursor_sharing induced error ORA-00600 (Database)

- Detailed installation OpenCV2.3.1 under CentOS 6.5 (Linux)

- Hadoop - Task Scheduling System Comparison (Server)

- CentOS 7 Docker build private warehouse registry (Linux)

- Profile Linux users login shell and login to read (Linux)

- How to fix Ubuntu / Mint can not add PPA source of error (Linux)

- Use the Find command to help you find those files that need to be cleaned (Linux)

- Zabbix configuration external network mail alarm (Server)

- Linux, Chrome browser font settings beautification (Linux)

- Math objects easily overlooked but very convenient method --JavaScript (Programming)

 
         
  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:      
 
- Linux install the Java Runtime Environment and the output Hello World under (CentOS) (Linux)
- Java reflection summary (Programming)
- WinSCP to transfer text files will automatically convert the format (Linux)
- How to manage the time and date at systemd Linux systems (Linux)
- PLSQL Developer synchronization table tools (Database)
- In Spring AOP example explanation (Programming)
- Permissions and attributes of files and directories under Linux (Linux)
- Linux foreground to background process switch (Linux)
- Simple to use multi-threaded programming under Linux mutex and condition variable (Programming)
- Supervisor Installation and Configuration (Server)
- Spring + Log4j + ActiveMQ remote logging - Analysis of combat (Server)
- CentOS install SystemTap-2.6 (Linux)
- Java logging performance of those things (Programming)
- Chromium Install Flash Official Guide (Linux)
- JavaScript function part (Programming)
- RHEL5 multipath configuration (Linux)
- CentOS Nginx achieve 3 virtual machine load balancing (Server)
- Linux performance optimization tools perf top (Linux)
- On event processing browser compatibility notes (Programming)
- How UTorrent download the ISO image from the command line (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.