문제

  1. 메시지 대기열 중 하나 인 IPC, 공유 메모리 및 세마포어는 네트워크 IPC로 변환하기가 가장 쉽고 가장 어려운 것입니다.

  2. 시스템 v 공유 메모리를 네트워크 IPC 또는 POSIX 공유 메모리로 네트워크 IPC로 변환하는 것이 더 쉬울까요?

도움이 되었습니까?

해결책

Henrik Gustafsson이 말했듯이 :

  1. 메시지 대기열은 지금까지 네트워크로 변환하는 가장 쉬운 IPC 메커니즘입니다. 세마포어는 데이터를 전달하도록 설계되지 않았으며 공유 메모리는 일반적으로 네트워크를 통해 단일 시스템에서도 적절한 제어를 제공하기 위해 세마포어 제어 액세스 (또는 동등한 메커니즘)가 필요합니다. 즉, 시스템 v 메시지 대기열은 아마도 가장 널리 사용되는 IPC 메커니즘 일 것입니다.

  2. 공유 메모리 메커니즘의 변환은 대략 똑같이 어렵습니다. 주목해야 할 핵심은 실제로 '공유 메모리'를 사용하는 경우 거의 거의 없다는 것입니다. 사용 중에도 다른 동기화 도구가 있습니다.

다른 팁

  1. 메시지 대기열에서 수행하는 작업이 소켓 작업과 거의 동일한 매핑이 있다는 것을 근거로 메시지 대기열을 멀리 말하고 싶습니다.
  2. 아마도 마찬가지로, 나는 당신이 메시지 큐와 같이 SHM 위에 약간 더 많은 네트워크 친화적 추상화를 구현하는 것이 좋습니다. 네트워크 지원 구현이 있지만 네트워킹에 적합하지 않은 공유 메모리는 실제로 구현 한 구현은 실제로 누출 된 추상화입니다.
  1. Semaphores are not really a communication mechanism, they are for synchronization. Shared memory can be used over a network (Distributed Shared Memory), but that is quite hard to implement. Message queues are easy because they map directly onto network sockets.

  2. It would probably be quite similar difficulty; both APIs are similar, they just have a different interface.

(1). The easiest is message queues and the hardest is shared memory.

I think it is because message queues just require a pointer to the message queue data structure where as shared memory requires attaching the shared memory to the process address space of both the processes and allocating shared memory is difficult when the two processes are on different machines.

(2). It is easier to convert Posix shared memory than System V shared memory to network IPC.

I think it is because Posix supports both memory based and named semaphores and does not require kernel intervention whereas System V requires OS intervention.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top