117 lines · 2.3 KB · Text
RawDownload
.TH SEGMENT 3 .SH NAMEsegment \- long lived memory segments.SH SYNOPSIS.nf.B bind '#g' /mnt/segment .BI #g/ seg1.BI #g/ seg1 /ctl.BI #g/ seg1 /data.BI #g/ seg2.BI #g/ seg2 /ctl.BI #g/ seg2 /data ....fi.SH DESCRIPTION.PPThe.I segmentdevice provides a 2-level file system representinglong-lived sharable segments that processes may.IR segattach (2).The name of the directory is the.I classargument to.IR segattach ..PPNew segments are created under the top levelusing.B create(see.IR open (2)).The.B DMDIRbit must be set in the permissions..IR Remove (2)'ingthe directory makes the segment no longeravailable for.IR segattach .However, the segment will continue to exist until allprocesses using it either exit or.I segdetachit..PPWithin each segment directory are two files,.B dataand.BR ctl .Reading and writing.B dataaffects the contents of the segment.Reading and writing .B ctlretrieves and sets the segment's properties..PPThere is only one control message, which sets the segment'svirtual address and length in bytes:.EX	va \fIaddress length\fP.EE.I Addressis automatically rounded down to a page boundary and.I lengthis rounded up to end the segment at a page boundary.The segment will reside at the same virtual address inall processes sharing it.When the segmentis attached using.IR segattach,the address and length arguments are ignored in the call;they are defined only by the.B vacontrol message.Once the address and length are set, they cannot be reset..PPReading the control filereturns a message of the same format with the segment's actualstart address and length..PPOpening.B dataor reading.B ctlbefore setting the virtual address yields the error``segment not yet allocated''..PPThe permissions check when.IR segattach ingis equivalent to the one performed when opening.B datawith mode ORDWR..SH EXAMPLE.PPCreate a one megabyte segment at address 0x10000000:.EX	% bind '#g' /mnt/segment	% mkdir /mnt/segment/example	% echo 'va 0x10000000 0x100000' > /mnt/segment/example/ctl.EE.PPPut the string ``hi mom'' at the start of the segment:.EX	% echo -n hi mom > /mnt/segment/example/data.EE.PPAttach the segment to a process:.EX{	ulong va; 	va = segattach(0, "example", 0, 0);}.EE.SH "SEE ALSO.IR segattach (2).SH SOURCE.B /sys/src/9/port/devsegment.c