Talk C together (83rd back: C language instance-inter-process communication overview)

Source: Internet
Author: User

Talk C together (83rd back: C language instance-inter-process communication overview)

Hello, everyone. We are talking about the process stop in the first two times. The example here is:Inter-process communication. When you leave the rest of your time, your words will go right. Let's talk C chestnuts together!

Each process has its own resources. If resources need to be shared between different processes, communication between processes is required.IPC indicates inter-process communication). Here is an actual example:

The code for process A is as follows:

int main(){    int a = 3;    printf("%d \n",a);    return 0;}

The code for process B is as follows:

Int main () {int B = 3; printf ("% d \ n", B); printf ("% d \ n", ); // If process B wants to use resource A in process a, it needs to communicate with process A and return 0 ;}

From the code above, you can see that a process has its own resources and can use its own resources at will. However, if you want to use resources in other processes, you need to communicate between processes.

Communication between processes, There are three problems to solve:

1. How to communicate between processes; 2. How to Use critical resources between processes; 3. How to execute a task in an orderly manner between processes;

For question 1, we will explain it in the following chapter. We will not detail it here.

Regarding question 2 and question 3, we introduced a simple method of mutual exclusion when processes are mutually exclusive in the previous chapter. We will introduce other methods in the subsequent chapter. These two problems are actually the same as the process synchronization and mutex, which can solve the problem of Process Synchronization and mutex.

The Process Communication Between processes is a very important part of the process knowledge system. Today we are just an overview to give you a holistic grasp of these contents, in order to lay a good foundation for further learning. In the subsequent chapter, we will detail the content of inter-process communication. Let's look forward to it together, haha.

Let's talk about the example of inter-process communication. 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.