gdunlap/sched-sim.hg

view sim.h @ 0:d27bb3c56e71

Inital commit.
author George Dunlap <gdunlap@xensource.com>
date Tue Oct 13 16:06:36 2009 +0100 (2009-10-13)
parents
children ec2d50e41437
line source
1 #ifndef __SIM_H
2 #define __SIM_H
4 #include "stats.h"
6 enum runstate {
7 RUNSTATE_RUNNING,
8 RUNSTATE_RUNNABLE,
9 RUNSTATE_BLOCKED
10 };
12 enum {
13 STATE_RUN,
14 STATE_PREEMPT,
15 STATE_WAKE,
16 STATE_BLOCK,
17 STATE_MAX
18 };
20 struct vm
21 {
22 /* Public */
23 int vid;
25 enum runstate runstate;
26 int processor;
28 void *private;
30 /* State: i.e., runstate. Phase: "runnable" or "blocked". A single "runnable" phase may go through
31 * several "runnable" and "running" states. */
32 int state_start_time;
33 int time_this_phase;
34 int was_preempted;
36 struct {
37 struct cycle_summary state[STATE_MAX];
38 } stats;
40 int phase_index;
41 const struct sim_phase *e; /* Shortcut pointer to workload->list[phase_index] */
42 const struct vm_workload *workload;
44 };
46 struct sched_ops {
47 void (*sched_init)(void);
48 void (*vm_init)(int vid);
49 void (*wake)(int time, struct vm* v);
50 struct vm* (*schedule)(int time, int pid);
51 };
53 struct scheduler {
54 char *name;
55 struct sched_ops ops;
56 };
58 #define MAX_PCPU
59 struct global_pcpu_data {
60 int count;
61 struct pcpu {
62 int pid;
63 struct vm* current;
64 } pcpus[MAX_PCPU];
65 };
66 extern struct global_pcpu_data P;
68 struct vm* vm_from_vid(int vid);
69 #define current(_pid) (P.pcpus[(_pid)].current)
70 void sim_sched_timer(int time, int pid);
71 void sim_runstate_change(int now, struct vm *v, int new_runstate);
73 #endif /* __SIM_H */