From e31c69baf167fcc57d347346eb118c58ba0f5724 Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 17 Nov 2000 12:48:54 +0000 Subject: [PATCH] New scheme to calculate the size of the transportet unit The user may provide a water mark, if this is passed, the data is sent. Default is 56K constant. --- hadaq/hadtuqueue.c | 8 +++++++- hadaq/hadtuqueue.h | 1 + hadaq/param.tcl | 7 ++++--- hadaq/readout.c | 31 +++++++++++++++++++++++++------ 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/hadaq/hadtuqueue.c b/hadaq/hadtuqueue.c index f986fa7..aa4640f 100644 --- a/hadaq/hadtuqueue.c +++ b/hadaq/hadtuqueue.c @@ -1,4 +1,4 @@ -static char rcsId[] = "$Id: hadtuqueue.c,v 6.1 1999-08-31 10:37:23 muench Stab $"; +static char rcsId[] = "$Id: hadtuqueue.c,v 6.2 2000-11-17 12:48:54 hades Exp $"; #define _ANSI_C_SOURCE #include @@ -89,6 +89,12 @@ int HadTuQueue_empty(const HadTuQueue *my) return HadTu_size(my->hadTu) == (char *) my->run - (char *) my->hadTu; } +size_t HadTuQueue_size(const HadTuQueue *my) +{ + assert(HadTuQueue_invariant(my)); + return HadTu_size(my->hadTu); +} + void *HadTuQueue_alloc(const HadTuQueue *my, size_t size) { void *retVal; diff --git a/hadaq/hadtuqueue.h b/hadaq/hadtuqueue.h index 0ab4282..a0d4dba 100644 --- a/hadaq/hadtuqueue.h +++ b/hadaq/hadtuqueue.h @@ -21,6 +21,7 @@ void HadTuQueue_clear(HadTuQueue *my); int HadTuQueue_invariant(const HadTuQueue *my); int HadTuQueue_empty(const HadTuQueue *my); +size_t HadTuQueue_size(const HadTuQueue *my); void *HadTuQueue_alloc(const HadTuQueue *my, size_t size); void HadTuQueue_push(HadTuQueue *my); void *HadTuQueue_2voidP(const HadTuQueue *my); diff --git a/hadaq/param.tcl b/hadaq/param.tcl index 6ca545e..a514db1 100644 --- a/hadaq/param.tcl +++ b/hadaq/param.tcl @@ -5,15 +5,16 @@ set evtbuild(nrofmsgs) 1 set netmem(file) ./daq_netmem set netmem(stndln) 0 set netmem(priority) -1 -set netmem(inpath0) ATM:0:100 +set netmem(inpath0) ATM:0:150 set netmem(nrofmsgs) 1 set netmem(verb) debug set memnet(file) ./daq_memnet set memnet(stndln) 0 set memnet(priority) -1 -set memnet(outpath) ATM:0:100 -set memnet(bandwidth) 68000 +set memnet(outpath) ATM:0:150 +set memnet(bandwidth) 1000 set readout(file) ./daq_readout +#set readout(wmark) 0 set readout(stndln) 0 set readout(priority) -2 diff --git a/hadaq/readout.c b/hadaq/readout.c index 806bbb9..2713240 100644 --- a/hadaq/readout.c +++ b/hadaq/readout.c @@ -1,4 +1,4 @@ -static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/readout.c,v 6.13 2000-11-12 14:42:08 hades Exp $"; +static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/readout.c,v 6.14 2000-11-17 12:48:54 hades Exp $"; #define _POSIX_C_SOURCE 199309L #include @@ -19,6 +19,7 @@ static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/had #include "worker.h" typedef struct TheArgsS { + unsigned long waterMark; unsigned long isStandalone; unsigned long priority; unsigned long queueSize; @@ -35,10 +36,12 @@ void sigHandler(int sig) static void usage(const char *progName) { msglog(LOG_ERR, "Usage: %s [-a (agentCtrl)] [-p priority]\n", progName); + msglog(LOG_ERR, "Usage: [-q queueSize] [-w waterMark]\n"); msglog_usage(); } static void argsDump(TheArgs *my) { + msglog(LOG_DEBUG, "waterMark: %d\n", my->waterMark); msglog(LOG_DEBUG, "priority: %d\n", my->priority); msglog(LOG_DEBUG, "isStandalone: %d\n", my->isStandalone); msglog(LOG_DEBUG, "queueSize: %d\n", my->queueSize); @@ -46,6 +49,7 @@ static void argsDump(TheArgs *my) { } static void argsDefault(TheArgs *my) { + my->waterMark = 56 * 1024; my->priority = 0; my->isStandalone = 1; my->queueSize = 1 * 1024 * 1024; @@ -55,8 +59,11 @@ static void argsDefault(TheArgs *my) { static int argsFromCL(TheArgs *my, int argc, char *argv[]) { int i; - while ((i = getopt(argc, argv, "ap:q:v:")) != -1) { + while ((i = getopt(argc, argv, "w:ap:q:v:")) != -1) { switch (i) { + case 'w': + my->waterMark = atoi(optarg); + break; case 'a': my->isStandalone = 0; break; @@ -82,6 +89,7 @@ static int argsFromParam(TheArgs *my, int argc, char *argv[]) { int paramWasFound; conParam(param); + Param_getInt(param, argv[0], "wmark", ¶mWasFound, &my->waterMark); Param_getInt(param, argv[0], "stndln", ¶mWasFound, &my->isStandalone); Param_getInt(param, argv[0], "prio", ¶mWasFound, &my->priority); Param_getInt(param, argv[0], "qsize", ¶mWasFound, &my->queueSize); @@ -132,20 +140,31 @@ void main(int argc, char *argv[]) Worker_initEnd(worker); + + /* at somewhat more than the HadTuQueue header must fit into watermark */ + if (theArgs->waterMark < HadTu_hdrSize()) { + theArgs->waterMark = HadTu_hdrSize(); + } + while (setjmp(terminateJmp) == 0) { - int n = 0; void *hadTu; HadTuQueue *hadTuQueue; + size_t transportSize = theArgs->waterMark + Hardware_maxSubEvtSize(hw) + + sizeof(long); /* BUGBUG HadTuQueue truncates size to alignment, so add sizeof(long) here */ + + Worker_dump(worker, 1); - hadTu = ShmTrans_alloc(shmTrans, 60 * 1024); + hadTu = ShmTrans_alloc(shmTrans, transportSize); #ifndef NDEBUG msglog(LOG_DEBUG, "shmTrans: %p = hadTu: %s\n", hadTu, HadTu_2charP(hadTu)); #endif hadTuQueue = allocMem(HadTuQueue_sizeOf()); - conHadTuQueue(hadTuQueue, hadTu, 60 * 1024); - while (n++ < 100 && NULL != (subEvt = HadTuQueue_alloc(hadTuQueue, Hardware_maxSubEvtSize(hw)))) { + conHadTuQueue(hadTuQueue, hadTu, transportSize); + while ( + HadTuQueue_size(hadTuQueue) <= theArgs->waterMark + && NULL != (subEvt = HadTuQueue_alloc(hadTuQueue, Hardware_maxSubEvtSize(hw))) + ) { Hardware_waitForTrigger(hw, subEvt); Hardware_readout(hw, subEvt); -- 2.43.0