comp.lang.ada
 help / color / mirror / Atom feed
* Re: Uninterruptible (atomic) operation?
@ 1996-12-09  0:00 W. Wesley Groleau (Wes)
  1996-12-09  0:00 ` Robert A Duff
  0 siblings, 1 reply; 11+ messages in thread
From: W. Wesley Groleau (Wes) @ 1996-12-09  0:00 UTC (permalink / raw)



:>  wwgrol> Can someone tell me the names if they exist of
:>  wwgrol> system calls to "hog the CPU" for a short time and release it.
:>
:> There are none (in general).
:>
:> Shared memory is only for use with *cooperating* processes. That is, you
:> know damn well all the processes are using the semaphore, because you wrote
:> them all. That's how it's done.

OK, let's put it another way:  The shared memory is updated only rarely,
but the reads are very frequent.  One of the processes reads it so often
that folks are concerned about the overhead.  The value they're reading
is used for communications timings.  If the writing process can "hog" the
cpu for the five to ten machine instructions necessary to do the writes,
then everyone else can "trust" the atomicity of the values.

(And if we used Ada-95 we could use pragma Atomic.)

(And if wishes were horses...)

---------------------------------------------------------------------------
W. Wesley Groleau (Wes)                                Office: 219-429-4923
Hughes Defense Communications (MS 10-40)                 Home: 219-471-7206
Fort Wayne,  IN   46808                  (Unix): wwgrol@pseserv3.fw.hac.com
---------------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Uninterruptible (atomic) operation?
@ 1996-12-11  0:00 W. Wesley Groleau (Wes)
  1996-12-09  0:00 ` John McCabe
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: W. Wesley Groleau (Wes) @ 1996-12-11  0:00 UTC (permalink / raw)



> In article <E25tK3.3G7@world.std.com> bobduff@world.std.com (Robert A Duff)
> writes:
>
>   > Pragma Atomic is essentially the same thing as Ada 83's pragma Shared.
>   > I don't think it's what you want in this case.
>
>   Actually this is the case where pragma Shared or pragma Atomic can
> be used, if supported for the object type.  Wes just needs to lock the
> value while it is being modified.  The trick is to have a lock which
> all the potential modifiers respect, and to use pragma Atomic, and
> Atomic reads and writes, so that the readers can trust the value they
> see.
>
>     (Potential) Writer:
>
>        Acquire(lock);
>        Temp := Atomic_Object;
>        -- operations on Temp...
>        Atomic_Object := Temp;
>        Release(lock);
>
>     Reader:
>
>        Temp := Atomic_Object;
>        -- use value in temp.

This is pretty close.  But why do we need the lock?  Isn't that implied
by Atomic/Shared?  LRM 83 9.11 (11) "each of direct reading and direct
updating is implemented as an individual implementation."

My (additional) problem is two-fold:

1. Typically, the hidden implementation of such is that a semaphore is
used during both write or read to keep out other writers and readers.
In the case of protected objects (which I can't use anyway, this is still
true, except multiple readers are allowed).  What I am trying to do,
is find a way for the writer to disable preemption, so that readers
are kept out even though the readers do not incur the overhead of the
semaphore.  That is, if the reader tries to read _during_the_write_
there will be a slight delay, but most of the time a read is as fast
as any other variable.

2. An Ada 83 (which I'm stuck with) solution to (1) may not work if
the reader and the writer are parts of independent Unix processes, and
the shared object is created by system calls.  At first, I thought of
the solution where the item shared is a pointer to the object, and
the writer could overwrite the pointer atomically, after non-atomically
updating/creating a new object.  Problem there is that the shared memory
is guaranteed to be the same address for all processes using it.  But
if it contains a pointer, the object pointed to in process X may be at
a virtual address that is used for something else by process Y.

---------------------------------------------------------------------------
W. Wesley Groleau (Wes)                                Office: 219-429-4923
Hughes Defense Communications (MS 10-40)                 Home: 219-471-7206
Fort Wayne,  IN   46808                  (Unix): wwgrol@pseserv3.fw.hac.com
---------------------------------------------------------------------------




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

end of thread, other threads:[~1996-12-13  0:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-12-09  0:00 Uninterruptible (atomic) operation? W. Wesley Groleau (Wes)
1996-12-09  0:00 ` Robert A Duff
1996-12-10  0:00   ` Bob Gilbert
1996-12-11  0:00   ` Robert I. Eachus
1996-12-11  0:00     ` Robert S. White
  -- strict thread matches above, loose matches on Subject: below --
1996-12-11  0:00 W. Wesley Groleau (Wes)
1996-12-09  0:00 ` John McCabe
1996-12-13  0:00   ` Robert Dewar
1996-12-12  0:00 ` Robert Dewar
1996-12-13  0:00 ` Robert I. Eachus
1996-12-13  0:00 ` J-P. Rosen

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