-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim.h
91 lines (72 loc) · 2.14 KB
/
sim.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
Copyright (C) 2010 Citrix Systems UK Ltd
Author: George Dunlap
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __SIM_H
#define __SIM_H
#include "stats.h"
#include "workload.h"
#include "sched.h"
enum runstate {
RUNSTATE_RUNNING,
RUNSTATE_RUNNABLE,
RUNSTATE_BLOCKED
};
enum {
STATE_RUN,
STATE_PREEMPT,
STATE_WAKE,
STATE_BLOCK,
STATE_MAX
};
struct vm
{
/* Public */
int vid;
enum runstate runstate;
int processor;
void *private;
/* State: i.e., runstate. Phase: "runnable" or "blocked". A single "runnable" phase may go through
* several "runnable" and "running" states. */
int state_start_time;
int time_this_phase;
int was_preempted;
struct {
struct cycle_summary state[STATE_MAX];
} stats;
int phase_index;
const struct sim_phase *e; /* Shortcut pointer to workload->list[phase_index] */
const struct vm_workload *workload;
};
#define MAX_PCPU 16
struct global_pcpu_data {
int count, idle;
struct pcpu {
int pid;
int idle; /* Indicates may be woken up if work appears */
struct vm* current;
} pcpus[MAX_PCPU];
};
extern struct global_pcpu_data P;
#ifdef VM_DATA_PUBLIC
struct global_vm_data {
int count;
struct vm vms[MAX_VMS];
};
extern struct global_vm_data V;
#endif
struct vm* vm_from_vid(int vid);
#define current(_pid) (P.pcpus[(_pid)].current)
void sim_sched_timer(int time, int pid);
void sim_runstate_change(int now, struct vm *v, int new_runstate);
#endif /* __SIM_H */