https://www.inflearn.com/course/%EC%9A%B4%EC%98%81%EC%B2%B4%EC%A0%9C-%EA%B3%B5%EB%A3%A1%EC%B1%85-%EC%A0%84%EA%B3%B5%EA%B0%95%EC%9D%98/dashboard
위 자료를 참고했다.
3.4 Interprocess Communication
Independent한 Process
Process가 cooperate하는 경우
- 다른 프로세스에 의해 영향받을 수 있음
- 서로 다른 프로세스 간 데이터 공유
IPC (Inter-Process Communication)
- Cooperating하는 프로세스 간에는 IPC 메커니즘이 요구됨
- 즉, 데이터를 송수신하는 것
- 다음의 두 가지 IPC 모델 존재
- Shared memory
- Message passing

각각 어디를 참조하는지에 주목

message passing의 경우, OS에 일을 맡긴다고 생각. message queue 사용
3.5 IPC in Shared-Memory Systems
- Producer-Consumer Problem을 고려
- cooperating하는 프로세스 간 가장 기본적인 문제
- Producer는 buffer를 채우고, Consumer는 buffer에 있는 걸 사용하는 방식
- 이 buffer가 shared memory인 셈

- Consumer는 buffer가 찰 때까지 waiting
- 이 Shared memory를 OS가 관리
3.6 IPC in Message-Passing Systems
- Shared memory에 접근하고 조작하는 것은 application programmer들이 명시적으로 해줘야 함
Message-Passing
- OS가 cooperating process에 수단 제공
Message-passing operations
- send(message)
- receive(message)
상세 내부 메커니즘은 OS에 system call 등에 의해 처리되는 것
- 두 프로세스 간의 communication link는 다양하게 구현 가능
- direct/indirect communication
- synchronous/asynchronous communication
- automatic/explicit buffering
Direct communication
- communication 상에 있는 recipient와 sender의 name이 명시적이어야 함
- communication link는 자동적으로 생성됨
- 이 링크는 "두 프로세스"와만 관련되어있음. 즉, 그 두 프로세스 사이에 하나만 있음
Indirect communication
- 메세지는 mailbox / port로부터 송수신할 수 있음. 즉, 매개체가 있는 것
- 두 개의 프로세스가 쌍을 이뤘을 때(같이 shared mailbox를 가질 때) communication link가 생성됨
- 이때, 링크는 두 개 이상의 프로세스와 관련될 수 있음

- 두 프로세스 간 여러 개의 링크가 존재할 수 있음
OS가 제공하는 것
- 새로운 mailbox 생성
- mailbox를 통해 메세지 송수신(send/receive)

요런 느낌
구현 시 design options
- blocking(synchronous) / non-blocking(asynchronous)
ex) blocking send: message가 수신될때까지 sender가 block되는 것
blocking receive: message가 유효할때까지 receiver가 block되는 것
- 서비스의 특성(동기적이어야하는지, 비동기적이어도 되는지)에 따라 trade off 생각해 방법 선택