RawMemory
.@Deprecated public class RawMemoryFloatAccess extends RawMemoryAccess
See RawMemoryAccess
for commentary on changes in the
preferred use of this class following RTSJ 2.0.
By default, the byte addressed by offset
is the byte
at the lowest address of the floating point processor's floating
point representation. When 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 when 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 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, indicating 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 and Description |
---|
RawMemoryFloatAccess(java.lang.Object type,
long size)
Deprecated.
Constructs an instance of
RawMemoryFloatAccess with the given
parameters, and sets the object to the mapped state. |
RawMemoryFloatAccess(java.lang.Object type,
long base,
long size)
Deprecated.
Constructs an instance of
RawMemoryFloatAccess with the
given parameters, and sets the object to the mapped state. |
Modifier and Type | Method and Description |
---|---|
double |
getDouble(long offset)
Deprecated.
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)
Deprecated.
Gets
number doubles starting at the given offset in
the memory area associated with this object and assigns them to the
double array passed starting at position low . |
float |
getFloat(long offset)
Deprecated.
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)
Deprecated.
Gets
number floats starting at the given offset in the
memory area associated with this object and assign them to the
floats array passed starting at position low . |
void |
setDouble(long offset,
double value)
Deprecated.
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)
Deprecated.
Sets
number doubles starting at the given offset in
the memory area associated with this object from the doubles array
passed starting at position low . |
void |
setFloat(long offset,
float value)
Deprecated.
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)
Deprecated.
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 . |
public RawMemoryFloatAccess(java.lang.Object type, long base, long size)
RawMemoryFloatAccess
with the
given parameters, and sets the object to the mapped state. When the
platform supports virtual memory, maps 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. The attributes of the mapping operation are controlled
by the vMFlags and vMAttributes of the
PhysicalMemoryTypeFilter
objects that matched this
object's type
parameter. (See
PhysicalMemoryTypeFilter.getVMAttributes()
and
PhysicalMemoryTypeFilter.getVMFlags()
.
type
- An instance of Object
representing the
type of memory required, e.g., dma, shared,
for defining the base address and controlling the
mapping. When the required memory has more than one
attribute, type
may be an array of
objects. When type
is null
or a
reference to an array with no entries, any type of memory
is acceptable. Note that type
values are
compared by reference (==), not by value
(equals
).base
- The physical memory address of the region.size
- The size of the area in bytes.StaticSecurityException
- when the application doesn't have
permissions to access physical memory, the
specified range of addresses, or the given type of memory.OffsetOutOfBoundsException
- when the address is invalid.SizeOutOfBoundsException
- when the size is negative or
extends into an invalid range of memory.UnsupportedPhysicalMemoryException
- when the underlying
hardware does not support the given type, or when no matching
PhysicalMemoryTypeFilter
has been registered with
the PhysicalMemoryManager
.MemoryTypeConflictException
- when the specified base does not point to
memory that matches the request type, or when type
specifies incompatible memory attributes.java.lang.OutOfMemoryError
- when the requested type of memory exists, but there is
not enough of it free to satisfy the request.public RawMemoryFloatAccess(java.lang.Object type, long size)
RawMemoryFloatAccess
with the given
parameters, and sets the object to the mapped state.
When the platform supports virtual memory, maps
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. The attributes of the mapping operation are controlled
by the vMFlags and vMAttributes of the
PhysicalMemoryTypeFilter
objects that matched this
object's type
parameter. (See
PhysicalMemoryTypeFilter.getVMAttributes()
and
PhysicalMemoryTypeFilter.getVMFlags()
.
type
- An instance of Object
representing the
type of memory required, e.g., dma, shared),
for defining the base address and controlling the
mapping. When the required memory has more than one
attribute, type
may be an array of
objects. When type
is null
or a
reference to an array with no entries, any type of memory
is acceptable. Note that type
values are
compared by reference (==), not by value
(equals
).size
- The size of the area in bytes.StaticSecurityException
- when the application doesn't have
permissions to access physical memory, the specified
range of addresses, or the given type of memory.SizeOutOfBoundsException
- when the size is negative or
extends into an invalid range of memory.UnsupportedPhysicalMemoryException
- when the underlying
hardware does not support the given type, or when no
matching PhysicalMemoryTypeFilter
has been
registered with the PhysicalMemoryManager
.MemoryTypeConflictException
- when the specified base does
not point to memory that matches the request type, or
when type
specifies incompatible memory
attributes.java.lang.OutOfMemoryError
- when the requested type of memory exists,
but there is not enough of it free to satisfy the
request.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. When 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 double.OffsetOutOfBoundsException
- when the offset is invalid.SizeOutOfBoundsException
- when the object is not mapped,
or when the double falls in an invalid address range.StaticSecurityException
- when 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 assigns them to the
double
array passed starting at position low
.
The loads are not required to be atomic even when they are located on natural boundaries.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When 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
- when 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 when the offset is within the
object but outside the
mapped area. (See RawMemoryAccess.map(long,long)
).SizeOutOfBoundsException
- when the object is not mapped, or
when 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 double
array could,
therefore, be partially updated when the raw memory is
unmapped or remapped mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is less than 0 or greater
than bytes.length - 1
, or when
low + number
is greater than or
equal to bytes.length
.StaticSecurityException
- when 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. When the float is aligned on a "natural"
boundary it is always loaded from memory in a single atomic
operation. When 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. When 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
- when 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 when the offset is
within the object but outside the mapped area. (See
RawMemoryAccess.map(long,long)
).SizeOutOfBoundsException
- when the object is not mapped, or
when the float falls in an invalid address range.StaticSecurityException
- when 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
floats
array passed starting at position low
.
When 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.
When 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. When 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 load.OffsetOutOfBoundsException
- when 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 when the offset is within the
object but outside the
mapped area. (See RawMemoryAccess.map(long,long)
).SizeOutOfBoundsException
- when the object is not mapped, or
when 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 float
array could, therefore,
be partially updated when the raw memory is unmapped or
remapped mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is
less than 0 or greater than bytes.length - 1
,
or when low + number
is greater than
or equal to bytes.length
.StaticSecurityException
- when 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 when 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. When 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
- when 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 when the offset is within the
object but outside the
mapped area. (See RawMemoryAccess.map(long,long)
).SizeOutOfBoundsException
- when the object is not mapped,
or when the double falls in an invalid address range.StaticSecurityException
- when 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 doubles
array
passed starting at position low
. Even when 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. When 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
- when 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 when the offset is
within the object but outside the mapped area. (See
RawMemoryAccess.map(long,long)
).SizeOutOfBoundsException
- when the object is not mapped, or
when 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 when the raw memory is
unmapped or remapped mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is less than 0 or greater
than bytes.length - 1
, or when
low + number
is greater than or
equal to bytes.length
.StaticSecurityException
- when 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. When 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 float.value
- The float to write.OffsetOutOfBoundsException
- when 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 when the offset is
within the object but outside the mapped area. (See
RawMemoryAccess.map(long,long)
).SizeOutOfBoundsException
- when the object is not mapped, or
when the float falls in an invalid address range.StaticSecurityException
- when 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. When 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
- when 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 when the offset is
within the object but outside the mapped area. (See
RawMemoryAccess.map(long, long)
).SizeOutOfBoundsException
- when the object is not mapped, or
when 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 store of the array into memory could,
therefore, be only partially complete when the raw memory
is unmapped or remapped mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is
less than 0 or greater than bytes.length -
1
, or when low + number
is greater than
or equal to bytes.length
.StaticSecurityException
- when this access is not permitted by the
security manager.