IPC's are the mechanism used to communicate between 2 or more processes.
Before going further lets understand why processes need to communicate.
1) Because large amount of cpu time will be used if everything is controlled by a single process.
2) User need to wait, till one task need to complete.
3) IF the kernel is not preemptive, high priority task will wait till completion of current task.
So we need to communication. There are many links available on net why process need communication.
But what are the different ways to communicate process each other. How to identify process A need to talk to process B. Of course your mind will think we can use PID to communicate. Right and wrong.
Some questions about communication.
1) what does it mean process to communicate actually?
2) what happens the process which is waiting for data to arrive to process.
3) Lets not use any communication. We are happy with our own single process to do the task all.
To answer above, processes communicate via some simple mechanism. What they communicate. Ideally sharing the resources nothing but communication. Resources can be anything like file descriptors, data(global, static), signals, list of open files etc. All these will be shared to other processes to make the program efficient, smart and fast.
To share these we need to take care about synchronization. A big problem for processes to communicate.
Lets take standard scenario of client/server applications. These are 2 processes, client created by client.c and server created by server.c.
The use of these 2 programs is to write the data on the standard output. Server program will create a nasty funny string "Why it is working" and write on a buffer..Consider buffer is now standard ipc mechanism. Now client will come up and read the contents of buffer and prints on the screen. The data is then removed from buffer. Thats all. End of story.
Some simple problems
1) What happens if buffer is not free/not available.
2) What happens if client reads data from buffer
3) what happens if buffer is full.
4) what happens when client is reading, but server is writing.
5) etc..
So buffer and points 2 and 3 are important. point is just about the different mechanism for communication and rest are for synchronization.
It is boring, we are not yet started ipc's. :-(
1) pipes
2) message queues
3) shared memory
4) sockets
5) signals
Above are used for IPC. Why there are so many. Again it depends on the way to communicate like
1) Within proceses like program called fork/vfork
2) Whether process is interested to only read or write
3) whether to communicate 2 systems over a network.
4) etc
The best, easy and fastest IPC is shared memory. Because processes are directly accessed memory very faster without copying into user space.
Before going further lets understand why processes need to communicate.
1) Because large amount of cpu time will be used if everything is controlled by a single process.
2) User need to wait, till one task need to complete.
3) IF the kernel is not preemptive, high priority task will wait till completion of current task.
So we need to communication. There are many links available on net why process need communication.
But what are the different ways to communicate process each other. How to identify process A need to talk to process B. Of course your mind will think we can use PID to communicate. Right and wrong.
Some questions about communication.
1) what does it mean process to communicate actually?
2) what happens the process which is waiting for data to arrive to process.
3) Lets not use any communication. We are happy with our own single process to do the task all.
To answer above, processes communicate via some simple mechanism. What they communicate. Ideally sharing the resources nothing but communication. Resources can be anything like file descriptors, data(global, static), signals, list of open files etc. All these will be shared to other processes to make the program efficient, smart and fast.
To share these we need to take care about synchronization. A big problem for processes to communicate.
Lets take standard scenario of client/server applications. These are 2 processes, client created by client.c and server created by server.c.
The use of these 2 programs is to write the data on the standard output. Server program will create a nasty funny string "Why it is working" and write on a buffer..Consider buffer is now standard ipc mechanism. Now client will come up and read the contents of buffer and prints on the screen. The data is then removed from buffer. Thats all. End of story.
Some simple problems
1) What happens if buffer is not free/not available.
2) What happens if client reads data from buffer
3) what happens if buffer is full.
4) what happens when client is reading, but server is writing.
5) etc..
So buffer and points 2 and 3 are important. point is just about the different mechanism for communication and rest are for synchronization.
It is boring, we are not yet started ipc's. :-(
1) pipes
2) message queues
3) shared memory
4) sockets
5) signals
Above are used for IPC. Why there are so many. Again it depends on the way to communicate like
1) Within proceses like program called fork/vfork
2) Whether process is interested to only read or write
3) whether to communicate 2 systems over a network.
4) etc
The best, easy and fastest IPC is shared memory. Because processes are directly accessed memory very faster without copying into user space.
No comments:
Post a Comment