Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/port/edf.h

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname port/edf.h 2002/0315
## diff -e /dev/null /n/emeliedump/2002/0315/sys/src/9/port/edf.h
0a
enum {
	Nproc = 8,
	Nres = 8,
	Ntask = 8,
	Maxtasks = 20,
	Maxresources = 20,
	Maxsteps = Maxtasks * 2 * 100,	/* 100 periods of maximum # of tasks */

	/* Edf.flags field */
	Verbose = 0x1,
	Useblocking = 0x2,
};

typedef uvlong	Ticks;

typedef struct Task		Task;
typedef struct Resource	Resource;
typedef struct Edf		Edf;
typedef struct Taskq		Taskq;

enum Edfstate {
	EdfUnused,		/* task structure not in use */
	EdfExpelled,		/* in initialization, not yet admitted */
	EdfAdmitted,		/* admitted, but not started */

	EdfIdle,			/* admitted, but no member processes */
	EdfAwaitrelease,	/* released, but too early (on qwaitrelease) */
	EdfReleased,		/* released, but not yet scheduled (on qreleased) */
	EdfRunning,		/* one of this task's procs is running (on stack) */
	EdfExtra,			/* one of this task's procs is running in extra time (off stack) */
	EdfPreempted,		/* the running proc was preempted */
	EdfBlocked,		/* none of the procs are runnable as a result of sleeping */
	EdfDeadline,		/* none of the procs are runnable as a result of scheduling */
};
typedef enum Edfstate	Edfstate;

struct Edf {
	/* time intervals */
	Ticks	D;		/* Deadline */
	Ticks	Δ;		/* Inherited deadline */
	Ticks	T;		/* period */
	Ticks	C;		/* Cost */
	Ticks	S;		/* Slice: time remaining in this period */
	/* times */
	Ticks	r;		/* (this) release time */
	Ticks	d;		/* (this) deadline */
	Ticks	t;		/* Start of next period, t += T at release */
	/* for schedulability testing */
	Ticks	testΔ;
	int		testtype;	/* Release or Deadline */
	Ticks	testtime;
	Task	*	testnext;
	/* other */
	Edfstate	state;
};

struct Task {
	QLock;
	Edf;
	Ticks	scheduled;
	Schedq	runq;		/* Queue of runnable member procs */
	Proc *	procs[Nproc];	/* List of member procs; may contain holes */
	int		nproc;		/* number of them */
	Resource*	res[Nres];		/* List of resources; may contain holes */
	int		nres;			/* number of them */
	char		*user;		/* mallocated */
	Dirtab	dir;
	int		flags;		/* e.g., Verbose */
	Task		*rnext;
};

struct Taskq
{
	Lock;
	Task*	head;
	int		(*before)(Task*, Task*);	/* ordering function for queue (nil: fifo) */
};

struct Resource
{
	char	*	name;
	Task *	tasks[Ntask];	/* may contain holes */
	int		ntasks;
	Ticks	Δ;
	/* for schedulability testing */
	Ticks	testΔ;
};

extern Lock		edftestlock;	/* for atomic admitting/expelling */
extern Task		tasks[Maxtasks];	/* may contain holes */
extern int			ntasks;
extern Resource	resources[Maxresources];	/* may contain holes */
extern int			nresources;
extern Lock		edflock;
extern Taskq		qwaitrelease;
extern Taskq		qreleased;
extern Taskq		qextratime;
extern Taskq		edfstack[];
extern int			edf_stateupdate;
extern void		(*devsched)(Task *, Ticks, int);
extern char *		edf_statename[];

#pragma	varargck	type	"T"		Time
#pragma	varargck	type	"U"		Ticks

/* Interface: */
void		edf_preempt(Task*);		/* Stop current task, administrate run time, leave on stack */
void		edf_deadline(Proc*);		/* Remove current task from edfstack, schedule its next release */
void		edf_release(Task*);		/* Release a task */
void		edf_schedule(Task *);	/* Run a released task: remove from qrelease, push onto edfstack */
char *	edf_admit(Task*);
void		edf_expel(Task*);
void		edf_bury(Proc*);		/* Proc dies, update Task membership */
void		edf_sched(Task*);		/* Figure out what to do with task (after a state change) */
int		isedf(Proc*);			/* Proc must be edf scheduled */
void		edf_stop(Proc*);		/* Just event generation; should probably be done differently */
int		edf_anyready(void);
void		edf_ready(Proc*);
Proc	*	edf_runproc(void);
void		edf_block(Proc*);		/* Edf proc has blocked, do the admin */
void		edf_init(void);
int		edf_waitlock(Lock*);
void		edf_releaselock(Lock*);
Time		ticks2time(Ticks);
Ticks	time2ticks(Time);
.
## diffname port/edf.h 2002/0316
## diff -e /n/emeliedump/2002/0315/sys/src/9/port/edf.h /n/emeliedump/2002/0316/sys/src/9/port/edf.h
100c
extern void		(*devrt)(Task *, Ticks, int);
.
13a
typedef vlong	Time;
.
## diffname port/edf.h 2002/0320
## diff -e /n/emeliedump/2002/0316/sys/src/9/port/edf.h /n/emeliedump/2002/0320/sys/src/9/port/edf.h
87c
	Ticks	testDelta;
.
85c
	Ticks	Delta;
