UNIX IPC
Submitted by tuanpham on Sun, 08/02/2009 - 10:16
| IPC Mechanism | Message Size | Speed | Who Can Use? | Details |
| unnamed pipe | Very large (as long as reading is also going on so pipe does not get full) |
moderate no disk access |
Processes must be related. |
cat myFile | sort OR int pfds[2]; |
| named pipe | Very large |
slow disk access |
Any 2 processes on the same machine can communicate through a named pipe. |
mkfifo myPipe OR mkfifo() |
| signals | small |
moderate Signals are not presented to the process immediately they are generated, they must wait until the process is running again. |
Normal processes can send signals only to processes with the same uid and gid or to processes in the same process group. |
kill kill() |
| file position | small-- just the length of a long (approx. 4 Billion) |
moderate | Processes must be related. | lseek() |
| trace | Used by debuggers. Quite complicated and unsafe for general use. | |||
| files | Very large |
slow disk access |
Any 2 processes on the same machine can communicate through a file. | A very common form of IPC. Concurrency issues - suppose reader outraces the writer and gets EOF. |
| file characteristics | small |
slow disk access |
Any 2 processes on the same machine can communicate through file characteristics. |
stat OR stat() |
| shared memory | Very large | fastest IPC of all | Processes are usually related, but it is possible to dedicate an absolute memory location. | |
|
semaphore a flag used to prevent 2 or more processes from accessing the same resource at the same time. |
small |
moderate for unnamed can be slow or moderate for named (system dependent) |
Processes don't have to be related, must be on the same machine. | |
| message | medium (500 bytes or so) |
moderate | ||
| socket | Very large | moderate | Any 2 processes (don't need to be on the same machine) can communicate through sockets. | socket() bind() listen() accept() write() or read() |
»
- Login to post comments
