Gnu Mach Ipc

Progress Of Siddu.Baddela

Mach Ipc

1st Sarath.MS tore my papers on mach messages

How is the Ipc in Gnu/Mach is different from common unix or linux ipcs ?

In monolithic kernels like Gnu/linux the communication is synchronous and all the ipc calls should happen through the kernel
Two different process cannot communicate directly. The route of the communication is through the kernel
In a microkernel system, the synchronous kernel call model must be extended to allow one program to call another.
so Gnu/Mach use asynchronous type of communication. And the ipc is done through messages smiler to tcp/ip communication
The communication works on three things messages,ports,port set
Even the kernel services are accessed through ipc's(messages)
The message contains header and the content(payload).
The header contains the size of the payload most and the address of the receiver.
Threads use ports to send and receive messages. The messages are queued at each port and the messages are accessed in the
order they are received by the port.
To maintain constancy ports are maintained by the process. Many process can have send rights in mach language capabilities. but only one process can have receive right. One more right is send-once if a process have this right then it can send only one message.
this rights are also transfered using messages.
One more important thing is a only the process with receive right can transfer its receive right to another process.
So a process with send right can send messages but has to wait for receive right to receive messages from the queue.
port set is a set of ports
a process can receive message from port sets
a process can manipulate the sets using port capabilities
Important thing to remember here is the port set rights cannot be sent through the messages.
Port rights are maintained by the kernel they can be transferd from one process to another or even to process in another system
they are location independent way of naming ports
The port queue is a protected data structure, only accessible via the kernel's exported message primitives.

To send large amount of data mach ipc uses VM system to transfer huge data.
How?
Simple message contains the address of the data to be transfers so the receiver can read directly from the address and receive the data ;-)

first thing
headers to be included

mach/port.h

important things in port.h header
mach_port_t defines a port(port name)
this is a 32 bit integer so machine-dependent
a message carries port rights (rights to another task)
MACH_PORT_NULL is legal value. it indicates the absences of any port or port rights
MACH_PORT_DEAD it has port rights but the port is died
different port rights are
MACH_PORT_RIGHT_SEND gives permission to send for the task
MACH_PORT_RIGHT_RECEIVE to receive
MACH_PORT_RIGHT_SEND_ONCE send only once (user reference count to 1)
MACH_PORT_RIGHT_PORT_SET sets the port
MACH_PORT_RIGHT_DEAD_NAME use to hold the name
MACH_PORT_RIGHT_NUMBER ????

user reference count

mach/message.h

signature of mach_msg function as in message.h header
extern mach_msg_return_t
mach_msg
#if defined(c_plusplus) || defined(STDC)
(mach_msg_header_t *msg,
mach_msg_option_t option,
mach_msg_size_t send_size,
mach_msg_size_t rcv_size,
mach_port_t rcv_name,
mach_msg_timeout_t timeout,
mach_port_t notify);
#else /* c_plusplus || STDC */
#ifdef LINTLIBRARY
(msg, option, send_size, rcv_size, rcv_name, timeout, notify)
mach_msg_header_t *msg;
mach_msg_option_t option;
mach_msg_size_t send_size;
mach_msg_size_t rcv_size
mach_port_t rcv_name;
mach_msg_timeout_t timeout;
mach_port_t notify;
{ return MACH_RCV_SUCCESS; }
#else /* LINTLIBRARY */
();
#endif /* LINTLIBRARY */
#endif /* c_plusplus || STDC */

Function used to send and receive messages

mach_msg_return_t mach_msg (mach_msg_header_t *msg, mach_msg_option_t option, mach_msg_size_t send_size, mach_msg_size_t rcv_size, mach_port_t rcv_name, mach_msg_timeout_t timeout, mach_port_t notify)

The mach_msg function is used to send and receive messages. Mach messages contain typed data, which can include port rights and references to large regions of memory.

  • msg is the address of a buffer in the caller's address space.
  • Message buffers should be aligned on long-word boundaries.
  • The message options option are bit values, combined with bitwise-or. One or both of MACH_SEND_MSG and MACH_RCV_MSG should be used just like how you did in unix open system call .
  • Other options act as modifiers.
  • When sending a message, send_size specifies the size of the message buffer.
    • Otherwise zero should be supplied.
  • When receiving a message, rcv_size specifies the size of the message buffer. Otherwise zero should be supplied.
    • When receiving a message, rcv_name specifies the port or port set. Otherwise MACH_PORT_NULL should be supplied.
  • When using the MACH_SEND_TIMEOUT and MACH_RCV_TIMEOUT options, timeout specifies the time in milliseconds to wait before giving up. Otherwise MACH_MSG_TIMEOUT_NONE should be supplied.
  • When using the MACH_SEND_NOTIFY, MACH_SEND_CANCEL, and MACH_RCV_NOTIFY options, notify specifies the port used for the notification. Otherwise MACH_PORT_NULL should be supplied.

If the option argument is MACH_SEND_MSG, it sends a message. The send_size argument specifies the size of the message to send. The msgh_remote_port field of the message header specifies the destination of the message.

If the option argument is MACH_RCV_MSG, it receives a message. The rcv_size argument specifies the size of the message buffer that will receive the message; messages larger than rcv_size are not received. The rcv_name argument specifies the port or port set from which to receive.

If the option argument is MACH_SEND_MSG|MACH_RCV_MSG, then mach_msg does both send and receive operations. If the send operation encounters an error (any return code other than MACH_MSG_SUCCESS), then the call returns immediately without attempting the receive operation. Semantically the combined call is equivalent to separate send and receive calls, but it saves a system call and enables other internal optimizations.

If the option argument specifies neither MACH_SEND_MSG nor MACH_RCV_MSG, then mach_msg does nothing.

Some options, like MACH_SEND_TIMEOUT and MACH_RCV_TIMEOUT, share a supporting argument. If these options are used together, they make independent use of the supporting argument's value.

— Data type: mach_msg_timeout_t

This is a natural_t used by the timeout mechanism. The units are milliseconds. The value to be used when there is no timeout is MACH_MSG_TIMEOUT_NONE.

Hi siddu
i am at a presentation
remove this line soon
bye

note

referred from
http://www.gnu.org/software/hurd/gnumach-doc/Mach-Message-Call.html#Mach-Message-Call
Gnu/Mach source
if you any one edit this page to add extra detail use monospace letters like thi
Thank You

Yeah.. i tore them
sarathmssarathms 1165128753|%e %b %Y, %H:%M %Z|agohover

do you really have to mention it as the first point that i tore your papers on the Mach IPC?
on the positive side, it shows my progress in the project. its like "it all started with my tearing of the pages."

unfold Yeah.. i tore them by sarathmssarathms, 1165128753|%e %b %Y, %H:%M %Z|agohover
Anonymous (59.93.77.x) 1176451490|%e %b %Y, %H:%M %Z|agohover

hi guys we have the same batch as u

SIDDu hussain
sharath chandra
pavan kumar

i dont understand whats this site is for can u please tell me

Email:moc.oohay|etarip_n_kcarc#moc.oohay|etarip_n_kcarc

unfold by Anonymous (59.93.77.x), 1176451490|%e %b %Y, %H:%M %Z|agohover
Add a new comment
page_revision: 19, last_edited: 1166786023|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.