1
Some rough notes about the Oz threading model
2
=============================================
4
(almost verbatim from CTM)
9
Fair scheduling through round-robin.
11
With priority levels : three queues exist, which manage high, medium,
12
low priority threads. The time slice ratio for these is
13
100:10:1. Threads inherit the priority of their parent.
15
Mozart uses an external timer approach to implement thread preemption.
20
All these ops are defined in a Thread namespace/module.
22
this() -> current thread's name (*not* another thread's name)
23
state(t) -> return state of t in {runnable, blocked, terminated}
24
suspend(t) : suspend t
25
resume(t) : resume execution of t
26
preempt(t) : preempt t
27
terminate(t) : terminate t immediately
28
injectException(t, e) : raise exception e in t
29
setPriority(t, p) : set t's priority to p
31
Interestingly, coroutines can be build upon this thread
32
API. Coroutines have two ops : spawn and resume.
34
spawn(p) -> creates a coroutine with procedure p, returns pid
35
resume(c) : transfers control from current coroutine to c
37
The implementation of these ops in terms of the threads API is as
48
Thread.suspend(Thread.this())