.
50c
	Ticks	testDelta;
.
41c
	Ticks	Delta;		/* Inherited deadline */
.
## diffname port/edf.h 2002/0410
## diff -e /n/emeliedump/2002/0320/sys/src/9/port/edf.h /n/emeliedump/2002/0410/sys/src/9/port/edf.h
107,124d
102c
extern char *		edfstatename[];
.
100c
extern int			edfstateupdate;
.
## diffname port/edf.h 2002/0503
## diff -e /n/emeliedump/2002/0410/sys/src/9/port/edf.h /n/emeliedump/2002/0503/sys/src/9/port/edf.h
53a
	/* statistics gathering */
	ulong	periods;	/* number of periods */
	ulong	missed;	/* number of deadlines missed */
	ulong	preemptions;
	Ticks	total;		/* total time used */
	Ticks	aged;	/* aged time used */
.
## diffname port/edf.h 2002/0704
## diff -e /n/emeliedump/2002/0503/sys/src/9/port/edf.h /n/emeliedump/2002/0704/sys/src/9/port/edf.h
17,20c
typedef struct Task			Task;
typedef struct Resource		Resource;
typedef struct Edf			Edf;
typedef struct Taskq			Taskq;
.
## diffname port/edf.h 2002/0830
## diff -e /n/emeliedump/2002/0704/sys/src/9/port/edf.h /n/emeliedump/2002/0830/sys/src/9/port/edf.h
41c
	Ticks	Delta;	/* Inherited deadline */
.
## diffname port/edf.h 2002/0831
## diff -e /n/emeliedump/2002/0830/sys/src/9/port/edf.h /n/emeliedump/2002/0831/sys/src/9/port/edf.h
114a
int		putlist(Head*, List*);
int		enlist(Head*, void*);
int		delist(Head*, void*);
.
96,99c
struct ResourceItem {
	List;			/* links and identifies the resource (must be first) */
	Ticks	C;	/* cost */
	Head	h;	/* sub resource items */
};

extern QLock		edfschedlock;
extern Head		tasks;
extern Head		resources;
.
89,90c
	Head	tasks;
.
87a
	Ref;
.
69,72c
	Head	procs;		/* List of member procs */
	Head	res;			/* List of resources */
.
65a
	Ref;					/* ref count for farbage collection */
	int		taskno;		/* task number in Qid  */
.
37a
struct List {
	List	*	next;	/* next in list */
	void	*	i;		/* item in list */
};

struct Head {
	List	*next;	/* First item in list */
	int	n;		/* number of items in list */
};

.
20a
typedef struct List			List;
typedef struct Head			Head;
.
## diffname port/edf.h 2002/0912
## diff -e /n/emeliedump/2002/0831/sys/src/9/port/edf.h /n/emeliedump/2002/0912/sys/src/9/port/edf.h
110a
	int		x;	/* exclusive access (as opposed to shared-read access) */
.
46,47c
	List	*next;		/* First item in list */
	int	n;			/* number of items in list */
.
41c
	List	*	next;		/* next in list */
.
18a
typedef struct ResourceItem	ResourceItem;
.
14,15c
typedef vlong				Time;
typedef uvlong				Ticks;
.
## diffname port/edf.h 2002/1119
## diff -e /n/emeliedump/2002/0912/sys/src/9/port/edf.h /n/emeliedump/2002/1119/sys/src/9/port/edf.h
136a
char *	parsetime(Time*, char*);
void *	findlist(Head*, void*);
Task *	findtask(int);
List *		onlist(Head*, void*);
int		timeconv(Fmt*);
void		resourcefree(Resource*);
Resource*	resource(char*, int);
void		removetask(Task*);
void		taskfree(Task*);
char *	parseresource(Head*, CSN*, char*);
char *	seprintresources(char*, char*);
char *	seprintcsn(char*, char*, Head*);
void		resourcetimes(Task*, Head*);
char*	dumpq(char*, char*, Taskq*, Ticks);
char*	seprinttask(char*, char*, Task*, Ticks);
char*	dumpq(char*, char*, Taskq*, Ticks);

#define	DEBUG	if(1){}else iprint
.
115a
struct TaskLink {
	List;				/* links and identifies the task (must be first) */
	Ticks		C;	/* cost */
	int			R;	/* read-only access (as opposed to exclusive access) */
};

.
109,113c
struct CSN {
	List;					/* links and identifies the resource (must be first) */
	Task			*t;		/* task the CSN belongs to */
	Ticks		C;		/* cost */
	int			R;		/* read-only access (as opposed to exclusive access) */
	Ticks		Delta;	/* of the Tasks critical section */
	Ticks		testDelta;
	Ticks		S;		/* Remaining slice */
	CSN*		p;		/* parent resource items */
.
85c
	Head	csns;			/* List of resources */
	CSN		*curcsn;		/* Position in CSN tree or nil */
.
40a
typedef enum Edfstate		Edfstate;
typedef struct Edf			Edf;
typedef struct Head			Head;
typedef struct List			List;
typedef struct Resource		Resource;
typedef struct Task			Task;
typedef struct Taskq			Taskq;
typedef struct CSN			CSN;
typedef struct TaskLink		TaskLink;

.
39d
17,23c
};
.
14,15c
	Infinity = 0xffffffffffffffffULL,
.
12d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].