PreviousUpNext

15.4.1139  src/lib/std/src/nj/set-sigalrm-frequency.pkg

## set-sigalrm-frequency.pkg
#
# How often should the kernel send a SIGALRM signal to us?
# (Usually about 50Hz.)

# Compiled by:
#     src/lib/std/src/standard-core.sublib

# See also:
#     src/lib/std/src/internal-cpu-timer.pkg
#     src/lib/std/src/internal-wallclock-timer.pkg


# An interface to system interval timers.

stipulate

    package int =  int_guts;                                    # int_guts                              is from   src/lib/std/src/int-guts.pkg
    package w1i =  one_word_int_guts;                           # one_word_int_guts                     is from   src/lib/std/src/one-word-int-guts.pkg
    package ci  =  mythryl_callable_c_library_interface;        # mythryl_callable_c_library_interface  is from   src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg
    #
    fun cfun  fun_name
        =
        ci::find_c_function { lib_name => "heap", fun_name };
        #
        ###############################################################
        # The function(s) in this package should be called centrally,
        # called early, and preferably called seldom. (IMHO, ideally
        # never called.) 
        #
        # Consequently I'm not taking the time and effort to switch it
        # over from using find_c_function() to using find_c_function'().
        #                                  -- 2012-04-21 CrT
herein

    package   set_sigalrm_frequency
    : (weak)  Set_Sigalrm_Frequency                             # Set_Sigalrm_Frequency is from   src/lib/std/src/nj/set-sigalrm-frequency.api
    {
        fun tick ()
            =
            {   (tick' ()) ->   (s, us);
                #
                time_guts::from_microseconds
                    (w1i::to_multiword_int s * (int::to_multiword_int 1000000)  +  int::to_multiword_int us);
            }
            where
                my tick' : Void -> ((w1i::Int, Int))
                    =
                    cfun "interval_tick__unimplemented";        # Ultimately invokes   _lib7_runtime_interval_tick__unimplemented   in   src/c/lib/heap/interval-tick.c
                                                                # This is currently UNIMPLEMENTED.
            end;


        fun from_time_opt (THE time)
                =>
                {   usec =  time_guts::to_microseconds  time;
                    #
                    (multiword_int_guts::div_mod (usec, 1000000))
                        ->
                        (sec, usec);

                    THE ( w1i::from_multiword_int  sec,
                                   int::from_multiword_int  usec
                        );
                };

            from_time_opt NULL
                =>
                NULL;
        end;


        fun set_sigalrm_frequency  tim_opt
            =
            set_sigalrm_frequency' (from_time_opt  tim_opt)
            where
                my set_sigalrm_frequency':   Null_Or( (w1i::Int, Int) ) -> Void
                    =
                    cfun "set_sigalrm_frequency";                               # Ultimately invokes   do_set_sigalrm_frequency         in   src/c/lib/heap/libmythryl-heap.c
            end;
    };
end;




## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext