[Linux-hls-cvs] qosman/src adj.c,1.1.1.1,1.2 clnt-us.c,1.1.1.1,1.2 pid.c,1.1.1.1,1.2 prop.c,1.1.1.1,
Status: Pre-Alpha
Brought to you by:
lucabe
|
From: Luca A. <lu...@us...> - 2004-04-09 13:53:21
|
Update of /cvsroot/linux-hls/qosman/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23177/src Modified Files: adj.c clnt-us.c pid.c prop.c pscompr.c qman-c.c qman-s.c qosport-ks.c simpleadj.c srv-ks.c srv-us.c Log Message: - Some cleanups in the demos - New "text only" demo (will be used to test the pps model) - Interface change (names...) - Fix bug in feeback functions statistics - Resynch with my local tree (too many changes to mention) Index: prop.c =================================================================== RCS file: /cvsroot/linux-hls/qosman/src/prop.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** prop.c 21 Feb 2004 13:01:53 -0000 1.1.1.1 --- prop.c 9 Apr 2004 13:39:57 -0000 1.2 *************** *** 41,45 **** /* This file implements the proportional compression function */ /************************************************************************/ - /* #include <stdlib.h> What is this for??? */ #include <basetype.h> #include <funcs.h> --- 41,44 ---- *************** *** 47,51 **** #include "prop.h" #ifdef __PROP_STATS__ ! #include "stats.h" #endif --- 46,50 ---- #include "prop.h" #ifdef __PROP_STATS__ ! /* #include "stats.h" */ #endif Index: simpleadj.c =================================================================== RCS file: /cvsroot/linux-hls/qosman/src/simpleadj.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** simpleadj.c 21 Feb 2004 13:01:54 -0000 1.1.1.1 --- simpleadj.c 9 Apr 2004 13:39:57 -0000 1.2 *************** *** 46,73 **** #include <funcs.h> ! #include "simpleadj.h" ! ! /* #define __ADJ_DEBUG__ */ /* This is only usefull in a multithreaded environment... */ ! void simpleadj_init(void) { } ! void *simpleadj_create(DWORD q, DWORD desired, DWORD ts, DWORD period) { ! return NULL; } ! void simpleadj_destroy(void *parms) { } ! REAL simpleadj_feedb(void *parms, int l) { ! return 1; } ! void simpleadj_setb(void *parms, REAL band) { } --- 46,84 ---- #include <funcs.h> ! struct feedbk_stat; ! #include "req.h" /* This is only usefull in a multithreaded environment... */ ! static void simpleadj_init(void) { } ! static void *simpleadj_create(DWORD q, DWORD desired, DWORD ts, DWORD period) { ! return NULL; } ! static void simpleadj_destroy(void *parms) { } ! static REAL simpleadj_feedb(void *parms, int l) { ! return 1; } ! static void simpleadj_setb(void *parms, REAL band) ! { ! } ! ! static void simpleadj_setstats(struct feedbk_stat *p, int iden) { } + struct reqactions simpleactions = { + simpleadj_init, + simpleadj_create, + simpleadj_destroy, + simpleadj_setb, + simpleadj_feedb, + simpleadj_setstats + }; Index: qman-c.c =================================================================== RCS file: /cvsroot/linux-hls/qosman/src/qman-c.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** qman-c.c 21 Feb 2004 13:01:54 -0000 1.1.1.1 --- qman-c.c 9 Apr 2004 13:39:57 -0000 1.2 *************** *** 48,52 **** #include "server.h" #include "req.h" - #include "simpleadj.h" #include "qos.h" #include "stats.h" --- 48,51 ---- *************** *** 55,84 **** #define SINGLE - /* - #define QOSDBG - */ - /* For communication between adaptive tasks and the global QoS adapter... */ ! PORT qosport = 0; /* PPS task scheduling quantum */ static DWORD ppsq = 0; ! ! void (*req_init) (void) = simpleadj_init; ! void *(*req_create) (DWORD q, DWORD desired, DWORD maxfb, DWORD period) = ! simpleadj_create; ! void (*req_destroy) (void *parms) = simpleadj_destroy; ! void (*req_setb) (void *parms, REAL band) = simpleadj_setb; ! REAL (*req_feedb) (void *parms, int l) = simpleadj_feedb; ! ! /* This is the function to plug a different feedback function in */ ! void setreq(struct reqactions *p) ! { ! req_init = p->req_init; ! req_create = p->req_create; ! req_destroy = p->req_destroy; ! req_setb = p->req_setb; ! req_feedb = p->req_feedb; ! } /* --- 54,64 ---- #define SINGLE /* For communication between adaptive tasks and the global QoS adapter... */ ! static PORT qosport = 0; /* PPS task scheduling quantum */ static DWORD ppsq = 0; ! static struct reqactions req; ! extern struct reqactions simpleactions; /* *************** *** 86,110 **** * to the QoS Manager Task */ ! void globalfeedbk(ID task, REAL newb) { struct qoscmd cmd; cmd.task = task; ! cmd.newvalue = newb; ! cmd.type = GLOB_QCHANGE; sendtoport(qosport, &cmd); } ! void p_change(ID task, WORD newp) { struct qoscmd cmd; ! cmd.type = P_CHANGE; cmd.task = task; ! cmd.newvalue1 = newp; sendtoport(qosport, &cmd); } void qtask_register(ID task, REAL b, unsigned int w, DWORD p, DWORD dl, DWORD q) { --- 66,114 ---- * to the QoS Manager Task */ ! static void p_change(ID task, WORD newp) { struct qoscmd cmd; + + cmd.type = P_CHANGE; cmd.task = task; ! cmd.newvalue1 = newp; sendtoport(qosport, &cmd); } ! static void q_change(ID task, WORD newq) { struct qoscmd cmd; ! cmd.type = Q_CHANGE; cmd.task = task; ! cmd.newvalue1 = newq; sendtoport(qosport, &cmd); } + static void b_change(ID task, REAL newb) + { + struct qoscmd cmd; + + cmd.type = B_CHANGE; + cmd.task = task; + cmd.newvalue = newb; + + sendtoport(qosport, &cmd); + } + + #ifndef SINGLE + static void globalfeedbk(ID task, REAL newb) + { + struct qoscmd cmd; + cmd.task = task; + cmd.newvalue = newb; + cmd.type = GLOB_QCHANGE; + + sendtoport(qosport, &cmd); + } + #endif + void qtask_register(ID task, REAL b, unsigned int w, DWORD p, DWORD dl, DWORD q) { *************** *** 154,189 **** } - void q_change(ID task, WORD newq) - { - struct qoscmd cmd; - cmd.type = Q_CHANGE; - cmd.task = task; - cmd.newvalue1 = newq; - sendtoport(qosport, &cmd); - } ! void b_change(ID task, REAL newb) { ! struct qoscmd cmd; ! ! cmd.type = B_CHANGE; ! cmd.task = task; ! cmd.newvalue = newb; ! ! sendtoport(qosport, &cmd); } ! int qman_init(struct qmparm *p) { ppsq = p->psq; /* Usefull only for multithreaded environments, like HARTIK */ ! req_init(); - cprintf("Connecting...\n"); qosport = connecttoport("QoS_Port", sizeof(struct qoscmd), O_WRONLY | O_NONBLOCK); - cprintf("Connected!!!\n"); if (qosport < 0) { return -1; --- 158,182 ---- } ! /****************************************************************************/ ! /* Interface Functions */ ! /****************************************************************************/ ! /* This is the function to plug a different feedback function in */ ! void qman_feedback(struct reqactions *p) { ! memcpy(&req, p, sizeof(struct reqactions)); } ! int qman_init(struct qman_attr *p) { ppsq = p->psq; + memcpy(&req, &simpleactions, sizeof(struct reqactions)); /* Usefull only for multithreaded environments, like HARTIK */ ! req.req_init(); qosport = connecttoport("QoS_Port", sizeof(struct qoscmd), O_WRONLY | O_NONBLOCK); if (qosport < 0) { return -1; *************** *** 196,200 **** * Creates a QoS Managed Task */ ! ID qset_addtask(struct qparm * t) { REAL band; --- 189,193 ---- * Creates a QoS Managed Task */ ! ID qman_task(struct qtask_attr *t) { REAL band; *************** *** 205,209 **** newtask = getfreedescriptor(); band = USEC2BAND(t->wcet, t->per); ! #ifdef QOSDBG cprintf("Creating new QoS task with bandwidth %lu ( = %d / %d)", real_to_int(band), t->wcet, t->per); --- 198,202 ---- newtask = getfreedescriptor(); band = USEC2BAND(t->wcet, t->per); ! #ifdef __QOSDBG_CLIENT__ cprintf("Creating new QoS task with bandwidth %lu ( = %d / %d)", real_to_int(band), t->wcet, t->per); *************** *** 221,229 **** /* qos_abort(111); */ } ! #ifdef QOSDBG cprintf(" --- deadline %d\n", drel); #endif /* initial Q, desired late value... */ ! newtask->adj = req_create(t->wcet, 0, drel /* ??? */, t->per); newtask->period = t->per; res = inittask(t->name, t->body, t->arg, t->w, t->wcet, t->per, drel, --- 214,222 ---- /* qos_abort(111); */ } ! #ifdef __QOSDBG_CLIENT__ cprintf(" --- deadline %d\n", drel); #endif /* initial Q, desired late value... */ ! newtask->adj = req.req_create(t->wcet, 0, drel /* ??? */, t->per); newtask->period = t->per; res = inittask(t->name, t->body, t->arg, t->w, t->wcet, t->per, drel, *************** *** 235,239 **** newtask->id = res; ! #ifdef QOSDBG cprintf("Task created and activated!!!\n"); #endif --- 228,232 ---- newtask->id = res; ! #ifdef __QOSDBG_CLIENT__ cprintf("Task created and activated!!!\n"); #endif *************** *** 242,246 **** } ! void qtask_changeperiod(WORD newp) { ID p; --- 235,239 ---- } ! void qman_task_changeperiod(WORD newp) { ID p; *************** *** 251,255 **** } ! void qtask_end(int retvalue) { ID p; --- 244,248 ---- } ! void qman_task_end(int retvalue) { ID p; *************** *** 260,264 **** #if 0 /* TODO!!!! */ set[i].valid = UNVALID; ! req_destroy(set[i].adj); rescale_destroy(set[i].compress); endtask(); --- 253,257 ---- #if 0 /* TODO!!!! */ set[i].valid = UNVALID; ! req.req_destroy(set[i].adj); rescale_destroy(set[i].compress); endtask(); *************** *** 273,277 **** * - go to sleep :) */ ! int qtask_endcycle(void) { int l; --- 266,270 ---- * - go to sleep :) */ ! int qman_task_endcycle(void) { int l; *************** *** 285,313 **** /* First of all, set the compressed bandwidth */ ! #ifdef QOSDBG cprintf("QTask EndCycle (%d): old bandwidth = %lu...\n", myid, real_to_int(oldb)); #endif ! req_setb(myself->adj, oldb); #ifdef SINGLE ! l = howlate(myid) - myself->period; ! #ifdef QOSDBG cprintf(" Scheduling Error: %d\n", l); #endif ! newb = req_feedb(myself->adj, l); ! #ifdef QOSDBG cprintf(" Requested BW (from controller): %lu\n", real_to_int(newb)); #endif b_change(myid, newb); #else ! l = howlate(myid) - myself->period; ! newb = req_feedb(myself->adj, l); globalfeedbk(myid, newb); #endif - // resetcount(); - endinstance(); --- 278,304 ---- /* First of all, set the compressed bandwidth */ ! #ifdef __QOSDBG_CLIENT__ cprintf("QTask EndCycle (%d): old bandwidth = %lu...\n", myid, real_to_int(oldb)); #endif ! req.req_setb(myself->adj, oldb); #ifdef SINGLE ! l = internal_howlate(myid) - myself->period; ! #ifdef __QOSDBG_CLIENT__ cprintf(" Scheduling Error: %d\n", l); #endif ! newb = req.req_feedb(myself->adj, l); ! #ifdef __QOSDBG_CLIENT__ cprintf(" Requested BW (from controller): %lu\n", real_to_int(newb)); #endif b_change(myid, newb); #else ! l = internal_howlate(myid) - myself->period; ! newb = req.req_feedb(myself->adj, l); globalfeedbk(myid, newb); #endif endinstance(); *************** *** 318,322 **** * Creates a new PPS task */ ! ID ps_addtask(struct psparm * t) { ID res; --- 309,313 ---- * Creates a new PPS task */ ! ID qman_pstask(struct pstask_attr *t) { ID res; *************** *** 326,330 **** newtask = getfreedescriptor(); ! #ifdef QOSDBG cprintf("Parameters: Q=%ld, W=%lu", t->quantum, t->w); #endif --- 317,321 ---- newtask = getfreedescriptor(); ! #ifdef __QOSDBG_CLIENT__ cprintf("Parameters: Q=%ld, W=%lu", t->quantum, t->w); #endif *************** *** 343,347 **** } newtask->id = res; ! #ifdef QOSDBG cprintf("Created!!!\n"); #endif --- 334,338 ---- } newtask->id = res; ! #ifdef __QOSDBG_CLIENT__ cprintf("Created!!!\n"); #endif *************** *** 349,350 **** --- 340,356 ---- return res; } + + void qman_setstats(struct feedbk_stat *p, int id) + { + req.req_setstats(p, id); + } + + int qman_howlate(ID task) + { + return internal_howlate(task); + } + int qman_budget(ID task) + { + return internal_budget(task); + } + Index: pid.c =================================================================== RCS file: /cvsroot/linux-hls/qosman/src/pid.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** pid.c 21 Feb 2004 13:01:53 -0000 1.1.1.1 --- pid.c 9 Apr 2004 13:39:57 -0000 1.2 *************** *** 25,35 **** #include "stats.h" #include "req.h" - #include "pid.h" #define MAXADJ 64 - //#define __ADJ_DEBUG__ #define min(a,b) (a < b) ? a : b #ifdef __ADJ_STATS__ /* Statistics... */ --- 25,46 ---- #include "stats.h" #include "req.h" #define MAXADJ 64 #define min(a,b) (a < b) ? a : b + struct pidparm { + int iden; + int progr; + + REAL oldb; + REAL p1; + REAL p2; + int desired; + int ts; + int period; + int oldepsilon; + }; + #ifdef __ADJ_STATS__ /* Statistics... */ *************** *** 38,50 **** static int static_id; - struct reqactions pidactions = { - pid_init, - pid_create, - pid_destroy, - pid_setb, - pid_feedb, - pid_setstats - }; - /* P1 * 1000 and P2 * 1000 */ #define P1 100 --- 49,52 ---- *************** *** 135,138 **** --- 137,141 ---- alpha = real_mul(parms->oldb, real_sum(real_sum(parms->p1, parms->p2), int_to_real(-2))); + #if 0 cprintf("a: %ld=", real_to_int(alpha)); cprintf("(%ld + %ld + %ld (%ld)) * %d\n", real_to_int(parms->p1) *************** *** 140,144 **** real_to_int(real_sum(real_sum(parms->p1, parms->p2), int_to_real(-2))), real_to_int(parms->oldb)); ! /* beta = parms->oldb * (1.0 - parms->p1 * parms->p2); */ beta = real_mul(parms->oldb, real_sum(int_to_real(1), --- 143,147 ---- real_to_int(real_sum(real_sum(parms->p1, parms->p2), int_to_real(-2))), real_to_int(parms->oldb)); ! #endif /* beta = parms->oldb * (1.0 - parms->p1 * parms->p2); */ beta = real_mul(parms->oldb, real_sum(int_to_real(1), *************** *** 148,155 **** --- 151,160 ---- alpha = real_mul(parms->oldb, real_sum(real_sum(parms->p1, parms->p2), int_to_real(-1))); + #if 0 cprintf("a: %ld=", real_to_int(alpha)); cprintf("%ld + %ld + %ld (%ld)\n", real_to_int(parms->p1) , real_to_int(parms->p2), -1, real_sum(real_sum(parms->p1, parms->p2), int_to_real(-1))); + #endif /* beta = parms->oldb * (-parms->p1 * parms->p2); */ *************** *** 199,203 **** #ifdef __ADJ_STATS__ ! if (pidstats != NULL) { pidstats[parms->iden][parms->progr].time = /*qos_time()*/ parms->progr; pidstats[parms->iden][parms->progr].l = epsilon; --- 204,208 ---- #ifdef __ADJ_STATS__ ! if (pidstats[parms->iden] != NULL) { pidstats[parms->iden][parms->progr].time = /*qos_time()*/ parms->progr; pidstats[parms->iden][parms->progr].l = epsilon; *************** *** 228,229 **** --- 233,243 ---- parms->oldb = band; } + + struct reqactions pidactions = { + pid_init, + pid_create, + pid_destroy, + pid_setb, + pid_feedb, + pid_setstats + }; Index: qosport-ks.c =================================================================== RCS file: /cvsroot/linux-hls/qosman/src/qosport-ks.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** qosport-ks.c 21 Feb 2004 13:01:54 -0000 1.1.1.1 --- qosport-ks.c 9 Apr 2004 13:39:57 -0000 1.2 *************** *** 28,36 **** static wait_queue_head_t qos_dev_queue; static ssize_t qosdev_read(struct file *f, char *buf, size_t count, loff_t *pos); static ssize_t qosdev_write(struct file *f, const char *buf, size_t count, loff_t *dummy); static int qosdev_open(struct inode *in, struct file *f); static int qosdev_close(struct inode *in, struct file *f); ! struct file_operations qos_fops = { read: qosdev_read, write: qosdev_write, --- 28,87 ---- static wait_queue_head_t qos_dev_queue; + #if 0 static ssize_t qosdev_read(struct file *f, char *buf, size_t count, loff_t *pos); static ssize_t qosdev_write(struct file *f, const char *buf, size_t count, loff_t *dummy); static int qosdev_open(struct inode *in, struct file *f); static int qosdev_close(struct inode *in, struct file *f); ! #endif ! ! static int available_qos_data(void) ! { ! return (queue_head != queue_tail); ! } ! ! static ssize_t qosdev_read(struct file *f, char *buf, size_t count, loff_t *pos) ! { ! /* No read() on the QoS device */ ! return -1; ! ! } ! ! static ssize_t qosdev_write(struct file *f, const char *buf, size_t count, loff_t *dummy) ! { ! if (count != msgdim) { ! /* FIXME: find a better error code */ ! return -1; ! } ! if ((queue_tail + 1) % MAX_MESSAGES == queue_head) { ! /* Here, we consider the queue as full... */ ! /* FIXME: find a better error code */ ! return -1; ! } ! if (copy_from_user(qos_queue + queue_tail * msgdim, buf, count)) { ! return -EFAULT; ! } ! if (!available_qos_data()) { ! wake_up_interruptible(&qos_dev_queue); ! } ! queue_tail = (queue_tail + 1) % MAX_MESSAGES; ! ! return count; ! } ! ! static int qosdev_open(struct inode *in, struct file *f) ! { ! MOD_INC_USE_COUNT; ! ! return 0; ! } ! ! static int qosdev_close(struct inode *in, struct file *f) ! { ! MOD_DEC_USE_COUNT; ! ! return 0; ! } ! ! static struct file_operations qos_fops = { read: qosdev_read, write: qosdev_write, *************** *** 38,41 **** --- 89,96 ---- release: qosdev_close }; + + + + /* Err... Probably we will need to store the message dimension in * a general way. For now, let's make it simple... *************** *** 75,83 **** } - static int available_qos_data(void) - { - return (queue_head != queue_tail); - } - int receivefromport(PORT port, void *p) { --- 130,133 ---- *************** *** 97,144 **** return 1; } - - static ssize_t qosdev_read(struct file *f, char *buf, size_t count, loff_t *pos) - { - /* No read() on the QoS device */ - return -1; - - } - - - - static ssize_t qosdev_write(struct file *f, const char *buf, size_t count, loff_t *dummy) - { - if (count != msgdim) { - /* FIXME: find a better error code */ - return -1; - } - if ((queue_tail + 1) % MAX_MESSAGES == queue_head) { - /* Here, we consider the queue as full... */ - /* FIXME: find a better error code */ - return -1; - } - if (copy_from_user(qos_queue + queue_tail * msgdim, buf, count)) { - return -EFAULT; - } - if (!available_qos_data()) { - wake_up_interruptible(&qos_dev_queue); - } - queue_tail = (queue_tail + 1) % MAX_MESSAGES; - - return count; - } - - static int qosdev_open(struct inode *in, struct file *f) - { - MOD_INC_USE_COUNT; - - return 0; - } - - static int qosdev_close(struct inode *in, struct file *f) - { - MOD_DEC_USE_COUNT; - - return 0; - } - --- 147,148 ---- Index: pscompr.c =================================================================== RCS file: /cvsroot/linux-hls/qosman/src/pscompr.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** pscompr.c 21 Feb 2004 13:01:54 -0000 1.1.1.1 --- pscompr.c 9 Apr 2004 13:39:57 -0000 1.2 *************** *** 41,50 **** /* This file implements the bandwidth assignment for PPS tasks */ /************************************************************************/ - /* #include <stdlib.h> Check!!! */ #include <basetype.h> #include <funcs.h> #include "ps.h" ! #include "stats.h" #define MAXPPS 64 --- 41,49 ---- /* This file implements the bandwidth assignment for PPS tasks */ /************************************************************************/ #include <basetype.h> #include <funcs.h> #include "ps.h" ! /* #include "stats.h" */ #define MAXPPS 64 *************** *** 54,58 **** #ifdef __PS_STATS__ ! struct taskstat propstats[10000][10]; static int sk = 0; #endif --- 53,57 ---- #ifdef __PS_STATS__ ! static struct taskstat propstats[10000][10]; static int sk = 0; #endif Index: srv-ks.c =================================================================== RCS file: /cvsroot/linux-hls/qosman/src/srv-ks.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** srv-ks.c 21 Feb 2004 13:01:54 -0000 1.1.1.1 --- srv-ks.c 9 Apr 2004 13:39:57 -0000 1.2 *************** *** 27,39 **** #include <cbs.h> - /* - #include <time.h> - #include <scheduler.h> - */ /* FIXME: fill the #includes */ #include <global.h> - //#include "server.h" /* 4 server_init */ - MODULE_LICENSE("GPL"); --- 27,33 ---- *************** *** 52,70 **** int cprintf(char *s, ...) { ! static char buff[1024]; ! va_list parms; ! int result; ! va_start(parms, s); ! result = vsprintf(buff, s, parms); ! va_end(parms); ! printk("%s", buff); ! ! return (result); } void qman_error(const char *s) { ! cprintf("%s\n", s); } /* --- 46,64 ---- int cprintf(char *s, ...) { ! static char buff[1024]; ! va_list parms; ! int result; ! va_start(parms, s); ! result = vsprintf(buff, s, parms); ! va_end(parms); ! printk("%s", buff); ! ! return (result); } void qman_error(const char *s) { ! cprintf("%s\n", s); } /* *************** *** 73,80 **** void qos_abort(int code) { ! /* FIXME: We are a kernel module... WTF should we do here? */ ! cprintf("Aborting... code = %d\n", code); ! ! BUG(); } --- 67,74 ---- void qos_abort(int code) { ! /* FIXME: We are a kernel module... WTF should we do here? */ ! cprintf("Aborting... code = %d\n", code); ! ! BUG(); } *************** *** 87,100 **** struct qtask_global *manager_registertask(void) { ! struct qtask_global *p; ! p = kmalloc(sizeof(struct qtask_global), GFP_ATOMIC); ! return p; } void manager_unregistertask(struct qtask_global *p) { ! kfree(p); } --- 81,94 ---- struct qtask_global *manager_registertask(void) { ! struct qtask_global *p; ! p = kmalloc(sizeof(struct qtask_global), GFP_ATOMIC); ! return p; } void manager_unregistertask(struct qtask_global *p) { ! kfree(p); } *************** *** 108,112 **** DWORD sys_utilization(REAL rmu) { ! return fake_u; } --- 102,106 ---- DWORD sys_utilization(REAL rmu) { ! return fake_u; } Index: clnt-us.c =================================================================== RCS file: /cvsroot/linux-hls/qosman/src/clnt-us.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** clnt-us.c 21 Feb 2004 13:01:53 -0000 1.1.1.1 --- clnt-us.c 9 Apr 2004 13:39:57 -0000 1.2 *************** *** 37,44 **** #include "client.h" - /* - #define QOSDBG - */ - #define MAX_RSV 100 --- 37,40 ---- *************** *** 53,71 **** int cprintf(char *s, ...) { ! char buff[1024]; ! va_list parms; ! int result; ! va_start(parms, s); ! result = vsprintf(buff, s, parms); ! va_end(parms); ! write(logfile, buff, strlen(buff)); ! return (result); } void qman_error(const char *s) { ! cprintf("%s: %s\n", s, strerror(errno)); } --- 49,67 ---- int cprintf(char *s, ...) { ! char buff[1024]; ! va_list parms; ! int result; ! va_start(parms, s); ! result = vsprintf(buff, s, parms); ! va_end(parms); ! write(logfile, buff, strlen(buff)); ! return (result); } void qman_error(const char *s) { ! cprintf("%s: %s\n", s, strerror(errno)); } *************** *** 80,84 **** struct qtask_local *getfreedescriptor(void) { ! return &localdescr; } --- 76,80 ---- struct qtask_local *getfreedescriptor(void) { ! return &localdescr; } *************** *** 89,101 **** struct qtask_local *getdescr(void) { ! return &localdescr; } ID currenttask(void) { ! struct qtask_local *p; ! p = getdescr(); ! return p->id; } --- 85,97 ---- struct qtask_local *getdescr(void) { ! return &localdescr; } ID currenttask(void) { ! struct qtask_local *p; ! p = getdescr(); ! return p->id; } *************** *** 105,175 **** */ ID inittask(char *name, void (*body) (WORD), ! WORD arg, unsigned int w, DWORD q, DWORD period, DWORD drel, BYTE model) { ! pid_t pid; ! int res; ! struct sched_param sp; ! struct cbs_param cs; ! struct qtask_local *myself; #ifdef QOSDBG ! cprintf(" Creatin' task with period...%d\n", period); #endif ! pid = fork(); ! if (pid < 0) { ! qman_error("Cannot fork task!!!\n"); ! return NULLID; ! } ! if (pid == 0) { ! struct sigaction sa; ! struct itimerval it; /* Remember: My ID is my PID... */ ! qtask_register(getpid(), USEC2BAND(q, period), w, period, drel, q); ! /* Make periodic... */ ! /* We must setup a periodic signal (setitimer)*/ ! sa.sa_handler = activation_handler; ! sigemptyset(&sa.sa_mask); ! sa.sa_flags=0; ! res = sigaction(SIGALRM, &sa, NULL); ! it.it_interval.tv_sec = 0; ! it.it_interval.tv_usec = period; ! it.it_value.tv_sec = 0; ! it.it_value.tv_usec = period; ! res = setitimer(ITIMER_REAL, &it, NULL); ! if (res < 0) { ! qman_error("ITimerSet"); ! exit(-1); ! } ! myself = getdescr(); ! myself->id = getpid(); ! cprintf(" In child..."); ! body(arg); ! /* We should not arrive here... */ ! cprintf(" Task finished...\n"); ! qtask_unregister(getpid()); ! exit(0); ! } ! /* Here, we must transform the child in a CBS guy */ ! sp.sched_size = sizeof(struct cbs_param); ! sp.sched_p = &cs; ! cs.signature = CBS_SIGNATURE; ! cs.max_budget = q; ! cs.period = drel; ! res = sched_setscheduler(pid, SCHED_CBS, &sp); ! if (res < 0) { ! cprintf("Cannot create the CPU reserve for task %s!!!\n", name); ! return NULLID; ! } ! return pid; } --- 101,174 ---- */ ID inittask(char *name, void (*body) (WORD), ! WORD arg, unsigned int w, DWORD q, DWORD period, DWORD drel, BYTE model) { ! pid_t pid; ! int res; ! struct sched_param sp; ! struct cbs_param cs; ! struct qtask_local *myself; #ifdef QOSDBG ! cprintf(" Creatin' task with period...%d\n", period); #endif ! pid = fork(); ! if (pid < 0) { ! qman_error("Cannot fork task!!!\n"); ! return NULLID; ! } ! if (pid == 0) { ! struct sigaction sa; ! struct itimerval it; /* Remember: My ID is my PID... */ ! qtask_register(getpid(), USEC2BAND(q, period), w, period, drel, q); ! if (model == MM_TASK) { ! /* Make periodic... */ ! /* We must setup a periodic signal (setitimer)*/ ! sa.sa_handler = activation_handler; ! sigemptyset(&sa.sa_mask); ! sa.sa_flags=0; ! res = sigaction(SIGALRM, &sa, NULL); ! it.it_interval.tv_sec = 0; ! it.it_interval.tv_usec = period; ! it.it_value.tv_sec = 0; ! it.it_value.tv_usec = period; ! res = setitimer(ITIMER_REAL, &it, NULL); ! if (res < 0) { ! qman_error("ITimerSet"); ! /* FIXME: Maybe return error? */ ! exit(-1); ! } ! } ! myself = getdescr(); ! myself->id = getpid(); ! cprintf(" In child..."); ! body(arg); ! /* We should not arrive here... */ ! cprintf(" Task finished...\n"); ! qtask_unregister(getpid()); ! exit(0); ! } ! /* Here, we must transform the child in a CBS guy */ ! sp.sched_size = sizeof(struct cbs_param); ! sp.sched_p = &cs; ! cs.signature = CBS_SIGNATURE; ! cs.max_budget = q; ! cs.period = drel; ! res = sched_setscheduler(pid, SCHED_CBS, &sp); ! if (res < 0) { ! cprintf("Cannot create the CPU reserve for task %s!!!\n", name); ! return NULLID; ! } ! return pid; } *************** *** 177,231 **** DWORD q) { ! pid_t pid; ! // struct timespec rq, z; ! unsigned long int t; ! int res; ! struct qtask_local *myself; ! struct sched_param sp; ! struct cbs_param cs; #ifdef QOSDBG ! cprintf("Creatin' PS task\n"); #endif ! /* Create the task with a long period (like a bkg task...) */ ! t = 1000000; ! pid = fork(); ! if (pid < 0) { ! qman_error("Cannot fork task!!!\n"); ! ! return NULLID; ! } ! if (pid == 0) { ! myself = getdescr(); ! myself->id = getpid(); ! pstask_register(getpid(), weight, q); ! body(arg); ! /* We should not arrive here... */ ! cprintf("PS task finished...\n"); ! pstask_unregister(getpid()); ! exit(0); ! } ! /* Here, we must transform the child in a CBS guy */ ! sp.sched_size = sizeof(struct cbs_param); ! sp.sched_p = &cs; ! cs.signature = CBS_SIGNATURE; ! cs.max_budget = q; ! cs.period = t; ! res = sched_setscheduler(pid, SCHED_CBS, &sp); ! if (res < 0) { ! cprintf("Cannot create the CPU reserve for task %s!!!\n", name); ! return NULLID; ! } ! return pid; } int endinstance(void) { ! return pause(); } --- 176,230 ---- DWORD q) { ! pid_t pid; ! unsigned long int t; ! int res; ! struct qtask_local *myself; ! struct sched_param sp; ! struct cbs_param cs; #ifdef QOSDBG ! cprintf("Creatin' PS task\n"); #endif ! /* Create the task with a long period (like a bkg task...) */ ! t = 1000000; ! pid = fork(); ! if (pid < 0) { ! qman_error("Cannot fork task!!!\n"); ! return NULLID; ! } ! if (pid == 0) { ! myself = getdescr(); ! myself->id = getpid(); ! pstask_register(getpid(), weight, q); ! ! body(arg); ! /* We should not arrive here... */ ! cprintf("PS task finished...\n"); ! pstask_unregister(getpid()); ! exit(0); ! } ! /* Here, we must transform the child in a CBS guy */ ! sp.sched_size = sizeof(struct cbs_param); ! sp.sched_p = &cs; ! cs.signature = CBS_SIGNATURE; ! cs.max_budget = q; ! cs.period = t; ! res = sched_setscheduler(pid, SCHED_CBS, &sp); ! if (res < 0) { ! cprintf("Cannot create the CPU reserve for task %s!!!\n", name); ! return NULLID; ! } ! ! return pid; } int endinstance(void) { ! return pause(); } *************** *** 235,296 **** REAL glob_getband(ID task) { ! int res; ! struct sched_param sp; ! struct cbs_error ce; ! DWORD q, t; ! REAL band; ! int id; ! id = currenttask(); ! /* We need some way to get the current parameters of this task... */ ! sp.sched_size = sizeof(struct cbs_error); ! sp.sched_p = &ce; ! ce.signature = E_SIGNATURE; ! res = sched_getparam(getpid(), &sp); ! if (res < 0) { ! cprintf("Cannot get the scheduling parameters for task %d!!!\n", ! getpid()); ! return 0; ! } ! q = ce.max_budget; ! t = ce.period; ! band = USEC2BAND(q, t); ! return band; } PORT connecttoport(char *name, int size, int mode) { ! int res = -1; ! char localname[256]; ! sprintf(localname, "/tmp/%s", name); #ifdef QOSDBG ! cprintf("Connecting to the QoS server through port %s\n", name); #endif ! res = open(localname, mode); #ifdef QOSDBG ! cprintf("%s --> ", localname); #endif ! if (res < 0) { ! return -1; ! } #ifdef QOSDBG ! cprintf("Connected\n"); #endif ! msgdim = size; ! return res; /* In Linux, this is not used... */ } int sendtoport(PORT port, void *p) { ! write(port, p, msgdim); ! return 1; } --- 234,295 ---- REAL glob_getband(ID task) { ! int res; ! struct sched_param sp; ! struct cbs_error ce; ! DWORD q, t; ! REAL band; ! int id; ! id = currenttask(); ! /* We need some way to get the current parameters of this task... */ ! sp.sched_size = sizeof(struct cbs_error); ! sp.sched_p = &ce; ! ce.signature = E_SIGNATURE; ! res = sched_getparam(getpid(), &sp); ! if (res < 0) { ! cprintf("Cannot get the scheduling parameters for task %d!!!\n", ! getpid()); ! return 0; ! } ! q = ce.max_budget; ! t = ce.period; ! band = USEC2BAND(q, t); ! return band; } PORT connecttoport(char *name, int size, int mode) { ! int res = -1; ! char localname[256]; ! sprintf(localname, "/tmp/%s", name); #ifdef QOSDBG ! cprintf("Connecting to the QoS server through port %s\n", name); #endif ! res = open(localname, mode); #ifdef QOSDBG ! cprintf("%s --> ", localname); #endif ! if (res < 0) { ! return -1; ! } #ifdef QOSDBG ! cprintf("Connected\n"); #endif ! msgdim = size; ! return res; /* In Linux, this is not used... */ } int sendtoport(PORT port, void *p) { ! write(port, p, msgdim); ! return 1; } *************** *** 300,339 **** int qostask_init(int p) { ! return 1; } ! int howlate(ID dummy) { ! int res; ! struct sched_param sp; ! struct cbs_error ce; ! sp.sched_size = sizeof(struct cbs_error); ! sp.sched_p = &ce; ! ce.signature = E_SIGNATURE; ! res = sched_getparam(getpid(), &sp); ! if (res < 0) { ! cprintf("Cannot get the scheduling error!!!\n"); ! return -1; ! } ! return (int)ce.e; } ! int getq(ID dummy) { ! int res; ! struct sched_param sp; ! struct cbs_error ce; ! sp.sched_size = sizeof(struct cbs_error); ! sp.sched_p = &ce; ! ce.signature = E_SIGNATURE; ! res = sched_getparam(getpid(), &sp); ! if (res < 0) { ! cprintf("Cannot get the scheduling error!!!\n"); ! return -1; ! } ! return (int)ce.max_budget; } --- 299,338 ---- int qostask_init(int p) { ! return 1; } ! int internal_howlate(ID dummy) { ! int res; ! struct sched_param sp; ! struct cbs_error ce; ! sp.sched_size = sizeof(struct cbs_error); ! sp.sched_p = &ce; ! ce.signature = E_SIGNATURE; ! res = sched_getparam(getpid(), &sp); ! if (res < 0) { ! cprintf("Cannot get the scheduling error!!!\n"); ! return -1; ! } ! return (int)ce.e; } ! int internal_budget(ID dummy) { ! int res; ! struct sched_param sp; ! struct cbs_error ce; ! sp.sched_size = sizeof(struct cbs_error); ! sp.sched_p = &ce; ! ce.signature = E_SIGNATURE; ! res = sched_getparam(getpid(), &sp); ! if (res < 0) { ! cprintf("Cannot get the scheduling error!!!\n"); ! return -1; ! } ! return (int)ce.max_budget; } Index: srv-us.c =================================================================== RCS file: /cvsroot/linux-hls/qosman/src/srv-us.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** srv-us.c 21 Feb 2004 13:01:54 -0000 1.1.1.1 --- srv-us.c 9 Apr 2004 13:39:57 -0000 1.2 *************** *** 35,40 **** #include <cbs.h> - //#include "server.h" /* 4 server_init */ - #define CSERV 1000000 #define TSERV 10000000 --- 35,38 ---- Index: qman-s.c =================================================================== RCS file: /cvsroot/linux-hls/qosman/src/qman-s.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** qman-s.c 21 Feb 2004 13:01:54 -0000 1.1.1.1 --- qman-s.c 9 Apr 2004 13:39:57 -0000 1.2 *************** *** 26,37 **** static REAL rmu = 0; ! struct qtask_global *qosq; /* task set */ ! void (*rescale_init) (REAL fbw) = prop_init; ! void *(*rescale_create) (REAL u, unsigned int w) = prop_create; ! void (*rescale_destroy) (void *p) = prop_destroy; ! REAL (*rescale_getband) (void *p) = prop_getband; ! void (*rescale_setband) (void *p, REAL u) = prop_setband; ! void (*rescale_compress) (void) = prop_compress; /* --- 26,37 ---- static REAL rmu = 0; ! static struct qtask_global *qosq; /* task set */ ! static void (*rescale_init) (REAL fbw) = prop_init; ! static void *(*rescale_create) (REAL u, unsigned int w) = prop_create; ! static void (*rescale_destroy) (void *p) = prop_destroy; ! static REAL (*rescale_getband) (void *p) = prop_getband; ! static void (*rescale_setband) (void *p, REAL u) = prop_setband; ! static void (*rescale_compress) (void) = prop_compress; /* *************** *** 39,43 **** * action runs... */ ! void adjustparms(void) { struct qtask_global *p; --- 39,43 ---- * action runs... */ ! static void adjustparms(void) { struct qtask_global *p; *************** *** 48,52 **** p->oldq = p->q; #ifdef QOSDBG ! cprintf(" Task %d: Changin' Q from %lu", p->id, p->q); #endif p->q = BAND2CAPACITY(p->drel, rescale_getband(p->compress)); --- 48,52 ---- p->oldq = p->q; #ifdef QOSDBG ! cprintf(" Task %d: Changin' Q from %lu", p->id, p->q); #endif p->q = BAND2CAPACITY(p->drel, rescale_getband(p->compress)); Index: adj.c =================================================================== RCS file: /cvsroot/linux-hls/qosman/src/adj.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** adj.c 21 Feb 2004 13:01:53 -0000 1.1.1.1 --- adj.c 9 Apr 2004 13:39:57 -0000 1.2 *************** *** 48,58 **** #include "stats.h" #include "req.h" - #include "adj.h" #define MAXADJ 64 - //#define __ADJ_DEBUG__ #define min(a,b) (a < b) ? a : b #ifdef __ADJ_STATS__ /* Statistics... */ --- 48,71 ---- #include "stats.h" #include "req.h" #define MAXADJ 64 #define min(a,b) (a < b) ? a : b + struct adjparm { + int iden; + int progr; + + int busy; + REAL oldb; + REAL b; + REAL incr; + int desired; + REAL max; + int period; + REAL acc; + }; + + #ifdef __ADJ_STATS__ /* Statistics... */ *************** *** 61,73 **** static int static_id; - struct reqactions adjactions = { - adj_init, - adj_create, - adj_destroy, - adj_setb, - adj_feedb, - adj_setstats - }; - /* * Inits the feeedback function environment... --- 74,77 ---- *************** *** 90,94 **** } adjstats[i] = p; ! #endif __ADJ_STATS__ } --- 94,98 ---- } adjstats[i] = p; ! #endif /* __ADJ_STATS__ */ } *************** *** 98,118 **** void *adj_create(DWORD q, DWORD desired, DWORD ts, DWORD period) { ! struct adjparm *parms; ! parms = qos_alloc(sizeof(struct adjparm)); ! parms->b = USEC2BAND(q, period); #ifdef __ADJ_DEBUG__ ! cprintf(" Creating ADJ Controller: b = %f\n", parms->b); #endif ! parms->oldb = parms->b; ! parms->incr = 20 * parms->b; ! parms->desired = desired; ! parms->max = USEC2BAND(q, ts); /* FIXME: How to set the max value? */ ! parms->period = period; ! parms->acc = 0; ! parms->iden = static_id++; ! parms->progr = 0; ! return parms; } --- 102,122 ---- void *adj_create(DWORD q, DWORD desired, DWORD ts, DWORD period) { ! struct adjparm *parms; ! parms = qos_alloc(sizeof(struct adjparm)); ! parms->b = USEC2BAND(q, period); #ifdef __ADJ_DEBUG__ ! cprintf(" Creating ADJ Controller: b = %f\n", parms->b); #endif ! parms->oldb = parms->b; ! parms->incr = 20 * parms->b; ! parms->desired = desired; ! parms->max = USEC2BAND(q, ts); /* FIXME: How to set the max value? */ ! parms->period = period; ! parms->acc = 0; ! parms->iden = static_id++; ! parms->progr = 0; ! return parms; } *************** *** 122,128 **** void adj_destroy(void *p) { ! struct adjparm *parms = (struct adjparm *) p; ! qos_free(parms); } --- 126,132 ---- void adj_destroy(void *p) { ! struct adjparm *parms = (struct adjparm *) p; ! qos_free(parms); } *************** *** 132,195 **** REAL adj_feedb(void *p, int l) { ! struct adjparm *parms = (struct adjparm *) p; ! REAL newb; #ifdef __ADJ_DEBUG__ ! cprintf(" Period: %d --- Old BW: %lu --- err: %d --- BW: %lu\n", ! parms->period, real_to_int(parms->oldb), ! l - parms->desired, real_to_int(parms->b)); #endif /* newb = parms->oldb + ((l - parms->desired) * parms->b) / parms->period; */ /* WHAT A MESS!!! Use some helping variables... */ ! newb = real_sum(parms->oldb, ! real_int_div((real_int_mul(parms->b, (l - parms->desired))), ! parms->period)); #ifdef __ADJ_DEBUG__ ! cprintf(" Proportional BW: %lu\n", real_to_int(newb)); #endif ! if (l == parms->desired) { ! if (parms->acc >= real_int_div(parms->incr, 1)) { ! REAL tmp; ! tmp = real_sub(parms->acc, real_int_div(parms->incr, 1)); ! parms->acc = tmp; ! } else { ! parms->acc = 0; ! } } else { ! REAL tmp; ! ! tmp = real_sum(parms->acc, parms->incr); ! parms->acc = tmp; } #ifdef __ADJ_DEBUG__ ! cprintf(" Accumulated value: %lu\n", real_to_int(parms->acc)); #endif ! /* Saturation */ ! if (newb > parms->max) { ! newb = parms->max; ! } #ifdef __ADJ_STATS__ ! /* FIXME */ ! if (adjstats != NULL) { ! adjstats[parms->iden][parms->progr].time = /*qos_time()*/ parms->progr; ! adjstats[parms->iden][parms->progr].l = l; ! adjstats[parms->iden][parms->progr].band = newb; ! adjstats[parms->iden][parms->progr].fval[0] = parms->oldb; ! adjstats[parms->iden][parms->progr].fval[1] = ! (parms->b * (l - parms->desired)) / parms->period; ! adjstats[parms->iden][parms->progr].fval[2] = parms->acc; ! adjstats[parms->iden][parms->progr++].q = ! BAND2CAPACITY(parms->period, newb); ! } #endif ! parms->oldb = newb; ! return newb; } --- 136,199 ---- REAL adj_feedb(void *p, int l) { ! struct adjparm *parms = (struct adjparm *) p; ! REAL newb; #ifdef __ADJ_DEBUG__ ! cprintf(" Period: %d --- Old BW: %lu --- err: %d --- BW: %lu\n", ! parms->period, real_to_int(parms->oldb), ! l - parms->desired, real_to_int(parms->b)); #endif /* newb = parms->oldb + ((l - parms->desired) * parms->b) / parms->period; */ /* WHAT A MESS!!! Use some helping variables... */ ! newb = real_sum(parms->oldb, ! real_int_div((real_int_mul(parms->b, (l - parms->desired))), ! parms->period)); #ifdef __ADJ_DEBUG__ ! cprintf(" Proportional BW: %lu\n", real_to_int(newb)); #endif ! if (l == parms->desired) { ! if (parms->acc >= real_int_div(parms->incr, 1)) { ! REAL tmp; ! tmp = real_sub(parms->acc, real_int_div(parms->incr, 1)); ! parms->acc = tmp; } else { ! parms->acc = 0; } + } else { + REAL tmp; + + tmp = real_sum(parms->acc, parms->incr); + parms->acc = tmp; + } #ifdef __ADJ_DEBUG__ ! cprintf(" Accumulated value: %lu\n", real_to_int(parms->acc)); #endif ! /* Saturation */ ! if (newb > parms->max) { ! newb = parms->max; ! } #ifdef __ADJ_STATS__ ! /* FIXME */ ! if (adjstats[parms->iden] != NULL) { ! adjstats[parms->iden][parms->progr].time = /*qos_time()*/ parms->progr; ! adjstats[parms->iden][parms->progr].l = l; ! adjstats[parms->iden][parms->progr].band = newb; ! adjstats[parms->iden][parms->progr].fval[0] = parms->oldb; ! adjstats[parms->iden][parms->progr].fval[1] = ! (parms->b * (l - parms->desired)) / parms->period; ! adjstats[parms->iden][parms->progr].fval[2] = parms->acc; ! adjstats[parms->iden][parms->progr++].q = ! BAND2CAPACITY(parms->period, newb); ! } #endif ! parms->oldb = newb; ! return newb; } *************** *** 199,204 **** void adj_setb(void *p, REAL band) { ! struct adjparm *parms = (struct adjparm *) p; ! parms->oldb = band; } --- 203,217 ---- void adj_setb(void *p, REAL band) { ! struct adjparm *parms = (struct adjparm *) p; ! parms->oldb = band; } + + struct reqactions adjactions = { + adj_init, + adj_create, + adj_destroy, + adj_setb, + adj_feedb, + adj_setstats + }; |