
(a) Shared memory (b) Message Passing
A producer produces information that is consumed by as consumer.
ex) web server produces an HTML file, and browser consumes it.
→ A solution using shared-memory(Producer, Consumer가 공유):
to allow producer and consumer to run concurrently
Let a buffer of items be available (버퍼를 이용하자)
하지만, 공유 메모리에 접근하고 조작하기 위한 코드는 프로그래머에 의해 명시적으로 작성된다.
→ Message-Passing을 이용하자
O/S는 메시지 전달을 통해 소통할 수 있는 수단을 제공한다.
(프로그래머가 코드를 작성하지 않아도 된다.)
direct or indirect communication
Direct
each process that wants to communicate
send(P, message) : P 에게 메시지를 보낸다.
receive(Q, message) : Q에게 메시지를 받는다.
→ Communication Link가 automatically하게 생성
→ 한 쌍의 프로세스에 정확히 하나의 링크 존재
Indirect
messages are sent to and received from mailboxes or ports.
send(A, message) : mailbox A에 메시지를 보낸다.
receive(A, message): mailbox A에서 메시지를 받는다.
→ Communication Link가 “2개 이상”의 프로세스가 mailbox를 이용해야 생성된다
→ “2개 이상”의 프로세스에 하나의 공유 객체 mailbox 존재
→ 수 많은 링크 존재 (여러 개의 mailbox 이용 가능)
※ O/S provides a mechanism that allows a process to do:
Different design options for implementation
Blocking or Non-Blocking : Synchronous or asynchronous
→ mailbox의 용량 1MB / P가 1GB크기의 파일 send
: Q가 1GB의 파일을 다 받을 때 까지 P는 send, wait 반복
(파일을 다 보낸 후 요금 부과 가능 ⇒ 동기적)
→ mailbox의 용량 1MB / P가 1GB크기의 파일 send
: P ⇒ 파일 보내기, 다른 행동 반복
Q ⇒ 정상적인 메시지, null 메시지 수신 반복
(Q가 파일을 다 수신하기 전에 종료 할 수 있음. But 요금이 부과되면 안됨 ⇒ 비동기적)