@@ 6,7 6,8 @@
#include "io.h"
#include "ureg.h"
#include "../port/error.h"
-#include "../port/realtime.h"
+#include "realtime.h"
+#include "../port/edf.h"
#pragma varargck type "T" vlong
@@ 5,7 5,8 @@
#include "dat.h"
#include "fns.h"
#include "../port/error.h"
-#include "../port/realtime.h"
+#include "realtime.h"
+#include "../port/edf.h"
/* debugging */
int edfprint = 0;
@@ 9,18 9,10 @@ enum {
/* Edf.flags field */
Verbose = 0x1,
Useblocking = 0x2,
-};
-typedef vlong Time;
-typedef uvlong Ticks;
+ Infinity = 0xffffffffffffffffULL,
-typedef struct Task Task;
-typedef struct Resource Resource;
-typedef struct ResourceItem ResourceItem;
-typedef struct Edf Edf;
-typedef struct Taskq Taskq;
-typedef struct List List;
-typedef struct Head Head;
+};
enum Edfstate {
EdfUnused, /* task structure not in use */
@@ 36,7 28,16 @@ enum Edfstate {
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;
+
+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;
struct List {
List * next; /* next in list */
@@ 82,7 83,8 @@ struct Task {
Ticks scheduled;
Schedq runq; /* Queue of runnable member procs */
Head procs; /* List of member procs */
- Head res; /* List of resources */
+ Head csns; /* List of resources */
+ CSN *curcsn; /* Position in CSN tree or nil */
char *user; /* mallocated */
Dirtab dir;
int flags; /* e.g., Verbose */
@@ 106,11 108,21 @@ struct Resource
Ticks testDelta;
};
-struct ResourceItem {
- List; /* links and identifies the resource (must be first) */
- Ticks C; /* cost */
- int x; /* exclusive access (as opposed to shared-read access) */
- Head h; /* sub resource items */
+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 */
+};
+
+struct TaskLink {
+ List; /* links and identifies the task (must be first) */
+ Ticks C; /* cost */
+ int R; /* read-only access (as opposed to exclusive access) */
};
extern QLock edfschedlock;
@@ 134,3 146,21 @@ Ticks time2ticks(Time);
int putlist(Head*, List*);
int enlist(Head*, void*);
int delist(Head*, void*);
+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
@@ 4,7 4,8 @@
#include "dat.h"
#include "fns.h"
#include "../port/error.h"
-#include "../port/realtime.h"
+#include "realtime.h"
+#include "../port/edf.h"
static int
isedf(Proc*)