Skip to content

Commit

Permalink
Normative: Make the Atomics critical section imply synchronizes-with (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
syg committed Sep 9, 2019
1 parent fcae34e commit 543cc3b
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -36057,9 +36057,10 @@ <h1>ValidateAtomicAccess ( _typedArray_, _requestIndex_ )</h1>

<emu-clause id="sec-getwaiterlist" aoid="GetWaiterList">
<h1>GetWaiterList ( _block_, _i_ )</h1>
<p>A <dfn>WaiterList</dfn> is a semantic object that contains an ordered list of those agents that are waiting on a location (_block_, _i_) in shared memory; _block_ is a Shared Data Block and _i_ a byte offset into the memory of _block_.</p>
<p>A <dfn>WaiterList</dfn> is a semantic object that contains an ordered list of those agents that are waiting on a location (_block_, _i_) in shared memory; _block_ is a Shared Data Block and _i_ a byte offset into the memory of _block_. A WaiterList object also optionally contains a Synchronize event denoting the previous leaving of its critical section.</p>
<p>Initially a WaiterList object has an empty list and no Synchronize event.</p>
<p>The agent cluster has a store of WaiterList objects; the store is indexed by (_block_, _i_). WaiterLists are agent-independent: a lookup in the store of WaiterLists by (_block_, _i_) will result in the same WaiterList object in any agent in the agent cluster.</p>
<p>Operations on a WaiterList&mdash;adding and removing waiting agents, traversing the list of agents, suspending and notifying agents on the list&mdash;may only be performed by agents that have entered the WaiterList's critical section.</p>
<p>Operations on a WaiterList&mdash;adding and removing waiting agents, traversing the list of agents, suspending and notifying agents on the list, setting and retrieving the Synchronize event&mdash;may only be performed by agents that have entered the WaiterList's critical section.</p>
<p>The abstract operation GetWaiterList takes two arguments, a Shared Data Block _block_ and a nonnegative integer _i_. It performs the following steps:</p>
<emu-alg>
1. Assert: _block_ is a Shared Data Block.
Expand All @@ -36075,6 +36076,15 @@ <h1>EnterCriticalSection ( _WL_ )</h1>
<emu-alg>
1. Assert: The calling agent is not in the critical section for any WaiterList.
1. Wait until no agent is in the critical section for _WL_, then enter the critical section for _WL_ (without allowing any other agent to enter).
1. If _WL_ has a Synchronize event, then
1. NOTE: A _WL_ whose critical section has been entered at least once has a Synchronize event set by LeaveCriticalSection.
1. Let _execution_ be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
1. Let _eventsRecord_ be the Agent Events Record in _execution_.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
1. Let _entererEventList_ be _eventsRecord_.[[EventList]].
1. Let _enterEvent_ be a new Synchronize event.
1. Append _enterEvent_ to _entererEventList_.
1. Let _leaveEvent_ be the Synchronize event in _WL_.
1. Append (_leaveEvent_, _enterEvent_) to _eventRecords_.[[AgentSynchronizesWith]].
</emu-alg>
</emu-clause>

Expand All @@ -36083,6 +36093,12 @@ <h1>LeaveCriticalSection ( _WL_ )</h1>
<p>The abstract operation LeaveCriticalSection takes one argument, a WaiterList _WL_. It performs the following steps:</p>
<emu-alg>
1. Assert: The calling agent is in the critical section for _WL_.
1. Let _execution_ be the [[CandidateExecution]] field of the calling surrounding's Agent Record.
1. Let _eventsRecord_ be the Agent Events Record in _execution_.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
1. Let _leaverEventList_ be _eventsRecord_.[[EventList]].
1. Let _leaveEvent_ be a new Synchronize event.
1. Append _leaveEvent_ to _leaverEventList_.
1. Set the Synchronize event in _WL_ to _leaveEvent_.
1. Leave the critical section for _WL_.
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -36144,15 +36160,6 @@ <h1>NotifyWaiter ( _WL_, _W_ )</h1>
<emu-alg>
1. Assert: The calling agent is in the critical section for _WL_.
1. Assert: _W_ is on the list of waiters in _WL_.
1. Let _execution_ be the [[CandidateExecution]] field of the surrounding agent's Agent Record.
1. Let _eventsRecord_ be the Agent Events Record in _execution_.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier().
1. Let _agentSynchronizesWith_ be _eventsRecord_.[[AgentSynchronizesWith]].
1. Let _notifierEventList_ be _eventsRecord_.[[EventList]].
1. Let _waiterEventList_ be the [[EventList]] field of the element in _execution_.[[EventsRecords]] whose [[AgentSignifier]] is _W_.
1. Let _notifyEvent_ and _waitEvent_ be new Synchronize events.
1. Append _notifyEvent_ to _notifierEventList_.
1. Append _waitEvent_ to _waiterEventList_.
1. Append (_notifyEvent_, _waitEvent_) to _agentSynchronizesWith_.
1. Notify the agent _W_.
</emu-alg>
<emu-note>
Expand Down

0 comments on commit 543cc3b

Please sign in to comment.