ipcs - IPC ????????? - PowerPoint PPT Presentation

About This Presentation
Title:

ipcs - IPC ?????????

Description:

Title: Last modified by: kishima Created Date: 9/29/2005 6:48:08 AM Document presentation format: – PowerPoint PPT presentation

Number of Views:111
Avg rating:3.0/5.0
Slides: 13
Provided by: bacspotDi
Category:

less

Transcript and Presenter's Notes

Title: ipcs - IPC ?????????


1
????????
  • ???????????????
  • ????????????????
  • ???????????
  • ipcs - IPC ?????????
  • ipcrm IPC????(??????????????????? ID)?????
  • ???????????
  • ????????????
  • ????????????
  • msgget???????
  • msgget???????
  • msgrcv???????

2
???????????????
????A?B?? ?????????
????A?B?? ?????????
???????????????????
???? A
???? B
????A msgget() msgsnd()
????B msgget() msgrcv()
???????
  • ??????
  • ????
  • ?????

????
  • ???????
  • ????
  • ????

????????
????
3
????????????????
  • ????????????????????
  • ?????????????????????????????
  • ???????????????
  • ??????????
  • msgget ?????????????????????
  • msgsnd ?????????(struct msgbuf)??????????????
  • ??????????
  • msgget ???????????????????????????????
  • msgrcv ?????????(struct msgbuf)??????????????
  • ??????????????????????
  • struct msgbuf
  • long mtypes
  • char mtextMSG_SIZ

4
???????????
ipcs -q ------ ???????? -------- ?? msqid
??? ?? ?????? ?????
./msend Enter message aaaa ./msend Enter
message kkkkkkk ipcs -q ------ ????????
-------- ?? msqid ??? ??
?????? ????? 0x61018097 98304 oida 666
512 2 ./mrecv message
received from 1825 aaaa message received from
1826 kkkkkkkk
???????2?
5
ipcs - IPC ?????????
  • ipcs ??IPC ??????????????????
  • -i ?????????? id ??????????????????????
  • ???????????????
  • -m ???????????????????
  • -q ??????????????
  • -s ??????????
  • -a ?????????????????(??????)?
  • ????????????????????
  • -t ?????????????????????
  • -p ??????????????????????ID??????
  • -c ???????????????????????????
  • -l ???????????????
  • -u ??????????????????????.

6
ipcrm IPC????(??????????????????? ID)?????
  • ipcrm ? System V ??????? (interprocess
    communication, IPC) ??????????????????????????????
    ??
  • ??????????????????????????????????????????????????
    ?????????
  • ?????????????????????????????? (????????????????
    IPC ?????????????) ????????
  • ???????????????????????? (attach) ?????????????
    (shmdt(2) ?) ??????????????????? (detach)
    ????????
  • -M shmkey ???????????? shmkey
    ??????????????????????
  • -m shmid ???????????? shmid ????????????????????
    ??
  • -Q msgkey msgkey ????????????????????
  • -q msgid msgid ????????????????????
  • -S semkey semkey ????????????????
  • -s semid semid ????????????????

7
???????????
ipcs -q ------ ???????? -------- ??
msqid ??? ?? ?????? ????? 0x61018097
98304 oida 666 0
0 ipcrm msg 98304 ??????????? ipcs
-q ------ ???????? -------- ?? msqid
??? ?? ?????? ?????
?????? ?????
msgid
8
????????????
msend.c
?????
???????????
????????
9
????????????
mrecv.c
?????
???????????
????????
mtype?????ID??????
10
msgget???????
msgget ???????????????????
?????????? include ltsys/types.hgt include
ltsys/ipc.hgt include ltsys/msg.hgt ?? int
msgget(key_t key, int msgflg) ?? ??? ??????? ???
-1
  • msgflg
  • IPC_CREATE 0666

???) msgkey ftok("mrecv",'a') msgid
msgget(msgkey,IPC_CREAT0666)
11
msgget???????
msgsnd ??????????
???) struct msgbuf msgdata, p pmsgdata
p-gtmtypegetpid() msgkeyftok("mrecv",'a')
msgidmsgget(msgkey,IPC_CREAT0666)
msgsnd(msgid,p,sizeof(p-gtmtext),0)
?????????? include ltsys/types.hgt include
ltsys/ipc.hgt include ltsys/msg.hgt ?? int
msgsnd(int msgid, struct msgbuf msgp, size_t
msgsz, int msgflg) ?? ??? 0? ??? -1
????????? struct msgbuf long mtypes char
mtextMSG_SIZ
  • msgflg
  • IPC_NOWAIT ????????????????????????
  • ????????????????????????????????

12
msgrcv???????
msgrcv ??????????
?????????? include ltsys/types.hgt include
ltsys/ipc.hgt include ltsys/msg.hgt ?? ssize_t
msgrcv(int msgid, struct msgbuf msgp, size_t
msgsz, long msgtyp, int msgflg) ?? ???
mtext???????????? ??? -1
???) struct msgbuf msgdata, p pmsgdata
p-gtmtypegetpid() msgkeyftok("mrecv",'a')
msgidmsgget(msgkey,IPC_CREAT0666) rv
msgrcv(msgid,p,sizeof(p-gtmtext),0,0)
????????? struct msgbuf long mtypes char
mtextMSG_SIZ
Write a Comment
User Comments (0)
About PowerShow.com