C + + Learning Note 41: Process scheduling

Source: Internet
Author: User

Process scheduling strategy: FIFO, Time slice rotation, general dispatch, batch scheduling, high priority preemptive

The child process has no fixed order with the parent process, and cannot assume that the child process will be executed after the parent process, or that the child process must be executed before the parent process;

Zombie Process

    • The child process has ended, but the parent process has not been called to wait for the wait () function
    • The child process has been terminated, but has not been properly cleared to become a zombie process

means to clear the child process

    • The parent process calls the wait () function to ensure that the child process is cleared
    • Even if a child process dies before the parent process calls the wait () function, its exit status can be extracted and then cleared
    • Non-purged child processes are automatically adopted by the INIT process
#include <stdlib.h><sys/types.h><unistd.h>int  main () {    pid_t child_pid;     = fork ();     if 0)   // parent process, speed sleep 60 seconds        Sleep ();             Else                 // child process, exiting immediately        Exit (0);     return  0 ;}

C + + Learning Note 41: Process scheduling

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.