com.sun.rtsjx
Class SharedMemoryMapper

java.lang.Object
  extended by com.sun.rtsjx.CoreRawMemoryType
      extended by com.sun.rtsjx.SharedMemoryMapper
All Implemented Interfaces:
PhysicalMemoryMapper, javax.realtime.PhysicalMemoryTypeFilter

public class SharedMemoryMapper
extends CoreRawMemoryType
implements PhysicalMemoryMapper

Shared memory support.

PhysicalMemoryManager.SHARED provides the common addConstraints call

new instances are created for each physical memory request.


Constructor Summary
SharedMemoryMapper()
           
SharedMemoryMapper(long base, long size)
           
SharedMemoryMapper(java.lang.Object[] param)
           
 
Method Summary
 void addConstraints(PhysicalMemoryRequest request)
          Add new constraints to a physical memory request.
 void checkMapperConstraints(PhysicalMemoryRequest request)
          Check the constraints due to the mapper itself.
 long get_mapped_address()
          Get the mapped address, or 0 if unmapped.
 int get_shared_id()
          Get the shared identifier.
 boolean isCompatibleWithPhysicalMemory()
          Returns true if this mapper is compatible with ImmortalPhysicalMemory, LTPhysicalMemory and VTPhysicalMemory.
 long map(PhysicalMemoryRequest request)
          Map the shared memory.
 void unmap(PhysicalMemoryRequest request)
          Undo a mapping.
 
Methods inherited from class com.sun.rtsjx.CoreRawMemoryType
checkConstraints, contains, find, getVMAttributes, getVMFlags, initialize, isPresent, isRemovable, onInsertion, onInsertion, onRemoval, onRemoval, unregisterInsertionEvent, unregisterRemovalEvent, vFind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SharedMemoryMapper

public SharedMemoryMapper()

SharedMemoryMapper

public SharedMemoryMapper(long base,
                          long size)

SharedMemoryMapper

public SharedMemoryMapper(java.lang.Object[] param)
Method Detail

get_mapped_address

public long get_mapped_address()
Description copied from interface: PhysicalMemoryMapper
Get the mapped address, or 0 if unmapped.

Specified by:
get_mapped_address in interface PhysicalMemoryMapper
Returns:
the mapped address, or 0 if unmapped.

addConstraints

public void addConstraints(PhysicalMemoryRequest request)
                    throws java.lang.SecurityException,
                           javax.realtime.OffsetOutOfBoundsException,
                           javax.realtime.SizeOutOfBoundsException,
                           javax.realtime.UnsupportedPhysicalMemoryException,
                           javax.realtime.MemoryTypeConflictException,
                           java.lang.OutOfMemoryError
Description copied from class: CoreRawMemoryType
Add new constraints to a physical memory request.

Overrides:
addConstraints in class CoreRawMemoryType
Parameters:
request - null or PhysicalMemoryRequest containing the previously parsed constraints.
Throws:
java.lang.SecurityException - Thrown if application doesn't have permissions to access physical memory, the specified range of addresses, or the given type of memory.
javax.realtime.OffsetOutOfBoundsException - Thrown if the address is invalid.
javax.realtime.SizeOutOfBoundsException - Thrown if the size is negative or extends into an invalid range of memory.
javax.realtime.UnsupportedPhysicalMemoryException - Thrown if the underlying hardware does not support the given type, or if no matching PhysicalMemoryTypeFilter has been registered with the PhysicalMemoryManager.
javax.realtime.MemoryTypeConflictException - Thrown if the specified base does not point to memory that matches the request type, or if type specifies incompatible memory attributes.
java.lang.OutOfMemoryError - Thrown if the requested type of memory exists, but there is not enough of it free to satisfy the request.
See Also:
PhysicalMemoryRequest

checkMapperConstraints

public void checkMapperConstraints(PhysicalMemoryRequest request)
                            throws javax.realtime.SizeOutOfBoundsException,
                                   javax.realtime.MemoryTypeConflictException
Description copied from interface: PhysicalMemoryMapper
Check the constraints due to the mapper itself.

The default implementation does nothing.

Specified by:
checkMapperConstraints in interface PhysicalMemoryMapper
Parameters:
request - constraints issued from the parsing of a memory type.
Throws:
javax.realtime.SizeOutOfBoundsException - Thrown if the size is negative or extends into an invalid range of memory.
javax.realtime.MemoryTypeConflictException - Thrown if the specified base does not point to memory that matches the request type, or if type specifies incompatible memory attributes.

get_shared_id

public int get_shared_id()
Get the shared identifier.

It is the result of the shmget UNIX call.


map

public long map(PhysicalMemoryRequest request)
         throws javax.realtime.OffsetOutOfBoundsException,
                javax.realtime.SizeOutOfBoundsException,
                javax.realtime.MemoryTypeConflictException,
                java.lang.OutOfMemoryError
Map the shared memory.

request.initial_pbase is used as the shared memory key.

request.get_len() provides the requested size.

request.get_flags() provides the flags for both the shmget and the shmat calls.

If the key is not -1, shmget and shmat are performed for each map call.

If the key is equal to -1, IPC_PRIVATE shared memory is created with shmget. Once successful, the same share memory identifier is reused and only shmat is called.

Specified by:
map in interface PhysicalMemoryMapper
Parameters:
request - constraints issued from the parsing of a memory type.
Throws:
javax.realtime.OffsetOutOfBoundsException - Thrown if the address is invalid.
javax.realtime.SizeOutOfBoundsException - Thrown if the size is negative or extends into an invalid range of memory.
javax.realtime.MemoryTypeConflictException - Thrown if the specified base does not point to memory that matches the request type, or if type specifies incompatible memory attributes.
java.lang.OutOfMemoryError - Thrown if the requested type of memory exists, but there is not enough of it free to satisfy the request.

unmap

public void unmap(PhysicalMemoryRequest request)
Description copied from interface: PhysicalMemoryMapper
Undo a mapping.

Specified by:
unmap in interface PhysicalMemoryMapper
Parameters:
request - constraints issued from the parsing of a memory type.

isCompatibleWithPhysicalMemory

public boolean isCompatibleWithPhysicalMemory()
Description copied from interface: PhysicalMemoryMapper
Returns true if this mapper is compatible with ImmortalPhysicalMemory, LTPhysicalMemory and VTPhysicalMemory. false otherwise

Specified by:
isCompatibleWithPhysicalMemory in interface PhysicalMemoryMapper