gdunlap/sched-sim.hg

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sim.h	Tue Oct 13 16:06:36 2009 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +#ifndef __SIM_H
     1.5 +#define __SIM_H
     1.6 +
     1.7 +#include "stats.h"
     1.8 +
     1.9 +enum runstate {
    1.10 +    RUNSTATE_RUNNING,
    1.11 +    RUNSTATE_RUNNABLE,
    1.12 +    RUNSTATE_BLOCKED
    1.13 +};
    1.14 +
    1.15 +enum {
    1.16 +    STATE_RUN,
    1.17 +    STATE_PREEMPT,
    1.18 +    STATE_WAKE,
    1.19 +    STATE_BLOCK,
    1.20 +    STATE_MAX
    1.21 +};
    1.22 +
    1.23 +struct vm
    1.24 +{
    1.25 +    /* Public */
    1.26 +    int vid;
    1.27 +
    1.28 +    enum runstate runstate;
    1.29 +    int processor;
    1.30 +
    1.31 +    void *private;
    1.32 +
    1.33 +    /* State: i.e., runstate.  Phase: "runnable" or "blocked".  A single "runnable" phase may go through
    1.34 +     * several "runnable" and "running" states. */
    1.35 +    int state_start_time;
    1.36 +    int time_this_phase;
    1.37 +    int was_preempted;
    1.38 +
    1.39 +    struct {
    1.40 +        struct cycle_summary state[STATE_MAX];
    1.41 +    } stats;
    1.42 +
    1.43 +    int phase_index;
    1.44 +    const struct sim_phase *e; /* Shortcut pointer to workload->list[phase_index] */
    1.45 +    const struct vm_workload *workload;
    1.46 +
    1.47 +};
    1.48 +
    1.49 +struct sched_ops {
    1.50 +    void (*sched_init)(void);
    1.51 +    void (*vm_init)(int vid);
    1.52 +    void (*wake)(int time, struct vm* v);
    1.53 +    struct vm* (*schedule)(int time, int pid);
    1.54 +};
    1.55 +
    1.56 +struct scheduler {
    1.57 +    char *name;
    1.58 +    struct sched_ops ops;
    1.59 +};
    1.60 +
    1.61 +#define MAX_PCPU
    1.62 +struct global_pcpu_data {
    1.63 +    int count;
    1.64 +    struct pcpu {
    1.65 +        int pid;
    1.66 +        struct vm* current;
    1.67 +    } pcpus[MAX_PCPU];
    1.68 +};
    1.69 +extern struct global_pcpu_data P;
    1.70 +
    1.71 +struct vm* vm_from_vid(int vid);
    1.72 +#define current(_pid) (P.pcpus[(_pid)].current)
    1.73 +void sim_sched_timer(int time, int pid);
    1.74 +void sim_runstate_change(int now, struct vm *v, int new_runstate);
    1.75 +
    1.76 +#endif /* __SIM_H */
    1.77 +