Talk C Chestnut Bar (103th: C-language example-interprocess communication Parade)

Source: Internet
Author: User
Tags semaphore

Ladies and gentlemen, crossing, the last time we were talking about the use of semaphores for inter-process synchronization and mutual exclusion, the example we're talking about
The child is: inter-process communication big Parade . Gossip Hugh, words return to the positive. Let's talk C chestnuts together!

Crossing, we've introduced a variety of interprocess communication methods in front of Zhanghuizhong, and you may feel a bit cluttered, or have a lot of questions: why are there so many ways to communicate between processes? Which is the best way to communicate so much? In fact, so many inter-process communication methods in addition to historical reasons, but also related to the development of technology. These communication methods can not say which is the best, can only say which is most applicable . The type of communication used depends on our programming environment.

In this chapter, we will conduct a military parade to summarize and compare these methods of communication, through the parade to show their advantages, to avoid their shortcomings. Let everyone have a deeper understanding of them so that they can choose the most appropriate means of communication when writing a program.

Take part in this parade of troops from the Army, sea, land and air, they came from all corners, but to defend and walked together. This time to see the squad has a signal squad, pipeline, nameless pipe squad (relative to the command pipeline FIFO), named pipe Squad, Message Queue teams, shared memory teams, signal volume. The teams are ready to be inspected at all times.

flag Up!
Play It !
The parade officially begins!

Crossing, walking in the parade square is the front of the signal teams. The signal team is the oldest army in our history. The force was created with UNIX systems and made a remarkable contribution to the development of UNIX systems. After the Linux system was created, the force also busty into the Linux field, becoming one of the main ways of communication in the field. Signal teams for our troops timely transmission of various signals, so that we always walk in front of the enemy, effectively suppress the enemy.

The next appearance is the pipeline . Pipeline daytime, day and night fighting, effectively ensure the normal communication between the process. He and the signal side has a complementary role, his production effectively solved the signal side can only send signals can not transmit data shortcomings. He delivers massive amounts of data for interprocess communication, comparable to pipelines in a Linux shell.

As the saying goes: War brother, the father and son soldiers. Now the appearance is like father and son of the nameless pipe . They belong to the large branch of the pipeline, so the front of the pipeline to go through the same line in the clothing. Nameless pipes do good things everywhere, and they do not name them everywhere, because they are all living Lei Feng. The unnamed pipe force is preferred when communicating between parent and child processes.

Along with the loud voice of the army, we sent away the nameless pipe squad, ushered in the name of the pipeline . Named pipe troops are also part of this large branch of piping. They have a rural expansion of the battlefield, from the nameless pipe can only be extended between parent-child interprocess communication to be able to communicate between any processes. Is the most commonly used communication method in the process. Named pipe the birth of troops, such as equipped with high-tech equipment troops, for our army's modernization has made outstanding contributions, called the originator of modern troops.

One two three four! The slogan of the three big pipeline is still around the ear, message Queue teams have appeared in front of us. Message Queue troops are modern units that are tied to pipeline forces. Message Queuing forces are flexible and can be used in a variety of war environments. Where you need to go, is the most fear of the enemy troops. The pipeline force transmits the data stream, the message Queue troop transmits the data block, and can control the message block size and the packing itself. This is the embodiment of its flexibility. If the pipeline troops are sent to life-saving water, then the message queue troops sent to save food. Water is a liquid, similar to a stream of data; grain is a bag of bags, similar to a piece of news. The types of messages that need to be looked at during interprocess communication can be used to select the mode of inter-process communication based on the type of message, thus improving the efficiency of communication. Such as war, different battlefield needs different troops, they are a reason.

The air planes soar and the ground chariots roll. shared Memory The parade was taken by the chariot to receive the inspection. Shared Memory team is the most rapid response troops in our army. They used airplanes and chariots extensively to equip their troops, which greatly increased their combat speed. Stays is their usual style, if one day found God soldiers, which must be shared memory troops. Among the types of interprocess communication we describe, shared memory is the fastest way to communicate, because it communicates in the memory of the process, and it overcomes the drawbacks of one-way communication in the pipeline.

Crossing, the last to appear is the Semaphore Force , he is like the Army's neural network, able to effectively contact and command the various forces to conduct a comprehensive war. Modern warfare is a comprehensive form of war, with a semaphore force, we are in the modern war to grasp the initiative. Interprocess communication involves multiple processes, and using semaphores guarantees that multiple processes can communicate properly. That is, semaphores are often used to solve problems associated with mutual exclusion of process synchronization.

There were bursts of cheers, and the parade was officially over in the cheers of everyone!

Crossing, we're going to talk about the big parade of interprocess communication. I want to know what the following example, and listen to tell.

Talk C Chestnut Bar (103th: C-language example-interprocess communication Parade)

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.