In this section, we describe how to define concurrent objects and associated schedulers.
A simple coroutine, as described in the previous sections retains control until it voluntarily gives up control by executing a suspend.
In this section, we introduce the notion of pre-emptive suspend - implying that execution of a coroutine may be pre-empted after a specific number of time units.
The statement R.attach(50) resumes execution of the coroutine R - and after 50 units of time, R is suspended. A subsequent R.attach(50) will resume execution of R at the point of suspension.
P1: = Process
P2: = Process
P3: = Process
The SimpleSystem object contains a Process pattern and three objects, P1, P2, and P3, subpatterned from Process.
The SimpleSystem alternates between executing the three Process objects and gives P1, P2 and P3, 50, 60 or 70 units of execution time respectively.
The SimpleSystem object is thus a simple scheduler for the three Process objects.
By using the above primitives/principles, it is possible to build concurrency abstractions implementing monitor-like systems, rendezvous-like systems (in the style of Ada and CSP), message-passing systems, Actor-like systems, etc. See the reference mentioned here for examples of this.