Process/Coroutine Package in Java
University of Utah, Dec 1995
Warning:There are no fancy applets on this page,
click here to see some.
The code in divided in three packages, each of which can be reused
separately.
sim package:
- process.java,
scheduler.java
queues package:
- Queue,
PriorityQueue
(for historic reasons, all methods of this class are capitalized)
random package:
- rand,
erand, and
urand
For documentation generated by javadoc, see
here.
This is a straightforward port of the process.c/coroutine.c
library that uses Cthreads. A few points to note:
-
- all type checks have been removed as Java throws an exception
in this case.
-
- I got rid of rlink because I hated it. There is no limit on
the number of queues a process can be in. Similarly, there is
no need for carrier objects as they are internally provided
by the Queue class.
-
- Some functions have been removed as they don't fit in the Java model:
terminate_and_delete(), for instance.
Other functions have been omitted as there is no need for them anymore.
For instance, process::enqueue_proc(q) is simply
q.Enqueue(process)
-
- In general, functions and variables previously global such as
clock or current or activate() have become static members of the
scheduler class.
-
- there is no distinction between coroutines and processes anymore
-
- processes are implemented using Java threads, which interact
in a coroutine fashion. This is implemented using condition variables.
See Object.wait()
-
- Examples:
CPU scheduler with
test 1,
2, and
3
resource, a mutex implemented for processes with
a test
sieve, an coroutine-based implementation of
Erasthotenes' sieve.
carwash, a simulation of a car wash system.
powers, computing powers of n using DSS.
Condition variables with a
test,
Last change: Dec 14 1995