## threadkit-driver-for-posix.pkg
#
# This package is used as a generic argument in
#
#
src/lib/src/lib/thread-kit/src/posix/thread-scheduler-control.pkg#
# to generic thread_scheduler_control_g from
#
#
src/lib/src/lib/thread-kit/src/glue/thread-scheduler-control-g.pkg# Compiled by:
#
src/lib/std/standard.libstipulate
package iom = io_now_possible_mailop; # io_now_possible_mailop is from
src/lib/src/lib/thread-kit/src/core-thread-kit/io-now-possible-mailop.pkg package pd = process_deathwatch; # process_deathwatch is from
src/lib/src/lib/thread-kit/src/process-deathwatch.pkg package is = interprocess_signals; # interprocess_signals is from
src/lib/std/src/nj/interprocess-signals.pkg package top = timeout_mailop; # timeout_mailop is from
src/lib/src/lib/thread-kit/src/core-thread-kit/timeout-mailop.pkg # interprocess_signals_guts is from
src/lib/std/src/nj/interprocess-signals-guts.pkgherein
package threadkit_driver_for_posix
: (weak) Threadkit_Driver_For_Os # Threadkit_Driver_For_Os is from
src/lib/src/lib/thread-kit/src/posix/threadkit-driver-for-os.api {
fun start_threadkit_driver ()
=
top::reset_sleep_queue_to_empty ();
#
fun wake_sleeping_threads_and_schedule_fd_io_and_harvest_dead_subprocesses__iu ()
# # This function is (only) called twice, from
= #
src/lib/src/lib/thread-kit/src/glue/threadkit-base-for-os-g.pkg {
top::wake_sleeping_threads_whose_time_has_come__iu ();
#
iom::add_any_new_fd_io_opportunities_to_run_queue__iu (); # The only call to this fn.
pd::harvest_exit_statuses_of_dead_subprocesses__iu (); # The only call to this fn.
};
# Function called when there is nothing else to do.
# If possible we block until something happens that generates
# work to do, then returns TRUE. (If there is no possibility of
# anything ever generating work to do we return FALSE, which means
# that it is time to exit() the program. This is considered an error
# condition.)
#
# This function is called exactly once,
# by no_runnable_threads_left__fate() in:
#
#
src/lib/src/lib/thread-kit/src/glue/threadkit-base-for-os-g.pkg #
fun block_until_some_thread_becomes_runnable ()
=
case (top::time_until_next_sleeping_thread_wakes ())
#
THE t => { # Eventually, we should just go to sleep
# for the specified time: XXX BUGGO FIXME
#
is::pause (); # Ultimately calls unix clib pause().
TRUE;
};
NULL => if ( iom::have_fds_on_io_watch ()
or pd::have_child_processes_on_deathwatch ()
)
is::pause ();
TRUE;
else
FALSE;
fi;
esac;
fun stop_threadkit_driver ()
=
top::reset_sleep_queue_to_empty ();
};
end;
## COPYRIGHT (c) 1989-1991 John H. Reppy
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.