home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_10 / 8n10121a < prev    next >
Text File  |  1990-08-29  |  5KB  |  166 lines

  1. #define   _INTRPT_      0x7f
  2.  
  3. /* This structure is used to hold status information
  4.    on a process */
  5.  
  6. struct   _statusT
  7.    {
  8.       int                   kill_flag :2;
  9.       int                   wait_flag :2;
  10.       int                   fill_flag :12;
  11.    };
  12.  
  13.  
  14.  
  15. /* This structure holds all of the information that
  16.    defines a processes context */
  17.  
  18. struct   _simprocessT
  19.    {
  20.       struct _simprocessT   *next;
  21.       struct _simprocessT   *prev;
  22.       int                   init;
  23.       int                   proc_id;
  24.       struct _statusT       status;
  25.       unsigned   long          start_time;
  26.       void                  *waitpost;
  27.       int                   reg_ax;
  28.       int                   reg_bx;
  29.       int                   reg_cx;
  30.       int                   reg_dx;
  31.       int                   reg_es;
  32.       int                   reg_ds;
  33.       int                   reg_si;
  34.       int                   reg_di;
  35.       int                   reg_bp;
  36.       int                   reg_sp;
  37.       int                   reg_ss;
  38.       int                   reg_cs;
  39.       int                   reg_ip;
  40.       int                   reg_flag;
  41.    };
  42.  
  43. typedef   struct   _simprocessT * pprocess;
  44.  
  45. /* this is the interprocess communications structure, for
  46.    communications and synchronization */
  47.  
  48. struct   _postT
  49.    {
  50.       struct _postT         *next;
  51.       struct _postT         *prev;
  52.       char                   name[30];
  53.       int                   handle;
  54.       void                  *value;
  55.       pprocess               *waiting;
  56.    };
  57.  
  58.  
  59. /*      Process header block list, which is circular */
  60.  
  61. struct   _simprocessT   *processlist;
  62.  
  63.  
  64. /*      This process responds to the keyboard */
  65.  
  66. struct   _simprocessT   *kbprocess;
  67. int                      set_kb_process = 0;
  68.  
  69. /*      Total number of process */
  70.  
  71. int                      totalprocs = 1;
  72.  
  73.  
  74. /*      List of all current posts   */
  75.  
  76. struct   _postT         *postlist;
  77.  
  78. /*      Total number of posts in the system */
  79.  
  80. int      unsigned          totalposts;
  81.  
  82.  
  83. /*      Storage for the original interrupt vector,
  84.       which is replaced by task_handler*/
  85.  
  86. void      interrupt  (*old_vector)();
  87.  
  88.  
  89. /*      Globals used by setup_task  */
  90.  
  91. int                   _sim_init_val = 2;
  92. int                   glbl_sp;
  93. int                   glbl_ss;
  94. int                   glbl_bp;
  95. void                 (*glbl_fc)(void) = NULL;
  96.  
  97.  
  98. /*      Quick way to the system timer   */
  99.  
  100. long      unsigned      *systimer = MK_FP(0x0040,0x006c);
  101.  
  102.  
  103. /*      Simulation Time used by system */
  104.  
  105. long   unsigned          _sim_system_time;
  106.  
  107. long   unsigned          _last_update_time;
  108.  
  109.  
  110. /*      Simulation Time ratio used by system */
  111.  
  112. float                   _sim_time_ratio = 0;
  113.  
  114.  
  115. /*      Hidden routines handle installation of task
  116.       switcher, and actual task switching */
  117.  
  118. int               install_handler   (void);
  119. void   interrupt   task_handler      (unsigned bp,unsigned di,
  120.                                      unsigned si,unsigned ds,
  121.                                      unsigned es,unsigned dx,
  122.                                      unsigned cx,unsigned bx,
  123.                                      unsigned ax,unsigned ip,
  124.                                      unsigned cs,unsigned flags);
  125. void               sim_start         (void);
  126.  
  127.  
  128. /*      Simulation time available to programmer */
  129.  
  130. long   unsigned          CurrentTime;    /* Visible to programs */
  131.  
  132.  
  133. /*      Visible routine for process control   */
  134.  
  135. int               start_kb_process   (void   (*func)(void),int stacksize);
  136. int               start_process      (void   (*func)(void),int stacksize);
  137. void               stop_process      (int process_id);
  138. int               my_process_id      (void);
  139.  
  140.  
  141. /*      Visible routines for control of process time utilivation */
  142.  
  143. int               wait_until_time   (long unsigned   starttime);
  144. int               wait_for_time      (float   delaytime);
  145.  
  146.  
  147. /*      Sets the sim time to real time ratio - maximum running speed.
  148.       If this is set to 0.0, the system will run as fast as possible */
  149.  
  150. int               set_time_ratio      (float ratio);
  151.  
  152.  
  153. /*      Visible routines for the handling of posts */
  154.  
  155. int               init_post         (char   *postname);
  156. int               set_post          (int    posthandle,void   *pointer);
  157. void              *get_post            (int    posthandle);
  158. void              *wait_post         (int    posthandle);
  159.  
  160.  
  161. /*      Exiting the system, and cleaning up the interrupts
  162.       reports the value of the exit condition before
  163.       exiting, useful for signalling certain errors */
  164.  
  165. void               exit_processing   (int condition);
  166.