Multi-tasking synchronization and mutual exclusion

Source: Internet
Author: User

Modern operating systems are mostly multitasking operating systems, with a large number of scheduled entities running at the same time. In a multitasking operating system, multiple tasks that run concurrently may:

  • All require access/use of the same resource
  • There is a dependency between multiple tasks, and a task's run depends on another task

These two situations are the most basic problems encountered in multi-task programming, and also the core problem in multi-task programming, and synchronization and mutual exclusion are the two problems to solve.


Mutual exclusion : refers to the number of pieces of a walk between different tasks, when a task runs one of the program fragments, other tasks can not run any of their program fragments, only wait until the task runs out of this program fragment to run. The basic scenario is that a common resource can only be used by one process or thread at a time, and multiple processes or threads cannot use common resources at the same time.


synchronization : Refers to a number of pieces of a walk between different tasks, their operation must be in strict accordance with the specified sequence of operations, which depends on the specific task to be completed. The most basic scenario is that two or more two or more processes or threads work together in a predetermined sequence of steps. A task, for example, relies on the data generated by the B task.


Obviously, synchronization is a more complex mutex, and mutual exclusion is a special kind of synchronization . That is, mutual exclusion is that two tasks can not run at the same time, they will repel each other, must wait for one thread to run, another to run, and synchronization can not run concurrently, but he must be in some order to run the corresponding thread (also a mutex)! Therefore, mutexes are unique and exclusive, but mutual exclusion does not limit the order in which tasks are run, that is, tasks are unordered, and there is a sequential relationship between tasks that are synchronized.


Transferred from: http://blog.csdn.net/tennysonsky/article/details/46273709

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Multi-tasking synchronization and mutual exclusion

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.