06. 프로세스간 통신의 실제: Chapter 3. Processes (Part 4)

HotFried·2023년 9월 11일

Examples of IPC Systems

  • Shared Memory : POSIX Shared Memory
    • POSIX : Portable Operating System Interface (for UNIX)
  • Message Passing : Pipes
    • One of the earliest IPC mechanisms on UNIX systems.

Posix shared memory

  • using memory-mapped files(hdd, ssd가 아닌 memory에 파일 저장)
    → which associate the region of shared memory with a file

  • Producer

  • Consumer (Producer와 차이점)

  1. ftruncate(shm_fd, SIZE) → 공유 메모리의 크기를 결정하는 코드가 없다.
  2. sprintf → 메모리에 쓰지 않고 / printf → 메모리에서 읽어들인다.
  3. shm_unlink → 공유메모리를 제거한다.


Pipes Message Passing

  • A pipe acts as a conduit allowing two processes to communicate

  • Four issues of pipe implementation

    1. Unidirectional(단방향) or Bidirectional(양방향) communication?
    2. half-duplex or full-duplex?(반이중 전송방식 or 전이중 전송방식)
    3. Must a relationship exist between the communicating process?
      (부모, 자식과 같은 관계가 필요한가?)
    4. Can the pipes communicate over a network?
      (네트워크 통신 가능?)
  • Two common types of pipes:
    1. Ordinary pipes

      • 부모가 파이프를 만들고, 자식과의 통신을 위해 이용
      • allow two processes to communicate in producer-consumer fashion
        • Producer : writes to one end of the pipe(write end)
        • Consumer : reads from the other end (read end)

      unidirectional(단방향) : one-way communication possible

      bidirectional(양방향) : two-way communication / two pipes

  1. Named pipes
    • 부모-자식 관계 없이 접근 가능

Two other strategies in client-server systems

  1. Socket
    • defined as endpoints for communication
      ⇒ identified by ans IP address concatenated with
      port number

링크 : [소켓을 이용한 채팅프로그램]

  1. RPC (Remote Procedure Calls)

    • one of the most common forms of remote service
    • abstracts procedure calls between processes on networked systems.

    ⇒ 클라이언트는 Local에서 Procedure를 호출하는 것처럼 Remote host(원격 호스트)에서 Procedure를 호출합니다.

    • 서버와 클라이언트는 다른 주소 공간을 사용하고 있습니다. 그렇기 때문에 함수 호출에 사용되는 매개변수를 변환하는 작업이 필요하다. 이 변환을 담당하는 것이 Stub 이다.
    • Stub은 클라이언트와 서버 각각에 존재한다. client Stub은 함수 호출에 사용될 파라미터를 변환하는데, 이를 Marshalling이라고 한다.
    • 서버는 메시지를 받아서 Marshalled parameters를 풀어서 서버의 procedure를 작동한다.

참고 :

Silberschatz et al. 『Operating System Concepts』. WILEY, 2020.

주니온TV@Youtube: 자세히 보면 유익한 코딩 채널

profile
꾸준하게

0개의 댓글