2 ms·
http://brinch-hansen.net/papers/1999b.pdf http://brinch-hansen.net/papers/1999b.pdf > Hoare (1972) had introduced the concept of a conditional critical region
by mrkeen 3y ago
http://brinch-hansen.net/papers/1999b.pdf http://brinch-hansen.net/papers/1999b.pdf
> Hoare (1972) had introduced the concept of a conditional critical region
that is delayed until a shared data structure satisfies a Boolean condition. In
a shared class, I expressed the same idea by means of an await statement,
which can occur anywhere within a critical region (Brinch Hansen 1972).
> At the time I was concerned about the inefficiency of conditional critical
regions which retest Boolean conditions repeatedly until they are true. As
an alternative I decided to let the programmer control the frequency with
which scheduling expressions are reevaluated. I did this by associating explicit
queues with shared variables. Critical regions can delay calling processes in
these queues and resume them later (Brinch Hansen 1972).
public void send(int m)
{ while (full == max) await(e);
This ended up as a feature in software transaction memory as the 'retry' function - without the inefficiency of busy-waiting and without the programmer needing to pick a frequency of scheduling:
send m = do
when (full == max) retry
https://hackage.haskell.org/package/stm-2.5.3.0/docs/Control-Monad-STM.html#v:retry https://hackage.haskell.org/package/stm-2.5.3.0/docs/Control...
> Retry execution of the current memory transaction because it has seen values in TVars which mean that it should not continue (e.g. the TVars represent a shared buffer that is now empty). The implementation may block the thread until one of the TVars that it has read from has been updated.