Repository navigation
Expand file tree
/
Copy pathScheduler.H
More file actions
executable file
·74 lines (52 loc) · 2.24 KB
/
Copy pathScheduler.H
File metadata and controls
executable file
·74 lines (52 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
Author: Joshua Capehart
Based on code by:
R. Bettati
Department of Computer Science
Texas A&M University
A thread scheduler.
*/
#ifndef SCHEDULER_H
#define SCHEDULER_H
/*--------------------------------------------------------------------------*/
/* DEFINES
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/* INCLUDES
/*--------------------------------------------------------------------------*/
#include "machine.H"
#include "thread.H"
#define MAX_QUEUE_SIZE 1000
/*--------------------------------------------------------------------------*/
/* SCHEDULER
/*--------------------------------------------------------------------------*/
class Scheduler {
/* The scheduler may need private members... */
public:
int front_index;
int next_index;
Thread *ready_Queue[MAX_QUEUE_SIZE];
Scheduler();
/* Setup the scheduler. This sets up the ready queue, for example.
If the scheduler implements some sort of round-robin scheme, then the
end_of_quantum handler is installed here as well. */
virtual void yield();
/* Called by the currently running thread in order to give up the CPU.
The scheduler selects the next thread from the ready queue to load onto
the CPU, and calls the dispatcher function defined in 'threads.h' to
do the context switch. */
virtual void resume(Thread * _thread);
/* Add the given thread to the ready queue of the scheduler. This is called
for threads that were waiting for an event to happen, or that have
to give up the CPU in response to a preemption. */
virtual void add(Thread * _thread);
/* Make the given thread runnable by the scheduler. This function is called
typically after thread creation. Depending on the
implementation, this may not entail more than simply adding the
thread to the ready queue (see scheduler_resume). */
virtual void terminate(Thread * _thread);
/* Remove the given thread from the scheduler in preparation for destruction
of the thread. */
void printQueue();
};
#endif