00001 // scheduler.h 00002 // Data structures for the thread dispatcher and scheduler. 00003 // Primarily, the list of threads that are ready to run. 00004 // 00005 // Copyright (c) 1992-1993 The Regents of the University of California. 00006 // All rights reserved. See copyright.h for copyright notice and limitation 00007 // of liability and disclaimer of warranty provisions. 00008 00009 #ifndef SCHEDULER_H 00010 #define SCHEDULER_H 00011 00012 #include "copyright.h" 00013 #include "list.h" 00014 #include "thread.h" 00015 00016 // The following class defines the scheduler/dispatcher abstraction -- 00017 // the data structures and operations needed to keep track of which 00018 // thread is running, and which threads are ready but not running. 00019 00020 class Scheduler { 00021 public: 00022 Scheduler(); // Initialize list of ready threads 00023 ~Scheduler(); // De-allocate ready list 00024 00025 void ReadyToRun(Thread* thread); // Thread can be dispatched. 00026 Thread* FindNextToRun(); // Dequeue first thread on the ready 00027 // list, if any, and return thread. 00028 void Run(Thread* nextThread); // Cause nextThread to start running 00029 void Print(); // Print contents of ready list 00030 00031 private: 00032 List *readyList; // queue of threads that are ready to run, 00033 // but not running 00034 }; 00035 00036 #endif // SCHEDULER_H
1.2.14 written by Dimitri van Heesch,
© 1997-2002