Inter-process communication 1. Basic Principles

Source: Internet
Author: User

Under normal circumstances, a program can only access its own data, and does not communicate with other processes. Each process is a separate individual, and tasks can be completed without collaboration between processes. However, as the complexity of the problem needs to be solved increases, it is impossible for a single process to complete all the work. It is necessary that multiple processes work together to solve the problem faster, better, and better, for example, collaboration between people can make more things.

However, in consideration of security, the OS will restrict the process to only access its own data, and cannot extend the "hand" to the internal of other processes. What should I do? How can we solve inter-process communication problems?

If there is a problem, communication is required. If communication is required, a media of communication is required. For fairness and justice, the control of the communication media should not belong to any party of communication. As a result, in computer systems, only the OS itself is responsible for communication media control tasks.

Therefore, the basic principle of inter-process communication is that OS provides a media for communication between processes. Since communication is like communication in human society, communication requires time and money, and in computer systems, there must be a cost for communication. Out of the features of the solution, the OS provides a variety of communication methods, with different communication costs and different use costs and communication efficiency. The pipelines, message queues, and shared memory that we often hear are provided by the OS for interaction between processes.

Since it is communication, it must be an orderly conversation between the two parties. Otherwise it will be a quarrel and no one can hear what the other party says. Just as the judge in the court controls the timing and time for both sides to speak, OS must also provide such control methods to ensure orderly and harmonious communication of processes. The mutex lock, condition variable, record lock, file lock, and traffic signal we often hear are all in this column.

What is the media of communication?

As we mentioned above, pipelines, message queues, and shared memory are all the dialog methods provided by the OS. The words that a process calls must be saved somewhere at least temporarily, then it can be taken away (heard) by other processes ). The media that stores intermediate information is logically divided into three parts: file system, kernel, and memory. In fact, stored in the kernel is also stored in the memory, but this part of memory can only be accessed by the OS itself, normal processes cannot directly read and write.

Related Article

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.