posix
Class SharedMem

java.lang.Object
  extended by posix.IPC
      extended by posix.SharedMem

public class SharedMem
extends IPC

A Posix shared memory segment. Shared physical memory is not supported, since this requires superuser privilege and is very hardware dependent.


Nested Class Summary
static class SharedMem.shmid_ds
           
 
Nested classes/interfaces inherited from class posix.IPC
IPC.Perm
 
Field Summary
static long SHMLBA
          The modulus for attaching shared memory by logical address.
 
Fields inherited from class posix.IPC
egid, euid, id, IPC_ALLOC, IPC_CI, IPC_CREAT, IPC_EXCL, IPC_NOCLEAR, IPC_NOWAIT, IPC_PHYS, IPC_PRIVATE, owner, pid
 
Constructor Summary
SharedMem(int key, int flag)
          Attach an existing shared memory segment.
SharedMem(int key, int size, int flag)
          Attach or create a shared memory segment.
SharedMem(String path, int type)
           
 
Method Summary
 CPtr attach()
          Attach the shared memory for read/write at any available logical address.
 void dispose()
           
 SharedMem.shmid_ds getStatus()
          Return the permissions for this IPC data structure.
 void remove()
          Remove this IPC data structure from the system.
 void setPerm(IPC.Perm st)
          Set the user, group, mode for this IPC data structure.
 
Methods inherited from class posix.IPC
finalize, ftok, getId, getPerm, isPidValid, setPerm
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHMLBA

public static final long SHMLBA
The modulus for attaching shared memory by logical address. This is system dependent and therefore computed by the class initializer. While attaching shared memory to a specific address is somewhat system dependent, it can be handled by configuration or property settings.

Constructor Detail

SharedMem

public SharedMem(int key,
                 int flag)
          throws IPCException
Attach an existing shared memory segment.

Throws:
IPCException

SharedMem

public SharedMem(int key,
                 int size,
                 int flag)
          throws IPCException
Attach or create a shared memory segment.

Parameters:
key - IPC key or IPC_PRIVATE
size - size of shared memory
flag - options
Throws:
IPCException

SharedMem

public SharedMem(String path,
                 int type)
          throws IPCException
Throws:
IPCException
Method Detail

getStatus

public SharedMem.shmid_ds getStatus()
                             throws IPCException
Description copied from class: IPC
Return the permissions for this IPC data structure.

Specified by:
getStatus in class IPC
Throws:
IPCException

setPerm

public void setPerm(IPC.Perm st)
             throws IPCException
Set the user, group, mode for this IPC data structure.

Specified by:
setPerm in class IPC
Parameters:
st - a status obtained from IPC.getPerm() for this IPC and modified
Throws:
IPCException

attach

public CPtr attach()
            throws IPCException
Attach the shared memory for read/write at any available logical address. While posix supports attaching at a specific address (within system dependent contraints), I cannot see any utility for this in a Java program - so it is not supported for now. FIXME: support attaching readonly. Support detaching and reattaching at the same address to change readonly status.

Returns:
a CPtr to the attached memory segment
Throws:
IPCException

remove

public void remove()
Description copied from class: IPC
Remove this IPC data structure from the system.

Specified by:
remove in class IPC

dispose

public void dispose()
Overrides:
dispose in class IPC