Initial version
This commit is contained in:
commit
6f405265a5
102 changed files with 14486 additions and 0 deletions
39
code/threads/scheduler.h
Normal file
39
code/threads/scheduler.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
// scheduler.h
|
||||
// Data structures for the thread dispatcher and scheduler.
|
||||
// Primarily, the list of threads that are ready to run.
|
||||
//
|
||||
// Copyright (c) 1992-1993 The Regents of the University of California.
|
||||
// All rights reserved. See copyright.h for copyright notice and limitation
|
||||
// of liability and disclaimer of warranty provisions.
|
||||
|
||||
#ifndef SCHEDULER_H
|
||||
#define SCHEDULER_H
|
||||
|
||||
#include "copyright.h"
|
||||
#include "list.h"
|
||||
#include "thread.h"
|
||||
|
||||
// The following class defines the scheduler/dispatcher abstraction --
|
||||
// the data structures and operations needed to keep track of which
|
||||
// thread is running, and which threads are ready but not running.
|
||||
|
||||
class Scheduler:public dontcopythis
|
||||
{
|
||||
public:
|
||||
Scheduler (); // Initialize list of ready threads
|
||||
void Stop (); // Prevent further context switches
|
||||
~Scheduler (); // De-allocate ready list
|
||||
|
||||
void ReadyToRun (Thread * thread); // Thread can be dispatched.
|
||||
Thread *FindNextToRun (); // Dequeue first thread on the ready
|
||||
// list, if any, and return thread.
|
||||
void Run (Thread * nextThread); // Cause nextThread to start running
|
||||
void Print (); // Print contents of ready list
|
||||
|
||||
private:
|
||||
List * readyList; // queue of threads that are ready to run,
|
||||
// but not running
|
||||
bool halted; // Whether we should prevent context switches
|
||||
};
|
||||
|
||||
#endif // SCHEDULER_H
|
Loading…
Add table
Add a link
Reference in a new issue