]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
New scheme to calculate the size of the transportet unit
authorhades <hades>
Fri, 17 Nov 2000 12:48:54 +0000 (12:48 +0000)
committerhades <hades>
Fri, 17 Nov 2000 12:48:54 +0000 (12:48 +0000)
The user may provide a water mark, if this is passed, the data is
sent.  Default is 56K constant.

hadaq/hadtuqueue.c
hadaq/hadtuqueue.h
hadaq/param.tcl
hadaq/readout.c

index f986fa733f067e4b22a2fea617406d44994c9e7c..aa4640f36f443a24d6e92c278ee607031bce88c7 100644 (file)
@@ -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 <stddef.h>
@@ -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;
index 0ab4282de593a46262da7f8013c77e42e9936599..a0d4dba669f980ae0b85688ea00e41a0cc736851 100644 (file)
@@ -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);
index 6ca545ea9dc5c3255b550f7e860c54fd71a8e7e5..a514db1c0e77acf091b717c5e4cd032bd8a7c422 100644 (file)
@@ -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
 
index 806bbb90fe3c0735d3c97340b9c748970f032428..2713240b1cfb4fc0cf1534c9fb3083bde322fc45 100644 (file)
@@ -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 <unistd.h>
@@ -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", &paramWasFound, &my->waterMark);
        Param_getInt(param, argv[0], "stndln", &paramWasFound, &my->isStandalone);
        Param_getInt(param, argv[0], "prio", &paramWasFound, &my->priority);
        Param_getInt(param, argv[0], "qsize", &paramWasFound, &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);