compiler/
kernel/
lib/
scripts/
seed/
sublime/
test/
acceptance/
boot/
bootstrap/
cycles/
dispatch/
loader/
mmio/
native/
packages/
pages/
runtime/
kernel/
machine.ras
1.1 KiB
run
2.5 KiB
spin.rad
1.8 KiB
scheduling/
shared/
slots/
smp/
support/
sync/
termination/
tests/
trap/
package-golden
1.6 KiB
run
3.1 KiB
runner.rad
10.5 KiB
vim/
.gitignore
336 B
.gitsigners
112 B
CONTRIBUTING
2.1 KiB
LICENSE
1.1 KiB
Makefile
9.2 KiB
README
2.5 KiB
STYLE
2.5 KiB
std.lib
1.5 KiB
std.lib.test
662 B
test/runtime/spin.rad
raw
| 1 | //! Scheduled runtime compilation and an independent window witness. |
| 2 | export mod abi; |
| 3 | export mod sys; |
| 4 | |
| 5 | /// Startup fields used by the scheduled fixture. |
| 6 | record Request: Copy { |
| 7 | /// Readable binary package capability. |
| 8 | source: u64, |
| 9 | /// Complete binary package byte count. |
| 10 | length: u64, |
| 11 | /// Shared progress counters. |
| 12 | progress: *unsafe mut u64, |
| 13 | } |
| 14 | |
| 15 | /// Values supplied at domain activation. |
| 16 | record Env: Copy { |
| 17 | /// Input handle, byte count, and shared progress address. |
| 18 | argsPointer: *Request, |
| 19 | /// Actor index selected by the parent. |
| 20 | argsSize: u64, |
| 21 | /// Event capability installed at creation. |
| 22 | eventsHandle: u64, |
| 23 | /// Shared event queue address. |
| 24 | eventsPointer: u64, |
| 25 | } |
| 26 | |
| 27 | /// Compile a package twice or record progress during another domain's load. |
| 28 | @default unsafe fn main(env: *Env) { |
| 29 | let args = env.argsPointer; |
| 30 | let progress = @sliceOf(args.progress, 4); |
| 31 | let actor = env.argsSize as u32; |
| 32 | if actor == 2 { |
| 33 | assert progress[1] == 1; |
| 34 | let mut busy = false; |
| 35 | try sys::imageLoad(abi::Handle(0), abi::Handle(args.source), 0, args.length) catch error { |
| 36 | assert error == abi::Error::Busy; set busy = true; |
| 37 | }; |
| 38 | assert busy; |
| 39 | set progress[2] = 1; |
| 40 | return; |
| 41 | } |
| 42 | set progress[actor] = 1; |
| 43 | let image = try sys::imageLoad(abi::Handle(0), abi::Handle(args.source), 0, args.length) catch error { |
| 44 | set progress[actor] = 100 + error as u64; return; |
| 45 | }; |
| 46 | let info = try! sys::queryImage(image); |
| 47 | let repeated = try sys::imageLoad(abi::Handle(0), abi::Handle(args.source), 0, args.length) catch error { |
| 48 | set progress[actor] = 200 + error as u64; return; |
| 49 | }; |
| 50 | assert (try! sys::queryImage(repeated)).id == info.id; |
| 51 | set progress[3] = info.id; |
| 52 | set progress[actor] = 2; |
| 53 | } |