              <<< VAXAXP::NOTES$:[NOTES$LIBRARY]VMSNOTES.NOTE;1 >>>
               -< VAX and Alpha VMS - Digital Internal Use Only >-
================================================================================
Note 178.7                10 ms Time-base still there?                   7 of 17
XDELTA::HOFFMAN "Steve, OpenVMS Engineering"         40 lines  24-MAY-1996 14:12
                       -< sys$hiber/sys$schdwk example >-
--------------------------------------------------------------------------------

   sys$setimr and/or sys$schdwk could be used, as could device interrupts
   from an external clock peripheral.  sys$creprc isn't involved in this
   process -- I would not use sys$creprc for any operations even remotely
   approaching a 10ms interval.  For very short intervals, I'd tend to
   move directly into the timer queue (TQEs), and into system space.
    
   Something like this should be pretty close to what you need, tho' I have
   not tested this code, and it's certainly not good for 10ms intervals...

#include <descrip.h>
#include <ssdef.h>
#include <starlet.h>
#include <stdio.h>
#include <stsdef.h>
#include <lib$routines.h>

int main(int argc, char **argv )
  {
  int RetStat;
  $DESCRIPTOR( DateTimeText, "0 ::10");
  int DateTimeQuad[2];

  RetStat = sys$bintim( &DateTimeText, DateTimeQuad );
  if (!$VMS_STATUS_SUCCESS( RetStat )) lib$signal( RetStat );

  RetStat = sys$schdwk( 0, 0, DateTimeQuad, DateTimeQuad );
  if (!$VMS_STATUS_SUCCESS( RetStat )) lib$signal( RetStat );

  printf("Commencing Hibernation...\n");

  for (1;1;1)
    {
    RetStat = sys$hiber();
    if (!$VMS_STATUS_SUCCESS( RetStat )) lib$signal( RetStat );
    printf("Awakened; going back to sleep\n");
    }
          
  return SS$_NORMAL;
  }
