summaryrefslogtreecommitdiff
path: root/microkernel/mach/message.mdwn
blob: 4c49af17fbde91cbaa3b1746c39693591aa1763a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[[!meta copyright="Copyright © 2002, 2003, 2010, 2012 Free Software Foundation,
Inc."]]

[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable
id="license" text="Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no Invariant
Sections, no Front-Cover Texts, and no Back-Cover Texts.  A copy of the license
is included in the section entitled [[GNU Free Documentation
License|/fdl]]."]]"""]]

*Messages* are collections of typed data, with a defined layout, including an
[[ID|msgh_id]].

They are used for [[IPC]], and are sent to and received from [[port]]s using
the `mach_msg` interface.

These messages are not only opaque data.  They can also contain [[port
rights|port]] to be passed to another [[task]].  Port rights are either
*copied* or *moved*.  Notice that port receive right must be moved but not
copied because there can't be more than one task that holds the receive right
to a port.  The receiving task creates new local port name to the port rights
it received.

Some data in the message can be *out-of-line data*.  In the message, these are
*references* to memory regions ([[memory_object]]s) that are *virtually
copied*.  When the message is received in a task, these virtual copies become
part of the task by mapping them into the receiver's [[virtual_address_space]].
Another key concept that is applied is using *copy-on-write*, which means that
data is not copied immediately, but only when it is changed.  This is primarily
used to send large blocks of data efficiently, as it is too expensive to store
them in the kernel address space: extra copied need only be made at the moment
that the memory regions begin to diverge, by threads modifying them.