home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / CSWITCH.ZIP / TCB.H < prev    next >
C/C++ Source or Header  |  1990-07-02  |  3KB  |  65 lines

  1. /*
  2. ** Task Control Block (TCB) structure, along with other related
  3. ** memory structures for the Adept Multi-Tasker
  4. **
  5. ** Copyright 1990 Herb Rose
  6. **
  7. */
  8.  
  9. #define maxtasks 32
  10. #define num_mcbs 512
  11.  
  12. struct tcb_rec {
  13.     int     next_tcb;   /* tcbs are arranged as a table, this is next index */
  14.     int     base_pri;   /* base priority */
  15.     int     cur_pri;    /* current priority */
  16.     int     runcount;   /* how many times to run before swapping out */
  17.     unsigned int     stackseg;
  18.     unsigned int     stackptr;
  19.     int     mcb_ptr;    /* first mcb */
  20.     int     tcbflags;   /* various state flags */
  21.     int     cur_state;  /* numerical value for task state */
  22.     int     sem_wait_num;
  23.     unsigned int mcbs_in_use;    /* doubles as the logical page count */
  24.     unsigned int mcbs_avail;     /* doubles as the free paras if swappable */
  25.     unsigned int expused;       /* expanded memory allocated by cswitch */
  26.     unsigned int expfree;       /* free expanded memory */
  27.     unsigned int dtaseg;    /* this guys disk transfer area - segment */
  28.     unsigned int dtaoff;    /* dta offset   */
  29.     unsigned int pspseg;    /* our psp segment */
  30.     int     load_status;    /* status of last 'loadtask' call */
  31.     int     handle;
  32.     char    tcbname[10];
  33.     };
  34.  
  35. #define st_free    -1   /* this tcb not being used */
  36. #define st_active   0   /* the runner */
  37. #define st_ready    1   /* ready to run */
  38. #define st_sem_wait 2   /* waiting for a semaphore */
  39. #define st_delay    3   /* task is delaying */
  40. #define st_suspend  4   /* task is suspended - needs a wakeup signal */
  41. #define st_msg_wait 5   /* task is waiting for a message */
  42. #define st_stopping 6   /* task is terminating */
  43. #define st_swapout  7   /* task is currently swapped out */
  44.  
  45. /* the following are bit values for the flags word */
  46.  
  47. #define fl_no_swap  1   /* when this task is the runner, do not task swap */
  48. #define fl_in_dos   2   /* this task is in dos */
  49. #define fl_in_emm   4   /* this task executes in emm */
  50. #define fl_spawned  8   /* this task created with spawn */
  51.  
  52. struct mem_ctrl_block {
  53.     int fwd_link;       /* index of next tcb */
  54.     unsigned int actlen;         /* actual length of data (for message queues) */
  55.     unsigned int m_size;         /* number of paragraphs */
  56.     unsigned int m_address;      /* the segment address */
  57.     };
  58.  
  59. struct msgq_rec {
  60.     int mmcb[2];    /* hoq and toq mcbs for messages */
  61.     int mtcb;       /* same for tcbs */
  62.     };
  63.  
  64.  
  65.