1 / 19

IPC

IPC. Message Queue. Data Structure. msgque. IP_NOUSED. Two channels of Message queue. channel between normal processes IPC_KERNELD not set channel between kernel and kernel daemon kernel daemon:a process which automatically carries out loading and removing of modules. IPC_KERNELD set.

Download Presentation

IPC

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 Message Queue

  2. Data Structure msgque IP_NOUSED

  3. Two channels of Message queue • channel between normal processes • IPC_KERNELD not set • channel between kernel and kernel daemon • kernel daemon:a process which automatically carries out loading and removing of modules. • IPC_KERNELD set

  4. kerneld_msg{ mtype id version pid text[1]} msgbuf{ mtype mtext[1]} Message header

  5. sys_msgget() • allocate a new message queue, or gain access to an existing message queue. • Flags • IPC_CREAT:a new queue will be created if it is not yet present=>newque() • IPC_EXCL:If IPC_CREAT is set and such a queue exists, the function will return with the error EEXIST.

  6. sys_msgctl() • IPC_INFO:enters special values in the msginfo structure. • IPC_STAT:return current values of msqid_ds • IPC_SET:modify values of msqid_ds • IPC_RMID:remove all associated message queue structure

  7. sys_msgsnd() • Send message to message queue. • The process blocks if message length exceeds the value in msg_qbytes, the permitted maximum. • Blocking can be prevented by setting IPC_NOWAIT.

  8. sys_msgrcv() • receive messages of specified type from message queue. • msgtyp = 0 => get first. • msgtyp > 0 => get first message of matching type.(MSG_EXCEPT not set) • msgtyp < 0 => get message with least type must be < abs(msgtype).

  9. Message queue between kernel & kerneld • IPC_KERNELD set • kerneld_send() • responsible for sending messages to the kernel daemon. • KERNELD_WAIT set if we want an answer from kerneld. • kerneld_exit() • called when current process terminated.

  10. IPC PIPE

  11. Data Structure

  12. do_pipe • Called by system call pipe • set up a temporary inode and allocating a page of memory to base. • Return two file descriptors, one for reading, and one for writing.

  13. Open Pipe • pipe_read_open() • pipe_write_open() • pipe_rdwr_open()

  14. Pipe_Select() • To check whether data can be read from pipe or written to it. • sel_type: • SEL_IN:for read • SEL_OUT:for write • SEL_EX:for exception

  15. Pipe read operation Blocking Non-Blocking Locked Block calling EAGAIN pipe process Empty Block calling process EAGAIN if pipe if writing process writing processes present,else return 0 present, else 0 Else Read maximum number of characters up to requested position.

  16. Pipe write operation Blocking Non-blocking no reading Send SIGPIPE to writing process process and return EPIPE locked pipe atomic write block calling EAGAIN possible, but not process enough space in pipe buffer

  17. Pipe/FIFO write op(cont.) Blocking Non-blocking Buffer space write requested number of bytes sufficient for to buffer atomic write continue blocking as for blocking Else until requested write. Write number of bytes maximum has been written. Possible number of bytes.

  18. Release pipe • pipe_read_release() • pipe_write_release() • pipe_rdwr_release()

  19. Other operation • pipe_ioctl() • FIONREAD:write the number of bytes within the file not yet read to address arg. • pipe_lseek():invalid.

More Related