IPC:Message Queues

공부를 해보자/프로그래밍 2010. 3. 26. 13:29

시지 큐를 사용하는 프로그램을 작성했는데, receive하는쪽에서 엉뚱한 메모리 값이 변경되는 현상이 발생했다. 디버깅 하다 보니 아래 부분이 문제 였던 것으로 보인다.

msgsnd(key_id, (void *)&mbuf, sizeof(msgbuf), IPC_NOWAIT);
아래 처럼 변경하니까 정상동작 되었다.

msgsnd(key_id, (void *)&mbuf, strlen(mbuf.mtext)+1, IPC_NOWAIT);

아래 문서의 예제에서 힌트를 얻었다.

출처: http://www.cs.cf.ac.uk/Dave/C/node25.html

IPC:Message Queues:<sys/msg.h>

The basic idea of a message queue is a simple one.

Two (or more) processes can exchange information via access to a common system message queue. The sending process places via some (OS) message-passing module a message onto a queue which can be read by another process (Figure 24.1). Each message is given an identification or type so that processes can select the appropriate message. Process must share a common key in order to gain access to the queue in the first place (subject to other permissions -- see below).

'공부를 해보자 > 프로그래밍' 카테고리의 다른 글

[Link]정규표현식  (0) 2010.04.06
Lighttpd + FastCGI  (0) 2010.03.30
JPEG EXIF  (0) 2010.03.05
HTTP server push  (0) 2010.02.09
Streaming media protocols  (0) 2010.02.09
: