From 92a5f4dd054b3160994a4ea0c1c5fc98c67ce826 Mon Sep 17 00:00:00 2001 From: hadaq Date: Fri, 5 Oct 2007 09:17:26 +0000 Subject: [PATCH] reading of variable queue sizes from param file was introduced. S.Y. --- hadaq/evtbuild.c | 23 +++++++++++++++++++++-- hadaq/netmem.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/hadaq/evtbuild.c b/hadaq/evtbuild.c index d045c1f..f89d334 100644 --- a/hadaq/evtbuild.c +++ b/hadaq/evtbuild.c @@ -1,5 +1,5 @@ static char *rcsId = - "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.78 2007-04-24 15:28:42 hadaq Exp $"; + "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.79 2007-10-05 09:17:26 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L @@ -34,6 +34,7 @@ static char *rcsId = #include "ansiTape.h" #include "genid32.h" +#define MAXINPATH 32 #define NEVTIDS 64UL /* must be 2^n */ #define NEVTIDS_IN_FILE 0UL /* must be 2^n */ @@ -82,6 +83,10 @@ typedef struct TheArgsS unsigned int ressizelimit; double secsizelimit; double resdown_offset; + + /* the following arguments are for the variable queue size. S.Y. */ + long varQSize[MAXINPATH]; + int varQSizeCnt; } TheArgs; typedef struct TheStatsS @@ -238,6 +243,10 @@ argsDefault (TheArgs * my) my->secsizelimit = 0.; my->ressizelimit = 0; strcpy (my->respath, ""); + + for (i = 0; i < MAXINPATH; i++) { + my->varQSize[i] = 1 * 1024 * 1024; + } } static int @@ -457,6 +466,8 @@ argsFromParam (TheArgs * my, int argc, char *argv[]) Param_getString (param, name, "verb", ¶mWasFound, my->verbosity); Param_getInt (param, name, "evtid", ¶mWasFound, &my->evtId); Param_getInt (param, name, "maxfilesz", ¶mWasFound, &my->maxFileSz); + + Param_getIntArray(param, name, "varqsize", MAXINPATH, &my->varQSizeCnt, my->varQSize); desParam (param); } @@ -1396,7 +1407,15 @@ main (int argc, char *argv[]) char buf[_POSIX_PATH_MAX]; sprintf (buf, "netqueue%d", i); - shmTrans[i] = ShmTrans_create (buf, 2 * theArgs->queueSize); + + if( theArgs->queueSize > 0 ) { + /* The queueSize is given in CL. */ + shmTrans[i] = ShmTrans_create (buf, 2 * theArgs->queueSize); + } + else{ + shmTrans[i] = ShmTrans_create (buf, 2 * (long)theArgs->varQSize[i]); + } + hadTuQueue[i] = NULL; } } diff --git a/hadaq/netmem.c b/hadaq/netmem.c index cf72953..81f5e11 100644 --- a/hadaq/netmem.c +++ b/hadaq/netmem.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.28 2004-08-13 10:30:00 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.29 2007-10-05 09:17:26 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L @@ -29,6 +29,8 @@ typedef struct TheArgsS { unsigned long isStandalone; unsigned long priority; unsigned long queueSize; + long varQSize[MAXINPATH]; + int varQSizeCnt; char verbosity[PARAM_MAX_VALUE_LEN]; } TheArgs; @@ -71,6 +73,10 @@ static void argsDefault(TheArgs *my) my->isStandalone = 1; my->queueSize = 1 * 1024 * 1024; strcpy(my->verbosity, "info"); + + for (i = 0; i < MAXINPATH; i++) { + my->varQSize[i] = 1 * 1024 * 1024; + } } static int argsFromCL(TheArgs *my, int argc, char *argv[]) @@ -132,6 +138,9 @@ static int argsFromParam(TheArgs *my, int argc, char *argv[]) Param_getInt(param, name, "prio", ¶mWasFound, &my->priority); Param_getInt(param, name, "qsize", ¶mWasFound, &my->queueSize); Param_getString(param, name, "verb", ¶mWasFound, my->verbosity); + + /* this is an argument for a variable queue size. S.Y.*/ + Param_getIntArray(param, name, "varqsize", MAXINPATH, &my->varQSizeCnt, my->varQSize); desParam(param); } @@ -266,13 +275,30 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } sprintf(buf, "netqueue%d", i); - shmTrans[i] = ShmTrans_open(buf, 2 * theArgs->queueSize); + + if( theArgs->queueSize > 0 ){ + /* if the queueSize is given in CL */ + shmTrans[i] = ShmTrans_open(buf, 2 * theArgs->queueSize); + } + else{ + /* otherwise use variable queue size */ + shmTrans[i] = ShmTrans_open(buf, 2 * (long)theArgs->varQSize[i]); + } + if (shmTrans[i] == NULL) { syslog(LOG_ERR, "%s, %d: %s", __FILE__, __LINE__, strerror(errno)); exit(EXIT_FAILURE); } hadTu[i] = NULL; - hadTuSize[i] = theArgs->queueSize - HadTu_hdrSize(); + + if( theArgs->queueSize > 0) { + /* if the queueSize is given in CL */ + hadTuSize[i] = theArgs->queueSize - HadTu_hdrSize(); + } + else{ + /* otherwise use variable queue size */ + hadTuSize[i] = theArgs->varQSize[i] - HadTu_hdrSize(); + } } storeInfoStart(argv[0], time(NULL), theArgs); Worker_initEnd(worker); -- 2.43.0