|
SunSPOT API V4.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.squawk.realtime.RawMemoryAccess com.sun.squawk.realtime.RawMemoryFloatAccess
public class RawMemoryFloatAccess
This class holds the accessor methods for accessing a raw memory area by float and double types. Implementations are required to implement this class if and only if the underlying Java Virtual Machine supports floating point data types.
By default, the byte addressed by offset
is the byte at the
lowest address of the
floating point processor's floating point representation.
If the type of memory used for this
RawMemoryFloatAccess
region implements a non-standard floating
point format, accessor methods in this class continue to select bytes
starting at offset
from the base address and continuing toward
greater addresses. The memory type may control the mapping of these bytes into
the primitive data type. The memory type could even select bytes that are not
contiguous. In each case the documentation for the PhysicalMemoryTypeFilter
must document any mapping other than the "normal" one specified above.
All offset values used in this class are measured in bytes.
Atomic loads and stores on raw memory are defined in terms of physical memory. This memory may be accessible to threads outside the JVM and to non-programmed access (e.g., DMA), consequently atomic access must be supported by hardware. This specification is written with the assumption that all suitable hardware platforms support atomic loads for aligned floats. Atomic access beyond the specified minimum may be supported by the implementation.
Storing values into raw memory is more hardware-dependent than loading values. Many processor architectures do not support atomic stores of variables except for aligned stores of the processor's word size.
This class supports unaligned access to data, but it does not require the implementation to make such access atomic. Accesses to data aligned on its natural boundary will be atomic if the processor implements atomic loads and stores of that data size.
Except where noted, accesses to raw memory are not atomic with respect to the memory or with respect to threads. A raw memory area could be updated by another thread, or even unmapped in the middle of a method.
The characteristics of raw-memory access are necessarily platform dependent.
This specification provides a minimum requirement for the RTSJ platform, but it also
supports a optional system properties that identify a platform's level of support for atomic
raw put and get. (See RawMemoryAccess
.) The properties represent a four-dimensional sparse array with boolean values
whether that combination of access attributes is atomic. The default value for array entries is
false.
Many of the constructors and methods in this class throw
OffsetOutOfBoundsException
. This exception means that the
value given in the offset parameter is either negative or outside the
memory area.
Many of the constructors and methods in this class throw
SizeOutOfBoundsException
. This exception means that the value
given in the size parameter is either negative, larger than an allowable
range, or would cause an accessor method to access an address outside of
the memory area.
Constructor Summary | |
---|---|
RawMemoryFloatAccess(Object type,
long size)
Construct an instance of RawMemoryFloatAccess with the given parameters,
and set the object to the mapped state. |
|
RawMemoryFloatAccess(Object type,
long base,
long size)
Construct an instance of RawMemoryFloatAccess with the given parameters,
and set the object to the mapped state. |
Method Summary | |
---|---|
double |
getDouble(long offset)
Gets the double at the given offset in the memory area
associated with this object. |
void |
getDoubles(long offset,
double[] doubles,
int low,
int number)
Gets number doubles starting at the given offset in the memory area
associated with this object and assign
them to the double array passed starting at position low . |
float |
getFloat(long offset)
Gets the float at the given offset in the memory area
associated with this object. |
void |
getFloats(long offset,
float[] floats,
int low,
int number)
Gets number floats starting at the given offset in the memory area
associated with this object and assign
them to the int array passed starting at position low . |
void |
setDouble(long offset,
double value)
Sets the double at the given offset in the memory area
associated with this object. |
void |
setDoubles(long offset,
double[] doubles,
int low,
int number)
Sets number doubles starting at the given offset in the memory area
associated with this object from the
double array passed starting at position low . |
void |
setFloat(long offset,
float value)
Sets the float at the given offset in the memory area
associated with this object. |
void |
setFloats(long offset,
float[] floats,
int low,
int number)
Sets number floats starting at the given offset in the memory area
associated with this object from the
float array passed starting at position low . |
Methods inherited from class com.sun.squawk.realtime.RawMemoryAccess |
---|
getByte, getBytes, getInt, getInts, getLong, getLongs, getMappedAddress, getShort, getShorts, map, map, map, setByte, setBytes, setInt, setInts, setLong, setLongs, setShort, setShorts |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RawMemoryFloatAccess(Object type, long size)
RawMemoryFloatAccess
with the given parameters,
and set the object to the mapped state.
If the platform supports virtual memory, map
the raw memory into virtual memory.
The run time environment is allowed to choose the virtual address where the raw memory area corresponding to this object will be mapped.
type
- An instance of Object
representing the type of
memory required (e.g., dma, shared) - used to define the base address
and control the mapping. If the required memory has more than one
attribute, type
may be an array of objects. If type
is null or a reference to an array with no entries, any type of memory
is acceptable.size
- The size of the area in bytes.
SecurityException
- Thrown if the application doesn't have
permissions to access physical memory, the
specified range of addresses, or the given type of memory.
SizeOutOfBoundsException
- Thrown if the size is negative or
extends into an invalid range of memory.
UnsupportedPhysicalMemoryException
- Thrown if the underlying
hardware does not support the given type.
MemoryTypeConflictException
- Thrown if the specified base does not point to
memory that matches the request type, or if type
specifies
incompatible memory attributes.
OutOfMemoryError
- Thrown if the requested type of memory exists, but there is not
enough of it free to satisfy the request.public RawMemoryFloatAccess(Object type, long base, long size)
RawMemoryFloatAccess
with the given parameters,
and set the object to the mapped state.
If the platform supports virtual memory, map
the raw memory into virtual memory.
The run time environment is allowed to choose the virtual address where the raw memory area corresponding to this object will be mapped.
type
- An instance of Object
representing the type of
memory required (e.g., dma, shared) - used to define the base address
and control the mapping. If the required memory has more than one
attribute, type
may be an array of objects. If type
is null or a reference to an array with no entries, any type of memory
is acceptable.base
- The physical memory address of the region.size
- The size of the area in bytes.
SecurityException
- Thrown if the application doesn't have
permissions to access physical memory, the
specified range of addresses, or the given type of memory.
OffsetOutOfBoundsException
- Thrown if the address is invalid.
SizeOutOfBoundsException
- Thrown if the size is negative or
extends into an invalid range of memory.
UnsupportedPhysicalMemoryException
- Thrown if the underlying
hardware does not support the given type.
MemoryTypeConflictException
- Thrown if the specified base does not point to
memory that matches the request type, or if type
specifies
incompatible memory attributes.
OutOfMemoryError
- Thrown if the requested type of memory exists, but there is notMethod Detail |
---|
public double getDouble(long offset)
double
at the given offset in the memory area
associated with this object.
The load is not required to be atomic even it is located on a natural boundary.
Caching of the memory access is controlled by the memory type
requested
when the RawMemoryAccess
instance was created. If the memory is not cached,
this method guarantees serialized access (that is, the memory access at the memory
occurs in the same order as in the program. Multiple writes to the same location
may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw memory area
from which to load the long.
OffsetOutOfBoundsException
- Thrown if the offset is invalid.
SizeOutOfBoundsException
- Thrown if the object is not mapped,
or if the double falls in an invalid address range.
SecurityException
- Thrown if this access is
not permitted by the security manager.public void getDoubles(long offset, double[] doubles, int low, int number)
number
doubles starting at the given offset in the memory area
associated with this object and assign
them to the double array passed starting at position low
.
The loads are not required to be atomic even if they are located on natural boundaries.
Caching of the memory access is controlled by the memory type
requested
when the RawMemoryAccess
instance was created. If the memory is not cached,
this method guarantees serialized access (that is, the memory access at the memory
occurs in the same order as in the program. Multiple writes to the same location
may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw memory area
at which to start loading.doubles
- The array into which the loaded items are placed.low
- The offset which is the starting point in the given array for the
loaded items to be placed.number
- The number of doubles to load.
OffsetOutOfBoundsException
- Thrown if the offset is negative or greater than the size of the
raw memory area. The role of the SizeOutOfBoundsException
somewhat overlaps
this exception since it is thrown if the offset is within the object but outside the
mapped area. (See RawMemoryAccess.map(long base, long size)
).
SizeOutOfBoundsException
- Thrown if the object is not mapped,
or if a double falls in an invalid address range. This is checked at every
entry in the array to allow for the possibility that the memory area
could be unmapped or remapped. The doubles
array could, therefore, be
partially updated if the raw memory is unmapped or remapped mid-method.
ArrayIndexOutOfBoundsException
- Thrown if low
is less than 0 or greater
than bytes.length - 1
, or if low + number
is greater than or
equal to bytes.length
.
SecurityException
- Thrown if this access is
not permitted by the security manager.public float getFloat(long offset)
float
at the given offset in the memory area
associated with this object. If the float is aligned on a "natural"
boundary it is always loaded from memory
in a single atomic operation. If it is not on a natural boundary it may not be loaded atomically, and
the number and order of the load operations is unspecified.
Caching of the memory access is controlled by the memory type
requested
when the RawMemoryAccess
instance was created. If the memory is not cached,
this method guarantees serialized access (that is, the memory access at the memory
occurs in the same order as in the program. Multiple writes to the same location
may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw memory area
from which to load the float.
OffsetOutOfBoundsException
- Thrown if the offset is negative or greater than the size of the
raw memory area. The role of the SizeOutOfBoundsException
somewhat overlaps
this exception since it is thrown if the offset is within the object but outside the
mapped area. (See RawMemoryAccess.map(long base, long size)
).
SizeOutOfBoundsException
- Thrown if the object is not mapped,
or if the float falls in an invalid address range.
SecurityException
- Thrown if this access is
not permitted by the security manager.public void getFloats(long offset, float[] floats, int low, int number)
number
floats starting at the given offset in the memory area
associated with this object and assign
them to the int array passed starting at position low
.
If the floats are aligned on natural boundaries each float is loaded from memory in a single atomic operation. Groups of floats may be loaded together, but this is unspecified.
If the floats are not aligned on natural boundaries they may not be loaded atomically and the number and order of load operations is unspecified.
Caching of the memory access is controlled by the memory type
requested
when the RawMemoryAccess
instance was created. If the memory is not cached,
this method guarantees serialized access (that is, the memory access at the memory
occurs in the same order as in the program. Multiple writes to the same location
may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw memory area
at which to start loading.floats
- The array into which the floats loaded from the raw memory are placed.low
- The offset which is the starting point in the given array for the
loaded items to be placed.number
- The number of floats to loaded.
OffsetOutOfBoundsException
- Thrown if the offset is negative or greater than the size of the
raw memory area. The role of the SizeOutOfBoundsException
somewhat overlaps
this exception since it is thrown if the offset is within the object but outside the
mapped area. (See RawMemoryAccess.map(long base, long size)
).
SizeOutOfBoundsException
- Thrown if the object is not mapped,
or if a float falls in an invalid address range. This is checked at every
entry in the array to allow for the possibility that the memory area
could be unmapped or remapped. The floats
array could, therefore, be
partially updated if the raw memory is unmapped or remapped mid-method.
ArrayIndexOutOfBoundsException
- Thrown if low
is less than 0 or greater
than bytes.length - 1
, or if low + number
is greater than or
equal to bytes.length
.
SecurityException
- Thrown if this access is
not permitted by the security manager.public void setDouble(long offset, double value)
double
at the given offset in the memory area
associated with this object.
Even if it is aligned, the double value may not be updated atomically. It is unspecified how many
load and store operations will be used or in what order.
Caching of the memory access is controlled by the memory type
requested
when the RawMemoryAccess
instance was created. If the memory is not cached,
this method guarantees serialized access (that is, the memory access at the memory
occurs in the same order as in the program. Multiple writes to the same location
may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw memory area
at which to write the double.value
- The double to write.
OffsetOutOfBoundsException
- Thrown if the offset is negative or greater than the size of the
raw memory area. The role of the SizeOutOfBoundsException
somewhat overlaps
this exception since it is thrown if the offset is within the object but outside the
mapped area. (See RawMemoryAccess.map(long base, long size)
).
SizeOutOfBoundsException
- Thrown if the object is not mapped,
or if the double falls in an invalid address range.
SecurityException
- Thrown if this access is
not permitted by the security manager.public void setDoubles(long offset, double[] doubles, int low, int number)
number
doubles starting at the given offset in the memory area
associated with this object from the
double array passed starting at position low
.
Even if they are aligned, the double values may not be updated atomically. It is unspecified how many
load and store operations will be used or in what order.
Caching of the memory access is controlled by the memory type
requested
when the RawMemoryAccess
instance was created. If the memory is not cached,
this method guarantees serialized access (that is, the memory access at the memory
occurs in the same order as in the program. Multiple writes to the same location
may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw memory area
at which to start writing.doubles
- The array from which the items are obtained.low
- The offset which is the starting point in the given array for the
items to be obtained.number
- The number of items to write.
OffsetOutOfBoundsException
- Thrown if the offset is negative or greater than the size of the
raw memory area. The role of the SizeOutOfBoundsException
somewhat overlaps
this exception since it is thrown if the offset is within the object but outside the
mapped area. (See RawMemoryAccess.map(long base, long size)
).
SizeOutOfBoundsException
- Thrown if the object is not mapped,
or if the a short falls in an invalid address range. This is checked at every
entry in the array to allow for the possibility that the memory area
could be unmapped or remapped. The doubles
array could, therefore, be
partially updated if the raw memory is unmapped or remapped mid-method.
ArrayIndexOutOfBoundsException
- Thrown if low
is less than 0 or greater
than bytes.length - 1
, or if low + number
is greater than or
equal to bytes.length
.
SecurityException
- Thrown if this access is
not permitted by the security manager.public void setFloat(long offset, float value)
float
at the given offset in the memory area
associated with this object.
On most processor architectures an aligned float can be stored in an atomic operation, but
this is not required.
Caching of the memory access is controlled by the memory type
requested
when the RawMemoryAccess
instance was created. If the memory is not cached,
this method guarantees serialized access (that is, the memory access at the memory
occurs in the same order as in the program. Multiple writes to the same location
may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw memory area
at which to write the integer.value
- The float to write.
OffsetOutOfBoundsException
- Thrown if the offset is negative or greater than the size of the
raw memory area. The role of the SizeOutOfBoundsException
somewhat overlaps
this exception since it is thrown if the offset is within the object but outside the
mapped area. (See RawMemoryAccess.map(long base, long size)
).
SizeOutOfBoundsException
- Thrown if the object is not mapped,
or if the float falls in an invalid address range.
SecurityException
- Thrown if this access is
not permitted by the security manager.public void setFloats(long offset, float[] floats, int low, int number)
number
floats starting at the given offset in the memory area
associated with this object from the
float array passed starting at position low
.
On most processor architectures each aligned float can be stored in an atomic operation, but
this is not required.
Caching of the memory access is controlled by the memory type
requested
when the RawMemoryAccess
instance was created. If the memory is not cached,
this method guarantees serialized access (that is, the memory access at the memory
occurs in the same order as in the program. Multiple writes to the same location
may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw memory area
at which to start writing.floats
- The array from which the items are obtained.low
- The offset which is the starting point in the given array for the
items to be obtained.number
- The number of floats to write.
OffsetOutOfBoundsException
- Thrown if the offset is negative or greater than the size of the
raw memory area. The role of the SizeOutOfBoundsException
somewhat overlaps
this exception since it is thrown if the offset is within the object but outside the
mapped area. (See RawMemoryAccess.map(long base, long size)
).
SizeOutOfBoundsException
- Thrown if the object is not mapped,
or if the float falls in an invalid address range. This is checked at every
entry in the array to allow for the possibility that the memory area
could be unmapped or remapped. The store of the array into memory could, therefore, be
only partially complete if the raw memory is unmapped or remapped mid-method.
ArrayIndexOutOfBoundsException
- Thrown if low
is less than 0 or greater
than bytes.length - 1
, or if low + number
is greater than or
equal to bytes.length
.
SecurityException
- Thrown if this access is
not permitted by the security manager.
|
SunSPOT API V4.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |