The program workers
A demonstration of the lock and of the word wait.
One program, five threads, one queue of work. The first thread cuts a picture in tiles and puts all the tiles in the queue. Four threads take the tiles: each tile is computed by the thread that took it, and has the tint of this thread. A lock keeps the queue correct. A thread with no work waits on a word of memory; the first thread changes the word and wakes the four threads.
Before the picture, the four threads add to one number, first with the lock, then with no lock. With no lock, additions are lost.
| Fact | Value |
|---|---|
| Source | programs/workers |
| Boot image | in the boot image; the image is not built, so its size is not known |
| Imports | none |
| Imported by | none |
Exports
| Export | What it does |
|---|---|
| entry() |
Read from the source of the module, as the build reads it to describe the exports (tools/kerneltool/describe.odin).
What the root service gives it
| What | Value | As the root service says |
|---|---|---|
| Grants | {} | Not named in grants_of: the grants of each other program. |
| Budget: pages, programs, threads | {pages = 2048, programs = 1, threads = 9} |
Read from grants_of and things_of in programs/root/main.odin; budget_of in the same file adds the limits of processor time and of log records.
