/usr/share/doc/ats-lang-anairiats-examples/examples/TEST/libc_sched.dats is in ats-lang-anairiats-examples 0.2.5-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | (*
** some testing code for functions declared in
** libc/SATS/sched.sats
*)
//
// Author: Hongwei Xi (hwxi AT cs DOT bu DOT edu)
// Time: April, 2010
//
(* ****** ****** *)
staload "libc/SATS/sched.sats"
staload TYPES = "libc/sys/SATS/types.sats"
macdef pid_t = $TYPES.pid_of_int
extern fun ncore_get (): int
implement ncore_get () = let
var cs: cpu_set0_t // uninitialized
prval () = cpusetinit (cs) // not a real initialization
stavar nset: int
val nset = cpusetsize_get (cs)
val () = (print "nset = "; print nset; print_newline ())
val err = sched_getaffinity ((pid_t)0, nset, cs)
val () = assert_errmsg (nset >= 2, #LOCATION)
var count: Nat = 0
var i: Nat // uninitialized
val () = for* (cs: cpu_set_t nset) =>
(i := 0; i < 16; i := i + 1)
if (CPU_ISSET (i, cs) > 0) then (count := count + 1)
// end of [val]
in
count
end // end of [ncore_get]
(* ****** ****** *)
implement main () = () where {
val ncore = ncore_get ()
val () = (print "ncore = "; print ncore; print_newline ())
} // end of [main]
(* ****** ****** *)
(* end of [libc_sched.dats] *)
|