home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_03 / 1103042a < prev    next >
Text File  |  1992-11-15  |  2KB  |  67 lines

  1. /****************************************************/
  2. /*                                                  */
  3. /*      SSX.H - things needed to use SSX            */
  4. /*      (stack swap executive)                      */
  5. /*                                                  */
  6. /*      By Tom Green and Dennis Cronin              */
  7. /*      10/19/92                                    */
  8. /*                                                  */
  9. /****************************************************/
  10.  
  11. /* function pointer */
  12. typedef void (*fptr)(void);
  13.  
  14. /* this is a wait_q structure */
  15. typedef struct wait_q{
  16.     void *task_ptr;
  17.     int mesg_flg;
  18. }wait_q;
  19.  
  20. /* SSX prototypes */
  21. int ssx_init(void);
  22. void ssx_run(void);
  23. void ssx_stop(void);
  24. int ssx_task_create(unsigned char task_pri,
  25.                   unsigned char task_id,fptr task_ptr,
  26.                   unsigned int stack_size,char *name);
  27. void ssx_task_delay(long ticks);
  28. int ssx_task_delete(unsigned char task_id);
  29. unsigned char ssx_change_priority(unsigned char
  30.                                    new_priority);
  31. void ssx_wait(wait_q *wqptr);
  32. int ssx_wait_with_alarm(wait_q *wqptr,long timeout);
  33. int ssx_alert(wait_q *wqptr);
  34. void ssx_clock_tick(void);
  35. void ssx_set_time(long ticks);
  36. long ssx_get_time(void);
  37. void ssx_lock(void);
  38. void ssx_unlock(void);
  39. void ssx_switch(void);
  40.  
  41. /* SSX status codes */
  42.  
  43. #define SUCCESS                 0
  44. /* task ID error */
  45. #define TID_ERR                 1
  46. /* message waiting error */
  47. #define MW_ERR                  2
  48. /* no TCBs error */
  49. #define TCB_ERR                 3
  50. /* could not allocate stack for task */
  51. #define STACK_ERR               4
  52. /* task timed out (wait_with_alarm)  */
  53. #define TO_ERR                  5
  54. /* error initializing SSX */
  55. #define INIT_ERROR              6
  56.  
  57. /* initialize semaphore to having waiting message */
  58. #define SET_SEMAPHORE(wqptr)    (wqptr)->mesg_flg=1; \
  59.                                 (wqptr)->task_ptr=NULL
  60.  
  61. /* 
  62.  * initialize wait_q to NULL task_ptr and no
  63.  * message waiting
  64.  */
  65. #define INIT_WAIT_Q(wqptr)      (wqptr)->mesg_flg=0; \
  66.                                 (wqptr)->task_ptr=NULL
  67.