gdunlap/sched-sim.hg

annotate sim.h @ 1:ec2d50e41437

Handle multiple cpus.
author George Dunlap <gdunlap@xensource.com>
date Tue Oct 13 17:29:50 2009 +0100 (2009-10-13)
parents d27bb3c56e71
children 1d7310217c5a
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@1 5 #include "workload.h"
gdunlap@0 6
gdunlap@0 7 enum runstate {
gdunlap@0 8 RUNSTATE_RUNNING,
gdunlap@0 9 RUNSTATE_RUNNABLE,
gdunlap@0 10 RUNSTATE_BLOCKED
gdunlap@0 11 };
gdunlap@0 12
gdunlap@0 13 enum {
gdunlap@0 14 STATE_RUN,
gdunlap@0 15 STATE_PREEMPT,
gdunlap@0 16 STATE_WAKE,
gdunlap@0 17 STATE_BLOCK,
gdunlap@0 18 STATE_MAX
gdunlap@0 19 };
gdunlap@0 20
gdunlap@0 21 struct vm
gdunlap@0 22 {
gdunlap@0 23 /* Public */
gdunlap@0 24 int vid;
gdunlap@0 25
gdunlap@0 26 enum runstate runstate;
gdunlap@0 27 int processor;
gdunlap@0 28
gdunlap@0 29 void *private;
gdunlap@0 30
gdunlap@0 31 /* State: i.e., runstate. Phase: "runnable" or "blocked". A single "runnable" phase may go through
gdunlap@0 32 * several "runnable" and "running" states. */
gdunlap@0 33 int state_start_time;
gdunlap@0 34 int time_this_phase;
gdunlap@0 35 int was_preempted;
gdunlap@0 36
gdunlap@0 37 struct {
gdunlap@0 38 struct cycle_summary state[STATE_MAX];
gdunlap@0 39 } stats;
gdunlap@0 40
gdunlap@0 41 int phase_index;
gdunlap@0 42 const struct sim_phase *e; /* Shortcut pointer to workload->list[phase_index] */
gdunlap@0 43 const struct vm_workload *workload;
gdunlap@0 44
gdunlap@0 45 };
gdunlap@0 46
gdunlap@0 47 struct sched_ops {
gdunlap@0 48 void (*sched_init)(void);
gdunlap@0 49 void (*vm_init)(int vid);
gdunlap@0 50 void (*wake)(int time, struct vm* v);
gdunlap@0 51 struct vm* (*schedule)(int time, int pid);
gdunlap@0 52 };
gdunlap@0 53
gdunlap@0 54 struct scheduler {
gdunlap@0 55 char *name;
gdunlap@0 56 struct sched_ops ops;
gdunlap@0 57 };
gdunlap@0 58
gdunlap@1 59 #define MAX_PCPU 16
gdunlap@0 60 struct global_pcpu_data {
gdunlap@1 61 int count, idle;
gdunlap@0 62 struct pcpu {
gdunlap@0 63 int pid;
gdunlap@1 64 int idle; /* Indicates may be woken up if work appears */
gdunlap@0 65 struct vm* current;
gdunlap@0 66 } pcpus[MAX_PCPU];
gdunlap@0 67 };
gdunlap@0 68 extern struct global_pcpu_data P;
gdunlap@0 69
gdunlap@1 70
gdunlap@1 71 #ifdef VM_DATA_PUBLIC
gdunlap@1 72 struct global_vm_data {
gdunlap@1 73 int count;
gdunlap@1 74 struct vm vms[MAX_VMS];
gdunlap@1 75 };
gdunlap@1 76 extern struct global_vm_data V;
gdunlap@1 77 #endif
gdunlap@1 78
gdunlap@0 79 struct vm* vm_from_vid(int vid);
gdunlap@0 80 #define current(_pid) (P.pcpus[(_pid)].current)
gdunlap@0 81 void sim_sched_timer(int time, int pid);
gdunlap@0 82 void sim_runstate_change(int now, struct vm *v, int new_runstate);
gdunlap@0 83
gdunlap@0 84 #endif /* __SIM_H */
gdunlap@0 85