home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 362_01 / test4.c < prev    next >
C/C++ Source or Header  |  1991-12-11  |  2KB  |  52 lines

  1. /*****************************************************************************
  2.  *                    test4.c                     *
  3.  *****************************************************************************
  4.  * DESCRIPTION:    Verification routine for the RMAXTask multitasking system.   *
  5.  *                                         *
  6.  *        Check of timeouts on get_mail(), etc.                 *
  7.  *                                         *
  8.  * REVISIONS:     3 JUL 90 - RAC - Original code                     *
  9.  *****************************************************************************/
  10.  
  11. #include    <dos.h>
  12. #include    <stdio.h>
  13. #include    "\rmaxtask\source\rmaxtask.h"
  14.  
  15. TDESC    *my_mailbox;
  16. TDESC    *my_semaphore;
  17.  
  18. int    break_handler() {
  19.     stop_RMAXTask();                /* Do 'about to die' cleanup */
  20.     printf("\nCtrl-Break pressed.  Program terminated.\n");
  21.     return 0;                    /* This will abort program */
  22.     }                        /* End break_handler() */
  23.  
  24. void tt() {
  25.  
  26.     unsigned    i;
  27.  
  28.     for (;;) {
  29.     wait_sem(my_semaphore, 18);
  30.     printf("TICK ");
  31.     get_mail(&i, &i, my_mailbox, 18, 0);
  32.     printf("TOCK ");
  33.     }
  34.     }    
  35.     
  36. void main() {
  37.  
  38.     int        i;                /* Generic temp */
  39.  
  40.     start_RMAXTask();
  41.     ctrlbrk(break_handler);            /* Establish break handler */
  42.     my_mailbox = create_mailbox();
  43.     my_semaphore = create_sem(0);
  44.     create_task("tt", tt, STANDARD_PRIORITY, STANDARD_STACK);
  45.     for (i=1; i<=8; i++) {
  46.     printf("\nSuspending for %d seconds ", i);
  47.     wait_key(18 * i);
  48.     }    
  49.     stop_RMAXTask();                /*  a key is pressed */
  50.     printf("\nDone with main task.\n");
  51.     }
  52.