1 / 5

고급 IPC 설비 IPC 설비 키 key_t ftok(const char *path, int id) msgget 의 결과 IPC 설비 식별자 return

고급 IPC 설비 IPC 설비 키 key_t ftok(const char *path, int id) msgget 의 결과 IPC 설비 식별자 return - mqid = msgget((key_t)0100, 0644 | IPC_CREAT | IPC_EXCL); ipc_perm uid_t cuid; gid_t cgid; uid_t uid; gid_t gid; mode_t umode;. 메시지 전달 int msgget(key_t key, int permflags); IPC_CREAT

mihaly
Download Presentation

고급 IPC 설비 IPC 설비 키 key_t ftok(const char *path, int id) msgget 의 결과 IPC 설비 식별자 return

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 고급 IPC 설비 • IPC 설비 키 • key_t ftok(const char *path, int id) • msgget의 결과 IPC 설비 식별자 return • - mqid = msgget((key_t)0100, 0644 | IPC_CREAT | IPC_EXCL); • ipc_perm • uid_t cuid; • gid_t cgid; • uid_t uid; • gid_t gid; • mode_t umode;

  2. 메시지 전달 • int msgget(key_t key, int permflags); • IPC_CREAT • IPC_EXCL • mqid = msgget((key_t)0100, 0644 | IPC_CREAT | IPC_EXCL); • int msgsnd(int mqid, const void *message, size_t size, int flags); • int msgrcv(int mqid, void *message, size_t size, long msg_type, int flags); • struct mymsg { • long mtype; • char mtext[SOMEVALUE}; • }

  3. 메시지 전달 • IPC_NOWAIT, MSG_NOERROR • msg_type • - msg_type > 0 • 그 값을 갖는 첫 메시지를 읽음 • - msg_type = 0 • 큐의 제일 첫 번째 메시지를 읽음 • - msg_type < 0 • 메시지의 mtype 값이 msg_type의 절대값보다 작거나 같은 것 • 중에서 최소값을 갖는 첫 번째 메시지를 읽음 • (예제) etest.c, stest.c, q.h

  4. Msgctl 시스템 호출 • int msgctl(int mqid, int command, struct msqid_ds *msq_stat); • IPC_STAT • IPC_SET • IPC_RMID • 예제 – showmsg.c

  5. 실습 • fork와 message queue를 사용한 통신 프로그램 • 자식이 표준 입력한 내용을 mtype=1로 부모에게 전달 • 더 이상의 내용이 없을 때 자식은 mtype=2로 전달 • 부모는 mtype=1이면 받은 내용을 출력하며, mtype=2이면 exit • ipcs & ipcrm –q key

More Related