DIRECTORY UnixTypes; UnixShm0: CEDAR DEFINITIONS = BEGIN IpcPerm: TYPE = MACHINE DEPENDENT RECORD [--common IPC access structure uid: UnixTypes.UID, -- (owner's) user id gid: UnixTypes.GID, -- (owner's) group id cuid: UnixTypes.UID, -- creator's user id cgid: UnixTypes.GID, -- creator's group id mode: CARD16, -- access modes; r/w permission; (set op sets only low 9 bits) seq: CARD16, -- slot usage sequence number key: CARD -- key ]; ShmIdDs: TYPE = MACHINE DEPENDENT RECORD [ ipcPerm: IpcPerm, -- operation permission struct segsz: INT, -- size of segment in bytes lpid: UnixTypes.UID, -- process ID of last shmop cpid: UnixTypes.UID, -- process ID of creator nAttch: CARD16, -- number of current attaches unused1: CARD16, -- depending on C compiler's padding algorithm ! aTime: UnixTypes.Time, -- last shmat time dTime: UnixTypes.Time, -- last shmdt time cTime: UnixTypes.Time, -- last change time amp: POINTER -- segment anon¬map pointer ]; SharedMemoryIdentifier: TYPE = RECORD [val: CARD]; errorSharedMemoryIdentifier: SharedMemoryIdentifier = [CARD.LAST]; SharedMemoryKey: TYPE = RECORD [val: CARD]; ipcPRIVATE: SharedMemoryKey = [0]; --private key to create new SharedMemoryIdentifier ShmGetFlags: TYPE = RECORD [val: CARD]; ipcALLOC: ShmGetFlags = [0100000B]; -- entry currently allocated ipcCREAT: ShmGetFlags = [0001000B]; -- create entry if key doesn't exist ipcEXCL: ShmGetFlags = [0002000B]; -- fail if key exists allPerms: ShmGetFlags = [0000777B]; -- (not in found ipc.h) ShmGet: PROC [key: SharedMemoryKey, size: INT, shmflg: ShmGetFlags] RETURNS [shmId: SharedMemoryIdentifier] = TRUSTED MACHINE CODE { ".XR_ShmGet" }; IPCCtlCmd: TYPE = RECORD [val: CARD]; ipcRMID: IPCCtlCmd = [0]; -- remove identifier ipcSET: IPCCtlCmd = [1]; -- set options ipcSTAT: IPCCtlCmd = [2]; -- get options ShmCtl: PROC [shmId: SharedMemoryIdentifier, cmd: IPCCtlCmd, buf: POINTER TO ShmIdDs] RETURNS [UnixTypes.SysCallResult] = TRUSTED MACHINE CODE { ".XR_ShmCtl" }; ShmAtFlags: TYPE = RECORD [CARD]; noFlags: ShmAtFlags = [000000]; shmRDOnly: ShmAtFlags = [010000]; -- attach read-only (else read-write) shmRnd: ShmAtFlags = [020000]; -- round attach address to SHMBA RawVM: TYPE = POINTER; ShmAt: PROC [id: SharedMemoryIdentifier, addr: RawVM, flags: ShmAtFlags ¬ noFlags] RETURNS [INT] = TRUSTED MACHINE CODE { ".XR_ShmAt" }; ShmDt: PROC [addr: RawVM] RETURNS [UnixTypes.SysCallResult] = TRUSTED MACHINE CODE { ".XR_ShmDt" }; VMReserve: PROC [nbytes: CARD] RETURNS [address: RawVM] = TRUSTED MACHINE CODE { ".XR_VMReserve" }; UNTHREADEDShmCtl: UNSAFE PROC [shmId: SharedMemoryIdentifier, cmd: IPCCtlCmd, buf: POINTER TO ShmIdDs] RETURNS [UnixTypes.SysCallResult] = TRUSTED MACHINE CODE { "*#include \n"; "#include \n"; "#include \n"; ".shmctl" }; RegisterUNTHREADEDTerminationCleanupProc: UNSAFE PROC [cleanup: PROC [REF], data: REF ¬ NIL] RETURNS [UnixTypes.SysCallResult] = TRUSTED MACHINE CODE { ".XR_RegisterTerminationCleanupProc" }; END. Ž UnixShm0.mesa Copyright Σ 1990, 1991 by Xerox Corporation. All rights reserved. Created by Christian Jacobi, January 29, 1990 Christian Jacobi, January 24, 1991 5:30 pm PST Procedures and types to access the Unix shared memory features. The procedures are left with original Unix parameters and are not nicely Cedar packaged so that the Unix documentation and .h files still point to the corresponding features. Described types found in and . --shared memory descriptor structure --low order 9 bits for permission stuff Returns shared memory identifier or errorSharedMemoryIdentifier. Shared memory control operations. Attaches shared memory segment. Returns address of memory segment or -1 on failure. WARNING: Do explicitely allocate the memory with VMReserve. A 0 addr would confuse the garbage collector. Unmaps shared memory segment at addr from calling processes address space. But segment and contents are retained. --The following procedures do not look like belonging here from a purist point of view. However, they are always needed together with the real shared memory stuff. Returns page aligned address. --VMReserve is not a Unix shared memory feature, but it is always needed together with ShmAt. Shared memory control operations, version NOT to be called from a regular Cedar/Mesa thread. --UNTHREADEDShmCtl must not be used by normal Cedar code but only by a registered cleanup procedure from a Unix process. It is needed for returning allocated segments when the process dies. Register a cleanup proc to be called automatically just before PCR terminates. The cleanup proc is called from a Unix process rather than a thread -- it should do native Unix system calls and avoid thread operations such as entering monitors. --RegisterUNTHREADEDTerminationCleanupProc is not a Unix shared memory feature, but it is always necessary to provide cleanup when using Unix shared memory.. Κ±•NewlineDelimiter –(cedarcode) style™šœ ™ Jšœ Οeœ7™BJšœ-™-J™.J™—codešΟk œ ˜K˜—KšΟnœžœž œ˜Kšž˜K˜šœ?™?Kšœ―™―K™5—K˜š œ žœžœž œžœΟc˜GKšœžœ ˜(Kšœžœ ˜)Kšœžœ ˜)Kšœžœ ˜*Kšœžœ >˜QKšœžœ ˜/Kšœžœ ˜K˜K˜—š œ žœžœž œžœ˜*Kšœ$™$Kšœ ˜1Kšœžœ ˜(Kšœžœ ˜1Kšœžœ ˜.Kšœžœ ˜.Kšœ žœ 0˜BKšœ ˜*Kšœ ˜)Kšœ ˜*Kšœžœ ˜.K˜K˜—šœžœžœžœ˜3Kšœ7žœžœ˜BK˜—šœžœžœžœ˜+Kšœ$ 2˜V—K˜šœ žœžœžœ˜'K™'Kšœ$ ˜@Kšœ$ $˜HKšœ& ˜;Kšœ% ˜