Communication between processes in the Linux system environment: traffic signals-general Linux technology-Linux programming and kernel information. For details, see the following.
I. Traffic Signal Overview
The traffic signal is not the same as that of other processes. It mainly provides resource access control for inter-process sharing. It is equivalent to a memory flag. A process can determine whether it can access some shared resources. At the same time, the process can modify the flag. In addition to access control, it can also be used for process synchronization. There are two types of traffic signals:
Binary signal light: the simplest form of signal light. The signal light value can only be 0 or 1, similar to mutex lock.
Note: the binary signal lamp can implement the mutex lock function, but the two have different concerns. The signal lamp emphasizes shared resources. As long as the shared resources are available, other processes can also modify the signal lamp value. The mutex also emphasizes the process. After resources are used by the process, it must be unlocked by the process itself.
Computing traffic signal: the traffic signal value can be any non-negative value (of course, subject to the kernel constraints ).
Ii. Linux traffic signals
Linux supports traffic signals in the same way as message queue. In red had 8.0 release, the traffic signals of System V are supported. Therefore, this article mainly introduces the system V signal lamp and its corresponding APIs. If there is no declaration, the System V signal lights are described below.
Note that the System V signal lamp usually refers to the Count signal lamp set.
3. Signal lights and Kernel
1. The System V traffic signal is continuously maintained with the kernel. This traffic signal set will be deleted only when the kernel restarts or is displayed and deleted. Therefore, the data structure (struct ipc_ids sem_ids) of the recorded signal lights in the system is located in the kernel. All the signal lights in the system can find the access entry in the structure sem_ids.
2. Explain how the kernel is connected with the signal light:
Here, struct ipc_ids sem_ids is the global data structure of the signal lamp recorded in the kernel. It describes a specific signal lamp and its related information.
(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // linux.ccidnet.com/col/attachment/2006/11/902659.gif'); ">
The structure of struct sem is as follows: