October 2024
Intermediate to advanced
272 pages
6h 54m
English
Occam processes are fantastic; Occam arrays are fabulous. Why don’t we combine them and get something even better—arrays of processes? Occam supports them via process replication.
Let’s look again at the code example and revisit the problem, “What if you want to multiplex N=128 channels? Should you copy the block N=128 times?” No, you should instruct Occam to replicate the highlighted block N times:
| | ALT |
| » | enabled.i & src.i ? x |
| » | dest ! x |
| » | ... |
The result is a process replication (also highlighted in the following example):
| | VAL N IS 128: |
| | PROC mux () |
| | CHAN OF INT dest: |
| | [N]CHAN OF INT src: |
| | [N]BOOL enabled: |
| | INT x: |
| | |
| | WHILE TRUE |
| | -- The replicated part |
| » | ALT i=0 FOR ... |
Read now
Unlock full access