gdunlap/sched-sim.hg

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