gdunlap/sched-sim.hg

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