From 948211e604f7979cc924c1be757f27c8500ce6dc Mon Sep 17 00:00:00 2001 From: hadaq Date: Tue, 10 Aug 2004 11:10:43 +0000 Subject: [PATCH] make statistic readable by anyone --- hadaq/hades.tcl | 23 +++++++++++++---------- hadaq/psxshm.c | 21 ++++++++++++++++----- hadaq/worker.c | 4 ++-- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/hadaq/hades.tcl b/hadaq/hades.tcl index 66c2937..889e7d7 100644 --- a/hadaq/hades.tcl +++ b/hadaq/hades.tcl @@ -1,7 +1,10 @@ # the list of sub systems according to your needs, possible sub systems # are: trig rich0 rich1 rich2 mdc0 tof1 tof2 tof3 shw -set subSystems { trig rich0 rich1 rich2 tof1 tof2 tof3 tof4 shw mdc0 mdc1 } +set subSystems { trig shw rich0 rich1 rich2 tof1 tof2 tof3 } +#set subSystems { trig shw rich0 rich1 rich2 } +#set subSystems { trig rich0 rich1 rich2 tof1 tof2 tof3 tof4 } +#set subSystems { trig rich0 rich1 rich2 } # the component in the HADES_BASE_DIR set beamTime sep03 @@ -110,15 +113,15 @@ if {[lsearch $subSystems rich2] >= 0} { if {[lsearch $subSystems mdc0] >= 0} { set atmOffset 5 set vcc [expr $atmBase + $atmOffset] - agent create r2f-14 hades /hades/usr/hades/$beamTime/mdc/hwmdc - worker create r2f-14:memnet -a -p -2 -w $bandwidth($atmOffset) -o $prot:$addr:$vcc - worker create r2f-14:readout -s mdc0 -a -p -1 -w $watermark_mdc -v notice - group add acquisition r2f-14:memnet - group add acquisition r2f-14:readout - lappend init r2f-14:mdc0:init - lappend reset [ list r2f-14 ". \$HOME/.bash_profile; cd \$HOME/$beamTime/slow; ./mdc0 reset" ] - lappend start [ list r2f-14 ". \$HOME/.bash_profile; cd \$HOME/$beamTime/slow; ./mdc0 start" ] - lappend stop [ list r2f-14 ". \$HOME/.bash_profile; cd \$HOME/$beamTime/slow; ./mdc0 stop" ] + agent create r2f-8 hades /hades/usr/hades/$beamTime/mdc/hwmdc + worker create r2f-8:memnet -a -p -2 -w $bandwidth($atmOffset) -o $prot:$addr:$vcc + worker create r2f-8:readout -s mdc0 -a -p -1 -w $watermark_mdc -v notice + group add acquisition r2f-8:memnet + group add acquisition r2f-8:readout + lappend init r2f-8:mdc0:init + lappend reset [ list r2f-8 ". \$HOME/.bash_profile; cd \$HOME/$beamTime/slow; ./mdc0 reset" ] + lappend start [ list r2f-8 ". \$HOME/.bash_profile; cd \$HOME/$beamTime/slow; ./mdc0 start" ] + lappend stop [ list r2f-8 ". \$HOME/.bash_profile; cd \$HOME/$beamTime/slow; ./mdc0 stop" ] lappend inPaths "-i $prot:0:$vcc" } diff --git a/hadaq/psxshm.c b/hadaq/psxshm.c index 8516e20..d6a7506 100644 --- a/hadaq/psxshm.c +++ b/hadaq/psxshm.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/psxshm.c,v 6.5 2003-03-02 16:25:00 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/psxshm.c,v 6.6 2004-08-10 11:10:43 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L #include @@ -16,6 +16,7 @@ static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hada PsxShm *PsxShm_open(const char *name, int oflag, mode_t mode, off_t size) { PsxShm *my; + int prot; if (NULL == (my = malloc(sizeof(PsxShm)))) { goto cleanup0; @@ -29,7 +30,18 @@ PsxShm *PsxShm_open(const char *name, int oflag, mode_t mode, off_t size) goto cleanup2; } } - if ((void *) MAP_FAILED == (my->addr = mmap(0, my->size, PROT_READ | PROT_WRITE, MAP_SHARED, my->fd, 0L))) { + + prot = 0; + if (oflag & O_RDONLY) { + prot |= PROT_READ; + } + if (oflag & O_WRONLY) { + prot |= PROT_WRITE; + } + if (oflag & O_RDWR) { + prot |= PROT_READ | PROT_WRITE; + } + if ((void *) MAP_FAILED == (my->addr = mmap(0, my->size, prot, MAP_SHARED, my->fd, 0L))) { goto cleanup2; } return my; @@ -55,9 +67,8 @@ int PsxShm_close(PsxShm *my) { int ret; - if ( - 0 > munmap(my->addr, my->size) - || 0 > close(my->fd) + if (0 > munmap(my->addr, my->size) + || 0 > close(my->fd) ) { ret = -1; } else { diff --git a/hadaq/worker.c b/hadaq/worker.c index c8baf26..941fad5 100644 --- a/hadaq/worker.c +++ b/hadaq/worker.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.25 2003-09-02 19:54:21 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.26 2004-08-10 11:10:43 hadaq Exp $"; #define WORKER_NEW_PROTOCOL @@ -65,7 +65,7 @@ static int createStatShm(Worker *my) syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno)); retVal = -1; } else { - my->shm = PsxShm_open(ipcName, O_CREAT | O_RDWR, S_IRWXU, WORKER_MAX_NUM_STATS * sizeof(Statistic)); + my->shm = PsxShm_open(ipcName, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO, WORKER_MAX_NUM_STATS * sizeof(Statistic)); if (NULL == my->shm) { syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno)); retVal = -1; -- 2.43.0