2 * On my
400MhZ system
, thread
-switch
10000000 takes
4.98s
, which comes out to
3 * 2,008,032 switches per second
.
13 datatype t
= T
of (int * t
) Thread
.t
15 val done
: Thread
.Runnable
.t option ref
= ref NONE
17 fun loop (n
: int, T t
): unit
=
19 then switch (fn _
=> valOf (!done
))
22 val (n
, t
) = switch (fn t
' => prepare (t
, (n
- 1, T t
')))
30 case CommandLine
.arguments () of
32 | s
:: _
=> valOf (Int.fromString s
)
35 (done
:= SOME (prepare (cur
, ()))
36 ; prepare (new loop
, (numSwitches
, T (new loop
)))))
44 * ("thread-switch", fn _
=> (Main
.main(); OS
.Process
.success
))