SEND
Purpose
send sends a message to a mailbox.
Synopsis
#include <types.h>
#include <stub.h>
int send(Message_Header
*header, char *buffer, int size);
Parameters
-
header: the message header, including
the message destination;
-
buffer: the pointer for the area
where the message is stored;
-
size: the message size in bytes.
Description
send sends the message pointed by buffer,
that is size bytes long, to the mailbox specified by the field to
in header.
This system call is normally used by servers
to send back a reply to a client service request. Although there is no
formal restrictions on its use by clients, the act
system call is by far more adequate.
send verifies the message destination
to determine one of the following three cases:
-
The destination is one of the internal
kernel mailboxes: message is passed to the proper manager inside the kernel;
-
The destination is a mailbox is local,
i. e., is in the same host where the sender is running: the sender is blocked
and the massage will be passed to the first thread that executes receive
on the mailbox;
-
The destination is a remote mailbox, i.
e., is not in the same host where the sender is running: the network server
is take as the destination and the message is handled just like in the
previous case.
Note that in the last case, the sender blocks
only until one of the network server
threads executes receive, i. e., there
are no delivery guaranties for the message. In network terminology, this
implementation of send is synchronous and not confirmed.
The handling of non-local messages is do entirely
outside the kernel by the network server.
Return Values
On success, send returns 0 and the
message stored in buffer is delivered to its recipient or to the
network server.
On fail, send returns a negative value
indicating one of the following errors:
See Also
receive, act,
Capability, Message_Header,
network server
Notes
The decision of making a blocking send is
to avoid buffer handling inside the kernel. In this implementation the
message is directly copied to the destination task address space if it
is small or shared and marked copy-on-write if it is bigger the a certain
value.
send is indeed, act(header,
buffer, size, NULL, NULL, NULL).