Scheduler.h
inter/Scheduler.h · 1.2 KB
From the archive interlude_1beta5.tar.gz
Download the archive « Back to the archive contents
#ifndef SCHEDULER_H
#define SCHEDULER_H
#pragma interface
#include "Process.h"
#include "sockets.h"
extern class Process;
typedef struct proc_node {
Process* process;
struct proc_node *next, *prev;
};
//
// these parameters need some explaining. when a process starts, it is
// given default_max_ticks time cycles total for execution. each pass through
// the scheduler runs until the Process structure tells it that it's expended
// default_slice_size ticks, then the scheduler goes on to the next process.
// to reward 'nice' processes, however, i've set it up so that the process
// will get back sleep_return*default_slice_size ticks whenever it executes
// a 'sleep' with a 1 second or greater sleep time.
//
const int default_slice_size = 250;
const int default_max_ticks = 50000;
const int sleep_return = 3;
class Scheduler {
friend class Process;
friend class Frame;
protected:
struct proc_node* proc_queue;
struct proc_node *tail_pointer;
public:
Scheduler();
~Scheduler();
int add_process (int obj_on, Value* mthd_nm, Val_List* actuals,
int ticks = default_max_ticks);
int rm_process (int pid);
void one_cycle (int slice_size = default_slice_size);
};
#endif /* SCHEDULER_H */