Linux Kernel Scheduling

Source: Internet
Author: User

One system calls do_fork ()
1. The current process calls fork () to create a sub-process and enters the kernel
2. The current process is divided into more than half of the time slices to the sub-process,
3 if the remaining time slice of the current process is 0, set need_sched = 1,
4. Exit from the system call
5 to ret_from_sys_call
6 To ret_with_reschedule
7. The current process requires scheduling and jumps to reschedule.
8 call schedule ()
9 schedule () processes the scheduling requirements of the current process,
10 if other processes can run, the switch will take place within schedule.

Binary clock disconnection do_timer ()
11 when the clock is disconnected, 8235-> irq0-> do_timer_interrupt ()-> do_timer ()
12-> update_process_times (): decrease the time slice of the current process,
13 if the current process time slice is 0, set the current process need_sched = 1,
14. Exit from the interrupted call,
15 to ret_from_intr
16 to ret_with_reschedule,
17. The current process requires scheduling and jumps to reschedule.
18 call schedule ()
19 schedule () processes the scheduling requirements of the current process,
20 if other processes can run, the switch will take place within schedule.

3. Wake-up process wake_up_process ()
21 The current process calls fork () to create a sub-process and enters the kernel
22 The current process calls wake_up_process to wake up process x
23. Set process X to running and add it to the runqueue queue,
24 call reschedule_idle ()
25 it is found that process X is more qualified to run than the current process. Set the current process need_sched = 1,
26. Exit from system call
27 to ret_from_sys_call
28 to ret_with_reschedule
29 found that the current process requires scheduling, jump to reschedule
30 call schedule ()
31 schedule () processes the scheduling requirements of the current process,
32 if other processes can run, the switch will take place within schedule. This time, most of them may switch to process x

4. setscheduler ()
33 enter the system call setscheduler ()
34. Change the scheduling policy of process x
35 advance process X's position in the runqueue queue
36 set the current process need_sched = 1,
37 exit from system call
38 to ret_from_sys_call
39 to ret_with_reschedule
40. The current process requires scheduling and jumps to reschedule.
41 call schedule ()
42 schedule () processes the scheduling requirements of the current process,
43 if other processes can run, the switch will take place within schedule.

5. Call sys_sched_yield ()
44 access sys_sched_yield ()
45. If there are other processes that offer courtesy,
46 set the current process need_sched = 1,
47 exit from system call
48 to ret_from_sys_call
49 to ret_with_reschedule
50 found that the current process requires scheduling, jump to reschedule
51 call schedule ()
52 schedule () processes the scheduling requirements of the current process,
53 if other processes can run, the switch will take place within schedule.

Need_sched indicates that the CPU needs to be scheduled before the system space is returned to the user space.

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.