-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>
#include "worker.h"
typedef struct TheArgsS {
+ unsigned long waterMark;
unsigned long isStandalone;
unsigned long priority;
unsigned long queueSize;
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);
}
static void argsDefault(TheArgs *my) {
+ my->waterMark = 56 * 1024;
my->priority = 0;
my->isStandalone = 1;
my->queueSize = 1 * 1024 * 1024;
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;
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);
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);