#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>

#include <arch/basetype.h>
#include <arch/funcs.h>

#include <prop.h>
#include <ps.h>

#include <req.h>
#include <qos.h>

static inline WORD task_getabsdl(struct qtask_global *p)
{
    /* Need OS binding... */
    /* For the moment, let's assume D = P */
    return 0;
}

static inline struct qtask_global *id2num(struct qtask_global *h, ID id)
{
    struct qtask_global *p;
    int done;

    p = h;
    done = 0;
    while ((p != NULL) && !done) {
	if (p->id == id) {
	    done = 1;
	} else {
	    p = p->next;
	}
    }

    return p;
}

struct qtask_global *manager_registertask(void);
void manager_unregistertask(struct qtask_global *p);
PORT makeport(char *name, int dim, int mode);
PORT connecttoport(char *name, int dim, int mode);
int receivefromport(PORT port, void *p);
int sendtoport(PORT port, void *p);
void qos_abort(int code);
DWORD sys_utilization(float rmu);
int server_create(void);
struct qtask_local *getfreedescriptor(void);
ID inittask(char *name, void (*body) (WORD),
	    WORD arg, int w, DWORD q, DWORD period, DWORD drel,
	    BYTE model);
ID initpstask(char *name, TASK(*body) (WORD), WORD arg, float w, DWORD q);
ID currenttask(void);
struct qtask_local *getdescr(void);
int endinstance(void);
DWORD howlate(ID task);
void resetcount(void);
int qostask_init(int p);
