2011-03-25 14:19:20 -05:00
|
|
|
// xfail-stage0
|
2011-05-03 20:13:51 -05:00
|
|
|
// xfail-stage1
|
|
|
|
// xfail-stage2
|
2010-06-23 23:03:09 -05:00
|
|
|
// This checks that preemption works.
|
|
|
|
|
2011-04-19 15:35:49 -05:00
|
|
|
fn starve_main(chan[int] alive) {
|
2010-06-23 23:03:09 -05:00
|
|
|
log "signalling main";
|
|
|
|
alive <| 1;
|
|
|
|
log "starving main";
|
|
|
|
let int i = 0;
|
|
|
|
while (true) {
|
|
|
|
i += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-19 15:35:49 -05:00
|
|
|
fn main() {
|
2010-06-23 23:03:09 -05:00
|
|
|
let port[int] alive = port();
|
|
|
|
log "main started";
|
|
|
|
let task s = spawn starve_main(chan(alive));
|
|
|
|
let int i;
|
|
|
|
log "main waiting for alive signal";
|
|
|
|
i <- alive;
|
|
|
|
log "main got alive signal";
|
2010-07-22 17:05:35 -05:00
|
|
|
while (i < 50) {
|
2010-06-23 23:03:09 -05:00
|
|
|
log "main iterated";
|
|
|
|
i += 1;
|
|
|
|
}
|
|
|
|
log "main completed";
|
|
|
|
}
|