home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_04 / 8n04099a < prev    next >
Text File  |  1990-03-20  |  1KB  |  51 lines

  1.  
  2. ********************************************************
  3. This scheduler treats LEVEL1 as the highest level of priority.
  4. IDLE tests greater than all other levels. 
  5.  
  6. struct actions {
  7.    int priority;
  8.    void (*action)();
  9.    char * arg;
  10.    struct actions *nxtptr;
  11.    } ready [MAX_WAIT], next;
  12.  
  13. main ()
  14. {
  15. ...
  16. /* initiate interrupt handlers */
  17. while (TRUE){
  18.   clevel = IDLE;
  19.   do_loop();
  20.   }
  21. }
  22.  
  23. void do_loop()
  24. {
  25.  
  26. scheduler:
  27.  
  28.     if (clevel == LEVEL2) return;
  29.     else if ((clevel > LEVEL2) && (getnext(LEVEL2) != EMPTY)){
  30.          push (clevel);
  31.          clevel == LEVEL2; /*should be locked */
  32.          (*next.action)(next.arg);
  33.          clevel=pop();     /*lock*/
  34.          goto scheduler;
  35.          }
  36.     else if ((clevel > LEVEL3) && (getnext(LEVEL3) != EMPTY)){
  37.          push (clevel);
  38.          clevel == LEVEL3; /*lock*/
  39.          (*next.action)(next.arg);
  40.          clevel=pop();     /*lock*/
  41.          goto scheduler;
  42.          }
  43.     else return;
  44. }
  45.  
  46. *********************LISTING 6*************************
  47.  
  48.  
  49.  
  50.  
  51.