@@ -33,16 +33,15 @@ accounts for their long form.
3333
3434A program consists of (at most) 5 pages, identified
3535by ` page_i: ` , where 1 <= i <= 5.
36- Each page identifier is followed by a (possibly empty)
37- sequence of rules RULE:
36+ Each page identifier appears at most once and
37+ is followed by a (possibly empty) sequence of rules RULE:
3838
3939```
4040page_i: RULE*
4141```
4242
4343Rules that are presented without a preceding page identifier
4444are added to page 1. Pages need not be presented in order.
45- Each page identifier can appear at most once.
4645
4746Each rule has an optional section WHEN and an optional section DO.
4847
@@ -152,8 +151,7 @@ Execution begins by transitioning (switching) to page 1.
152151The absence of an optional element/value in the when or do section of a rule
153152results in the use of a default element/value, as follows:
154153
155- - A rule with an empty do section never executes (no matching performed
156- on it).
154+ - A rule with an empty do section never executes (no matching performed on it).
157155- A rule with an empty when section defaults to start_page signal with no delay.
158156- Signal defaults are as follows
159157 - start_page defaults to no delay
@@ -187,7 +185,7 @@ Regardless of their origin, signals are ordered and processed one
187185at a time using a FIFO queue. Each signal has a name corresponding to
188186the signals named in the when section; a signal carries a payload, which
189187may be an event or a value. Some special kinds of signals are
190- used for timers, as detailed later.
188+ used for batch updates to variables and timers, as detailed later.
191189
192190### Resources and conflicts
193191
@@ -205,7 +203,7 @@ Actions have effects by writing to (updating) a resource, which are as follows:
205203If two rules have actions that update the same resource, they are said
206204to be in _ conflict_ if it is possible for them to execute at the same time.
207205
208- ### Rule matching
206+ ### Rule matching and execution
209207
210208Upon reception of a signal, it is first necessary to find the
211209rules that are _ enabled_ for execution by the signal. The first
@@ -237,10 +235,39 @@ T are started.
237235
238236### Updating state
239237
238+ We guarantee that all actions that are executed ` instantly ` will read from
239+ the same state, even if they update variables; we do so by
240+ queuing updates to variables for processing later, rather than applying
241+ updates immediately to the current state. By construction,
242+ updates to variables (or any other resource) are guaranteed not to conflict,
243+ so the order in which the instant actions are executed does not matter.
244+
245+ The set of updated variables and their (potentially new) values are processed
246+ together as follows: TBD - updates to variables are batched together in
247+ an aggregate-signal.
248+
240249### Switching pages
241250
251+ Rules from different pages should never execute simultaneously.
252+ When switching from the current page to another page N (even if the
253+ same), the following takes place
254+
255+ - pause generation and processing of signals
256+ - clear queue of all signals
257+ - halt all currently executing rules
258+ - set the current page to N
259+ - add start_page signal to queue
260+ - add aggregate signal for update of all variables to queue
261+ - start all timer-based rules
262+ - restore signal generation/processing
263+
242264### Timers
243265
266+ When section sets a timer, when it fires, we generate a special
267+ timer_fired signal that specifies the rule's index and waits to
268+ receive that signal (this is done as all actions must execute
269+ in response to signals rather than invisible transitions).
270+
244271## Example
245272
246273Here is the MicroCode program corresponding to
0 commit comments