summaryrefslogtreecommitdiff
path: root/os/port/edf.h
blob: dfd2b4a9e8de1911d67cc71a0ebff537b8ebe51a (plain)
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
enum {
	Maxsteps = 200 * 100 * 2,	/* 100 periods of 200 procs */

	/* Edf.flags field */
	Admitted		= 0x01,
	Sporadic		= 0x02,
	Yieldonblock		= 0x04,
	Sendnotes		= 0x08,
	Deadline		= 0x10,
	Yield			= 0x20,
	Extratime		= 0x40,

	Infinity = ~0ULL,
};

typedef struct Edf		Edf;

struct Edf {
	/* time intervals */
	vlong		D;			/* Deadline */
	vlong		Delta;		/* Inherited deadline */
	vlong		T;			/* period */
	vlong		C;			/* Cost */
	vlong		S;			/* Slice: time remaining in this period */
	/* times */
	vlong		r;			/* (this) release time */
	vlong		d;			/* (this) deadline */
	vlong		t;			/* Start of next period, t += T at release */
	vlong		s;			/* Time at which this proc was last scheduled */
	/* for schedulability testing */
	vlong		testDelta;
	int			testtype;	/* Release or Deadline */
	vlong		testtime;
	Proc		*testnext;
	/* other */
	ushort		flags;
	Timer;
	/* Stats */
	vlong		edfused;
	vlong		extraused;
	vlong		aged;
	ulong		periods;
	ulong		missed;
};

extern Lock	edftestlock;	/* for atomic admitting/expelling */

#pragma	varargck	type	"t"		vlong
#pragma	varargck	type	"U"		uvlong

/* Interface: */
Edf*		edflock(Proc*);
void		edfunlock(void);