IPC(Interprocess Communication)

2021. 12. 2. 18:15Operating System

Independent vs cooperating process

Independent: 다른 프로세스에 영향을 끼치거나 영향을 받을 수 없음 

Cooperating: 다른 프로세스 실행에 영향을 끼치거나 영향을 받을 수 있

 - 장점: 정보공유 / 계산 속도 증가/ modularity/ 편리함

 


IPC(Interprocess Communication)

IPC(Interprocess Communication) : 내부 프로세스 간의 협력, 커뮤니케이션 - cooperaing process가 필요한것 

 

Communication Model

 

 

Shared Memory

  • communication하기를 원하는 프로세스 간의 공유된 메모리 공간
  • system call을 부를 필요가 없음
  • 속도가 빠름
  • 생성 공간의 제한이 있음
  • OS가 아닌 users processes에 의해 통제 및 관리
  • 프로세스들이 공유 메모리에 접근하면 그들의 action을 동기화
  • Producer - Consumer Problem
    • cooperating process의 파라다임
    • producer 프로세스가  공유 공간이 가득 찼는데 생산을 시도
    • consumer 프로세스가 공유 공간이 비었는데 소비를 시도
    • unbounded-buffer : 버퍼의 크기 제한 없음
    • bounded-buffer: 버퍼으 크기가 정해졌다고 생각. 이때 문제 발생

 


Message Passing

  • 프로세스가 communicate 하거나 동기화 하기 위한 매커니즘
  • 메시지 시스템 - 프로세스가 공유된 변수에 기대지 않고 서로 의사소통
  • send & receive 연산 이 있음
  • 메시지 크기는 고정되거나 변화

방법

1. 두 프로세스 사이에 communication link생성

2. send와 receive를 이용

 


 

Direct Communication 

  • 프로세스는 이름을 명시적으로 지정 

       -  send(P, message) / receive(Q, message)

 

  • communication link 특징

        -link는 자동으로 생성

        -link하나는 정확히 한 짝의 process와 연관

        -link는 한방향 혹은 양방향(주로 bi-directional)

 

 

Indirect Communication

  • 메시지는 mailbox에서 받음

         -mailbox는 유일한 ID를 가짐

         -프로세스는 mailbox를 공유할 때만 communication가능

         - mailbox 생성 -> mailbox로 메시지 받아 -> mailbox파괴

 

  • communication link특징

          -link는 프로세스가 mailbox공유할 때 생성

          -link는 여러 프로세스와 연관

          -프로세스의 각 짝은 여러 communication link공유

 


 

Synchronization

메시지 전송이 blocking이거나 non-blocking방식 둘 중 하나

  • Blocking - 동기식

메시지를 받거나 메시지가 가능하기 전까지 send와 receivce를 block

 

  • Non-blocking - 비동기식

메시지를 보내고 그냥 계속 진행

유효한 메시지나 null 메시지를 받음


 

 출처

https://talkingaboutme.tistory.com/entry/Process-Inter-Process-Communication-IPC

운영체제 9th Edition(공룔책)

https://www.geeksforgeeks.org/inter-process-communication-ipc/

'Operating System' 카테고리의 다른 글

Chapter 4: Threads  (0) 2021.12.10
System Program  (0) 2021.12.02
System Calls  (0) 2021.12.02
Operating System Service  (0) 2021.12.02
프로세스(Process) & 스레드(Thread)  (0) 2021.11.22