1 / 7

고급 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

sheng
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 • ftok의 경로를 현재 directory로 변경할 것

  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

  6. 세마포 • p(sem), wait(sem) • v(sem), signal(sem) • invariant • (세마포의 초기값 + v 연산횟수 – 완료된 p 연산횟수) >= 0 • int semget(key_t key, int nsems, int permflags) • int semclt (int semid, int sem_num, int command, union semun ctl_arg); • union semun { • int val; • struct semid_ds *buf; • ushort *array; • }

  7. 세마포 • int semop(int semid, struct sembuf *op_array, size_t num_ops); • sem_op에 관한 p281~p282 내용 숙지할 것 • (예제) p283 (test2.c) • (실습) 부모가 A에서 Z까지 화면출력하고 자식이 a에서 z까지 화면 출력 • 하는 program을 semaphore를 쓰는 경우와 쓰지 않는 경우로 나누어서 비교 • (test3.c 수정)

More Related