Processes and Threads in Linux

Source: Internet
Author: User

Application: A set of instructions and parameters that can be executed by the operating system, is static, and is stored in disk space;

Process: In the operating system after running the program, the program is running, is an application of the execution process, but also the operating system allocates memory, CPU and other system resources of the basic unit;

Threads: An execution unit of process resources that can be shared in a process;

An application can correspond to multiple processes, and a process can have multiple threads of execution;

System operation process is mainly: the process of creating, terminating the process, has been controlling the communication between the process and synchronization;

Process creation Process:

1. Copy the environment configuration of the parent process;

2. Build the process structure in the kernel;

3. Put the created process structure into the process list;

4. The system allocates resources to this process;

5. Copy the memory mapping information of the parent process;

6. Manage file descriptors and connection points;

7. Notify the parent process;

How the process terminates:

1. Return from the main function;

2. Call exit or _exit function;

3. Call the Abort function;

4. Terminated by signal;

When a process terminates, the system frees resources owned by the process, including memory, kernel structure, and so on.

Inter-process communication methods:

1. Pipeline: The kernel for two processes to establish a communication channel, one end can only write data, an end can read data, complete communication;

2. Shared memory: Multiple processes share a memory and operate the memory to complete the communication;

3. Message Queuing: A linked list in the kernel, the sender process sends the message to the kernel, the kernel puts the message into the list, waits for the receiving process to send a request message, and after receiving the request message, the kernel takes the message off the list and gives it to the receiver to complete the communication, which is completely asynchronous;

4. Semaphore: A shared value, mainly used for inter-process synchronization and protection of shared resources;

Processes and Threads:

A thread is an execution unit of a process that is part of a process;

The process is the basic unit of the operating system allocates resources, the system only allocates CPU resources for the thread, and other system resources can only share the system resources of the process, the thread is the basic unit of execution;

The system through the Process Control table PCB scheduling thread, and through the thread Control table TCB to the thread scheduling;

Processes and Threads in Linux

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.