210 likes | 529 Views
Interprocess Communication Mechanisms. IPC. Signals Pipes System V IPC. Signals. Signal asynchronous events to one or more processes Oldest IPC method used by UNIX Intel Box 1)SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
E N D
IPC • Signals • Pipes • System V IPC
Signals • Signal asynchronous events to one or more processes • Oldest IPC method used by UNIX • Intel Box • 1)SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL • 5) SIGTRAP 6) SIGIOT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALR 15)SIGTERM 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
Signal • Processes can ignore most of the signals except SIGSTOP, SIGKILL • A process can choose to block, handle or allow kernel to handle it • For example, SIGFPE(floating point exception) : core dump and the exit
Linux Signals • task_struct • Pending signals : signal (32 bits) • A mask of blocked signal : blocked • sigaction array: address of handling routine or a flag to ignore the signal (modified by system calls) • Normal process canonly send signals to processes with the same uid and gid or to the processes in the same process group
Signal Handling • Signals are not presented to the process immediately they are generated., they must wait until the process is running again. • Every time a process exits from a system call its signal and blocked fields are checked and, if there are any unblocked signals, they can now be delivered
Signal Handling • Processes can elect to wait for signals if they wish, they are suspended in state Interruptible until a signal is presented • The Linux signal processing code looks at the sigaction structure for each of the current unblocked signal
Pipe • $ls | pr |lpr • Linux using two file data structure which point at the same temporary VFS inode (points to a physical page within memory) • use standard read/write library function
Named Pipe • FIFO • created by mkfifo command
System V IPC Mechanism • Message queues, semaphores and shared memory • UNIX System V in 1983
Message Queues • Allow one or more processes to write messages, which will be read by one or more reading processes • msgque --> msqid_ds • Linux kernel : wait queue
Semaphores • A semaphore is a location in memory whose value can be tested and set (atomic) by more than one processes • Can be used to implement critical regions • To prevent deadlock : sem_undo data structure
Shared Memory • Allow one or more processes to communicate via memory that appears in all of their virtual address space • shmid_ds data structure