segment – long lived memory segments
bind ’#g’ /mnt/segment
device provides a 2-level file system representing
long-lived sharable segments that processes may
The name of the directory is the
New segments are created under the top level
bit must be set in the permissions.
the directory makes the segment no longer
However, the segment will continue to exist until all
processes using it either exit or
Within each segment directory are two files,
Reading and writing
affects the contents of the segment.
Reading and writing
retrieves and sets the segment’s properties.
There is only one control message, which sets the segment’s
virtual address and length in bytes:
va address length type
is automatically rounded down to a page boundary and
is rounded up to end the segment at a page boundary.
The segment will reside at the same virtual address in
all processes sharing it.
can be specified as
Fixed segments are uncached and physically continuous
with a fixed physical base address suitable for hardware
Sticky segments are like normal shared segments but
preallocated at creation time and never swapped out.
Only the hostower is allowed to create
the address and length arguments are ignored in the call;
they are defined only by the
Once the address and length are set, they cannot be reset.
Reading the control file
returns a message of the same format with the segment’s actual
start address and length. For
segments, the type and physical base address are appended.
before setting the virtual address yields the error
“segment not yet allocated”.
The permissions check when
is equivalent to the one performed when opening
with mode ORDWR.
Create a one megabyte segment at address 0x10000000:
% bind '#g' /mnt/segment
% mkdir /mnt/segment/example
% echo 'va 0x10000000 0x100000' > /mnt/segment/example/ctl
Put the string “hi mom” at the start of the segment:
% echo -n hi mom > /mnt/segment/example/data
Attach the segment to a process:
va = segattach(0, "example", 0, 0);