comp.lang.ada
 help / color / mirror / Atom feed
* Concurrent access to packed arrays
@ 2001-01-21 10:59 Florian Weimer
  2001-01-21 16:00 ` Robert Dewar
       [not found] ` <3A71447B.A2082CA3@mac.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Florian Weimer @ 2001-01-21 10:59 UTC (permalink / raw)


For simplicity, assume the array is of type String.  Some machines
(early Alphas?) do not offer load/store functions for individual
octets, so the characters of a string might not be independently
addressable.  Now suppose we have a string object and a variable which
indicates the last position in the string which has been written:

        The_String : String (1 .. Some_Maximum);
        Last_Written : Natural;
        pragma Atomic (Last_Written);

Task A1, A2, ... make a copy of Last_Written and read data from
The_String (1 .. Copy_Of_Last_Written).  Task B continues to write to
The_String (Last_Written + 1 .. Some_Maximum) and update Last_Written.
This might result in concurrent read and write access to the same
memory location, but I think this will work anyway because task B
writes to the location without changing the part interpreted by the
reading tasks.  However, according to the Ada standard, this scenario
results in erroneous execution.

Now my question: Are there in fact platforms where this doesn't work?
Shall I play safe and apply pragma Atomic_Components (and use an
unpacked array instead of a packed one)?



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-01-27 23:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-21 10:59 Concurrent access to packed arrays Florian Weimer
2001-01-21 16:00 ` Robert Dewar
     [not found] ` <3A71447B.A2082CA3@mac.com>
2001-01-27 16:37   ` Florian Weimer
2001-01-27 23:06     ` Mats Weber
2001-01-27 23:56       ` Robert Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox