Inter-process Communication overview
Interprocess communication has the following objectives:
1, the data transmission, a process needs to send it to another process, the amount of data sent between a byte to a few m;
2, sharing data, multiple processes want to operate shared data, a process of data modification, other processes should immediately see;
3, notification event, a process needs to send a message to another or a group of processes to notify them of something happened;
4, resource sharing, multiple processes share the same resources. In order to do this, the kernel is required to provide locking and synchronization mechanisms;
5. Process control, some processes want to fully control the execution of another process (such as the debug process), at which point the control process wants to be able to intercept all the falls and exceptions of another process and be able to know its state changes in a timely manner.
The communication between Linux processes is developed from the following sections:
Early UNIX interprocess communication: including pipelines, FIFO, signal.
Interprocess communication based on System V: Includes System V Message Queuing, System V Semaphore (Semaphore), System V shared memory.
Based on socket interprocess communication.
POSIX interprocess communication: includes POSIX Message Queuing, POSIX semaphore, POSIX shared memory.
In Linux, IPC-related commands include: IPCS, IPCRM (release IPC),
The IPCS command is a tool for displaying the state of interprocess communication facilities under Linux. We know that when the system is interprocess communication (IPC), the available methods include semaphores, shared memory, message queues, pipelines, signals (signal), sockets, etc. [2]. Use IPCS to view the status of shared memory, semaphores, and message queues.
For example, to perform IPCS on CentOS6.0
The specific usage is summarized as follows:
1, show all the IPC facilities
# ipcs-a
2. Show all message queues
# Ipcs-q
3, display all the signal quantity
# ipcs-s
4, show all the shared memory
# ipcs-m
5, display the IPC facilities details
# IPCS-Q-i ID
ID corresponds to Shmid, Semid, MsgId, etc. -Q The type of facility (queue), view semaphore details use-s to view shared memory use-M.
6. Show the limited size of the IPC facility
# IPCS-M-L
-M corresponds to the facility type, optional parameters include-Q,-M, S.
7. Show the authority relation of IPC facility
# ipcs-c
# IPCS-M-C
# IPCS-Q-C
# Ipcs-s-C
8. Displays the ID of the process that has recently visited the IPC facility.
# ipcs-p
# IPCS-M-P
# IPCS-Q-P
9. Display the last operation time of IPC facility
# ipcs-t
# IPCS-Q-T
# IPCS-M-T
# ipcs-s-T
10, display the current status of the IPC facility
# Ipcs-u
The IPCS command on Linux does not support the-B and-O Directives on Unix, and the-L and-u directives are not supported in Unix, so you need to be aware of this issue when writing Cross-platform scripts.