Download presentation
Presentation is loading. Please wait.
Published byOsborne Mathews Modified over 8 years ago
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
Message kerneld_msg{ –mtype –id –version –pid –text[1]} msgbuf{ –mtype –mtext[1]} 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 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 BlockingNon-Blocking Locked Block calling EAGAIN pipe process Empty Block calling processEAGAIN if pipe if writing process writing processes present,else return 0present, else 0 Else Read maximum number of characters up to requested position.
16
Pipe write operation Blocking Non-blocking no readingSend SIGPIPE to writing process processand return EPIPE locked pipe atomic write block calling EAGAIN possible, but not process enough space in pipe buffer
17
Pipe/FIFO write op(cont.) BlockingNon-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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.