Você está na página 1de 2

POSIX Message Queues

1. What is a message Queue? a. Processes can communicate with one another by means of IPC messages. Each message generated by a process is sent to an IPC message queue, where it stays until another process reads it. 2. How message queue works? a. A message is composed of fixed-size header and a variable length text. It can be labeled with an integer value, which allows a process to selectively retrieve messages from message queue. b. Once a process reads a message from IPC message queue, kernel destroys the message. Therefore, only one process can receive a message queue. 3. What are the advantages of message queues? a. POSIX message queues are i. A much simpler file based interfaces to applications ii. Native support for message priorities Priority decides on position of message in the queue iii. Native support for asynchronous notification of message arrivals By means of either signals or thread creation iv. Timeouts for blocking send and receive operations 4. How POSIX message queues are created? a. Application invokes mq_open() to open a message queue i. First argument of the function is string specifying the name of the queue b. mq_open() returns a descriptor for the queue. This is specified while sending and receiving message queus. i. similar to the descriptor returned by open() system call 5. How POSIX message queues communicate? a. Once the POSIX message has been created, application can send and receive messages using function mq_send) and mq_receive(). 6. What is the difference between mq_close() and mq_unlink()? a. mq_close() closes POSIX message queue without destroying it; mq_unlink() Destroys POSIX message queue 7. What is the difference between mq_send() and mq_timedsend()? a. mq_send() sends a message to POSIX message queue mq_timedsend() defines a time limit for application to wait for send operation to complete. 8. What is the difference between mq_receive and mq_timedreceive()? a. mq_receive() receives a message to POSIX message queue mq_timedsend() defines a time limit for application to wait for receive operation to complete.

9. What is the function of mq_notify()? a. It establishes an asynchronous notification mechanism for the arrival of messages in an empty POSIX message queue 10. What is function of mq_getattr() and mq_setattr()? a. Respectively they get and set attributes of a POSIX message queue. i. This attribute specifies whether the send and receive operations should be blocking or nonblocking 11. How POSIX message queues are implemented in linux 2.6? a. In linux 2.6 a special file system named mqueue implements POSIX message queues. i. mqueue contains an inode for each existing queue ii. kernel offers functions to operate on message queues for creation of message queue and for sending and receiving messages.

Você também pode gostar