Talk C chestnuts together (103rd back: C language instance-inter-process communication parade)

Source: Internet
Author: User

Talk C chestnuts together (103rd back: C language instance-inter-process communication parade)

Hello, everyone. In the previous session, we talked about the use of semaphores for inter-process synchronization and mutual exclusion. This is an example.
Sub-statement:Inter-process communication parade. When you leave the rest of your time, your words will go right. Let's talk C chestnuts together!

We have introduced a variety of inter-process communication methods in the previous chapter. You may feel a bit messy or have various questions: why are there so many inter-process communication methods? Which of the following communication methods is the best? In fact, in addition to the historical reasons, so many inter-process communication methods are also related to the development of technology. ThisWhich of the following communication methods is best?. The specific communication method depends on our programming environment.

In this chapter, we will summarize and compare these communication modes by military parade, and show their advantages through military parade to avoid their shortcomings. Let everyone have a deeper understanding of them, so as to select the most appropriate communication mode when writing programs.

The teams participating in this parade came from our army, our army, land, and air. They came from all over the world, but they joined in order to safeguard their country. The teams for this reference include the signal team, the pipeline team, and the unnamed pipeline Team (compared with the command pipeline FIFO). Name the pipeline team, the Message Queue team, the shared memory team, and the semaphore team. All teams are ready for review at any time.

Raise the flag!
Play music!
The parade officially started!

What's at the forefront of the parade matrix?Signal team. The signal team is the longest army in our military history. The force emerged with the emergence of Unix systems and made outstanding contributions to the development of Unix systems. After the emergence of Linux systems, the Force was not afraid of danger, and it entered the Linux field, becoming one of the main methods of Process Communication in this field. The signal team sent all kinds of signals to our army in a timely manner, so that we could always stay in front of the enemy and effectively suppress the enemy.

Which of the following statements will be displayed?Pipeline team. The pipeline team fought day and night to effectively ensure normal communication between processes. He and the signal team complement each other, and his generation effectively solves the disadvantages that the signal team can only send signals but cannot transmit data. He delivers massive data for inter-process communication, comparable to the pipelines in Linux shell.

As the saying goes: go to war with siblings and go into battle with fathers and children. It's like a father or child soldier.Untitled pipeline team. They belong to the big branch of the pipeline, so they are similar to those of the pipeline team in clothing. The unknown pipeline troops do well everywhere, and leave no names everywhere, because they are all alive Lei Feng. The unnamed pipeline troops are preferred for inter-Parent and Child processes.

With the sound of a bright military song, we sent away the unnamed pipeline team and ushered inNamed pipeline team. The named pipeline troops are also affiliated with the large branch of the pipeline. They have expanded the battlefield in the suburbs, from an unknown pipeline that can only communicate between parent and child processes to any process. Is the most commonly used communication method in processes. The birth of the named pipeline troops is like the troops equipped with high-tech equipment. They have made outstanding contributions to the modernization of our army and are the originator of the modern army.

July 1234! The voices of the three major MPs queues are still in our ears,MQ teamIt's already in front of us. The message queue force is a modern force parallel to the pipeline force. Message Queue troops are flexible and can be used in various war environments. The enemy is the most feared army. The pipeline forces transmit data streams, while the Message Queue forces transmit data blocks, and can control the size and packaging of the message blocks by themselves. This is the embodiment of its flexibility. If the pipeline forces send life-saving water, the Message Queue forces send life-saving food. Water is a liquid, similar to data streams; grain is a bag, similar to a message. During inter-process communication, you need to check the message type. You can select the inter-process communication mode based on the message type to improve the communication efficiency. For example, different battlefields require different troops.

Air planes soar, and tanks on the ground are rolling.Shared Memory teamReceive review in a chariot. The shared memory team is the most responsive force in our army. They widely use aircraft and tanks to equip troops, greatly improving the combat speed of the troops. It is their consistent style. If the sky falls, it must be shared memory units. Among the communication methods described above, shared memory is the fastest communication mode because it communicates in the process memory, it also overcomes the shortcomings of one-way communication in pipelines.

What is the final appearance of the audience?SemaphoresLike the neural network of the troops, he can effectively contact and direct each army to carry out a comprehensive battle. Modern War is a comprehensive form of war. With the semaphore troops, we have taken the initiative in modern war. Multiple processes are involved in inter-process communication. using semaphores can ensure normal communication between multiple processes. That is to say, semaphores are often used to solve the problem related to process synchronization and mutex.

There were bursts of cheers from the audience, and the parade was officially concluded!

Let's talk about the example of the inter-process communication parade. I want to know what examples will be provided later, and I will try again.

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.