Multi-process programming
Writing in front This article is mainly based on the programming practical experience on UNIX system, as a part of its own programming practices within a period, it can be published. It is an article on UNIX programmers. Little experience is for reference only; if you are not worth it, please advise you.
I. Features of multi-process procedures Because the UNIX system is a module multiple user system, the CPU is assigned to each user by time, and it should be used in essence to be used to use the CPU to all process, each process has its own The operating environment allows "Semi-finished Products" that has been "forgotten" when the CPU is switched, and the process of "semi-finished products" is calculated in DOS. The process of switching is a "DOS Interrupt" processing process, including three levels. : (1) Saving of user data: including the main segment (Text), Data Section (DATA, BSS), Stack, Shared Memory, Save: Save of Register Data: including PC (Program Counter, pointing to the address to be executed), PSW (Processor Status Word, Processor Word), SP (Stack Pointer, Stack Pointer), PCBP (Pointer Of Process Control Block, Process Control Block Pointer ), Fp (Frame Pointer) General register, etc. (3) Save of system hierarchical: including Proc, U, Virtual Storage Space Management Table, Interrupt Processing Stack. To allow it to get the CPU time slice again, since the system has handled all These interrupt processes, what else do we have to worry about? We don't use the multi-process feature provided by the system, let several programs work together, simply and efficiently give it out. In addition, The UNIX system itself is also written in C language. Multi-process programming is the characteristics of UNIX. When we are familiar with multi-process programming, there will be a deeper understanding of the UNIX system mechanism. First, I will introduce multi-process programs. Some of the highlighted features: 1. Parallelization of a complex event is to decompose into a number of simple events, which has formed this concept in the brain of the programmer, first breaking the problem into a small Question, subdivide the small question, and finally make a function on a suitable scale. It is also said in software engineering. If we think about the way, some small problems can not be Interfering, you can Time processing, and in the key point, you need to be unified in one place. This way to run in parallel, at least from the person's time concept. And the calculation of each small problem is more simple. 2 Simple and orderly programs are not asia managed by programmers, and the programmer is designed for each process, and the organically combined with each process is combined, for each process. The design is simple, only carefully cope with the total control section (in fact, it is also very simple), you can complete the construction of the entire program. 3. Mutual discharging this feature is the characteristics of the operating system, each process is independent, no Credit. 4. Serving, for example, in a data phone query system, designs a program to process only a single query, complete a transaction. When the phone query starts, the process is produced to deal with this query; When a phone comes in, the master program produces such a process to deal with it. After each process completes the query task, it disappears. This programming is more simple, as long as you do a query program.
II. Common multi-process programming system call 1.Fork () function: Create a new process. Syntax: #include
Note: This call passes the parameter string to a command interpreter (typically SH) execution, that is, String is interpreted as a command, executed by the SH. If the parameter string is an empty pointer, check whether the command interpreter exists This command can be the same as the command line command, but since the command is placed in the system call, you should pay attention to the processing of special meaning characters when compiling. The command is found to be defined by the PATH environment variable. Command The consequences of the generated generally do not affect the parent process. Return Value: When the parameter is an empty pointer, the return value is not zero when the command interpreter is valid. If the parameter is not a null pointer, the return value is the return status of the command. (With WaitPID ()), the command is invalid or syntax error returns a non-zero value, and the command executed is terminated. Another situation returns -1. Example: char command [81]; int i; for (i = 1; i <8; i ) {sprintf (Command, "PS -T TTY% 02i", I); System (Command);} 3.exec () function: Perform a file syntax: #include
Int Execle (path, arg0, ..., argn, (char *) 0, ENVP) char * path, * arg0, ..., * argn, * envp [];
Int Execve (Path, Argv, Envp) Char * Path, * Argv [], * envp [];
Int Execvp (File, Argv) Char * file, * argv []; Description: This is a system called family, used to transfer a new program into the memory, and overwrite, generate new memory Process image. The new program can be an executable or shell batch command. When the C program is executed, it is called: main (int Argc, char * argv [], char * envp []); argc is the parameter Number, is the array of various parameter string pointer, and ENVP is a pointer array array of new processes. Theargc is at least 1, argv [0] is the program file name, so in the above EXC system call family, Path is the path name of the new process file. File is a new process file name. If File is not a full path name, the system call will automatically find the corresponding executable to the corresponding executable file. If the new process file is not an executable goal Files (such as batch files), execlp () and execvp () will form the file content as a standard input of a command interpreter to form system (). Arg0, ... and other pointers pointing to the end of '/ 0' ending The valid parameters of the new process are set, and the parameter list ends with an empty pointer. In turn, Arg0 must exist and point to the new process file name or path name. Similarly, Argv is a string pointer array, argv [0] points The new process file name or path name is ended with an empty pointer. ENVP is a string pointer array, ending with an empty pointer, which forms a newly-active environment. Opened before calling these system calls to new processes It is also open, unless it has defined a Close-ON-EXEC flag. The open file pointer remains unchanged in the new process, all related file locks are also reserved. Calling process settings and being captured The new process is restored to the default setting, and the other remains unchanged. When the new process starts, press the SUID and GID settings of the file in the file, the UID and GID of the SUID and GID are effective UID and GID. The new process also inherits the following properties:. Additional GID.. Process No... Parent process number.. Process group number Session number. Control terminal. The rest of the ALARM clock signal. The current work directory.. Root directory.. File creation mask.. Resource limit.. User time, system time, child process user time, child process System time.. Record lock.. Process signal mask. Successful return value, because the original process has wonless. Example: Printf ("Now this process will be ps command / n"); Execl ("/ bin / ps", "ps", "- ef", null) ;
4.Popen () function: Initialize the pipeline from / to a process. Syntax: #include
Sys / types.h> #include
/ * The process group number of the child process has been modified to be the same as its process number * / exit (0);} 9.exit () function: Termination process. Syntax: #include
INT SIGHOLD (SIG) INT SIG;
Int Sigrelse (SIG) INT SIG
Int Sigignore (SIG) int Sig;
INT Sigpause (SIG) INT SIG; Description: These system calls provide a simple signal processing for the application to specify the specified signal. Signal () and SIGSET () are used to modify the signal positioning. Parameter SIG Specify the signal (except sigkill and sigstop, this Both signals are processed by the system, the user program cannot be captured. DISP specifies a new signal positioning, that is, a new signal processing function pointer. Can be SIG_IGN, SIG_DFL or signal handle address. If SIGNAL (), DISP is a signal handle address When SIG does not receive this signal for SIGILL, SIGTRAP, or SIGPWR, the system first resets the SIG signal handle as SIG_DFL, then executes the signal handle. If SIGSET (), the DISP is the signal handle address, the signal, the system First, add this signal to the signal mask of the calling process, then execute the signal handle. After the signal handle runs, the system will recover the signal mask of the calling process to receive the preamble. In addition, when using sigset (), The DISP is SIG_HOLD, then the signal will join the signal mask of the calling process and the signal is positioned unchanged. Sighold () adds the signal to the signal mask of the calling process. Sigrelse () Signal from the signal mask of the signal from the calling process Delete. SIGIGNORE () Sets the positioning of the signal to SIG_IGN. Sigpause () Remove the signal from the signal mask of the calling process while hanging the calling process until the signal is received. If the signal SIGCHLD is positioned as SIG_IGN, then call The child process of the process will not turn into a zombie process at the end. The calling process also does not have to wait for the child process to return and do the phase handling. Return Value: Signal () Returns the value of the DISP that is recently called Signal () setting. Otherwise, returns SIG_ERR. Example 1: Set the user's own Signal interrupt processing function, as an example: int flag = 0; void myself () {flag = 1; Printf ("get signal sigint / n"); / * To reset the sigint signal interrupt processing function as this function Then execute step * / void (* a); a = myself; signal (sigint, a); flag = 2;} main () {while (1) {SLEEP (2000); / * Waiting interrupt Signal * / if (Flag == 1) {Printf ("Skip System Call Sleep / N); EXIT (0);} IF (Flag == 2) {Printf ("
Skip System Call Sleep / N "); Printf (" Waiting for Next Signal / N ");}}} 11.kill () Features: Send a signal to one or set of processes. Syntax: #include
/ * To reset the SIGALRM signal interrupt processing function is this function *: step * / void (* a) (); a = myself; Signal (SigaLRM, A); flag = 2;} main () {ALARM (100); / * 100 seconds post timeout interrupt signal * / while (1) {SLEEP (2000); / * Wait for interrupt signal * / if (flag == 1) {Printf ("Skip System Call Sleep / N" ); Exit (0);} if (flag == 2) {Printf ("Skip System Call Sleep / N); Printf (" Waiting for Next Signal / N ");}}} 13.msgsnd () function: Send a message to the specified message queue. Syntax: #include
IPC_nowait is not true, the calling process will hang up until one of the cases occur: * The message is sent out. * Message Queue Sign is deleted by the system. The system call returns -1. * Calling process receives an unnealated ignore The interrupt signal, the calling process continues to be executed or terminated. After the call is successful, the relevant structure of the specified message queue does the following action:. Message number (MSG_QNUM) plus 1. Message Queuing Recently Send Process No. (MSG_LSPID) Change to call The process number. Message queue transmission time (msg_stime) is changed to the current system time. The above information can be seen by command ipcs -a. Return Value: Return 0, otherwise returns -1. 14.msgrcv () function: From message queue Message of the specified type. Syntax: #include
IPC_nowait is not true, the calling process will hang up until one of the cases occur: * The type of message in the queue is valid. * Message Queue flag is deleted by the system. System call returns -1. * Call process Receive To an unloaded interrupt signal, the calling process continues to execute or terminated. After the call is successful, the relevant structure corresponding to the specified message queue does the following action:. Message (MSG_QNUM) minus 1. Message Queue Recent receiving process number ( Msg_lrpid) Change to the process number. Message queue receipt time (MSG_rtime) change to the current system time. The above information can be seen using the command ipcs -a. Return Value: The return value is equal to the number of bytes that receive the actual message body Uncomfortable returns -1. 15.msgctl () function: Message Control Operation Syntax: #include
Description: This system calls return the identifier of the message queue associated with the parameter KEY. If the facts are established, the identifier and data structure related to the message queue will be created:. If the parameter key is equal to IPC_Private.. If the parameter Key Without an existing message queue identifier, the value (MSGFLG & IPC_CREAT) is true. When you create a message queue, the data structure associated with the new message queue identifier will be initialized as follows:. MSG_Perm.cuid and Msg_perm.uid is set to call the effective UID of the process. Msg_perm.cgid and msg_perm.gid are set to the valid GID of the calling process. MSG_Perm.Mode Access bit is set to MSGFLG access ratio.. Msg_lrpid, Msg_stime, msg_rtime is set to 0.. MSG_cTime is set to the current system time. Msg_qbytes is set to the maximum value allowed by the system. Return value: Return a non-0 value, called a message queue identifier; otherwise the return value is -1 Example: This example will include system calls that include all message queues described above: #define rkey 0x9001L / * read message queue's key value * / #define WKey 0x9002L / * write message queue's key value * / #Define msgflg 0666 / * Message queue access * / #define ipc_wait 0 / * Wait in the include * / int RMSQID; / * read message queue identifier * / int WMSQID; / * Write message queue identifier * / struct msgbuf { mtype CHAR MTEXT [200];} BUF; / * If the read message queue already has the identifier, it is created and acquired ((rmsqid = msgget (rkey, msgflg | ipc_creat)) <0) { Printf ("GET Read Message Queue Failed / N); EXIT (1);} / * If there is a write message queue already failed, if there is no existence, create and acquire the identifier * / if ((WMSQID = msgget (WKEY, MSGFLG | IPC_CREAT | IPC_TRUNC)) <0) {PrintF ("Get Write Message Queue Failed / N); EXIT (2);} / * Receive all types of messages * / if (MSGRCV (RMSQID, & Buf, Sizeof Msgbuf) -SizeOf (long), 0L, IPC_Wait> 0) Printf ("get% ld type message from queue:% s / n"
, Buf.mtype, buf.mtext); Else {PrintF ("Get Message Failed / N"); EXIT (3);} buf.mtype = 3L IF (Msgsnd (WMSQID, & Buf, Sizeof (Struct Msgbuf) - Sizeof LONG), IPC_NOWAIT> 0) Printf ("Send Message OK / N"); Else {PrintF ("Send Message Failed / N"); Exit (4);} Msgctl (WMSQID, IPC_rmid, (Struct Msqid *) NULL 17. SHMAT () Function: Connect shared memory operation. Syntax: #include
#include
#define shmkey 74 #define k 1024 int shmid; cleanup () {shmctl (shmid, ipc_rmid, 0); exit (0);} main () {INT * PINT; char * addr1, * addr2; extern char * shmat ); Extern cleanup (); for (i = 0; i <20; i ) signal (i, cleanup); shmid = shmget (shmKey, 128 * k, 0777 | ipc_creat); addr1 = shmat (shmid, 0,0 ); Addr2 = shmat (shmid, 0,0); Printf ("AddR1 0x% x addr2 0x% x / n", addr1, addr2; PINT = (int *) addr1; for (i = 0; i <256 i ) * Pint = i; PINT = (int *) addr1; * Pint = 256; PINT = (int *) addr2; for (i = 0; i <256; i ) printf ("index% d / TValue% D / N ", I, * Pint ; shmdt (addr1); shmdt (addr2); PA Use ();} 21.SemctL () function: Semicalation control operation. Syntax: #include
Note: This system call provides a semaphore control operation, and the operational behavior is defined by the CMD. These commands are operated on the amount specified by SEMID and semnum. Each command requires a corresponding permission level:. GetVal: Returns the value of Semval, requires read rights.. SetVal: Set the value of the semval to arg.val. After successful execution, the semadj's value of all the processes corresponding to all processes are cleared, requiring the renovation. GetPid: Returns read permissions. Getncnt: Returns the value of semncnt, requires read privileges.. Getzcnt: Returns the value of Semzcnt, requires read rights. The following command is on a set of semval in a set of semaples Operation: getall: Returns the value of each SemVal while placing each value into an array pointed to by arg.aray. When this command is successfully executed, the number of semadj's values corresponding to all processes are cleared, requiring Modify the permissions. Set the respective SEMVAL values according to the arguments pointed to by arg.aray. When this command is successfully executed, the semadj's value corresponding to all processes are cleared, and there is a modification permission. The following command is in any situation. It is effective: IPC_STAT: Put the value of each member of the data structure related to the SEMID into the structure points to the arg.buf. Requires read privileges.. IPC_set: Set the following members of the SEMID related data structure, set The data is read from the structure points to the arg.buf: SEM_PERM.UID SEM_PERM.GID SEM_PERM.MODE This command is only It can be operated by a process operation of the appropriate permissions with a valid UID equal to SEM_PERM.CUID or SEM_PERM.UID.. IPC_rmid: Deletes a seminding amount identifier and associated set of seminated signals and data structures specified by SemID. This command is only A process operation that can be appropriately permissions by the effective UID equal to SEM_PERM.CUID or SEM_PERM.UID. Return Value: If the call is successful, return the following value according to CMD: getVal: Semval value. GetPid: sempid value. Getncnt: The value of semncnt: semzcnt: Others: 0. Returns -1. 22.Semget () function: Get a set of semaphors. Syntax: #include
Description: Returns the signal amount identifier associated with the key. If the following fact is established, the amount of SemiD_DS data structure and a set of NSEMS semons associated with the semaphore:. KEY is equal to IPC_Private. .. There is no signal volume related to Key, and the Semflg & IPC_CREAT is true. The SEMID_DS data structure related to the new semaphore is initialized as follows:. In the operational permissions structure, SEM_PERM.CUID and SEM_PERM.UID settings are equal to the invoking process UID.. SEM_PERM.CGID and SEM_PERM.GID settings are equal to the valid GID of the calling process.. Access permission bit SEM_PERM.MODE setting is equal to SEMFLG's access ratio.. SEM_IME setting is equal to 0, SEM_CTIME settings equal to Current system time. Return value: If the call is successful, return a non-0 value, called the signal quantifier; otherwise return -1. 23.Semop () function: Signal operation. Syntax: #include
IPC_nowait) is false, the system call will increase the SemncNT value (plus one) associated with the specified semaphore, and the calling process is not until one of the following conditions is satisfied: (1). Semval value becomes unspeakable than SEM_OP absolute value When this happens, the specified semncNT is reduced, if (SEMFLG & SEM_UNDO) is true, the absolute value of SEM_OP is added to the SemAdj value of the call process specifies the amount of semaphore. (2). Call the process waiting for SEMID Has been deleted. (3). Calling process sways to the signal, at this time, the SEMNCNT value of the specified semaphore is reduced, the process executes the interrupt service program. If SEM_OP is a positive value, the call process has modified permissions, The value of SEM_OP is added to the value of Semval, if the SEM_OP subtracts the semadj value of the calling process to specify the semaphore. If the SEM_OP is 0, the calling process has read rights, one of the following cases will be generated : * If SEMVAL is 0, the system calls return immediately. * If SEMVAL is not equal to 0 and (SEMFLG & IPC_Nowait) is true, the system calls return immediately. * If SEMVAL is not equal to 0 and (SEMFLG & IPC_Nowait), this system call will The SemzcNT value of the specified semaphore is plus one, and the calling process happens until one of the following occurs: (1). Semval value is 0, the SemzcNT value of the specified semaphore is reduced. (2). Call the process waiting for SEMID Has been deleted by the system. (3). Calling process traps to the signal, at this time, specify the amount of semaphore The semncnt value is reduced, the process is called execution interrupt service program. Return Value: Returns 0, otherwise returns -1. Example: This example will include all system calls included in the above semaphore: #include
} Main (argc, argv) int Argc; char * argv []; {INT I, FIRST, SECOND; Short InitArray [2], OutArray [2]; Extern cleanup (); if (argc == 1) {for (ARGC == 1) {for i = 0; I <20; i ) Signal (I, Clearup); SEMID = Semget (SemKey, 2,0777 | IPC_CREAT); IPC_Creat); IPCRAY [0] = IITARRAY [1] = 1; Semctl (SEMID, 2, SETALL, InitArray); SemctL (SemID, 2, Getall, OutArray); Printf ("SEM INIT VALS% D% D / N", OutArray [0], OutArray [1]); Pause (); / * Sleep to be a software Interrupt signal wake-up * /} else if (argv [1] [0] == 'a') {first = 0; second = 1;} else {first = 1; second = 0;} SEMID = Semget (SEMKEY, 2 , 0777); psembuf.se m_op = -1; psembuf.sem_flg = SEM_UNDO; vsembuf.sem_op = 1; vsembuf.sem_flg = SEM_UNDO; for (count = 0 ;; xcount ) {psembuf.sem_num = first; semop (semid, & psembuf, 1); psembuf. SEM_NUM = Second; Semop (SemID, & Psembuf, 1); Printf ("proc% d count% d / n", getpid (), count); vsembuf.sem_num = second; semop (semid, & vsembuf, 1); vsembuf. SEM_NUM = First; Semop (SemID, & Vsembuf, 1);
}} 24.sdener () function: Share data segment Synchronous Access, Plock. Syntax: #nclude
Sys / sd.h> int SDGETV (AddR) Char * Addr; Description: Used to synchronize coordination is using the process of shared data segments. Return to the version number of the shared data segment. When there is a process to do Sdleave () operations When the version number will be modified. Return value: If the call is successful, return to the version number of the shared data segment, otherwise return -1. 29.sdwaitv () function: Synchronize Share Data Access. Syntax: #include
/ * Apply for access to access, activate the process * / sdleave ("" The Data Now IN Area1 IS [% S] / N ", BUF); 31.Getenv () function is activated if the process application access is accessed. : Get the specified environment variable. Syntax: #include
III. Multi-process programming skills 1. Main program structure (1) Event master mode If the application belongs to the transaction mode, the main function is designed to monitor the event. When the event occurs, a new process can be generated. The transaction can allow the child process to exit the system after the transaction is complete. This processing method generally does not need messaging. (2) If the information coordination method is completed by multiple process coordination processing, you can generate these processes, through the message Delivery between processes, enabling each process to coordinate and complete a transaction. This means of processing is generally after generating several processes, calling other program files with EXEC (), making different procedures at the same time The system is running in the system. Then via the IPC mechanism, allow each program to be coordinated. 2. Select the main bifurcation point (1) Event initial generation program structure corresponding to the event master mode. Key point to select events The initial generation point, such as the chain information given by the network program. The master program is recognized as an event after receiving the message, then generate a child process processing: Receive transaction information, transaction processing , Send return transaction information, turn off the link, etc. After the completion, the sub-process exit the system. (2) The main program produces a program structure corresponding to the information coordination mode. The master program is only responsible for generating several child processes, each sub-process calls EXEC () Different execution files into memory operation, the master program can exit the system after generating all child processes, and leave the child process in memory. 3. Process relationship processing (1) Parental process relationship. The concept of the process group handling the process group is like this. When the system starts, the first process is init, the process group number is equal to the process number, and the process group number of all the sub-process it produces is the same, the child process of the child process Also inherited the process group number, so that all sub-processes generated by init belong to the same process group. However, the parent-child process of the same process group may communicate on the signal, if the parent process is prior to the child process Exit the system, then the child process will become an orphan process, which may become a zombie process. Thus, the child process is running in the case of not "willing". To solve this problem, the child process can form a new process. Group, toned SE The TPGRP () is separated from the original process group, producing a new process group, the process group number is the same as its process number. In this way, the parent process will not affect the child process before running. Sub-process signal processing However, doing the above handles can not solve another difficulty, that is, the child process does not find its parent process (the parent process has exited, the child process is changed to 1). Send child process exits the signal Without the parent process, the child is not possible to completely exit running, which may enter a zombie state. So the parent process will return the processing, generated sub-process, in the parent process before generating child processes. After exiting the run, the sub-process returns the processing of its process returns signal will give the default processing by the system. The child process can be properly exited. (2) Brothers process relationship. Exchange process number for information coordination mode, Each brother process needs to know each other to understand the input number in order to make the signal processing mechanism. The relatively reasonable method is that the parent process generates a space for shared memory, and each child process sets its own process number in the shared memory when starting. When a child process sends a signal to another or because other originals need to know another child process number, you can access the required process number in shared memory. 4. Inter-process communication processing ( 1) Shared memory requires locking mechanisms that do not have a lock mechanism when there is a design in the shared, so that multiple processes will have problems when accessing shared memory. Such as:
A process modifies a shared memory unit, and another process may modify the unit immediately when reading the shared memory unit, which will affect the correctness of the program. At the same time, there is also a time-time system for each process. Processing, may cause different correctness. According to the operating system's mode of operation, there is a read lock and write lock to ensure the consistency of the data. So there is no lock mechanism sharing memory, you must use the semaphore To ensure the correct operation of shared memory. (2) Message Queue Requires Key Value Message Queuing Operation After the access to the message queue, you must read the same key value in the message queue through a key value, write a message. Enter the message key. This can distinguish between different transactions through different key values, so that the same message queue can be used simultaneously without conflict. If the reading message queue uses the key value 0, read the first queue in the message queue. Message, regardless of its key value. (3) Signals require signal processing function settings and reset When the user process needs to do handles yourself, you can define the interrupt processing function yourself, and set the interrupt processing function and the Interrupts associated. In this way, the user process then calls the user-defined function after receiving the interrupt, and the user process continues to run from the interruption after the processing is completed (if the user-defined interrupt function does not have a long hop function or exiting operation. Change the system call of the running command address. After the interrupt signal is processed, the interrupt processing function will be restored to the last default processing function instead of maintaining a user-defined function, so in the user-defined interrupt processing function. Refine the interrupt and function's own association. (4) IPC's permissions set in the message queue, shared memory, and semaphore, have user access settings, settings with access to files, such as files, such as (777) RWXRWXRWX) Use the command IPCS to see the message queue generated in the system, shared memory, and semaphore. The meaning is similar to file access. Just execution bits are invalid. In the name of the famous pipe and file, share memory The way the file defines the user's access rights. You can see that they can use the command LS -L to exist and have access to the right limit, and you can see the file type of the famous pipeline is P, file mode sharing memory file type. For s. (5) signal interrupt, the system calls the first-level effective system to consider the interrupt when the design system is called. Problem. When the process runs to a system call, the process enters the interrupt process. After the processing is complete, the process will skip the system call to enter the next program directive. It should be noted that the interrupt occurs in system call Level 1 instead of subroutine or function level. The timeout interrupt is set before a subscriber is called in a subroutine, and the system is interrupted after the subroutine is interrupted. The instruction after the program is interrupted, instead of continuing processing from the latter instruction to call the subroutine directive. (6) Features of various IPC mode. Message queue:
Define and generate a message queue through the message queue. Any process can access the message queue as if there is access to the message. The message queue is listed as a memory block mode. The length of the message element in the message queue can be anywhere in the system parameter limit. Length. The message element is classified by the message type, and its access is accessed by type. You must obtain a message queue identifier before a read and write operation, that is, access to the access relationship. A message in the message queue is After reading, you can delete it from the queue. The message queue has a lock mechanism process, that is, a process is not accessible when the process is access. The system resources and efficiency should be paid to the operation. When the permission is allowed, the message queue information is bidirectional Shared Memory defines and generates shared memory by shared memory. Any process can access shared memory as long as access rights and know Key. Sharing memory data segment. Shared memory can be systematically Any length within the parameter limit. Access to the shared memory is the same as the access method of the group. After obtaining the shared memory identifier, the shared memory is coupled to the process data segment, you can start reading and write, and do it after all operations are completed Shared memory and process data segment is detached to complete all shared memory access processes. The data in the shared memory will not disappear after the data is read. Shared memory has no lock mechanism processing, that is, multiple processes may be accessed at the same time. The same data unit shared memory. The shared memory is used to operate with the signal to have a lock mechanism to ensure that the data is consistent. When permission is allowed, the information transfer of shared memory is two-way.. Sample In generating lock mechanisms, avoiding data inconsistency. No other data information. No parent and child relationship or brother relationship. The signal signal is defined by the system. The transmission of the signal can be permissible. The signal is an event-occurring information flag without other information. The signal does not have a data block. The signal processing can be defined by the user. The signal may be issued by the user process, the operating system (software or hardware reason). Some signals are It is not possible to be shielded. The signal is interrupted is a function of the system call level. The information transfer of the signal is unidirectional. The pipeline is a special device file for the system, which can be a memory method, or a deposit method. Pipeline Transmission is generally unidirectional, that is, one pipelines, if two processes need to do two-way passwords require 2 pipes. There are two ends when the pipe is generated, one end is read, one end is written, two processes should be coordinated, A process read from the read party, another process writes to the write side. The read and write function of the pipeline uses the flow device, namely: