�� ���� (3� ��)
- ��: ��� �� (Message Passing)� ���� �� ���� ��� ��(Mediation)� �� ���� ���(Message) ��� ���� ����� IPC (Inter-Process Communication) ����.
- ��: �� ���(Shared Memory)� �� ��� ���� ��� ��, ��(Queuing)� �����, ���(Synchronization) ��� �� ���� ���� ��� � �� ��� ���� ��� ���� ����.
- ��: System V IPC�
msgsnd()/msgrcv()API� ����, ������(Microkernel) ������ ���� � �� ��� ��� ��� ����, �� ������ RPC (Remote Procedure Call)� ��� �(Message Queue) ����� ��� ��.
. �� � ��� (Context & Necessity)
- ��: ��� ��� �� ����(Sender)� ���� ��� ���� ��� �(System Call)� �� ���� �� ��� ��� �(Message Queue)� ����, �� ����(Receiver)� ���� ��� �� �� ��� ���� ��� �� �� ����.
- ���: �� ���(Shared Memory) ��� ��� ����, �� �� ��(���)� ���� �� ���� ��� ����(Semaphore)� ���(Mutex) �� ��� �� ���(Deadlock)�� �� ��(Race Condition)� ��� �� ����. �� ��� ��� ��� ���� ��� ���� ���� �����, ���� ���� ����� ���� ��� ���� ���� ���. �� ����� ��� �� ���� � ����� ��� API ���� �� ����� ��� ��.
- � ��: �� ���� � ��� �� ������ ��� �� �� �����, ��� ��� ���(��)� �� ��� ���� ��� ��. ���� ��� ���� ���(��� �)� ���� ���� �����, ��� ����� ��� ���.
- �� ��: 1970�� Brinch Hansen� Hoare� ��� ����� ��� ��� ��� �����, AT&T Bell Labs� System V UNIX�� IPC� ���� ������. Carnegie Mellon University� Mach ������� ���� � �� ��� ��� ��� ��� ��� ��� �����, �� �� macOS� iOS� XNU ��� �����.
��� ��� �� �� �� (�� �� ��)
Process A Kernel Space Process B
(Sender) (Receiver)
msgbuf msgsnd Message Queue msgbuf
Type copy(1) M1 M2 Type
Data ... ... Data
Size Size
(FIFO)
msgrcv copy(2)
[�� 1] msgsnd(): A� ��� �� �� ��� � (�� 1�)
[�� 2] msgrcv(): �� ��� � B� ��� �� (�� 1�)
[��] ��� �� ���� �� �� (Lock, Queue, Scheduling)
[����� ��] � ������ ��� ���� ��� ���� �� ��� ��� ����. msgsnd() ��� �� ���� ��� �� ����� ��� �� ���� ���� �� �� ��� ��� �� ��(Copy 1)��. �� ��� ��� �� �� �� �(Lock)� ���� ����, �� ���� ��� �� ������ ���� ��� ��� ����. �� ����� msgrcv()� ���� ��� �� ���� ���� �� ���� ��� �� ��� ��(Copy 2)��. ��� ���� ���� �(Lock)�� ��� ��� ��� ��� ��. ��� �� ��(FIFO)� �� ��� ���� ����.
- � �� �� ��: �� ���� '����'��� ��� ��� '��� ���'���. ���� ��(���)� ��� �� ���(��)� ���� ���� ����, ���� ��� ����� ���� ���� �� �� ��� ����.
. ���� � �� �� (Deep Dive)
System V ��� � API �� ��
| API �� | �� | ���� | ��� | �� �� |
|---|---|---|---|---|
| msgget() | ��� � �� �� �� � ��� �� | key, msgflg | msqid (���) | ��� ��� �� |
| msgsnd() | ���� �� �� | msqid, msgp, msgsz, msgflg | 0 (��) | �� �� |
| msgrcv() | ��� ��� �� | msqid, msgp, msgsz, mtype, msgflg | �� ��� � | �� �� |
| msgctl() | ��� � ��(��, �� ��) | msqid, cmd, buf | 0 (��) | ��� ��/�� |
��� ���(struct msgbuf) ��
��� ���(struct msgbuf)� �� ��
struct msgbuf {
long mtype; // ��� �� (��, ���� ��� �� ��)
char mtext[1]; // ��� �� (�� �� ���)
};
��� � ��
mtype=1 "Hello Process B" msgrcv(type=1)
�� �� ��
mtype=2 "Emergency: Error #404"
mtype=3 "Data: {temp: 35.2}" msgrcv(type=3)
�� �� ��
* ���� mtype� ���� �� ��� ���� ��� ��
* mtype=0 �� �� ��(FIFO) ��� ��
[����� ��] System V ��� �� �� ��� ��� ���� mtype(��� ��) ��� ��� ���. � ��� �� ���� msgrcv() �� � mtype �� ����, ��� ��� ��� ��� ���� ����� �� � ��. �� ��, ��(Emergency) ���� mtype=2� ��� �� ���� mtype=1� ���, �� ����� ����� mtype=2 ���� �� ���� �� ����� ��� � ��. �� ��� FIFO ��� �� ��� ��� ���(Routing)� ���� ��.
��� �� vs �� ��� �� ��
��� �� vs �� ���: ��� �� ���
�� �� ��� �� (Message Passing) �� ��� (Shared Memory)
�� �� (�� �� 2� + �� ��) �� �� (0� ��)
��� �� �� �� ��� �� �� ��
��� �� �� ���� �� �� ��� ���� �� �� ��
�� ��� �� (API ����� ��) �� (��� �� ��)
��� �� ��� (�� �� �� ��) �� (��� ���)
�� �� �� �� (RPC, ���� �� ��) �� (�� �� ��)
���� ��� O X
� �� ��:
- �� ��� + ��� �� ��� ��
- ��� ��� + �� �� �� ��� (+ ���)
- ���� �� �� ��� �� (��� ��)
[����� ��] � ���� IPC ���� �� ��� ������(Trade-off)� �� vs ���� ��� ����. ��� ��� ��� �� ��� ����� ����� ���� �����, ���� ��� �� ��� ����� 2�� ��� �� ����� ����. �� �� ���� � �� ��� ��� �����, ��� ��� ���� ���� ���� ���� �� ���� ��. �� ��� ��� ��(Socket)�� RPC� ����� ���� ���� ���(Network Transparency)� ����, �� ���� ��� �� �� ���� ����� ��� ��� ��.
- � �� �� ��: ����(�� ���)� ���� ���� ��� ����(���)� ��� ��, ��(��� ��)� ���� ��(��)� �� ��� ����, ��� �� ��(����)��� � � ��� ��� ����.
. �� �� � ��� ��
��������� ��� ��
������(Microkernel) ������ ��� ��� ��� IPC ��� ��� ���. ���� ��(Monolithic Kernel)��� ��� �� �� ��(Function Call)� �����, ��������� �� ���, ���� ����, ���� ���� ��� �� ��� �� ����� �����, ��� � ��� ���� � ��� ��� ����.
| ������ | ��� �� �� | �� ��� �� |
|---|---|---|
| Mach (CMU) | �� IPC� ��� ��� �� | Copy-on-Write, Port Right |
| L4 (Jochen Liedtke) | IPC ����� ��� ��� | ���� �� ��, Fast IPC |
| QNX | ��� ��� �� ���� �� ��� �� | Zero-copy ��� �� |
| MINIX 3 | ���� �� ��� �� ��� �� | �� �� �� �� |
- � �� �� ��: ���� ��� '� �� �� �� ��� �� ��'��, ������� '� ��� �� ��� �� �� ��� �� ���(��� ��)� ���� ��'� ����. �� ���� ��� �� ��� �� ��� ���� ���.
. �� �� � ���� ��
�� ����
-
���� -- RabbitMQ/Kafka �� ��� ���: ����� ����� �� ��� �� �� ���� ��� �(RabbitMQ)� ��(Publish)��, �� ��� �� ��� ��� ��(Subscription)� �� ���� ��(Consume)�� ��� �� ����(Event-Driven Architecture). �� � ���(Coupling)� ��� �� ��� ���� ��� ��(Decoupling)�� �� ����.
-
���� -- POSIX ��� �(mq_open)� ��� ���� � �� ��: ��� �� ����� �� ��� �� ����� ����� �� �� ���(
mq_send(priority=10))� �� ��, �� �����mq_receive()� ���� �� �� ��� ����. POSIX ��� �� System V ��� �� �� �� ����� �����select()/poll()� ���� ��� I/O ���(Multiplexing)� ����.
�� �����
- ���: ��� �� �� ��� ��(
msgmax)� �� �� ��� �(msgmnb)� ��� ���� �� ���? ��� ��� ���� ��(IPC_NOWAIT)� ��� �� ������? - �� ���: ��� �� ��(Permission)�
0600� �� ���� ������? ���� ��� �� � �� ��� �� ���(Orphaned Message)� ���� ���� ���� ��� ���?
����
-
��� � �� (Queue Starvation): ����� �� ���� ����� �� ��� �, �� ����� ���� ��� ���� ��� ��(Starvation) ��� ����. �� ���� �� ���(Aging) ���� �� ��� ��� ���� ����� ����� ����� ��.
-
� �� �� ��: VIP(�� ����)� �� �� ���� ���� �� ��(�� ����)� ��� ��� ���� �� ����, �� ��� ��� ���� � ��� ���� ��� ��(���)� �����.
. ���� � ��
��/�� ����
| �� | ��� �� �� | �� ��� �� | ��� ��� �� �� |
|---|---|---|---|
| �� | �� ���(1KB ��)� �� | ��� ��(1MB ��)� �� | �� ��� ���� |
| �� | �� �� �� 2�/��� | �� � �� �� 0� | �� �� �� ��� |
| �� | ���� ��� �� | �� �� �� �� | �� ��� ��� |
| �� | ��� �� �� | �� ��� �� | �� ��� � ��� |
�� ��
- Zero-Copy ��� ��: ����
io_uring� �� ��� ��� I/O ������ ��� �� � ��� ��� �����, ���� ��� ��� �� ��� ���� ��. - eBPF �� �� � ��� ���: eBPF (Extended Berkeley Packet Filter)� ���� �� ���� ���� ����� ���� � ��, ���� ���-�� ��� ��� ��� �� ��� ����� ��� � ��.
�� ��
- IEEE Std 1003.1 (POSIX.1):
mq_open(),mq_send(),mq_receive(),mq_close()��� POSIX ��� � ��. - System V IPC:
msgget(),msgsnd(),msgrcv(),msgctl()��� ��� ��� � API.
��� ��� ��� ��� �� ��(���, �� ��, ��� ��)� �� ���� ��� IPC ����. �� ����� ��� �����, ���� ���, �� ���, �� ��� ��� ���� ���� �� ������ ����� �� ���, ��� � ����� ��� ��� �� �� ������.
- � �� �� ��: ��� �� ��� ���� ���� ���(��� ��) ���� �� �� ��(�� ���)�� � �� � ����, ��� ����� ��� �� �� �� ��(����)��� ��� � �� �� ��� �� ������.
� �� �� � (Knowledge Graph)
| �� �� | �� � ��� �� |
|---|---|
| �� ��� (Shared Memory) | ��� ��� ���� IPC. ��� ���� ���� ���� �� ���� �� �� �� ���� ����. |
| ��� (Pipe) | ��� ��� ��� ��. ��� ��� ����� �� ��� ����� ��� �� ��� ����. |
| ������ (Microkernel) | �� ���� ��� ����� �����, ���� � ��� � ��� �� �� ��� ��� ��� OS �� ��� ����. |
| RPC (Remote Procedure Call) | ��� ��� ���� ���� ���� ���. �� ����� ��� �� �� ���� ��� � �� ��. |
| �� (Socket) | ����� �� ��� ��� �� �����. TCP/UDP ���� �� ��� ��� �� ��� ��� ����. |
� ���� �� 3� �� ��
- � ��� �� ��� ��� �� ��� ���� �(�� ���) ��� � ����, �� ��� ��(��)� ��(���)� ���� ��� �� ��� ���.
- �� A� ��� �� ���(��) ��� �� ���� ���(��� �)� ���� ����, �� B� �� ��� ��� ��� � ���.
- � ��� �� ���� ��� ���� ���� ��� ��, �� ��(����)� �� ����� ��� �� � �� �� ��� ������!