home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / lan / soss.arj / INCLUDE / TASK.H < prev    next >
C/C++ Source or Header  |  1991-04-11  |  1KB  |  46 lines

  1. /* Copyright 1986 by Carnegie Mellon */
  2. /*  Copyright 1983 by the Massachusetts Institute of Technology  */
  3.  
  4. /* task.h
  5.     4/17/84 - Added tk_sleep().
  6.     5/23/84 - Added tk_exit(), guard words and context switch counting.
  7.                     <John Romkey>
  8. */
  9.  
  10. #ifndef TASK_H                /* DDP */
  11. #define TASK_H    1            /* DDP */
  12.  
  13. /* This file contains definitions for the IBM PC tasking package. */
  14.  
  15.  
  16. typedef    int    stack;            /* type of data in task stacks */
  17. typedef char    event;
  18.  
  19. typedef    struct    task    {    /* an IBM PC task - top of its stack */
  20.     stack    *tk_fp;            /* task's current frame ptr */
  21.     char    *tk_name;        /* the task's name */
  22.     int    ev_flg;            /* flag set if task is scheduled */
  23.     struct    task *tk_nxt;        /* pointer to next task */
  24.     unsigned tk_count;        /* number of wakeups */
  25.     unsigned *tk_guard;        /* pointer to lowest guardword */
  26.     unsigned tk_size;        /* stack size */
  27.     stack    tk_stack[1];        /* top of task's stack */
  28.     }    *Task;
  29.  
  30. typedef struct task task;
  31.  
  32. extern    struct    task    *tk_cur;    /* currently running task */
  33. extern    struct    task    *tk_init ();    /* initialize task system */
  34. extern    struct    task    *tk_fork ();    /* fork a new task */
  35. extern    unsigned TDEBUG;        /* tasking debugging */
  36. extern    long tk_wakeups;
  37.  
  38. /* Useful macro */
  39.  
  40. #define tk_wake(tk)     { (tk)->ev_flg = TRUE; tk_wakeups++; (tk)->tk_count++; }
  41. #define    tk_yield()    { tk_wake(tk_cur); tk_block(); }
  42.  
  43. #define    tk_setef(t, e)    { tk_wake((t)); *(e) = 1; }
  44. #define    tk_sleep(t)    t->ev_flg = FALSE
  45. #endif                    /* DDP */
  46.