[Linux Programming Interface] IPC(行程間通訊)的各種機制

MuLong PuYang
3 min readDec 15, 2018

我記得以前在做有關分散式運算的系統程式的時候,有時候就會看到IPC出問題,當時有去查過IPC就是interprocess communication,中文就是行程間通訊。現在回想起來當時確實是對分散式系統不夠了解其中心哲學(迷之音: 難道現在就有嗎?),無法理解所謂的分散式系統,是很多很多的行程共同構建的,所以自然而然的,出現IPC問題,也就是行程間的通訊問題也是很自然的事。

以下是The Linux Programming Interface關於行程間通訊的各種機制,我想這很值得一看

signals, which are used to indicate that an event has occurred;

訊號: 用來指出事件的發生

pipes (familiar to shell users as the | operator) and FIFOs, which can be used to transfer data between processes;

管線(對於shell的使用者來說,更熟悉的是 | 的操作符)以及FIFO: 在行程間傳遞資料

sockets, which can be used to transfer data from one process to another, either on the same host computer or on different hosts connected by a network;

socket: 可以從一個process傳遞資料到另一個process,不管是在相同主機上或者由網路所相連的不同主機上

file locking, which allows a process to lock regions of a file in order to prevent other processes from reading or updating the file contents;

檔案上鎖: 為了防止其他行程讀取或者是更新檔案內容,允取一個process來鎖定住檔案的部分內容

message queues, which are used to exchange messages (packets of data) between processes;

訊息佇列: 在行程間交換訊息(資料封包)

semaphores, which are used to synchronize the actions of processes;

號誌: 用來同步各行程的動作

shared memory, which allows two or more processes to share a piece of memory. When one process changes the contents of the shared memory, all of the other processes can immediately see the changes

共享記憶體: 允許兩個或多個行程共享記憶體區塊。當一個行程改變了共享記憶體裡面的內容,其他全部的行程可以立即的看到改變

--

--