Analysis based on linux process

foreword

  1. This blog is an analysis and understanding of the linux process.
  2. . Accept everyone's suggestions humbly.

content

What is a process?

    All runnable software on a computer, usually including the operating system, is organized into several sequential processes, or processes for short.

create process

     Linux calls fork to create child processes (except process 0 (created by the system), which are created by other processes in the Linux system. The process that creates a new process, that is, the process that calls the fork function is the parent process, and the newly created process as a child process).
pid_t pid; 
pid=fork(); 
if (pid < 0) 
printf("error in fork!"); 
else if (pid == 0) 
printf("i am the child process, my process id is %d\n",getpid()); 
else 
printf("i am the parent process, my process id is %d\n",getpid()); 

The main event causes the creation of the process

  1. system initialization
  2. A running program executes a system call that creates a process
  3. User requests to create a new process
  4. Initialization of a batch job

termination of the process

  1. normal exit call exit
  2. Exit with an error For example, compile and run a file that does not exist
  3. critical error e.g. divide by 0
  4. Killed by another process Call kill

state transition of a process

1. Waiting state: waiting for the completion of an event;

2. Ready state: waiting for the system to allocate a processor for operation;

3. Running state: The possessing processor is running.

process scheduling

  1. Definition: Whether in batch or time-sharing systems, there are generally more user processes than processors, which causes them to compete for processors. In addition, system processes also need to use the processor. This requires the process scheduler to dynamically assign the processor to a process in the ready queue to execute it according to a certain strategy.
  2. A scheduler class framework is implemented in the linux kernel, which defines the functions that the scheduler should implement, and each specific scheduler class must implement these functions. Linux uses four scheduler classes: stop_sched_class, rt_sched_class, fair_sched_class, idle_sched_class. You can refer to this blog https://www.cnblogs.com/ck1020/p/6089970.html
  3. Five service types, please refer to http://www.xitongzhijia.net/xtjc/20171023/109740.html

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325143338&siteId=291194637