tac0S
Template Affectional Command Operating System
scheduler.h
Go to the documentation of this file.
1 
11 #ifndef SCHEDULER_H
12 #define SCHEDULER_H
13 
14 #include "copyright.h"
15 #include "list.h"
16 #include "thread.h"
17 
21 
22 class Scheduler
23 {
24  public:
25  Scheduler (); // Initialize list of ready threads
26  ~Scheduler (); // De-allocate ready list
27 
28  void ReadyToRun (Thread * thread); // Thread can be dispatched.
29  Thread *FindNextToRun (); // Dequeue first thread on the ready
30  // list, if any, and return thread.
31  void Run (Thread * nextThread); // Cause nextThread to start running
32  void Print (); // Print contents of ready list
33  bool RemoveThreadFromReadyList(Thread * threadToRemove); // Remove the thread of current readyList
34 
35  private:
36  List * readyList; // queue of threads that are ready to run,
37  // but not running
38 };
39 
40 #endif // SCHEDULER_H
The following class defines the scheduler/dispatcher abstraction – the data structures and operation...
Definition: scheduler.h:22
bool RemoveThreadFromReadyList(Thread *threadToRemove)
Scheduler::RemoveThreadFromReadyList Remove a specific thread from the ready list.
Definition: scheduler.cc:160
void ReadyToRun(Thread *thread)
Scheduler::ReadyToRun Mark a thread as ready, but not running. Put it on the ready list...
Definition: scheduler.cc:55
Scheduler()
Scheduler::Scheduler Initialize the list of ready but not running threads to empty.
Definition: scheduler.cc:31
~Scheduler()
Scheduler::~Scheduler De-allocate the list of ready threads.
Definition: scheduler.cc:41
void Run(Thread *nextThread)
Scheduler::Run Dispatch the CPU to nextThread. Save the state of the old thread, and load the state o...
Definition: scheduler.cc:92
The following class defines a "thread control block" – which represents a single thread of execution...
Definition: thread.h:79
Data structures for managing threads.
Definition: list.h:46
Routines to manage a singly-linked list of "things". Defining TRUE and FALSE is usually a Bad Idea...
void Print()
Scheduler::Print Print the scheduler state – in other words, the contents of the ready list...
Definition: scheduler.cc:151
Thread * FindNextToRun()
Scheduler::FindNextToRun Return the next thread to be scheduled onto the CPU. If there are no ready t...
Definition: scheduler.cc:72