Relationship of processes and threads

Source: Internet
Author: User
  1. The CPU of the computer is the core, it handles all the computational tasks, the equivalent of a factory
  2. Suppose a factory is allowed to operate only one workshop, that is, a single CPU can only run one process, when other processes are in a non-operational state, the workshop is equivalent to the process
  3. But in a workshop, there can be a lot of workers, many workers work together to run things inside the workshop, this is the multi-line Cheng process running tasks, a process can have multiple threads
  4. Workshop Some rooms can allow multiple workers to enter, that is, the memory of the process can be shared, each thread can use the shared memory
  5. Some rooms accommodate more people, while toilets allow only one person to go in, that is, when sharing memory, only one thread is allowed to operate, other threads wait (blocking)
  6. Prevent others from entering the test with a lock, which is a mutex (Mutual exclusion, abbreviated mutex), preventing multiple threads from reading a memory address at the same time
  7. But there are also rooms that allow more than one person, that is, some memory areas can only be used for a fixed number of threads, put a few keys in the doorway, enter a person to take a key, this is called the semaphore (Semaphore)

The operating system is designed so that it boils down to three points:

(1) Multi-process mode, allowing multiple tasks to run simultaneously;

(2) in multi-threaded form, allowing individual tasks to be divided into different parts of the operation;

(3) Provide a coordination mechanism to prevent conflicts between processes and threads, and to allow the sharing of resources between processes and threads on the other.

Relationship of processes and threads

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.