CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
evf::FUShmBuffer Class Reference

#include <FUShmBuffer.h>

Public Member Functions

pid_t clientPrcId (unsigned int index)
 
void discardDqmCell (unsigned int iCell)
 
void discardOrphanedRecoCell (unsigned int iCell)
 
void discardRawCell (FUShmRawCell *cell)
 
void discardRecoCell (unsigned int iCell)
 
FUShmDqmCelldqmCell (unsigned int iCell)
 
FUShmDqmCelldqmCellToRead ()
 
dqm::State_t dqmState (unsigned int index)
 
unsigned int evtNumber (unsigned int index)
 
pid_t evtPrcId (unsigned int index)
 
evt::State_t evtState (unsigned int index)
 
time_t evtTimeStamp (unsigned int index)
 
void finishReadingDqmCell (FUShmDqmCell *cell)
 
void finishReadingRawCell (FUShmRawCell *cell)
 
void finishReadingRecoCell (FUShmRecoCell *cell)
 
void finishWritingRawCell (FUShmRawCell *cell)
 
void initialize (unsigned int shmid, unsigned int semid)
 
void lock ()
 
int nbRawCellsToRead () const
 
int nbRawCellsToWrite () const
 
unsigned int nClients () const
 
unsigned int nDqmCells () const
 
unsigned int nRawCells () const
 
unsigned int nRecoCells () const
 
void printDqmState (unsigned int index)
 
void printEvtState (unsigned int index)
 
FUShmRawCellrawCell (unsigned int iCell)
 
FUShmRawCellrawCellToDiscard ()
 
FUShmRawCellrawCellToRead ()
 
FUShmRawCellrawCellToWrite ()
 
FUShmRecoCellrecoCell (unsigned int iCell)
 
FUShmRecoCellrecoCellToRead ()
 
void releaseRawCell (FUShmRawCell *cell)
 
bool removeClientPrcId (pid_t prcId)
 
void reset ()
 
void scheduleRawCellForDiscard (unsigned int iCell)
 
void scheduleRawCellForDiscardServerSide (unsigned int iCell)
 
void scheduleRawEmptyCellForDiscard ()
 
void scheduleRawEmptyCellForDiscard (FUShmRawCell *cell)
 
void scheduleRawEmptyCellForDiscardServerSide (FUShmRawCell *cell)
 
void sem_print ()
 
int semid () const
 
bool setDqmState (unsigned int index, dqm::State_t state)
 
bool setEvtState (unsigned int index, evt::State_t state)
 
int shmid () const
 
void unlock ()
 
void writeDqmEmptyEvent ()
 
bool writeDqmEventData (unsigned int runNumber, unsigned int evtAtUpdate, unsigned int folderId, unsigned int fuProcessId, unsigned int fuGuid, unsigned char *data, unsigned int dataSize)
 
bool writeErrorEventData (unsigned int runNumber, unsigned int fuProcessId, unsigned int iRawCell)
 
void writeRawEmptyEvent ()
 
void writeRawLumiSectionEvent (unsigned int)
 
void writeRecoEmptyEvent ()
 
bool writeRecoEventData (unsigned int runNumber, unsigned int evtNumber, unsigned int outModId, unsigned int fuProcessId, unsigned int fuGuid, unsigned char *data, unsigned int dataSize)
 
bool writeRecoInitMsg (unsigned int outModId, unsigned int fuProcessId, unsigned int fuGuid, unsigned char *data, unsigned int dataSize)
 
 ~FUShmBuffer ()
 

Static Public Member Functions

static FUShmBuffercreateShmBuffer (bool semgmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize=0x400000, unsigned int recoCellSize=0x400000, unsigned int dqmCellSize=0x400000)
 
static key_t getSemKey ()
 
static FUShmBuffergetShmBuffer ()
 
static key_t getShmDescriptorKey ()
 
static key_t getShmKey ()
 
static bool releaseSharedMemory ()
 
static int sem_create (key_t key, int nsem)
 
static int sem_destroy (int semid)
 
static int sem_get (key_t key, int nsem)
 
static void * shm_attach (int shmid)
 
static int shm_create (key_t key, int size)
 
static int shm_destroy (int shmid)
 
static int shm_get (key_t key, int size)
 
static int shm_nattch (int shmid)
 
static unsigned int size (bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
 

Private Member Functions

key_t dqmCellShmKey (unsigned int iCell)
 
 FUShmBuffer (bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
 
int incEvtDiscard (unsigned int index)
 
unsigned int indexForEvtNumber (unsigned int evtNumber)
 
unsigned int nextDqmReadIndex ()
 
unsigned int nextDqmWriteIndex ()
 
unsigned int nextIndex (unsigned int offset, unsigned int nCells, unsigned int &iNext)
 
unsigned int nextRawReadIndex ()
 
unsigned int nextRawWriteIndex ()
 
unsigned int nextRecoReadIndex ()
 
unsigned int nextRecoWriteIndex ()
 
void postDqmIndexToRead (unsigned int index)
 
void postDqmIndexToWrite (unsigned int index)
 
void postDqmRead ()
 
void postDqmWrite ()
 
void postIndex (unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
 
void postRawDiscard ()
 
void postRawDiscarded ()
 
void postRawIndexToRead (unsigned int index)
 
void postRawIndexToWrite (unsigned int index)
 
void postRawRead ()
 
void postRawWrite ()
 
void postRecoIndexToRead (unsigned int index)
 
void postRecoIndexToWrite (unsigned int index)
 
void postRecoRead ()
 
void postRecoWrite ()
 
bool rawCellReadyForDiscard (unsigned int index)
 
key_t rawCellShmKey (unsigned int iCell)
 
key_t recoCellShmKey (unsigned int iCell)
 
void sem_init (int isem, int value)
 
void sem_post (int isem)
 
int sem_wait (int isem)
 
bool setClientPrcId (pid_t prcId)
 
bool setEvtDiscard (unsigned int index, unsigned int discard)
 
bool setEvtNumber (unsigned int index, unsigned int evtNumber)
 
bool setEvtPrcId (unsigned int index, pid_t prcId)
 
bool setEvtTimeStamp (unsigned int index, time_t timeStamp)
 
key_t shmKey (unsigned int iCell, unsigned int offset)
 
void waitDqmRead ()
 
void waitDqmWrite ()
 
void waitRawDiscard ()
 
void waitRawDiscarded ()
 
void waitRawRead ()
 
void waitRawWrite ()
 
void waitRecoRead ()
 
void waitRecoWrite ()
 

Private Attributes

unsigned int clientPrcIdOffset_
 
unsigned int dqmCellOffset_
 
unsigned int dqmCellPayloadSize_
 
unsigned int dqmCellTotalSize_
 
unsigned int dqmReadIndex_
 
unsigned int dqmReadLast_
 
unsigned int dqmReadNext_
 
unsigned int dqmReadOffset_
 
unsigned int dqmStateOffset_
 
unsigned int dqmWriteIndex_
 
unsigned int dqmWriteLast_
 
unsigned int dqmWriteNext_
 
unsigned int dqmWriteOffset_
 
unsigned int evtDiscardOffset_
 
unsigned int evtNumberOffset_
 
unsigned int evtPrcIdOffset_
 
unsigned int evtStateOffset_
 
unsigned int evtTimeStampOffset_
 
unsigned int nClients_
 
unsigned int nClientsMax_
 
unsigned int nDqmCells_
 
unsigned int nRawCells_
 
unsigned int nRecoCells_
 
unsigned int rawCellOffset_
 
unsigned int rawCellPayloadSize_
 
unsigned int rawCellTotalSize_
 
unsigned int rawDiscardIndex_
 
unsigned int rawReadLast_
 
unsigned int rawReadNext_
 
unsigned int rawReadOffset_
 
unsigned int rawWriteLast_
 
unsigned int rawWriteNext_
 
unsigned int rawWriteOffset_
 
unsigned int recoCellOffset_
 
unsigned int recoCellPayloadSize_
 
unsigned int recoCellTotalSize_
 
unsigned int recoReadIndex_
 
unsigned int recoReadLast_
 
unsigned int recoReadNext_
 
unsigned int recoReadOffset_
 
unsigned int recoWriteIndex_
 
unsigned int recoWriteLast_
 
unsigned int recoWriteNext_
 
unsigned int recoWriteOffset_
 
bool segmentationMode_
 
int semid_
 
int shmid_
 

Static Private Attributes

static const char * semKeyPath_
 
static const char * shmKeyPath_
 

Detailed Description

Definition at line 39 of file FUShmBuffer.h.

Constructor & Destructor Documentation

FUShmBuffer::FUShmBuffer ( bool  segmentationMode,
unsigned int  nRawCells,
unsigned int  nRecoCells,
unsigned int  nDqmCells,
unsigned int  rawCellSize,
unsigned int  recoCellSize,
unsigned int  dqmCellSize 
)
private

Definition at line 53 of file FUShmBuffer.cc.

References clientPrcIdOffset_, dqmCellOffset_, dqmCellPayloadSize_, dqmCellTotalSize_, dqmReadOffset_, dqmStateOffset_, dqmWriteOffset_, evtDiscardOffset_, evtNumberOffset_, evtPrcIdOffset_, evtStateOffset_, evtTimeStampOffset_, i, nClientsMax_, nDqmCells_, nRawCells_, nRecoCells_, rawCellOffset_, rawCellPayloadSize_, rawCellTotalSize_, rawReadOffset_, rawWriteOffset_, recoCellOffset_, recoCellPayloadSize_, recoCellTotalSize_, recoReadOffset_, recoWriteOffset_, segmentationMode_, evf::FUShmDqmCell::size(), evf::FUShmRawCell::size(), and evf::FUShmRecoCell::size().

Referenced by createShmBuffer(), getShmBuffer(), releaseSharedMemory(), and size().

60  : segmentationMode_(segmentationMode)
61  , nClientsMax_(128)
63  , rawCellPayloadSize_(rawCellSize)
65  , recoCellPayloadSize_(recoCellSize)
67  , dqmCellPayloadSize_(dqmCellSize)
68 {
72 
73  void* addr;
74 
76  addr=(void*)((unsigned long)this+rawWriteOffset_);
77  new (addr) unsigned int[nRawCells_];
78 
79  rawReadOffset_=rawWriteOffset_+nRawCells_*sizeof(unsigned int);
80  addr=(void*)((unsigned long)this+rawReadOffset_);
81  new (addr) unsigned int[nRawCells_];
82 
83  recoWriteOffset_=rawReadOffset_+nRawCells_*sizeof(unsigned int);
84  addr=(void*)((unsigned long)this+recoWriteOffset_);
85  new (addr) unsigned int[nRecoCells_];
86 
87  recoReadOffset_=recoWriteOffset_+nRecoCells_*sizeof(unsigned int);
88  addr=(void*)((unsigned long)this+recoReadOffset_);
89  new (addr) unsigned int[nRecoCells_];
90 
91  dqmWriteOffset_=recoReadOffset_+nRecoCells_*sizeof(unsigned int);
92  addr=(void*)((unsigned long)this+dqmWriteOffset_);
93  new (addr) unsigned int[nDqmCells_];
94 
95  dqmReadOffset_=dqmWriteOffset_+nDqmCells_*sizeof(unsigned int);
96  addr=(void*)((unsigned long)this+dqmReadOffset_);
97  new (addr) unsigned int[nDqmCells_];
98 
99  evtStateOffset_=dqmReadOffset_+nDqmCells_*sizeof(unsigned int);
100  addr=(void*)((unsigned long)this+evtStateOffset_);
101  new (addr) evt::State_t[nRawCells_];
102 
104  addr=(void*)((unsigned long)this+evtDiscardOffset_);
105  new (addr) unsigned int[nRawCells_];
106 
107  evtNumberOffset_=evtDiscardOffset_+nRawCells_*sizeof(unsigned int);
108  addr=(void*)((unsigned long)this+evtNumberOffset_);
109  new (addr) unsigned int[nRawCells_];
110 
111  evtPrcIdOffset_=evtNumberOffset_+nRawCells_*sizeof(unsigned int);
112  addr=(void*)((unsigned long)this+evtPrcIdOffset_);
113  new (addr) pid_t[nRawCells_];
114 
116  addr=(void*)((unsigned long)this+evtTimeStampOffset_);
117  new (addr) time_t[nRawCells_];
118 
120  addr=(void*)((unsigned long)this+dqmStateOffset_);
121  new (addr) dqm::State_t[nDqmCells_];
122 
124  addr=(void*)((unsigned long)this+clientPrcIdOffset_);
125  new (addr) pid_t[nClientsMax_];
126 
128 
129  if (segmentationMode_) {
132  addr=(void*)((unsigned long)this+rawCellOffset_);
133  new (addr) key_t[nRawCells_];
134  addr=(void*)((unsigned long)this+recoCellOffset_);
135  new (addr) key_t[nRecoCells_];
136  addr=(void*)((unsigned long)this+dqmCellOffset_);
137  new (addr) key_t[nDqmCells_];
138  }
139  else {
142  for (unsigned int i=0;i<nRawCells_;i++) {
143  addr=(void*)((unsigned long)this+rawCellOffset_+i*rawCellTotalSize_);
144  new (addr) FUShmRawCell(rawCellSize);
145  }
146  for (unsigned int i=0;i<nRecoCells_;i++) {
147  addr=(void*)((unsigned long)this+recoCellOffset_+i*recoCellTotalSize_);
148  new (addr) FUShmRecoCell(recoCellSize);
149  }
150  for (unsigned int i=0;i<nDqmCells_;i++) {
151  addr=(void*)((unsigned long)this+dqmCellOffset_+i*dqmCellTotalSize_);
152  new (addr) FUShmDqmCell(dqmCellSize);
153  }
154  }
155 }
unsigned int clientPrcIdOffset_
Definition: FUShmBuffer.h:303
int i
Definition: DBlmapReader.cc:9
unsigned int nRecoCells() const
Definition: FUShmBuffer.h:64
unsigned int rawReadOffset_
Definition: FUShmBuffer.h:277
static unsigned int size(unsigned int payloadSize)
unsigned int recoCellPayloadSize_
Definition: FUShmBuffer.h:313
unsigned int dqmReadOffset_
Definition: FUShmBuffer.h:292
unsigned int evtDiscardOffset_
Definition: FUShmBuffer.h:295
unsigned int nRecoCells_
Definition: FUShmBuffer.h:312
unsigned int dqmStateOffset_
Definition: FUShmBuffer.h:299
unsigned int dqmWriteOffset_
Definition: FUShmBuffer.h:289
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int evtNumberOffset_
Definition: FUShmBuffer.h:296
unsigned int dqmCellOffset_
Definition: FUShmBuffer.h:322
unsigned int evtStateOffset_
Definition: FUShmBuffer.h:294
static unsigned int size(unsigned int payloadSize)
unsigned int recoReadOffset_
Definition: FUShmBuffer.h:285
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
unsigned int nRawCells() const
Definition: FUShmBuffer.h:63
unsigned int dqmCellPayloadSize_
Definition: FUShmBuffer.h:320
unsigned int rawCellPayloadSize_
Definition: FUShmBuffer.h:306
unsigned int rawWriteOffset_
Definition: FUShmBuffer.h:274
unsigned int dqmCellTotalSize_
Definition: FUShmBuffer.h:321
unsigned int recoCellTotalSize_
Definition: FUShmBuffer.h:314
unsigned int nClientsMax_
Definition: FUShmBuffer.h:302
unsigned int rawCellTotalSize_
Definition: FUShmBuffer.h:307
FUShmBuffer(bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
Definition: FUShmBuffer.cc:53
unsigned int nDqmCells() const
Definition: FUShmBuffer.h:65
unsigned int evtPrcIdOffset_
Definition: FUShmBuffer.h:297
unsigned int recoWriteOffset_
Definition: FUShmBuffer.h:282
static unsigned int size(unsigned int payloadSize)
Definition: FUShmDqmCell.cc:97
unsigned int rawCellOffset_
Definition: FUShmBuffer.h:308
unsigned int recoCellOffset_
Definition: FUShmBuffer.h:315
unsigned int evtTimeStampOffset_
Definition: FUShmBuffer.h:298
FUShmBuffer::~FUShmBuffer ( )

Definition at line 159 of file FUShmBuffer.cc.

160 {
161 
162 }

Member Function Documentation

pid_t FUShmBuffer::clientPrcId ( unsigned int  index)

Definition at line 1380 of file FUShmBuffer.cc.

References clientPrcIdOffset_, getHLTprescales::index, and nClientsMax_.

1381 {
1382  assert(index<nClientsMax_);
1383  pid_t *prcid=(pid_t*)((unsigned long)this+clientPrcIdOffset_);
1384  prcid+=index;
1385  return *prcid;
1386 }
unsigned int clientPrcIdOffset_
Definition: FUShmBuffer.h:303
unsigned int nClientsMax_
Definition: FUShmBuffer.h:302
FUShmBuffer * FUShmBuffer::createShmBuffer ( bool  semgmentationMode,
unsigned int  nRawCells,
unsigned int  nRecoCells,
unsigned int  nDqmCells,
unsigned int  rawCellSize = 0x400000,
unsigned int  recoCellSize = 0x400000,
unsigned int  dqmCellSize = 0x400000 
)
static

Definition at line 844 of file FUShmBuffer.cc.

References gather_cfg::cout, FUShmBuffer(), getSemKey(), getShmDescriptorKey(), getShmKey(), initialize(), nDqmCells(), nRawCells(), nRecoCells(), L1TEmulatorMonitor_cff::p, releaseSharedMemory(), sem_create(), semid(), shm_attach(), shm_create(), shm_nattch(), shmid(), and size().

Referenced by evf::FUResourceTable::initialize().

851 {
852  // if necessary, release shared memory first!
854  cout<<"FUShmBuffer::createShmBuffer: "
855  <<"REMOVAL OF OLD SHARED MEM SEGMENTS SUCCESSFULL."
856  <<endl;
857 
858  // create bookkeeping shared memory segment
859  int size =sizeof(unsigned int)*7;
860  int shmid=shm_create(FUShmBuffer::getShmDescriptorKey(),size);if(shmid<0)return 0;
861  void*shmAddr=shm_attach(shmid); if(0==shmAddr)return 0;
862 
863  if(1!=shm_nattch(shmid)) {
864  cout<<"FUShmBuffer::createShmBuffer() FAILED: nattch="<<shm_nattch(shmid)<<endl;
865  shmdt(shmAddr);
866  return 0;
867  }
868 
869  unsigned int* p=(unsigned int*)shmAddr;
870  *p++=segmentationMode;
871  *p++=nRawCells;
872  *p++=nRecoCells;
873  *p++=nDqmCells;
874  *p++=rawCellSize;
875  *p++=recoCellSize;
876  *p++=dqmCellSize;
877  shmdt(shmAddr);
878 
879  // create the 'real' shared memory buffer
880  size =FUShmBuffer::size(segmentationMode,
882  rawCellSize,recoCellSize,dqmCellSize);
883  shmid =shm_create(FUShmBuffer::getShmKey(),size); if (shmid<0) return 0;
884  int semid=sem_create(FUShmBuffer::getSemKey(),9); if (semid<0) return 0;
885  shmAddr =shm_attach(shmid); if (0==shmAddr) return 0;
886 
887  if (1!=shm_nattch(shmid)) {
888  cout<<"FUShmBuffer::createShmBuffer FAILED: nattch="<<shm_nattch(shmid)<<endl;
889  shmdt(shmAddr);
890  return 0;
891  }
892  FUShmBuffer* buffer=new(shmAddr) FUShmBuffer(segmentationMode,
894  rawCellSize,recoCellSize,dqmCellSize);
895 
896  cout<<"FUShmBuffer::createShmBuffer(): CREATED shared memory buffer."<<endl;
897  cout<<" segmentationMode="<<segmentationMode<<endl;
898 
899  buffer->initialize(shmid,semid);
900 
901  return buffer;
902 }
unsigned int nRecoCells() const
Definition: FUShmBuffer.h:64
static int shm_nattch(int shmid)
static void * shm_attach(int shmid)
int shmid() const
Definition: FUShmBuffer.h:67
static key_t getShmDescriptorKey()
static bool releaseSharedMemory()
Definition: FUShmBuffer.cc:960
static int sem_create(key_t key, int nsem)
static unsigned int size(bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
void initialize(unsigned int shmid, unsigned int semid)
Definition: FUShmBuffer.cc:170
unsigned int nRawCells() const
Definition: FUShmBuffer.h:63
static key_t getShmKey()
static key_t getSemKey()
FUShmBuffer(bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
Definition: FUShmBuffer.cc:53
tuple cout
Definition: gather_cfg.py:41
static int shm_create(key_t key, int size)
unsigned int nDqmCells() const
Definition: FUShmBuffer.h:65
int semid() const
Definition: FUShmBuffer.h:68
void FUShmBuffer::discardDqmCell ( unsigned int  iCell)

Definition at line 491 of file FUShmBuffer.cc.

References evf::FUShmDqmCell::clear(), evf::dqm::DISCARDING, dqmCell(), dqmState(), evf::dqm::EMPTY, postDqmIndexToWrite(), postDqmWrite(), segmentationMode_, evf::dqm::SENT, setDqmState(), and evf::utils::state.

492 {
493  dqm::State_t state=dqmState(iCell);
494  assert(state==dqm::EMPTY||state==dqm::SENT);
496  FUShmDqmCell* cell=dqmCell(iCell);
497  cell->clear();
498  if (segmentationMode_) shmdt(cell);
499  setDqmState(iCell,dqm::EMPTY);
500  postDqmIndexToWrite(iCell);
501  postDqmWrite();
502 }
void postDqmIndexToWrite(unsigned int index)
dqm::State_t dqmState(unsigned int index)
char state
Definition: procUtils.cc:75
bool setDqmState(unsigned int index, dqm::State_t state)
FUShmDqmCell * dqmCell(unsigned int iCell)
void FUShmBuffer::discardOrphanedRecoCell ( unsigned int  iCell)

Definition at line 480 of file FUShmBuffer.cc.

References evf::FUShmRecoCell::clear(), postRecoIndexToWrite(), postRecoWrite(), recoCell(), and segmentationMode_.

481 {
482  FUShmRecoCell* cell=recoCell(iCell);
483  cell->clear();
484  if (segmentationMode_) shmdt(cell);
485  postRecoIndexToWrite(iCell);
486  postRecoWrite();
487 }
FUShmRecoCell * recoCell(unsigned int iCell)
void postRecoWrite()
Definition: FUShmBuffer.h:255
void postRecoIndexToWrite(unsigned int index)
void FUShmBuffer::discardRawCell ( FUShmRawCell cell)

Definition at line 456 of file FUShmBuffer.cc.

References postRawDiscard(), and releaseRawCell().

Referenced by evf::FUShmClient::readNext().

457 {
458  releaseRawCell(cell);
459  postRawDiscard();
460 }
void releaseRawCell(FUShmRawCell *cell)
Definition: FUShmBuffer.cc:506
void postRawDiscard()
Definition: FUShmBuffer.h:251
void FUShmBuffer::discardRecoCell ( unsigned int  iCell)

Definition at line 464 of file FUShmBuffer.cc.

References evf::FUShmRecoCell::clear(), nRawCells_, postRecoIndexToWrite(), postRecoWrite(), evf::FUShmRecoCell::rawCellIndex(), recoCell(), scheduleRawCellForDiscard(), and segmentationMode_.

465 {
466  FUShmRecoCell* cell=recoCell(iCell);
467  unsigned int iRawCell=cell->rawCellIndex();
468  if (iRawCell<nRawCells_) {
469  //evt::State_t state=evtState(iRawCell);
470  //assert(state==evt::SENT);
471  scheduleRawCellForDiscard(iRawCell);
472  }
473  cell->clear();
474  if (segmentationMode_) shmdt(cell);
475  postRecoIndexToWrite(iCell);
476  postRecoWrite();
477 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int rawCellIndex() const
Definition: FUShmRecoCell.h:23
FUShmRecoCell * recoCell(unsigned int iCell)
void postRecoWrite()
Definition: FUShmBuffer.h:255
void postRecoIndexToWrite(unsigned int index)
void scheduleRawCellForDiscard(unsigned int iCell)
Definition: FUShmBuffer.cc:420
FUShmDqmCell * FUShmBuffer::dqmCell ( unsigned int  iCell)

Definition at line 1568 of file FUShmBuffer.cc.

References gather_cfg::cout, dqmCellOffset_, dqmCellPayloadSize_, dqmCellShmKey(), dqmCellTotalSize_, nDqmCells_, query::result, segmentationMode_, shm_attach(), shm_get(), and shmid().

Referenced by discardDqmCell(), dqmCellToRead(), initialize(), writeDqmEmptyEvent(), and writeDqmEventData().

1569 {
1570  FUShmDqmCell* result(0);
1571 
1572  if (iCell>=nDqmCells_) {
1573  cout<<"FUShmBuffer::dqmCell("<<iCell<<") ERROR: "
1574  <<"iCell="<<iCell<<" >= nDqmCells="<<nDqmCells_<<endl;
1575  return result;
1576  }
1577 
1578  if (segmentationMode_) {
1579  key_t shmkey =dqmCellShmKey(iCell);
1580  int shmid =shm_get(shmkey,dqmCellTotalSize_);
1581  void* cellAddr=shm_attach(shmid);
1582  result=new (cellAddr) FUShmDqmCell(dqmCellPayloadSize_);
1583  }
1584  else {
1585  result=
1586  (FUShmDqmCell*)((unsigned long)this+dqmCellOffset_+iCell*dqmCellTotalSize_);
1587  }
1588 
1589  return result;
1590 }
static void * shm_attach(int shmid)
int shmid() const
Definition: FUShmBuffer.h:67
static int shm_get(key_t key, int size)
unsigned int dqmCellOffset_
Definition: FUShmBuffer.h:322
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
tuple result
Definition: query.py:137
unsigned int dqmCellPayloadSize_
Definition: FUShmBuffer.h:320
key_t dqmCellShmKey(unsigned int iCell)
unsigned int dqmCellTotalSize_
Definition: FUShmBuffer.h:321
tuple cout
Definition: gather_cfg.py:41
key_t FUShmBuffer::dqmCellShmKey ( unsigned int  iCell)
private

Definition at line 1646 of file FUShmBuffer.cc.

References gather_cfg::cout, dqmCellOffset_, nDqmCells_, and shmKey().

Referenced by dqmCell(), and releaseSharedMemory().

1647 {
1648  if (iCell>=nDqmCells_) {
1649  cout<<"FUShmBuffer::dqmCellShmKey() ERROR: "
1650  <<"iCell>=nDqmCells: "<<iCell<<">="<<nDqmCells_<<endl;
1651  return -1;
1652  }
1653  return shmKey(iCell,dqmCellOffset_);
1654 }
unsigned int dqmCellOffset_
Definition: FUShmBuffer.h:322
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
tuple cout
Definition: gather_cfg.py:41
key_t shmKey(unsigned int iCell, unsigned int offset)
FUShmDqmCell * FUShmBuffer::dqmCellToRead ( )

Definition at line 339 of file FUShmBuffer.cc.

References dqmCell(), dqmState(), evf::dqm::EMPTY, nextDqmReadIndex(), evf::dqm::SENDING, setDqmState(), evf::utils::state, waitDqmRead(), and evf::dqm::WRITTEN.

340 {
341  waitDqmRead();
342  unsigned int iCell=nextDqmReadIndex();
343  FUShmDqmCell* cell=dqmCell(iCell);
344  dqm::State_t state=dqmState(iCell);
345  assert(state==dqm::WRITTEN||state==dqm::EMPTY);
346  if (state==dqm::WRITTEN) setDqmState(iCell,dqm::SENDING);
347  return cell;
348 }
unsigned int nextDqmReadIndex()
dqm::State_t dqmState(unsigned int index)
char state
Definition: procUtils.cc:75
bool setDqmState(unsigned int index, dqm::State_t state)
FUShmDqmCell * dqmCell(unsigned int iCell)
dqm::State_t FUShmBuffer::dqmState ( unsigned int  index)

Definition at line 1340 of file FUShmBuffer.cc.

References dqmStateOffset_, getHLTprescales::index, and nDqmCells_.

Referenced by discardDqmCell(), dqmCellToRead(), finishReadingDqmCell(), printDqmState(), and writeDqmEventData().

1341 {
1342  assert(index<nDqmCells_);
1343  dqm::State_t *pstate=(dqm::State_t*)((unsigned long)this+dqmStateOffset_);
1344  pstate+=index;
1345  return *pstate;
1346 }
unsigned int dqmStateOffset_
Definition: FUShmBuffer.h:299
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
unsigned int FUShmBuffer::evtNumber ( unsigned int  index)

Definition at line 1350 of file FUShmBuffer.cc.

References evtNumberOffset_, getHLTprescales::index, and nRawCells_.

Referenced by indexForEvtNumber(), and setEvtNumber().

1351 {
1352  assert(index<nRawCells_);
1353  unsigned int *pevt=(unsigned int*)((unsigned long)this+evtNumberOffset_);
1354  pevt+=index;
1355  return *pevt;
1356 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int evtNumberOffset_
Definition: FUShmBuffer.h:296
pid_t FUShmBuffer::evtPrcId ( unsigned int  index)

Definition at line 1360 of file FUShmBuffer.cc.

References evtPrcIdOffset_, getHLTprescales::index, and nRawCells_.

1361 {
1362  assert(index<nRawCells_);
1363  pid_t *prcid=(pid_t*)((unsigned long)this+evtPrcIdOffset_);
1364  prcid+=index;
1365  return *prcid;
1366 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int evtPrcIdOffset_
Definition: FUShmBuffer.h:297
evt::State_t FUShmBuffer::evtState ( unsigned int  index)
time_t FUShmBuffer::evtTimeStamp ( unsigned int  index)

Definition at line 1370 of file FUShmBuffer.cc.

References evtTimeStampOffset_, getHLTprescales::index, and nRawCells_.

1371 {
1372  assert(index<nRawCells_);
1373  time_t *ptstmp=(time_t*)((unsigned long)this+evtTimeStampOffset_);
1374  ptstmp+=index;
1375  return *ptstmp;
1376 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int evtTimeStampOffset_
Definition: FUShmBuffer.h:298
void FUShmBuffer::finishReadingDqmCell ( FUShmDqmCell cell)

Definition at line 410 of file FUShmBuffer.cc.

References dqmState(), evf::dqm::EMPTY, evf::FUShmDqmCell::index(), segmentationMode_, evf::dqm::SENDING, evf::dqm::SENT, setDqmState(), and evf::utils::state.

411 {
412  dqm::State_t state=dqmState(cell->index());
413  assert(state==dqm::SENDING||state==dqm::EMPTY);
414  if (state==dqm::SENDING) setDqmState(cell->index(),dqm::SENT);
415  if (segmentationMode_) shmdt(cell);
416 }
unsigned int index() const
Definition: FUShmDqmCell.h:22
dqm::State_t dqmState(unsigned int index)
char state
Definition: procUtils.cc:75
bool setDqmState(unsigned int index, dqm::State_t state)
void FUShmBuffer::finishReadingRawCell ( FUShmRawCell cell)

Definition at line 385 of file FUShmBuffer.cc.

References evtState(), evf::FUShmRawCell::index(), evf::evt::PROCESSING, evf::evt::RAWREAD, evf::evt::RAWREADING, segmentationMode_, setEvtState(), setEvtTimeStamp(), evf::utils::state, and cond::rpcobgas::time.

Referenced by FUShmReader::fillRawData(), and evf::FUShmClient::readNext().

386 {
387  evt::State_t state=evtState(cell->index());
388  assert(state==evt::RAWREADING);
389  setEvtState(cell->index(),evt::RAWREAD);
391  setEvtTimeStamp(cell->index(),time(0));
392  if (segmentationMode_) shmdt(cell);
393 }
evt::State_t evtState(unsigned int index)
bool setEvtState(unsigned int index, evt::State_t state)
bool setEvtTimeStamp(unsigned int index, time_t timeStamp)
char state
Definition: procUtils.cc:75
unsigned int index() const
Definition: FUShmRawCell.h:22
void FUShmBuffer::finishReadingRecoCell ( FUShmRecoCell cell)

Definition at line 397 of file FUShmBuffer.cc.

References nRawCells_, evf::FUShmRecoCell::rawCellIndex(), segmentationMode_, evf::evt::SENT, and setEvtState().

398 {
399  unsigned int iRawCell=cell->rawCellIndex();
400  if (iRawCell<nRawCells_) {
401  //evt::State_t state=evtState(cell->rawCellIndex());
402  //assert(state==evt::SENDING);
404  }
405  if (segmentationMode_) shmdt(cell);
406 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int rawCellIndex() const
Definition: FUShmRecoCell.h:23
bool setEvtState(unsigned int index, evt::State_t state)
void FUShmBuffer::finishWritingRawCell ( FUShmRawCell cell)

Definition at line 372 of file FUShmBuffer.cc.

References evf::FUShmRawCell::evtNumber(), evtState(), evf::FUShmRawCell::index(), postRawIndexToRead(), postRawRead(), evf::evt::RAWWRITING, evf::evt::RAWWRITTEN, segmentationMode_, setEvtNumber(), setEvtState(), and evf::utils::state.

Referenced by evf::FUShmServer::writeNext().

373 {
374  evt::State_t state=evtState(cell->index());
375  assert(state==evt::RAWWRITING);
377  setEvtNumber(cell->index(),cell->evtNumber());
378  postRawIndexToRead(cell->index());
379  if (segmentationMode_) shmdt(cell);
380  postRawRead();
381 }
void postRawIndexToRead(unsigned int index)
evt::State_t evtState(unsigned int index)
unsigned int evtNumber() const
Definition: FUShmRawCell.h:25
bool setEvtNumber(unsigned int index, unsigned int evtNumber)
bool setEvtState(unsigned int index, evt::State_t state)
char state
Definition: procUtils.cc:75
unsigned int index() const
Definition: FUShmRawCell.h:22
key_t FUShmBuffer::getSemKey ( )
static

Definition at line 1084 of file FUShmBuffer.cc.

References gather_cfg::cout, query::result, SEM_KEYID, and semKeyPath_.

Referenced by createShmBuffer(), getShmBuffer(), and releaseSharedMemory().

1085 {
1086  key_t result=getuid()*1000+SEM_KEYID;
1087  if (result==(key_t)-1) cout<<"FUShmBuffer::getSemKey: ftok() failed "
1088  <<"for file "<<semKeyPath_<<"!"<<endl;
1089  return result;
1090 }
static const char * semKeyPath_
Definition: FUShmBuffer.h:325
tuple result
Definition: query.py:137
#define SEM_KEYID
Definition: FUShmBuffer.cc:32
tuple cout
Definition: gather_cfg.py:41
FUShmBuffer * FUShmBuffer::getShmBuffer ( )
static

Definition at line 906 of file FUShmBuffer.cc.

References gather_cfg::cout, FUShmBuffer(), getSemKey(), getShmDescriptorKey(), getShmKey(), nDqmCells(), nRawCells(), nRecoCells(), L1TEmulatorMonitor_cff::p, sem_get(), semid(), setClientPrcId(), shm_attach(), shm_get(), shm_nattch(), shmid(), and size().

Referenced by FUShmDQMOutputService::attachToShm(), and SM_SharedMemoryHandle::getShmBuffer().

907 {
908  // get bookkeeping shared memory segment
909  int size =sizeof(unsigned int)*7;
910  int shmid =shm_get(FUShmBuffer::getShmDescriptorKey(),size);if(shmid<0)return 0;
911  void* shmAddr=shm_attach(shmid); if (0==shmAddr) return 0;
912 
913  unsigned int *p=(unsigned int*)shmAddr;
914  bool segmentationMode=*p++;
915  unsigned int nRawCells =*p++;
916  unsigned int nRecoCells =*p++;
917  unsigned int nDqmCells =*p++;
918  unsigned int rawCellSize =*p++;
919  unsigned int recoCellSize =*p++;
920  unsigned int dqmCellSize =*p++;
921  shmdt(shmAddr);
922 
923  cout<<"FUShmBuffer::getShmBuffer():"
924  <<" segmentationMode="<<segmentationMode
925  <<" nRawCells="<<nRawCells
926  <<" nRecoCells="<<nRecoCells
927  <<" nDqmCells="<<nDqmCells
928  <<" rawCellSize="<<rawCellSize
929  <<" recoCellSize="<<recoCellSize
930  <<" dqmCellSize="<<dqmCellSize
931  <<endl;
932 
933  // get the 'real' shared memory buffer
934  size =FUShmBuffer::size(segmentationMode,
935  nRawCells,nRecoCells,nDqmCells,
936  rawCellSize,recoCellSize,dqmCellSize);
937  shmid =shm_get(FUShmBuffer::getShmKey(),size); if (shmid<0) return 0;
938  int semid=sem_get(FUShmBuffer::getSemKey(),9); if (semid<0) return 0;
939  shmAddr =shm_attach(shmid); if (0==shmAddr) return 0;
940 
941  if (0==shm_nattch(shmid)) {
942  cout<<"FUShmBuffer::getShmBuffer() FAILED: nattch="<<shm_nattch(shmid)<<endl;
943  return 0;
944  }
945 
946  FUShmBuffer* buffer=new(shmAddr) FUShmBuffer(segmentationMode,
947  nRawCells,nRecoCells,nDqmCells,
948  rawCellSize,recoCellSize,dqmCellSize);
949 
950  cout<<"FUShmBuffer::getShmBuffer(): shared memory buffer RETRIEVED."<<endl;
951  cout<<" segmentationMode="<<segmentationMode<<endl;
952 
953  buffer->setClientPrcId(getpid());
954 
955  return buffer;
956 }
unsigned int nRecoCells() const
Definition: FUShmBuffer.h:64
static int shm_nattch(int shmid)
static void * shm_attach(int shmid)
int shmid() const
Definition: FUShmBuffer.h:67
static key_t getShmDescriptorKey()
static int shm_get(key_t key, int size)
static unsigned int size(bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
bool setClientPrcId(pid_t prcId)
unsigned int nRawCells() const
Definition: FUShmBuffer.h:63
static key_t getShmKey()
static key_t getSemKey()
static int sem_get(key_t key, int nsem)
FUShmBuffer(bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
Definition: FUShmBuffer.cc:53
tuple cout
Definition: gather_cfg.py:41
unsigned int nDqmCells() const
Definition: FUShmBuffer.h:65
int semid() const
Definition: FUShmBuffer.h:68
key_t FUShmBuffer::getShmDescriptorKey ( )
static

Definition at line 1064 of file FUShmBuffer.cc.

References gather_cfg::cout, query::result, SHM_DESCRIPTOR_KEYID, and shmKeyPath_.

Referenced by createShmBuffer(), getShmBuffer(), and releaseSharedMemory().

1065 {
1066  key_t result=getuid()*1000+SHM_DESCRIPTOR_KEYID;
1067  if (result==(key_t)-1) cout<<"FUShmBuffer::getShmDescriptorKey: failed "
1068  <<"for file "<<shmKeyPath_<<"!"<<endl;
1069  return result;
1070 }
static const char * shmKeyPath_
Definition: FUShmBuffer.h:324
tuple result
Definition: query.py:137
#define SHM_DESCRIPTOR_KEYID
Definition: FUShmBuffer.cc:30
tuple cout
Definition: gather_cfg.py:41
key_t FUShmBuffer::getShmKey ( )
static

Definition at line 1074 of file FUShmBuffer.cc.

References gather_cfg::cout, query::result, SHM_KEYID, and shmKeyPath_.

Referenced by createShmBuffer(), getShmBuffer(), and releaseSharedMemory().

1075 {
1076  key_t result=getuid()*1000+SHM_KEYID;
1077  if (result==(key_t)-1) cout<<"FUShmBuffer::getShmKey: ftok() failed "
1078  <<"for file "<<shmKeyPath_<<"!"<<endl;
1079  return result;
1080 }
#define SHM_KEYID
Definition: FUShmBuffer.cc:31
static const char * shmKeyPath_
Definition: FUShmBuffer.h:324
tuple result
Definition: query.py:137
tuple cout
Definition: gather_cfg.py:41
int FUShmBuffer::incEvtDiscard ( unsigned int  index)
private

Definition at line 1429 of file FUShmBuffer.cc.

References evtDiscardOffset_, getHLTprescales::index, lock(), nRawCells_, query::result, and unlock().

Referenced by writeRecoEventData().

1430 {
1431  int result = 0;
1432  assert(index<nRawCells_);
1433  unsigned int *pcount=(unsigned int*)((unsigned long)this+evtDiscardOffset_);
1434  pcount+=index;
1435  lock();
1436  (*pcount)++;
1437  result = *pcount;
1438  unlock();
1439  return result;
1440 }
unsigned int evtDiscardOffset_
Definition: FUShmBuffer.h:295
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
tuple result
Definition: query.py:137
unsigned int FUShmBuffer::indexForEvtNumber ( unsigned int  evtNumber)
private

Definition at line 1318 of file FUShmBuffer.cc.

References evtNumber(), evtNumberOffset_, i, and nRawCells_.

Referenced by writeRecoEventData().

1319 {
1320  unsigned int *pevt=(unsigned int*)((unsigned long)this+evtNumberOffset_);
1321  for (unsigned int i=0;i<nRawCells_;i++) {
1322  if ((*pevt++)==evtNumber) return i;
1323  }
1324  assert(false);
1325  return 0xffffffff;
1326 }
int i
Definition: DBlmapReader.cc:9
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int evtNumberOffset_
Definition: FUShmBuffer.h:296
unsigned int evtNumber(unsigned int index)
void FUShmBuffer::initialize ( unsigned int  shmid,
unsigned int  semid 
)

Definition at line 170 of file FUShmBuffer.cc.

References dqmCell(), dqmCellOffset_, dqmCellPayloadSize_, dqmCellTotalSize_, i, evf::FUShmRawCell::initialize(), evf::FUShmRecoCell::initialize(), evf::FUShmDqmCell::initialize(), nDqmCells_, nRawCells_, nRecoCells_, rawCell(), rawCellOffset_, rawCellPayloadSize_, rawCellTotalSize_, recoCell(), recoCellOffset_, recoCellPayloadSize_, recoCellTotalSize_, reset(), segmentationMode_, semid(), semid_, shm_attach(), shm_create(), shmid(), shmid_, and shmKeyPath_.

Referenced by createShmBuffer().

171 {
172  shmid_=shmid;
173  semid_=semid;
174 
175  if (segmentationMode_) {
176  int shmKeyId=666;
177  key_t* keyAddr =(key_t*)((unsigned long)this+rawCellOffset_);
178  for (unsigned int i=0;i<nRawCells_;i++) {
179  *keyAddr =ftok(shmKeyPath_,shmKeyId++);
180  int shmid =shm_create(*keyAddr,rawCellTotalSize_);
181  void* shmAddr=shm_attach(shmid);
182  new (shmAddr) FUShmRawCell(rawCellPayloadSize_);
183  shmdt(shmAddr);
184  ++keyAddr;
185  }
186  keyAddr =(key_t*)((unsigned long)this+recoCellOffset_);
187  for (unsigned int i=0;i<nRecoCells_;i++) {
188  *keyAddr =ftok(shmKeyPath_,shmKeyId++);
189  int shmid =shm_create(*keyAddr,recoCellTotalSize_);
190  void* shmAddr=shm_attach(shmid);
191  new (shmAddr) FUShmRecoCell(recoCellPayloadSize_);
192  shmdt(shmAddr);
193  ++keyAddr;
194  }
195  keyAddr =(key_t*)((unsigned long)this+dqmCellOffset_);
196  for (unsigned int i=0;i<nDqmCells_;i++) {
197  *keyAddr =ftok(shmKeyPath_,shmKeyId++);
198  int shmid =shm_create(*keyAddr,dqmCellTotalSize_);
199  void* shmAddr=shm_attach(shmid);
200  new (shmAddr) FUShmDqmCell(dqmCellPayloadSize_);
201  shmdt(shmAddr);
202  ++keyAddr;
203  }
204  }
205 
206  for (unsigned int i=0;i<nRawCells_;i++) {
207  FUShmRawCell* cell=rawCell(i);
208  cell->initialize(i);
209  if (segmentationMode_) shmdt(cell);
210  }
211 
212  for (unsigned int i=0;i<nRecoCells_;i++) {
213  FUShmRecoCell* cell=recoCell(i);
214  cell->initialize(i);
215  if (segmentationMode_) shmdt(cell);
216  }
217 
218  for (unsigned int i=0;i<nDqmCells_;i++) {
219  FUShmDqmCell* cell=dqmCell(i);
220  cell->initialize(i);
221  if (segmentationMode_) shmdt(cell);
222  }
223 
224  reset();
225 }
int i
Definition: DBlmapReader.cc:9
void initialize(unsigned int index)
static void * shm_attach(int shmid)
void initialize(unsigned int index)
Definition: FUShmDqmCell.cc:46
unsigned int recoCellPayloadSize_
Definition: FUShmBuffer.h:313
int shmid() const
Definition: FUShmBuffer.h:67
unsigned int nRecoCells_
Definition: FUShmBuffer.h:312
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int dqmCellOffset_
Definition: FUShmBuffer.h:322
void initialize(unsigned int index)
Definition: FUShmRawCell.cc:74
FUShmRawCell * rawCell(unsigned int iCell)
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
static const char * shmKeyPath_
Definition: FUShmBuffer.h:324
FUShmRecoCell * recoCell(unsigned int iCell)
unsigned int dqmCellPayloadSize_
Definition: FUShmBuffer.h:320
unsigned int rawCellPayloadSize_
Definition: FUShmBuffer.h:306
unsigned int dqmCellTotalSize_
Definition: FUShmBuffer.h:321
unsigned int recoCellTotalSize_
Definition: FUShmBuffer.h:314
unsigned int rawCellTotalSize_
Definition: FUShmBuffer.h:307
static int shm_create(key_t key, int size)
unsigned int rawCellOffset_
Definition: FUShmBuffer.h:308
unsigned int recoCellOffset_
Definition: FUShmBuffer.h:315
FUShmDqmCell * dqmCell(unsigned int iCell)
int semid() const
Definition: FUShmBuffer.h:68
void evf::FUShmBuffer::lock ( void  )
inline
int FUShmBuffer::nbRawCellsToRead ( ) const

Definition at line 283 of file FUShmBuffer.cc.

References semid().

284 {
285  return semctl(semid(),2,GETVAL);
286 }
int semid() const
Definition: FUShmBuffer.h:68
int FUShmBuffer::nbRawCellsToWrite ( ) const

Definition at line 276 of file FUShmBuffer.cc.

References semid().

277 {
278  return semctl(semid(),1,GETVAL);
279 }
int semid() const
Definition: FUShmBuffer.h:68
unsigned int evf::FUShmBuffer::nClients ( ) const
inline

Definition at line 69 of file FUShmBuffer.h.

References nClients_.

69 { return nClients_; }
unsigned int nClients_
Definition: FUShmBuffer.h:301
unsigned int evf::FUShmBuffer::nDqmCells ( ) const
inline

Definition at line 65 of file FUShmBuffer.h.

References nDqmCells_.

Referenced by createShmBuffer(), getShmBuffer(), releaseSharedMemory(), and size().

65 { return nDqmCells_; }
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
unsigned int FUShmBuffer::nextDqmReadIndex ( )
private

Definition at line 1297 of file FUShmBuffer.cc.

References dqmReadNext_, dqmReadOffset_, nDqmCells_, and nextIndex().

Referenced by dqmCellToRead().

1298 {
1300 }
unsigned int dqmReadOffset_
Definition: FUShmBuffer.h:292
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
unsigned int dqmReadNext_
Definition: FUShmBuffer.h:290
unsigned int FUShmBuffer::nextDqmWriteIndex ( )
private

Definition at line 1290 of file FUShmBuffer.cc.

References dqmWriteNext_, dqmWriteOffset_, nDqmCells_, and nextIndex().

Referenced by writeDqmEmptyEvent(), and writeDqmEventData().

1291 {
1293 }
unsigned int dqmWriteNext_
Definition: FUShmBuffer.h:287
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int dqmWriteOffset_
Definition: FUShmBuffer.h:289
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
unsigned int FUShmBuffer::nextIndex ( unsigned int  offset,
unsigned int  nCells,
unsigned int &  iNext 
)
private

Definition at line 1204 of file FUShmBuffer.cc.

References lock(), evf::evtn::offset(), query::result, and unlock().

Referenced by nextDqmReadIndex(), nextDqmWriteIndex(), nextRawReadIndex(), nextRawWriteIndex(), nextRecoReadIndex(), and nextRecoWriteIndex().

1207 {
1208  lock();
1209  unsigned int* pindex=(unsigned int*)((unsigned long)this+offset);
1210  pindex+=iNext;
1211  iNext=(iNext+1)%nCells;
1212  unsigned int result=*pindex;
1213  unlock();
1214  return result;
1215 }
tuple result
Definition: query.py:137
unsigned int offset(bool)
unsigned int FUShmBuffer::nextRawReadIndex ( )
private

Definition at line 1241 of file FUShmBuffer.cc.

References nextIndex(), nRawCells_, rawReadNext_, and rawReadOffset_.

Referenced by rawCellToRead().

1242 {
1244 }
unsigned int rawReadOffset_
Definition: FUShmBuffer.h:277
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int rawReadNext_
Definition: FUShmBuffer.h:275
unsigned int FUShmBuffer::nextRawWriteIndex ( )
private

Definition at line 1234 of file FUShmBuffer.cc.

References nextIndex(), nRawCells_, rawWriteNext_, and rawWriteOffset_.

Referenced by rawCellToWrite().

1235 {
1237 }
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int rawWriteNext_
Definition: FUShmBuffer.h:272
unsigned int rawWriteOffset_
Definition: FUShmBuffer.h:274
unsigned int FUShmBuffer::nextRecoReadIndex ( )
private

Definition at line 1269 of file FUShmBuffer.cc.

References nextIndex(), nRecoCells_, recoReadNext_, and recoReadOffset_.

Referenced by recoCellToRead().

1270 {
1272 }
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int nRecoCells_
Definition: FUShmBuffer.h:312
unsigned int recoReadOffset_
Definition: FUShmBuffer.h:285
unsigned int recoReadNext_
Definition: FUShmBuffer.h:283
unsigned int FUShmBuffer::nextRecoWriteIndex ( )
private

Definition at line 1262 of file FUShmBuffer.cc.

References nextIndex(), nRecoCells_, recoWriteNext_, and recoWriteOffset_.

Referenced by writeErrorEventData(), writeRecoEmptyEvent(), writeRecoEventData(), and writeRecoInitMsg().

1263 {
1265 }
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int nRecoCells_
Definition: FUShmBuffer.h:312
unsigned int recoWriteNext_
Definition: FUShmBuffer.h:280
unsigned int recoWriteOffset_
Definition: FUShmBuffer.h:282
unsigned int evf::FUShmBuffer::nRawCells ( ) const
inline

Definition at line 63 of file FUShmBuffer.h.

References nRawCells_.

Referenced by createShmBuffer(), getShmBuffer(), and releaseSharedMemory().

63 { return nRawCells_; }
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int evf::FUShmBuffer::nRecoCells ( ) const
inline

Definition at line 64 of file FUShmBuffer.h.

References nRecoCells_.

Referenced by createShmBuffer(), getShmBuffer(), and releaseSharedMemory().

64 { return nRecoCells_; }
unsigned int nRecoCells_
Definition: FUShmBuffer.h:312
void FUShmBuffer::postDqmIndexToRead ( unsigned int  index)
private

Definition at line 1311 of file FUShmBuffer.cc.

References dqmReadLast_, dqmReadOffset_, nDqmCells_, and postIndex().

Referenced by writeDqmEmptyEvent(), and writeDqmEventData().

1312 {
1314 }
unsigned int dqmReadLast_
Definition: FUShmBuffer.h:291
unsigned int dqmReadOffset_
Definition: FUShmBuffer.h:292
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void FUShmBuffer::postDqmIndexToWrite ( unsigned int  index)
private

Definition at line 1304 of file FUShmBuffer.cc.

References dqmWriteLast_, dqmWriteOffset_, nDqmCells_, and postIndex().

Referenced by discardDqmCell().

1305 {
1307 }
unsigned int dqmWriteLast_
Definition: FUShmBuffer.h:288
unsigned int dqmWriteOffset_
Definition: FUShmBuffer.h:289
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void evf::FUShmBuffer::postDqmRead ( )
inlineprivate

Definition at line 261 of file FUShmBuffer.h.

References sem_post().

Referenced by writeDqmEmptyEvent(), and writeDqmEventData().

261 { sem_post(8); }
void sem_post(int isem)
void evf::FUShmBuffer::postDqmWrite ( )
inlineprivate

Definition at line 259 of file FUShmBuffer.h.

References sem_post().

Referenced by discardDqmCell().

259 { sem_post(7); }
void sem_post(int isem)
void FUShmBuffer::postIndex ( unsigned int  index,
unsigned int  offset,
unsigned int  nCells,
unsigned int &  iLast 
)
private

Definition at line 1219 of file FUShmBuffer.cc.

References getHLTprescales::index, lock(), evf::evtn::offset(), and unlock().

Referenced by postDqmIndexToRead(), postDqmIndexToWrite(), postRawIndexToRead(), postRawIndexToWrite(), postRecoIndexToRead(), and postRecoIndexToWrite().

1223 {
1224  lock();
1225  unsigned int* pindex=(unsigned int*)((unsigned long)this+offset);
1226  pindex+=iLast;
1227  *pindex=index;
1228  iLast=(iLast+1)%nCells;
1229  unlock();
1230 }
unsigned int offset(bool)
void evf::FUShmBuffer::postRawDiscard ( )
inlineprivate
void evf::FUShmBuffer::postRawDiscarded ( )
inlineprivate
void FUShmBuffer::postRawIndexToRead ( unsigned int  index)
private

Definition at line 1255 of file FUShmBuffer.cc.

References nRawCells_, postIndex(), rawReadLast_, and rawReadOffset_.

Referenced by finishWritingRawCell(), writeRawEmptyEvent(), and writeRawLumiSectionEvent().

1256 {
1258 }
unsigned int rawReadOffset_
Definition: FUShmBuffer.h:277
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int rawReadLast_
Definition: FUShmBuffer.h:276
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void FUShmBuffer::postRawIndexToWrite ( unsigned int  index)
private

Definition at line 1248 of file FUShmBuffer.cc.

References nRawCells_, postIndex(), rawWriteLast_, and rawWriteOffset_.

Referenced by releaseRawCell().

1249 {
1251 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int rawWriteOffset_
Definition: FUShmBuffer.h:274
unsigned int rawWriteLast_
Definition: FUShmBuffer.h:273
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void evf::FUShmBuffer::postRawRead ( )
inlineprivate

Definition at line 249 of file FUShmBuffer.h.

References sem_post().

Referenced by finishWritingRawCell(), writeRawEmptyEvent(), and writeRawLumiSectionEvent().

249 { sem_post(2); }
void sem_post(int isem)
void evf::FUShmBuffer::postRawWrite ( )
inlineprivate

Definition at line 247 of file FUShmBuffer.h.

References sem_post().

Referenced by releaseRawCell().

247 { sem_post(1); }
void sem_post(int isem)
void FUShmBuffer::postRecoIndexToRead ( unsigned int  index)
private

Definition at line 1283 of file FUShmBuffer.cc.

References nRecoCells_, postIndex(), recoReadLast_, and recoReadOffset_.

Referenced by writeErrorEventData(), writeRecoEmptyEvent(), writeRecoEventData(), and writeRecoInitMsg().

1284 {
1286 }
unsigned int nRecoCells_
Definition: FUShmBuffer.h:312
unsigned int recoReadOffset_
Definition: FUShmBuffer.h:285
unsigned int recoReadLast_
Definition: FUShmBuffer.h:284
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void FUShmBuffer::postRecoIndexToWrite ( unsigned int  index)
private

Definition at line 1276 of file FUShmBuffer.cc.

References nRecoCells_, postIndex(), recoWriteLast_, and recoWriteOffset_.

Referenced by discardOrphanedRecoCell(), and discardRecoCell().

1277 {
1279 }
unsigned int nRecoCells_
Definition: FUShmBuffer.h:312
unsigned int recoWriteLast_
Definition: FUShmBuffer.h:281
unsigned int recoWriteOffset_
Definition: FUShmBuffer.h:282
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void evf::FUShmBuffer::postRecoRead ( )
inlineprivate

Definition at line 257 of file FUShmBuffer.h.

References sem_post().

Referenced by writeErrorEventData(), writeRecoEmptyEvent(), writeRecoEventData(), and writeRecoInitMsg().

257 { sem_post(6); }
void sem_post(int isem)
void evf::FUShmBuffer::postRecoWrite ( )
inlineprivate

Definition at line 255 of file FUShmBuffer.h.

References sem_post().

Referenced by discardOrphanedRecoCell(), and discardRecoCell().

255 { sem_post(5); }
void sem_post(int isem)
void FUShmBuffer::printDqmState ( unsigned int  index)

Definition at line 836 of file FUShmBuffer.cc.

References gather_cfg::cout, dqmState(), and evf::utils::state.

837 {
839  cout<<"dqm evt "<<index<<" in state '"<<state<<"'."<<endl;
840 }
dqm::State_t dqmState(unsigned int index)
char state
Definition: procUtils.cc:75
tuple cout
Definition: gather_cfg.py:41
void FUShmBuffer::printEvtState ( unsigned int  index)

Definition at line 814 of file FUShmBuffer.cc.

References gather_cfg::cout, evf::evt::DISCARDING, evf::evt::EMPTY, evtState(), evf::evt::PROCESSED, evf::evt::PROCESSING, evf::evt::RAWREAD, evf::evt::RAWREADING, evf::evt::RAWWRITING, evf::evt::RAWWRITTEN, evf::evt::RECOWRITING, evf::evt::RECOWRITTEN, evf::evt::SENDING, evf::evt::SENT, evf::utils::state, and evf::evt::STOP.

Referenced by evf::FUShmServer::writeNext().

815 {
817  std::string stateName;
818  if (state==evt::EMPTY) stateName="EMPTY";
819  else if (state==evt::STOP) stateName="STOP";
820  else if (state==evt::RAWWRITING) stateName="RAWWRITING";
821  else if (state==evt::RAWWRITTEN) stateName="RAWRITTEN";
822  else if (state==evt::RAWREADING) stateName="RAWREADING";
823  else if (state==evt::RAWREAD) stateName="RAWREAD";
824  else if (state==evt::PROCESSING) stateName="PROCESSING";
825  else if (state==evt::PROCESSED) stateName="PROCESSED";
826  else if (state==evt::RECOWRITING)stateName="RECOWRITING";
827  else if (state==evt::RECOWRITTEN)stateName="RECOWRITTEN";
828  else if (state==evt::SENDING) stateName="SENDING";
829  else if (state==evt::SENT) stateName="SENT";
830  else if (state==evt::DISCARDING) stateName="DISCARDING";
831  cout<<"evt "<<index<<" in state '"<<stateName<<"'."<<endl;
832 }
evt::State_t evtState(unsigned int index)
char state
Definition: procUtils.cc:75
tuple cout
Definition: gather_cfg.py:41
FUShmRawCell * FUShmBuffer::rawCell ( unsigned int  iCell)

Definition at line 1516 of file FUShmBuffer.cc.

References gather_cfg::cout, nRawCells_, rawCellOffset_, rawCellPayloadSize_, rawCellShmKey(), rawCellTotalSize_, query::result, segmentationMode_, shm_attach(), shm_get(), and shmid().

Referenced by initialize(), rawCellToDiscard(), rawCellToRead(), rawCellToWrite(), and writeErrorEventData().

1517 {
1518  FUShmRawCell* result(0);
1519 
1520  if (iCell>=nRawCells_) {
1521  cout<<"FUShmBuffer::rawCell("<<iCell<<") ERROR: "
1522  <<"iCell="<<iCell<<" >= nRawCells()="<<nRawCells_<<endl;
1523  return result;
1524  }
1525 
1526  if (segmentationMode_) {
1527  key_t shmkey =rawCellShmKey(iCell);
1528  int shmid =shm_get(shmkey,rawCellTotalSize_);
1529  void* cellAddr=shm_attach(shmid);
1530  result=new (cellAddr) FUShmRawCell(rawCellPayloadSize_);
1531  }
1532  else {
1533  result=
1534  (FUShmRawCell*)((unsigned long)this+rawCellOffset_+iCell*rawCellTotalSize_);
1535  }
1536 
1537  return result;
1538 }
static void * shm_attach(int shmid)
int shmid() const
Definition: FUShmBuffer.h:67
static int shm_get(key_t key, int size)
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
tuple result
Definition: query.py:137
key_t rawCellShmKey(unsigned int iCell)
unsigned int rawCellPayloadSize_
Definition: FUShmBuffer.h:306
unsigned int rawCellTotalSize_
Definition: FUShmBuffer.h:307
tuple cout
Definition: gather_cfg.py:41
unsigned int rawCellOffset_
Definition: FUShmBuffer.h:308
bool FUShmBuffer::rawCellReadyForDiscard ( unsigned int  index)
private

Definition at line 1594 of file FUShmBuffer.cc.

References evtDiscardOffset_, getHLTprescales::index, lock(), nRawCells_, query::result, and unlock().

Referenced by scheduleRawCellForDiscard(), scheduleRawCellForDiscardServerSide(), scheduleRawEmptyCellForDiscard(), and scheduleRawEmptyCellForDiscardServerSide().

1595 {
1596  assert(index<nRawCells_);
1597  unsigned int *pcount=(unsigned int*)((unsigned long)this+evtDiscardOffset_);
1598  pcount+=index;
1599  lock();
1600  assert(*pcount>0);
1601  --(*pcount);
1602  bool result=(*pcount==0);
1603  unlock();
1604  return result;
1605 }
unsigned int evtDiscardOffset_
Definition: FUShmBuffer.h:295
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
tuple result
Definition: query.py:137
key_t FUShmBuffer::rawCellShmKey ( unsigned int  iCell)
private

Definition at line 1622 of file FUShmBuffer.cc.

References gather_cfg::cout, nRawCells_, rawCellOffset_, and shmKey().

Referenced by rawCell(), and releaseSharedMemory().

1623 {
1624  if (iCell>=nRawCells_) {
1625  cout<<"FUShmBuffer::rawCellShmKey() ERROR: "
1626  <<"iCell>=nRawCells: "<<iCell<<">="<<nRawCells_<<endl;
1627  return -1;
1628  }
1629  return shmKey(iCell,rawCellOffset_);
1630 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
tuple cout
Definition: gather_cfg.py:41
unsigned int rawCellOffset_
Definition: FUShmBuffer.h:308
key_t shmKey(unsigned int iCell, unsigned int offset)
FUShmRawCell * FUShmBuffer::rawCellToDiscard ( )

Definition at line 352 of file FUShmBuffer.cc.

References evf::evt::DISCARDING, evf::evt::EMPTY, evtState(), evf::FUShmRawCell::index(), evf::evt::LUMISECTION, evf::evt::PROCESSED, rawCell(), rawDiscardIndex_, evf::evt::SENT, setEvtState(), evf::utils::state, evf::evt::STOP, and waitRawDiscarded().

Referenced by evf::FUShmClient::readNext().

353 {
356  evt::State_t state=evtState(cell->index());
357  assert(state==evt::PROCESSED
358  ||state==evt::SENT
359  ||state==evt::EMPTY
360  ||state==evt::STOP
361  ||state==evt::LUMISECTION);
362  if (state!=evt::EMPTY
363  && state!=evt::LUMISECTION
364  && state!=evt::STOP
365  )
367  return cell;
368 }
evt::State_t evtState(unsigned int index)
FUShmRawCell * rawCell(unsigned int iCell)
bool setEvtState(unsigned int index, evt::State_t state)
unsigned int rawDiscardIndex_
Definition: FUShmBuffer.h:278
void waitRawDiscarded()
Definition: FUShmBuffer.h:252
char state
Definition: procUtils.cc:75
unsigned int index() const
Definition: FUShmRawCell.h:22
FUShmRawCell * FUShmBuffer::rawCellToRead ( )

Definition at line 304 of file FUShmBuffer.cc.

References evf::evt::EMPTY, evtState(), evf::evt::LUMISECTION, nextRawReadIndex(), rawCell(), evf::evt::RAWREADING, evf::evt::RAWWRITTEN, setEvtPrcId(), setEvtState(), evf::utils::state, evf::evt::STOP, and waitRawRead().

Referenced by FUShmReader::fillRawData(), and evf::FUShmClient::readNext().

305 {
306  waitRawRead();
307  unsigned int iCell=nextRawReadIndex();
308  FUShmRawCell* cell=rawCell(iCell);
309  evt::State_t state=evtState(iCell);
310  assert(state==evt::RAWWRITTEN
311  ||state==evt::EMPTY
312  ||state==evt::STOP
313  ||state==evt::LUMISECTION);
314  if (state==evt::RAWWRITTEN) {
315  setEvtPrcId(iCell,getpid());
317  }
318  return cell;
319 }
bool setEvtPrcId(unsigned int index, pid_t prcId)
evt::State_t evtState(unsigned int index)
unsigned int nextRawReadIndex()
FUShmRawCell * rawCell(unsigned int iCell)
bool setEvtState(unsigned int index, evt::State_t state)
char state
Definition: procUtils.cc:75
FUShmRawCell * FUShmBuffer::rawCellToWrite ( )

Definition at line 290 of file FUShmBuffer.cc.

References evf::evt::EMPTY, evtState(), nextRawWriteIndex(), rawCell(), evf::evt::RAWWRITING, setEvtDiscard(), setEvtState(), evf::utils::state, and waitRawWrite().

Referenced by scheduleRawEmptyCellForDiscard(), evf::FUShmServer::writeNext(), writeRawEmptyEvent(), and writeRawLumiSectionEvent().

291 {
292  waitRawWrite();
293  unsigned int iCell=nextRawWriteIndex();
294  FUShmRawCell* cell =rawCell(iCell);
295  evt::State_t state=evtState(iCell);
296  assert(state==evt::EMPTY);
298  setEvtDiscard(iCell,1);
299  return cell;
300 }
evt::State_t evtState(unsigned int index)
FUShmRawCell * rawCell(unsigned int iCell)
bool setEvtState(unsigned int index, evt::State_t state)
unsigned int nextRawWriteIndex()
char state
Definition: procUtils.cc:75
bool setEvtDiscard(unsigned int index, unsigned int discard)
FUShmRecoCell * FUShmBuffer::recoCell ( unsigned int  iCell)

Definition at line 1542 of file FUShmBuffer.cc.

References gather_cfg::cout, nRecoCells_, recoCellOffset_, recoCellPayloadSize_, recoCellShmKey(), recoCellTotalSize_, query::result, segmentationMode_, shm_attach(), shm_get(), and shmid().

Referenced by discardOrphanedRecoCell(), discardRecoCell(), initialize(), recoCellToRead(), writeErrorEventData(), writeRecoEmptyEvent(), writeRecoEventData(), and writeRecoInitMsg().

1543 {
1544  FUShmRecoCell* result(0);
1545 
1546  if (iCell>=nRecoCells_) {
1547  cout<<"FUShmBuffer::recoCell("<<iCell<<") ERROR: "
1548  <<"iCell="<<iCell<<" >= nRecoCells="<<nRecoCells_<<endl;
1549  return result;
1550  }
1551 
1552  if (segmentationMode_) {
1553  key_t shmkey =recoCellShmKey(iCell);
1554  int shmid =shm_get(shmkey,recoCellTotalSize_);
1555  void* cellAddr=shm_attach(shmid);
1556  result=new (cellAddr) FUShmRecoCell(recoCellPayloadSize_);
1557  }
1558  else {
1559  result=
1560  (FUShmRecoCell*)((unsigned long)this+recoCellOffset_+iCell*recoCellTotalSize_);
1561  }
1562 
1563  return result;
1564 }
key_t recoCellShmKey(unsigned int iCell)
static void * shm_attach(int shmid)
unsigned int recoCellPayloadSize_
Definition: FUShmBuffer.h:313
int shmid() const
Definition: FUShmBuffer.h:67
unsigned int nRecoCells_
Definition: FUShmBuffer.h:312
static int shm_get(key_t key, int size)
tuple result
Definition: query.py:137
unsigned int recoCellTotalSize_
Definition: FUShmBuffer.h:314
tuple cout
Definition: gather_cfg.py:41
unsigned int recoCellOffset_
Definition: FUShmBuffer.h:315
key_t FUShmBuffer::recoCellShmKey ( unsigned int  iCell)
private

Definition at line 1634 of file FUShmBuffer.cc.

References gather_cfg::cout, nRecoCells_, recoCellOffset_, and shmKey().

Referenced by recoCell(), and releaseSharedMemory().

1635 {
1636  if (iCell>=nRecoCells_) {
1637  cout<<"FUShmBuffer::recoCellShmKey() ERROR: "
1638  <<"iCell>=nRecoCells: "<<iCell<<">="<<nRecoCells_<<endl;
1639  return -1;
1640  }
1641  return shmKey(iCell,recoCellOffset_);
1642 }
unsigned int nRecoCells_
Definition: FUShmBuffer.h:312
tuple cout
Definition: gather_cfg.py:41
key_t shmKey(unsigned int iCell, unsigned int offset)
unsigned int recoCellOffset_
Definition: FUShmBuffer.h:315
FUShmRecoCell * FUShmBuffer::recoCellToRead ( )

Definition at line 323 of file FUShmBuffer.cc.

References nextRecoReadIndex(), nRawCells_, evf::FUShmRecoCell::rawCellIndex(), recoCell(), evf::evt::SENDING, setEvtState(), and waitRecoRead().

324 {
325  waitRecoRead();
326  unsigned int iCell =nextRecoReadIndex();
327  FUShmRecoCell* cell =recoCell(iCell);
328  unsigned int iRawCell=cell->rawCellIndex();
329  if (iRawCell<nRawCells_) {
330  //evt::State_t state=evtState(iRawCell);
331  //assert(state==evt::RECOWRITTEN);
332  setEvtState(iRawCell,evt::SENDING);
333  }
334  return cell;
335 }
unsigned int nextRecoReadIndex()
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int rawCellIndex() const
Definition: FUShmRecoCell.h:23
bool setEvtState(unsigned int index, evt::State_t state)
FUShmRecoCell * recoCell(unsigned int iCell)
void FUShmBuffer::releaseRawCell ( FUShmRawCell cell)

Definition at line 506 of file FUShmBuffer.cc.

References evf::FUShmRawCell::clear(), gather_cfg::cout, evf::evt::DISCARDING, evf::evt::EMPTY, evtState(), evf::FUShmRawCell::index(), evf::evt::LUMISECTION, postRawIndexToWrite(), postRawWrite(), evf::evt::RAWWRITING, segmentationMode_, setEvtDiscard(), setEvtNumber(), setEvtPrcId(), setEvtState(), setEvtTimeStamp(), evf::utils::state, and evf::evt::STOP.

Referenced by discardRawCell().

507 {
508  evt::State_t state=evtState(cell->index());
509  if(!(
510  state==evt::DISCARDING
511  ||state==evt::RAWWRITING
512  ||state==evt::EMPTY
513  ||state==evt::STOP
514  ||state==evt::LUMISECTION
515  )) std::cout << "=================releaseRawCell state " << state
516  << std::endl;
517 
518  assert(
519  state==evt::DISCARDING
520  ||state==evt::RAWWRITING
521  ||state==evt::EMPTY
522  ||state==evt::STOP
523  ||state==evt::LUMISECTION
524  );
525  setEvtState(cell->index(),evt::EMPTY);
526  setEvtDiscard(cell->index(),0);
527  setEvtNumber(cell->index(),0xffffffff);
528  setEvtPrcId(cell->index(),0);
529  setEvtTimeStamp(cell->index(),0);
530  cell->clear();
531  postRawIndexToWrite(cell->index());
532  if (segmentationMode_) shmdt(cell);
533  postRawWrite();
534 }
bool setEvtPrcId(unsigned int index, pid_t prcId)
evt::State_t evtState(unsigned int index)
bool setEvtNumber(unsigned int index, unsigned int evtNumber)
void postRawIndexToWrite(unsigned int index)
bool setEvtState(unsigned int index, evt::State_t state)
bool setEvtTimeStamp(unsigned int index, time_t timeStamp)
char state
Definition: procUtils.cc:75
unsigned int index() const
Definition: FUShmRawCell.h:22
tuple cout
Definition: gather_cfg.py:41
bool setEvtDiscard(unsigned int index, unsigned int discard)
bool FUShmBuffer::releaseSharedMemory ( )
static

Definition at line 960 of file FUShmBuffer.cc.

References gather_cfg::cout, dqmCellShmKey(), FUShmBuffer(), getSemKey(), getShmDescriptorKey(), getShmKey(), i, nDqmCells(), nRawCells(), nRecoCells(), L1TEmulatorMonitor_cff::p, rawCellShmKey(), recoCellShmKey(), sem_destroy(), sem_get(), semid(), shm_attach(), shm_destroy(), shm_get(), shm_nattch(), shmid(), evf::FUShmDqmCell::size(), evf::FUShmRawCell::size(), evf::FUShmRecoCell::size(), size(), and stor::utils::sleep().

Referenced by createShmBuffer(), and evf::FUResourceTable::~FUResourceTable().

961 {
962  // get bookkeeping shared memory segment
963  int size =sizeof(unsigned int)*7;
964  int shmidd =shm_get(FUShmBuffer::getShmDescriptorKey(),size); if(shmidd<0) return false;
965  void* shmAddr=shm_attach(shmidd); if (0==shmAddr) return false;
966 
967  unsigned int*p=(unsigned int*)shmAddr;
968  bool segmentationMode=*p++;
969  unsigned int nRawCells =*p++;
970  unsigned int nRecoCells =*p++;
971  unsigned int nDqmCells =*p++;
972  unsigned int rawCellSize =*p++;
973  unsigned int recoCellSize =*p++;
974  unsigned int dqmCellSize =*p++;
975  shmdt(shmAddr);
976 
977 
978  // get the 'real' shared memory segment
979  size =FUShmBuffer::size(segmentationMode,
980  nRawCells,nRecoCells,nDqmCells,
981  rawCellSize,recoCellSize,dqmCellSize);
982  int shmid=shm_get(FUShmBuffer::getShmKey(),size);if (shmid<0) return false;
983  int semid=sem_get(FUShmBuffer::getSemKey(),9); if (semid<0) return false;
984  shmAddr =shm_attach(shmid); if (0==shmAddr) return false;
985 
986  int att = 0;
987  for(; att <10; att++)
988  {
989  if(shm_nattch(shmid)>1) {
990  cout << att << " FUShmBuffer::releaseSharedMemory(): nattch="<<shm_nattch(shmid)
991  <<", failed attempt to release shared memory."<<endl;
992  ::sleep(1);
993  }
994  else
995  break;
996  }
997 
998  if(att>=10) return false;
999 
1000  if (segmentationMode) {
1001  FUShmBuffer* buffer=
1002  new (shmAddr) FUShmBuffer(segmentationMode,
1003  nRawCells,nRecoCells,nDqmCells,
1004  rawCellSize,recoCellSize,dqmCellSize);
1005  int cellid;
1006  for (unsigned int i=0;i<nRawCells;i++) {
1007  cellid=shm_get(buffer->rawCellShmKey(i),FUShmRawCell::size(rawCellSize));
1008  if ((shm_destroy(cellid)==-1)) return false;
1009  }
1010  for (unsigned int i=0;i<nRecoCells;i++) {
1011  cellid=shm_get(buffer->recoCellShmKey(i),FUShmRecoCell::size(recoCellSize));
1012  if ((shm_destroy(cellid)==-1)) return false;
1013  }
1014  for (unsigned int i=0;i<nDqmCells;i++) {
1015  cellid=shm_get(buffer->dqmCellShmKey(i),FUShmDqmCell::size(dqmCellSize));
1016  if ((shm_destroy(cellid)==-1)) return false;
1017  }
1018  }
1019  shmdt(shmAddr);
1020  if (sem_destroy(semid)==-1) return false;
1021  if (shm_destroy(shmid)==-1) return false;
1022  if (shm_destroy(shmidd)==-1) return false;
1023 
1024  return true;
1025 }
key_t recoCellShmKey(unsigned int iCell)
int i
Definition: DBlmapReader.cc:9
unsigned int nRecoCells() const
Definition: FUShmBuffer.h:64
static int shm_nattch(int shmid)
static void * shm_attach(int shmid)
static unsigned int size(unsigned int payloadSize)
int shmid() const
Definition: FUShmBuffer.h:67
static key_t getShmDescriptorKey()
static int shm_get(key_t key, int size)
static unsigned int size(bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
void sleep(Duration_t)
Definition: Utils.h:163
static unsigned int size(unsigned int payloadSize)
key_t rawCellShmKey(unsigned int iCell)
static int shm_destroy(int shmid)
unsigned int nRawCells() const
Definition: FUShmBuffer.h:63
key_t dqmCellShmKey(unsigned int iCell)
static key_t getShmKey()
static key_t getSemKey()
static int sem_get(key_t key, int nsem)
FUShmBuffer(bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
Definition: FUShmBuffer.cc:53
static int sem_destroy(int semid)
tuple cout
Definition: gather_cfg.py:41
unsigned int nDqmCells() const
Definition: FUShmBuffer.h:65
static unsigned int size(unsigned int payloadSize)
Definition: FUShmDqmCell.cc:97
int semid() const
Definition: FUShmBuffer.h:68
bool FUShmBuffer::removeClientPrcId ( pid_t  prcId)

Definition at line 1500 of file FUShmBuffer.cc.

References clientPrcIdOffset_, lock(), nClients_, and unlock().

Referenced by scheduleRawEmptyCellForDiscard(), and FUShmReader::~FUShmReader().

1501 {
1502  lock();
1503  pid_t *prcid=(pid_t*)((unsigned long)this+clientPrcIdOffset_);
1504  unsigned int iClient(0);
1505  while (iClient<=nClients_&&(*prcid)!=prcId) { prcid++; iClient++; }
1506  assert(iClient!=nClients_);
1507  pid_t* next=prcid; next++;
1508  while (iClient<nClients_-1) { *prcid=*next; prcid++; next++; iClient++; }
1509  nClients_--;
1510  unlock();
1511  return true;
1512 }
unsigned int clientPrcIdOffset_
Definition: FUShmBuffer.h:303
unsigned int nClients_
Definition: FUShmBuffer.h:301
void FUShmBuffer::reset ( void  )

Definition at line 229 of file FUShmBuffer.cc.

References dqmReadLast_, dqmReadNext_, dqmReadOffset_, dqmWriteLast_, dqmWriteNext_, dqmWriteOffset_, evf::evt::EMPTY, evf::dqm::EMPTY, i, nClients_, nDqmCells_, nRawCells_, nRecoCells_, rawReadLast_, rawReadNext_, rawReadOffset_, rawWriteLast_, rawWriteNext_, rawWriteOffset_, recoReadLast_, recoReadNext_, recoReadOffset_, recoWriteLast_, recoWriteNext_, recoWriteOffset_, sem_init(), sem_print(), setDqmState(), setEvtDiscard(), setEvtNumber(), setEvtPrcId(), setEvtState(), and setEvtTimeStamp().

Referenced by initialize().

230 {
231  nClients_=0;
232 
233  // setup ipc semaphores
234  sem_init(0,1); // lock (binary)
235  sem_init(1,nRawCells_); // raw write semaphore
236  sem_init(2,0); // raw read semaphore
237  sem_init(3,1); // binary semaphore to schedule raw event for discard
238  sem_init(4,0); // binary semaphore to discard raw event
239  sem_init(5,nRecoCells_);// reco write semaphore
240  sem_init(6,0); // reco send (read) semaphore
241  sem_init(7,nDqmCells_); // dqm write semaphore
242  sem_init(8,0); // dqm send (read) semaphore
243 
244  sem_print();
245 
246  unsigned int *iWrite,*iRead;
247 
249  iWrite=(unsigned int*)((unsigned long)this+rawWriteOffset_);
250  iRead =(unsigned int*)((unsigned long)this+rawReadOffset_);
251  for (unsigned int i=0;i<nRawCells_;i++) { *iWrite++=i; *iRead++ =0xffffffff; }
252 
254  iWrite=(unsigned int*)((unsigned long)this+recoWriteOffset_);
255  iRead =(unsigned int*)((unsigned long)this+recoReadOffset_);
256  for (unsigned int i=0;i<nRecoCells_;i++) { *iWrite++=i; *iRead++ =0xffffffff; }
257 
259  iWrite=(unsigned int*)((unsigned long)this+dqmWriteOffset_);
260  iRead =(unsigned int*)((unsigned long)this+dqmReadOffset_);
261  for (unsigned int i=0;i<nDqmCells_;i++) { *iWrite++=i; *iRead++ =0xffffffff; }
262 
263  for (unsigned int i=0;i<nRawCells_;i++) {
265  setEvtDiscard(i,0);
266  setEvtNumber(i,0xffffffff);
267  setEvtPrcId(i,0);
268  setEvtTimeStamp(i,0);
269  }
270 
271  for (unsigned int i=0;i<nDqmCells_;i++) setDqmState(i,dqm::EMPTY);
272 }
int i
Definition: DBlmapReader.cc:9
bool setEvtPrcId(unsigned int index, pid_t prcId)
unsigned int dqmWriteNext_
Definition: FUShmBuffer.h:287
unsigned int rawReadOffset_
Definition: FUShmBuffer.h:277
unsigned int dqmReadLast_
Definition: FUShmBuffer.h:291
unsigned int dqmReadOffset_
Definition: FUShmBuffer.h:292
unsigned int dqmWriteLast_
Definition: FUShmBuffer.h:288
unsigned int nRecoCells_
Definition: FUShmBuffer.h:312
unsigned int dqmWriteOffset_
Definition: FUShmBuffer.h:289
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int recoWriteLast_
Definition: FUShmBuffer.h:281
unsigned int recoWriteNext_
Definition: FUShmBuffer.h:280
bool setEvtNumber(unsigned int index, unsigned int evtNumber)
unsigned int recoReadOffset_
Definition: FUShmBuffer.h:285
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
bool setEvtState(unsigned int index, evt::State_t state)
unsigned int rawWriteNext_
Definition: FUShmBuffer.h:272
unsigned int recoReadLast_
Definition: FUShmBuffer.h:284
unsigned int rawReadNext_
Definition: FUShmBuffer.h:275
unsigned int rawReadLast_
Definition: FUShmBuffer.h:276
unsigned int rawWriteOffset_
Definition: FUShmBuffer.h:274
bool setEvtTimeStamp(unsigned int index, time_t timeStamp)
unsigned int rawWriteLast_
Definition: FUShmBuffer.h:273
unsigned int dqmReadNext_
Definition: FUShmBuffer.h:290
void sem_init(int isem, int value)
unsigned int recoWriteOffset_
Definition: FUShmBuffer.h:282
unsigned int nClients_
Definition: FUShmBuffer.h:301
unsigned int recoReadNext_
Definition: FUShmBuffer.h:283
bool setEvtDiscard(unsigned int index, unsigned int discard)
bool setDqmState(unsigned int index, dqm::State_t state)
void FUShmBuffer::scheduleRawCellForDiscard ( unsigned int  iCell)

Definition at line 420 of file FUShmBuffer.cc.

References evf::evt::EMPTY, evtState(), evf::evt::LUMISECTION, postRawDiscard(), postRawDiscarded(), evf::evt::PROCESSED, evf::evt::PROCESSING, rawCellReadyForDiscard(), rawDiscardIndex_, evf::evt::SENT, setEvtState(), evf::utils::state, evf::evt::STOP, and waitRawDiscard().

Referenced by discardRecoCell(), FUShmReader::fillRawData(), and evf::FUShmClient::readNext().

421 {
422  waitRawDiscard();
423  if (rawCellReadyForDiscard(iCell)) {
424  rawDiscardIndex_=iCell;
425  evt::State_t state=evtState(iCell);
426  assert(state==evt::PROCESSING
427  ||state==evt::SENT
428  ||state==evt::EMPTY
429  ||state==evt::STOP
430  ||state==evt::LUMISECTION
431  );
432  if (state==evt::PROCESSING) setEvtState(iCell,evt::PROCESSED);
434  }
435  else postRawDiscard();
436 }
void waitRawDiscard()
Definition: FUShmBuffer.h:250
evt::State_t evtState(unsigned int index)
bool setEvtState(unsigned int index, evt::State_t state)
bool rawCellReadyForDiscard(unsigned int index)
void postRawDiscard()
Definition: FUShmBuffer.h:251
unsigned int rawDiscardIndex_
Definition: FUShmBuffer.h:278
char state
Definition: procUtils.cc:75
void postRawDiscarded()
Definition: FUShmBuffer.h:253
void FUShmBuffer::scheduleRawCellForDiscardServerSide ( unsigned int  iCell)

Definition at line 440 of file FUShmBuffer.cc.

References evtState(), postRawDiscard(), postRawDiscarded(), evf::evt::PROCESSED, rawCellReadyForDiscard(), rawDiscardIndex_, evf::evt::RAWWRITTEN, setEvtState(), evf::utils::state, and waitRawDiscard().

441 {
442  waitRawDiscard();
443  if (rawCellReadyForDiscard(iCell)) {
444  rawDiscardIndex_=iCell;
445  evt::State_t state=evtState(iCell);
446  assert(state==evt::RAWWRITTEN
447  );
450  }
451  else postRawDiscard();
452 }
void waitRawDiscard()
Definition: FUShmBuffer.h:250
evt::State_t evtState(unsigned int index)
bool setEvtState(unsigned int index, evt::State_t state)
bool rawCellReadyForDiscard(unsigned int index)
void postRawDiscard()
Definition: FUShmBuffer.h:251
unsigned int rawDiscardIndex_
Definition: FUShmBuffer.h:278
char state
Definition: procUtils.cc:75
void postRawDiscarded()
Definition: FUShmBuffer.h:253
void FUShmBuffer::scheduleRawEmptyCellForDiscard ( )

Definition at line 590 of file FUShmBuffer.cc.

References evf::FUShmRawCell::index(), postRawDiscarded(), rawCellToWrite(), rawDiscardIndex_, setEvtNumber(), setEvtPrcId(), setEvtState(), setEvtTimeStamp(), and evf::evt::STOP.

Referenced by FUShmReader::fillRawData().

591 {
593  rawDiscardIndex_=cell->index();
594  setEvtState(cell->index(),evt::STOP);
595  setEvtNumber(cell->index(),0xffffffff);
596  setEvtPrcId(cell->index(),0);
597  setEvtTimeStamp(cell->index(),0);
599 }
bool setEvtPrcId(unsigned int index, pid_t prcId)
bool setEvtNumber(unsigned int index, unsigned int evtNumber)
bool setEvtState(unsigned int index, evt::State_t state)
unsigned int rawDiscardIndex_
Definition: FUShmBuffer.h:278
FUShmRawCell * rawCellToWrite()
Definition: FUShmBuffer.cc:290
bool setEvtTimeStamp(unsigned int index, time_t timeStamp)
unsigned int index() const
Definition: FUShmRawCell.h:22
void postRawDiscarded()
Definition: FUShmBuffer.h:253
void FUShmBuffer::scheduleRawEmptyCellForDiscard ( FUShmRawCell cell)

Definition at line 603 of file FUShmBuffer.cc.

References evf::FUShmRawCell::index(), postRawDiscard(), postRawDiscarded(), rawCellReadyForDiscard(), rawDiscardIndex_, removeClientPrcId(), segmentationMode_, setEvtNumber(), setEvtPrcId(), setEvtState(), setEvtTimeStamp(), evf::evt::STOP, and waitRawDiscard().

604 {
605  waitRawDiscard();
606  if (rawCellReadyForDiscard(cell->index())) {
607  rawDiscardIndex_=cell->index();
608  setEvtState(cell->index(),evt::STOP);
609  setEvtNumber(cell->index(),0xffffffff);
610  setEvtPrcId(cell->index(),0);
611  setEvtTimeStamp(cell->index(),0);
612  removeClientPrcId(getpid());
613  if (segmentationMode_) shmdt(cell);
615  }
616  else postRawDiscard();
617 }
bool setEvtPrcId(unsigned int index, pid_t prcId)
bool removeClientPrcId(pid_t prcId)
void waitRawDiscard()
Definition: FUShmBuffer.h:250
bool setEvtNumber(unsigned int index, unsigned int evtNumber)
bool setEvtState(unsigned int index, evt::State_t state)
bool rawCellReadyForDiscard(unsigned int index)
void postRawDiscard()
Definition: FUShmBuffer.h:251
unsigned int rawDiscardIndex_
Definition: FUShmBuffer.h:278
bool setEvtTimeStamp(unsigned int index, time_t timeStamp)
unsigned int index() const
Definition: FUShmRawCell.h:22
void postRawDiscarded()
Definition: FUShmBuffer.h:253
void FUShmBuffer::scheduleRawEmptyCellForDiscardServerSide ( FUShmRawCell cell)

Definition at line 620 of file FUShmBuffer.cc.

References evf::FUShmRawCell::index(), postRawDiscard(), postRawDiscarded(), rawCellReadyForDiscard(), rawDiscardIndex_, segmentationMode_, setEvtNumber(), setEvtPrcId(), setEvtState(), setEvtTimeStamp(), and evf::evt::STOP.

621 {
622  // waitRawDiscard();
623  if (rawCellReadyForDiscard(cell->index())) {
624  rawDiscardIndex_=cell->index();
625  setEvtState(cell->index(),evt::STOP);
626  setEvtNumber(cell->index(),0xffffffff);
627  setEvtPrcId(cell->index(),0);
628  setEvtTimeStamp(cell->index(),0);
629  // removeClientPrcId(getpid());
630  if (segmentationMode_) shmdt(cell);
632  }
633  else postRawDiscard();
634 }
bool setEvtPrcId(unsigned int index, pid_t prcId)
bool setEvtNumber(unsigned int index, unsigned int evtNumber)
bool setEvtState(unsigned int index, evt::State_t state)
bool rawCellReadyForDiscard(unsigned int index)
void postRawDiscard()
Definition: FUShmBuffer.h:251
unsigned int rawDiscardIndex_
Definition: FUShmBuffer.h:278
bool setEvtTimeStamp(unsigned int index, time_t timeStamp)
unsigned int index() const
Definition: FUShmRawCell.h:22
void postRawDiscarded()
Definition: FUShmBuffer.h:253
int FUShmBuffer::sem_create ( key_t  key,
int  nsem 
)
static

Definition at line 1164 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

Referenced by createShmBuffer().

1165 {
1166  int semid=semget(key,nsem,IPC_CREAT|0666);
1167  if (semid<0) {
1168  int err=errno;
1169  cout<<"FUShmBuffer::sem_create(key="<<key<<",nsem="<<nsem<<") failed: "
1170  <<strerror(err)<<endl;
1171  }
1172  return semid;
1173 }
list key
Definition: combine.py:13
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:68
int FUShmBuffer::sem_destroy ( int  semid)
static

Definition at line 1190 of file FUShmBuffer.cc.

References gather_cfg::cout, and query::result.

Referenced by releaseSharedMemory().

1191 {
1192  int result=semctl(semid,0,IPC_RMID);
1193  if (result==-1) cout<<"FUShmBuffer::sem_destroy(semid="<<semid<<") failed."<<endl;
1194  return result;
1195 }
tuple result
Definition: query.py:137
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:68
int FUShmBuffer::sem_get ( key_t  key,
int  nsem 
)
static

Definition at line 1177 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

Referenced by getShmBuffer(), and releaseSharedMemory().

1178 {
1179  int semid=semget(key,nsem,0666);
1180  if (semid<0) {
1181  int err=errno;
1182  cout<<"FUShmBuffer::sem_get(key="<<key<<",nsem="<<nsem<<") failed: "
1183  <<strerror(err)<<endl;
1184  }
1185  return semid;
1186 }
list key
Definition: combine.py:13
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:68
void FUShmBuffer::sem_init ( int  isem,
int  value 
)
private

Definition at line 1658 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

Referenced by reset().

1659 {
1660  if (semctl(semid(),isem,SETVAL,value)<0) {
1661  cout<<"FUShmBuffer: FATAL ERROR in semaphore initialization."<<endl;
1662  }
1663 }
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:68
void FUShmBuffer::sem_post ( int  isem)
private

Definition at line 1682 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

Referenced by postDqmRead(), postDqmWrite(), postRawDiscard(), postRawDiscarded(), postRawRead(), postRawWrite(), postRecoRead(), postRecoWrite(), and unlock().

1683 {
1684  struct sembuf sops[1];
1685  sops[0].sem_num=isem;
1686  sops[0].sem_op = 1;
1687  sops[0].sem_flg= 0;
1688  if (semop(semid(),sops,1)==-1) {
1689  cout<<"FUShmBuffer: ERROR in semaphore operation sem_post."<<endl;
1690  }
1691 }
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:68
void FUShmBuffer::sem_print ( )

Definition at line 792 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

Referenced by reset().

793 {
794  cout<<"--> current sem values:"
795  <<endl
796  <<" lock="<<semctl(semid(),0,GETVAL)
797  <<endl
798  <<" wraw="<<semctl(semid(),1,GETVAL)
799  <<" rraw="<<semctl(semid(),2,GETVAL)
800  <<endl
801  <<" wdsc="<<semctl(semid(),3,GETVAL)
802  <<" rdsc="<<semctl(semid(),4,GETVAL)
803  <<endl
804  <<" wrec="<<semctl(semid(),5,GETVAL)
805  <<" rrec="<<semctl(semid(),6,GETVAL)
806  <<endl
807  <<" wdqm="<<semctl(semid(),7,GETVAL)
808  <<" rdqm="<<semctl(semid(),8,GETVAL)
809  <<endl;
810 }
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:68
int FUShmBuffer::sem_wait ( int  isem)
private

Definition at line 1667 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

Referenced by lock(), waitDqmRead(), waitDqmWrite(), waitRawDiscard(), waitRawDiscarded(), waitRawRead(), waitRawWrite(), waitRecoRead(), and waitRecoWrite().

1668 {
1669  struct sembuf sops[1];
1670  sops[0].sem_num=isem;
1671  sops[0].sem_op = -1;
1672  sops[0].sem_flg= 0;
1673  if (semop(semid(),sops,1)==-1) {
1674  cout<<"FUShmBuffer: ERROR in semaphore operation sem_wait."<<endl;
1675  return -1;
1676  }
1677  return 0;
1678 }
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:68
int evf::FUShmBuffer::semid ( ) const
inline
bool FUShmBuffer::setClientPrcId ( pid_t  prcId)
private

Definition at line 1483 of file FUShmBuffer.cc.

References clientPrcIdOffset_, i, lock(), nClients_, nClientsMax_, and unlock().

Referenced by getShmBuffer().

1484 {
1485  lock();
1486  assert(nClients_<nClientsMax_);
1487  pid_t *prcid=(pid_t*)((unsigned long)this+clientPrcIdOffset_);
1488  for (unsigned int i=0;i<nClients_;i++) {
1489  if ((*prcid)==prcId) { unlock(); return false; }
1490  prcid++;
1491  }
1492  nClients_++;
1493  *prcid=prcId;
1494  unlock();
1495  return true;
1496 }
unsigned int clientPrcIdOffset_
Definition: FUShmBuffer.h:303
int i
Definition: DBlmapReader.cc:9
unsigned int nClientsMax_
Definition: FUShmBuffer.h:302
unsigned int nClients_
Definition: FUShmBuffer.h:301
bool FUShmBuffer::setDqmState ( unsigned int  index,
dqm::State_t  state 
)

Definition at line 1403 of file FUShmBuffer.cc.

References dqmStateOffset_, getHLTprescales::index, lock(), nDqmCells_, evf::utils::state, and unlock().

Referenced by discardDqmCell(), dqmCellToRead(), finishReadingDqmCell(), reset(), and writeDqmEventData().

1404 {
1405  assert(index<nDqmCells_);
1406  dqm::State_t *pstate=(dqm::State_t*)((unsigned long)this+dqmStateOffset_);
1407  pstate+=index;
1408  lock();
1409  *pstate=state;
1410  unlock();
1411  return true;
1412 }
unsigned int dqmStateOffset_
Definition: FUShmBuffer.h:299
unsigned int nDqmCells_
Definition: FUShmBuffer.h:319
char state
Definition: procUtils.cc:75
bool FUShmBuffer::setEvtDiscard ( unsigned int  index,
unsigned int  discard 
)
private

Definition at line 1416 of file FUShmBuffer.cc.

References evtDiscardOffset_, getHLTprescales::index, lock(), nRawCells_, and unlock().

Referenced by rawCellToWrite(), releaseRawCell(), reset(), and writeErrorEventData().

1417 {
1418  assert(index<nRawCells_);
1419  unsigned int *pcount=(unsigned int*)((unsigned long)this+evtDiscardOffset_);
1420  pcount+=index;
1421  lock();
1422  *pcount=discard;
1423  unlock();
1424  return true;
1425 }
unsigned int evtDiscardOffset_
Definition: FUShmBuffer.h:295
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
bool FUShmBuffer::setEvtNumber ( unsigned int  index,
unsigned int  evtNumber 
)
private

Definition at line 1444 of file FUShmBuffer.cc.

References evtNumber(), evtNumberOffset_, getHLTprescales::index, lock(), nRawCells_, and unlock().

Referenced by finishWritingRawCell(), releaseRawCell(), reset(), scheduleRawEmptyCellForDiscard(), and scheduleRawEmptyCellForDiscardServerSide().

1445 {
1446  assert(index<nRawCells_);
1447  unsigned int *pevt=(unsigned int*)((unsigned long)this+evtNumberOffset_);
1448  pevt+=index;
1449  lock();
1450  *pevt=evtNumber;
1451  unlock();
1452  return true;
1453 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int evtNumberOffset_
Definition: FUShmBuffer.h:296
unsigned int evtNumber(unsigned int index)
bool FUShmBuffer::setEvtPrcId ( unsigned int  index,
pid_t  prcId 
)
private

Definition at line 1457 of file FUShmBuffer.cc.

References evtPrcIdOffset_, getHLTprescales::index, lock(), nRawCells_, and unlock().

Referenced by rawCellToRead(), releaseRawCell(), reset(), scheduleRawEmptyCellForDiscard(), and scheduleRawEmptyCellForDiscardServerSide().

1458 {
1459  assert(index<nRawCells_);
1460  pid_t* prcid=(pid_t*)((unsigned long)this+evtPrcIdOffset_);
1461  prcid+=index;
1462  lock();
1463  *prcid=prcId;
1464  unlock();
1465  return true;
1466 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
unsigned int evtPrcIdOffset_
Definition: FUShmBuffer.h:297
bool FUShmBuffer::setEvtState ( unsigned int  index,
evt::State_t  state 
)
bool FUShmBuffer::setEvtTimeStamp ( unsigned int  index,
time_t  timeStamp 
)
private

Definition at line 1470 of file FUShmBuffer.cc.

References evtTimeStampOffset_, getHLTprescales::index, lock(), nRawCells_, stor::utils::timeStamp(), and unlock().

Referenced by finishReadingRawCell(), releaseRawCell(), reset(), scheduleRawEmptyCellForDiscard(), and scheduleRawEmptyCellForDiscardServerSide().

1471 {
1472  assert(index<nRawCells_);
1473  time_t *ptstmp=(time_t*)((unsigned long)this+evtTimeStampOffset_);
1474  ptstmp+=index;
1475  lock();
1476  *ptstmp=timeStamp;
1477  unlock();
1478  return true;
1479 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:305
std::string timeStamp(TimePoint_t)
Definition: Utils.cc:23
unsigned int evtTimeStampOffset_
Definition: FUShmBuffer.h:298
void * FUShmBuffer::shm_attach ( int  shmid)
static

Definition at line 1132 of file FUShmBuffer.cc.

References gather_cfg::cout, NULL, and query::result.

Referenced by createShmBuffer(), dqmCell(), getShmBuffer(), initialize(), rawCell(), recoCell(), and releaseSharedMemory().

1133 {
1134  void* result=shmat(shmid,NULL,0);
1135  if (0==result) {
1136  int err=errno;
1137  cout<<"FUShmBuffer::shm_attach("<<shmid<<") failed: "
1138  <<strerror(err)<<endl;
1139  }
1140  return result;
1141 }
int shmid() const
Definition: FUShmBuffer.h:67
#define NULL
Definition: scimark2.h:8
tuple result
Definition: query.py:137
tuple cout
Definition: gather_cfg.py:41
int FUShmBuffer::shm_create ( key_t  key,
int  size 
)
static

Definition at line 1094 of file FUShmBuffer.cc.

References gather_cfg::cout, query::result, and shmid().

Referenced by createShmBuffer(), and initialize().

1095 {
1096  // first check and possibly remove existing segment with same id
1097  int shmid=shmget(key,1,0644);//using minimal size any segment with key "key" will be connected
1098  if(shmid!=-1){
1099  // an existing segment was found, remove it
1100  shmid_ds shmstat;
1101  int result=shmctl(shmid,IPC_STAT,&shmstat);
1102  cout << "FUShmBuffer found segment for key 0x " << hex << key << dec
1103  << " created by process " << shmstat.shm_cpid << " owned by "
1104  << shmstat.shm_perm.uid << " permissions "
1105  << hex << shmstat.shm_perm.mode << dec << endl;
1106  result=shmctl(shmid,IPC_RMID,&shmstat);
1107  }
1108  shmid=shmget(key,size,IPC_CREAT|0644);
1109  if (shmid==-1) {
1110  int err=errno;
1111  cout<<"FUShmBuffer::shm_create("<<key<<","<<size<<") failed: "
1112  <<strerror(err)<<endl;
1113  }
1114  return shmid;
1115 }
int shmid() const
Definition: FUShmBuffer.h:67
static unsigned int size(bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
tuple result
Definition: query.py:137
list key
Definition: combine.py:13
tuple cout
Definition: gather_cfg.py:41
int FUShmBuffer::shm_destroy ( int  shmid)
static

Definition at line 1154 of file FUShmBuffer.cc.

References gather_cfg::cout, and query::result.

Referenced by releaseSharedMemory().

1155 {
1156  shmid_ds shmstat;
1157  int result=shmctl(shmid,IPC_RMID,&shmstat);
1158  if (result==-1) cout<<"FUShmBuffer::shm_destroy(shmid="<<shmid<<") failed."<<endl;
1159  return result;
1160 }
int shmid() const
Definition: FUShmBuffer.h:67
tuple result
Definition: query.py:137
tuple cout
Definition: gather_cfg.py:41
int FUShmBuffer::shm_get ( key_t  key,
int  size 
)
static

Definition at line 1119 of file FUShmBuffer.cc.

References gather_cfg::cout, and shmid().

Referenced by dqmCell(), getShmBuffer(), rawCell(), recoCell(), and releaseSharedMemory().

1120 {
1121  int shmid=shmget(key,size,0644);
1122  if (shmid==-1) {
1123  int err=errno;
1124  cout<<"FUShmBuffer::shm_get("<<key<<","<<size<<") failed: "
1125  <<strerror(err)<<endl;
1126  }
1127  return shmid;
1128 }
int shmid() const
Definition: FUShmBuffer.h:67
static unsigned int size(bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
list key
Definition: combine.py:13
tuple cout
Definition: gather_cfg.py:41
int FUShmBuffer::shm_nattch ( int  shmid)
static

Definition at line 1145 of file FUShmBuffer.cc.

Referenced by createShmBuffer(), evf::FUResourceTable::discard(), getShmBuffer(), and releaseSharedMemory().

1146 {
1147  shmid_ds shmstat;
1148  shmctl(shmid,IPC_STAT,&shmstat);
1149  return shmstat.shm_nattch;
1150 }
int shmid() const
Definition: FUShmBuffer.h:67
int evf::FUShmBuffer::shmid ( ) const
inline
key_t FUShmBuffer::shmKey ( unsigned int  iCell,
unsigned int  offset 
)
private

Definition at line 1609 of file FUShmBuffer.cc.

References gather_cfg::cout, i, evf::evtn::offset(), and segmentationMode_.

Referenced by dqmCellShmKey(), rawCellShmKey(), and recoCellShmKey().

1610 {
1611  if (!segmentationMode_) {
1612  cout<<"FUShmBuffer::shmKey() ERROR: only valid in segmentationMode!"<<endl;
1613  return -1;
1614  }
1615  key_t* addr=(key_t*)((unsigned long)this+offset);
1616  for (unsigned int i=0;i<iCell;i++) ++addr;
1617  return *addr;
1618 }
int i
Definition: DBlmapReader.cc:9
unsigned int offset(bool)
tuple cout
Definition: gather_cfg.py:41
unsigned int FUShmBuffer::size ( bool  segmentationMode,
unsigned int  nRawCells,
unsigned int  nRecoCells,
unsigned int  nDqmCells,
unsigned int  rawCellSize,
unsigned int  recoCellSize,
unsigned int  dqmCellSize 
)
static

Definition at line 1029 of file FUShmBuffer.cc.

References FUShmBuffer(), nDqmCells(), evf::evtn::offset(), query::result, evf::FUShmDqmCell::size(), evf::FUShmRawCell::size(), and evf::FUShmRecoCell::size().

Referenced by createShmBuffer(), getShmBuffer(), and releaseSharedMemory().

1036 {
1037  unsigned int offset=
1038  sizeof(FUShmBuffer)+
1039  sizeof(unsigned int)*4*nRawCells+
1040  sizeof(evt::State_t)*nRawCells+
1041  sizeof(dqm::State_t)*nDqmCells;
1042 
1043  unsigned int rawCellTotalSize=FUShmRawCell::size(rawCellSize);
1044  unsigned int recoCellTotalSize=FUShmRecoCell::size(recoCellSize);
1045  unsigned int dqmCellTotalSize=FUShmDqmCell::size(dqmCellSize);
1046 
1047  unsigned int realSize =
1048  (segmentationMode) ?
1049  offset
1050  +sizeof(key_t)*(nRawCells+nRecoCells+nDqmCells)
1051  :
1052  offset
1053  +rawCellTotalSize*nRawCells
1054  +recoCellTotalSize*nRecoCells
1055  +dqmCellTotalSize*nDqmCells;
1056 
1057  unsigned int result=realSize/0x10*0x10 + (realSize%0x10>0)*0x10;
1058 
1059  return result;
1060 }
unsigned int nRecoCells() const
Definition: FUShmBuffer.h:64
static unsigned int size(unsigned int payloadSize)
static unsigned int size(unsigned int payloadSize)
tuple result
Definition: query.py:137
unsigned int nRawCells() const
Definition: FUShmBuffer.h:63
unsigned int offset(bool)
FUShmBuffer(bool segmentationMode, unsigned int nRawCells, unsigned int nRecoCells, unsigned int nDqmCells, unsigned int rawCellSize, unsigned int recoCellSize, unsigned int dqmCellSize)
Definition: FUShmBuffer.cc:53
unsigned int nDqmCells() const
Definition: FUShmBuffer.h:65
static unsigned int size(unsigned int payloadSize)
Definition: FUShmDqmCell.cc:97
void evf::FUShmBuffer::unlock ( void  )
inline
void evf::FUShmBuffer::waitDqmRead ( )
inlineprivate

Definition at line 260 of file FUShmBuffer.h.

References sem_wait().

Referenced by dqmCellToRead().

260 { sem_wait(8); }
int sem_wait(int isem)
void evf::FUShmBuffer::waitDqmWrite ( )
inlineprivate

Definition at line 258 of file FUShmBuffer.h.

References sem_wait().

Referenced by writeDqmEmptyEvent(), and writeDqmEventData().

258 { sem_wait(7); }
int sem_wait(int isem)
void evf::FUShmBuffer::waitRawDiscard ( )
inlineprivate

Definition at line 250 of file FUShmBuffer.h.

References sem_wait().

Referenced by scheduleRawCellForDiscard(), scheduleRawCellForDiscardServerSide(), and scheduleRawEmptyCellForDiscard().

250 { sem_wait(3); }
int sem_wait(int isem)
void evf::FUShmBuffer::waitRawDiscarded ( )
inlineprivate

Definition at line 252 of file FUShmBuffer.h.

References sem_wait().

Referenced by rawCellToDiscard().

252 { sem_wait(4); }
int sem_wait(int isem)
void evf::FUShmBuffer::waitRawRead ( )
inlineprivate

Definition at line 248 of file FUShmBuffer.h.

References sem_wait().

Referenced by rawCellToRead().

248 { sem_wait(2); }
int sem_wait(int isem)
void evf::FUShmBuffer::waitRawWrite ( )
inlineprivate

Definition at line 246 of file FUShmBuffer.h.

References sem_wait().

Referenced by rawCellToWrite().

246 { sem_wait(1); }
int sem_wait(int isem)
void evf::FUShmBuffer::waitRecoRead ( )
inlineprivate

Definition at line 256 of file FUShmBuffer.h.

References sem_wait().

Referenced by recoCellToRead().

256 { sem_wait(6); }
int sem_wait(int isem)
void evf::FUShmBuffer::waitRecoWrite ( )
inlineprivate

Definition at line 254 of file FUShmBuffer.h.

References sem_wait().

Referenced by writeErrorEventData(), writeRecoEmptyEvent(), writeRecoEventData(), and writeRecoInitMsg().

254 { sem_wait(5); }
int sem_wait(int isem)
void FUShmBuffer::writeDqmEmptyEvent ( )

Definition at line 577 of file FUShmBuffer.cc.

References evf::FUShmDqmCell::clear(), dqmCell(), nextDqmWriteIndex(), postDqmIndexToRead(), postDqmRead(), segmentationMode_, and waitDqmWrite().

578 {
579  waitDqmWrite();
580  unsigned int iCell=nextDqmWriteIndex();
581  FUShmDqmCell* cell=dqmCell(iCell);
582  cell->clear();
583  postDqmIndexToRead(iCell);
584  if (segmentationMode_) shmdt(cell);
585  postDqmRead();
586 }
void postDqmIndexToRead(unsigned int index)
unsigned int nextDqmWriteIndex()
FUShmDqmCell * dqmCell(unsigned int iCell)
bool FUShmBuffer::writeDqmEventData ( unsigned int  runNumber,
unsigned int  evtAtUpdate,
unsigned int  folderId,
unsigned int  fuProcessId,
unsigned int  fuGuid,
unsigned char *  data,
unsigned int  dataSize 
)

Definition at line 763 of file FUShmBuffer.cc.

References gather_cfg::cout, dqmCell(), dqmCellPayloadSize_, dqmState(), evf::dqm::EMPTY, nextDqmWriteIndex(), postDqmIndexToRead(), postDqmRead(), segmentationMode_, setDqmState(), evf::utils::state, waitDqmWrite(), evf::FUShmDqmCell::writeData(), evf::dqm::WRITING, and evf::dqm::WRITTEN.

Referenced by FUShmDQMOutputService::writeShmDQMData().

770 {
771  if (dataSize>dqmCellPayloadSize_) {
772  cout<<"FUShmBuffer::writeDqmEventData() ERROR: buffer overflow."<<endl;
773  return false;
774  }
775 
776  waitDqmWrite();
777  unsigned int iCell=nextDqmWriteIndex();
778  FUShmDqmCell* cell=dqmCell(iCell);
779  dqm::State_t state=dqmState(iCell);
780  assert(state==dqm::EMPTY);
781  setDqmState(iCell,dqm::WRITING);
782  cell->writeData(runNumber,evtAtUpdate,folderId,fuProcessId,fuGuid,data,dataSize);
783  setDqmState(iCell,dqm::WRITTEN);
784  postDqmIndexToRead(iCell);
785  if (segmentationMode_) shmdt(cell);
786  postDqmRead();
787  return true;
788 }
void postDqmIndexToRead(unsigned int index)
unsigned int dqmCellPayloadSize_
Definition: FUShmBuffer.h:320
unsigned int nextDqmWriteIndex()
dqm::State_t dqmState(unsigned int index)
char state
Definition: procUtils.cc:75
void writeData(unsigned int runNumber, unsigned int evtAtUpdate, unsigned int folderId, unsigned int fuProcessId, unsigned int fuGuid, unsigned char *data, unsigned int dataSize)
Definition: FUShmDqmCell.cc:69
tuple cout
Definition: gather_cfg.py:41
bool setDqmState(unsigned int index, dqm::State_t state)
FUShmDqmCell * dqmCell(unsigned int iCell)
bool FUShmBuffer::writeErrorEventData ( unsigned int  runNumber,
unsigned int  fuProcessId,
unsigned int  iRawCell 
)

Definition at line 693 of file FUShmBuffer.cc.

References runTheMatrix::data, evf::FUShmRawCell::eventSize(), evf::FUShmRawCell::evtNumber(), evf::FUShmRawCell::fedAddr(), evf::FUShmRawCell::fedSize(), evf::evtn::getlbn(), i, FEDNumbering::MINTriggerGTPFEDID, nextRecoWriteIndex(), evf::FUShmRawCell::payloadAddr(), pos, postRecoIndexToRead(), postRecoRead(), rawCell(), dt_offlineAnalysis_common_cff::reco, recoCell(), evf::evt::RECOWRITING, evf::evt::RECOWRITTEN, segmentationMode_, setEvtDiscard(), setEvtState(), waitRecoWrite(), and evf::FUShmRecoCell::writeErrorEvent().

Referenced by FUShmReader::~FUShmReader().

696 {
697  FUShmRawCell *raw=rawCell(iRawCell);
698 
699  unsigned int dataSize=sizeof(uint32_t)*(4+1024)+raw->eventSize();
700  unsigned char *data =new unsigned char[dataSize];
701  uint32_t *pos =(uint32_t*)data;
702  // 06-Oct-2008, KAB - added a version number for the error event format.
703  //
704  // Version 1 had no version number, so the run number appeared in the
705  // first value. So, a reasonable test for version 1 is whether the
706  // first value is larger than some relatively small cutoff (say 32).
707  // Version 2 added the lumi block number.
708  //
709  *pos++=(uint32_t)2; // protocol version number
710  *pos++=(uint32_t)runNumber;
711  *pos++=(uint32_t)evf::evtn::getlbn(raw->fedAddr(FEDNumbering::MINTriggerGTPFEDID)) + 1;
712  *pos++=(uint32_t)raw->evtNumber();
713  for (unsigned int i=0;i<1024;i++) *pos++ = (uint32_t)raw->fedSize(i);
714  memcpy(pos,raw->payloadAddr(),raw->eventSize());
715 
716  // DEBUG
717  /*
718  if (1) {
719  stringstream ss;
720  ss<<"/tmp/run"<<runNumber<<"_evt"<<raw->evtNumber()<<".err";
721  ofstream fout;
722  fout.open(ss.str().c_str(),ios::out|ios::binary);
723  if (!fout.write((char*)data,dataSize))
724  cout<<"Failed to write error event to "<<ss.str()<<endl;
725  fout.close();
726 
727  stringstream ss2;
728  ss2<<"/tmp/run"<<runNumber<<"_evt"<<raw->evtNumber()<<".info";
729  ofstream fout2;
730  fout2.open(ss2.str().c_str());
731  fout2<<"dataSize = "<<dataSize<<endl;
732  fout2<<"runNumber = "<<runNumber<<endl;
733  fout2<<"evtNumber = "<<raw->evtNumber()<<endl;
734  fout2<<"eventSize = "<<raw->eventSize()<<endl;
735  unsigned int totalSize(0);
736  for (unsigned int i=0;i<1024;i++) {
737  unsigned int fedSize = raw->fedSize(i);
738  totalSize += fedSize;
739  if (fedSize>0) fout2<<i<<": "<<fedSize<<endl;
740  }
741  fout2<<"totalSize = "<<totalSize<<endl;
742  fout2.close();
743  }
744  */// END DEBUG
745 
746  waitRecoWrite();
747  unsigned int iRecoCell=nextRecoWriteIndex();
748  FUShmRecoCell* reco =recoCell(iRecoCell);
749  setEvtState(iRawCell,evt::RECOWRITING);
750  setEvtDiscard(iRawCell,1);
751  reco->writeErrorEvent(iRawCell,runNumber,raw->evtNumber(),fuProcessId,
752  data,dataSize);
753  delete [] data;
754  setEvtState(iRawCell,evt::RECOWRITTEN);
755  postRecoIndexToRead(iRecoCell);
756  if (segmentationMode_) { shmdt(raw); shmdt(reco); }
757  postRecoRead();
758  return true;
759 }
int i
Definition: DBlmapReader.cc:9
void waitRecoWrite()
Definition: FUShmBuffer.h:254
unsigned int evtNumber() const
Definition: FUShmRawCell.h:25
unsigned int getlbn(const unsigned char *)
unsigned char * payloadAddr() const
FUShmRawCell * rawCell(unsigned int iCell)
bool setEvtState(unsigned int index, evt::State_t state)
FUShmRecoCell * recoCell(unsigned int iCell)
unsigned char * fedAddr(unsigned int i) const
Definition: FUShmRawCell.cc:94
void writeErrorEvent(unsigned int rawCellIndex, unsigned int runNumber, unsigned int evtNumber, unsigned int fuProcessId, unsigned char *data, unsigned int dataSize)
unsigned int nextRecoWriteIndex()
unsigned int eventSize() const
void postRecoIndexToRead(unsigned int index)
unsigned int fedSize(unsigned int i) const
Definition: FUShmRawCell.cc:82
bool setEvtDiscard(unsigned int index, unsigned int discard)
void FUShmBuffer::writeRawEmptyEvent ( )

Definition at line 538 of file FUShmBuffer.cc.

References evtState(), evf::FUShmRawCell::index(), postRawIndexToRead(), postRawRead(), rawCellToWrite(), evf::evt::RAWWRITING, segmentationMode_, setEvtState(), evf::utils::state, and evf::evt::STOP.

539 {
541  evt::State_t state=evtState(cell->index());
542  assert(state==evt::RAWWRITING);
543  setEvtState(cell->index(),evt::STOP);
544  postRawIndexToRead(cell->index());
545  if (segmentationMode_) shmdt(cell);
546  postRawRead();
547 }
void postRawIndexToRead(unsigned int index)
evt::State_t evtState(unsigned int index)
bool setEvtState(unsigned int index, evt::State_t state)
FUShmRawCell * rawCellToWrite()
Definition: FUShmBuffer.cc:290
char state
Definition: procUtils.cc:75
unsigned int index() const
Definition: FUShmRawCell.h:22
void FUShmBuffer::writeRawLumiSectionEvent ( unsigned int  ls)

Definition at line 550 of file FUShmBuffer.cc.

References evtState(), evf::FUShmRawCell::index(), evf::evt::LUMISECTION, postRawIndexToRead(), postRawRead(), rawCellToWrite(), evf::evt::RAWWRITING, segmentationMode_, setEvtState(), evf::FUShmRawCell::setLumiSection(), and evf::utils::state.

551 {
553  cell->setLumiSection(ls);
554  evt::State_t state=evtState(cell->index());
555  assert(state==evt::RAWWRITING);
557  postRawIndexToRead(cell->index());
558  if (segmentationMode_) shmdt(cell);
559  postRawRead();
560 }
void postRawIndexToRead(unsigned int index)
evt::State_t evtState(unsigned int index)
bool setEvtState(unsigned int index, evt::State_t state)
FUShmRawCell * rawCellToWrite()
Definition: FUShmBuffer.cc:290
char state
Definition: procUtils.cc:75
unsigned int index() const
Definition: FUShmRawCell.h:22
void setLumiSection(unsigned int)
void FUShmBuffer::writeRecoEmptyEvent ( )

Definition at line 564 of file FUShmBuffer.cc.

References evf::FUShmRecoCell::clear(), nextRecoWriteIndex(), postRecoIndexToRead(), postRecoRead(), recoCell(), segmentationMode_, and waitRecoWrite().

565 {
566  waitRecoWrite();
567  unsigned int iCell=nextRecoWriteIndex();
568  FUShmRecoCell* cell =recoCell(iCell);
569  cell->clear();
570  postRecoIndexToRead(iCell);
571  if (segmentationMode_) shmdt(cell);
572  postRecoRead();
573 }
void waitRecoWrite()
Definition: FUShmBuffer.h:254
FUShmRecoCell * recoCell(unsigned int iCell)
unsigned int nextRecoWriteIndex()
void postRecoIndexToRead(unsigned int index)
bool FUShmBuffer::writeRecoEventData ( unsigned int  runNumber,
unsigned int  evtNumber,
unsigned int  outModId,
unsigned int  fuProcessId,
unsigned int  fuGuid,
unsigned char *  data,
unsigned int  dataSize 
)

Definition at line 661 of file FUShmBuffer.cc.

References gather_cfg::cout, incEvtDiscard(), indexForEvtNumber(), nextRecoWriteIndex(), postRecoIndexToRead(), postRecoRead(), recoCell(), recoCellPayloadSize_, evf::evt::RECOWRITING, evf::evt::RECOWRITTEN, segmentationMode_, setEvtState(), waitRecoWrite(), and evf::FUShmRecoCell::writeEventData().

Referenced by edm::FUShmOutputModule::doOutputEvent().

668 {
669  if (dataSize>recoCellPayloadSize_) {
670  cout<<"FUShmBuffer::writeRecoEventData() ERROR: buffer overflow."<<endl;
671  return false;
672  }
673 
674  waitRecoWrite();
675  unsigned int iCell=nextRecoWriteIndex();
676  FUShmRecoCell* cell =recoCell(iCell);
677  unsigned int rawCellIndex=indexForEvtNumber(evtNumber);
678  //evt::State_t state=evtState(rawCellIndex);
679  //assert(state==evt::PROCESSING||state==evt::RECOWRITING||state==evt::SENT);
680  setEvtState(rawCellIndex,evt::RECOWRITING);
681  incEvtDiscard(rawCellIndex);
682  cell->writeEventData(rawCellIndex,runNumber,evtNumber,outModId,
683  fuProcessId,fuGuid,data,dataSize);
684  setEvtState(rawCellIndex,evt::RECOWRITTEN);
685  postRecoIndexToRead(iCell);
686  if (segmentationMode_) shmdt(cell);
687  postRecoRead();
688  return true;
689 }
int incEvtDiscard(unsigned int index)
void waitRecoWrite()
Definition: FUShmBuffer.h:254
unsigned int recoCellPayloadSize_
Definition: FUShmBuffer.h:313
unsigned int evtNumber(unsigned int index)
bool setEvtState(unsigned int index, evt::State_t state)
FUShmRecoCell * recoCell(unsigned int iCell)
unsigned int nextRecoWriteIndex()
void postRecoIndexToRead(unsigned int index)
unsigned int indexForEvtNumber(unsigned int evtNumber)
tuple cout
Definition: gather_cfg.py:41
void writeEventData(unsigned int rawCellIndex, unsigned int runNumber, unsigned int evtNumber, unsigned int outModId, unsigned int fuProcessId, unsigned int fuGuid, unsigned char *data, unsigned int dataSize)
bool FUShmBuffer::writeRecoInitMsg ( unsigned int  outModId,
unsigned int  fuProcessId,
unsigned int  fuGuid,
unsigned char *  data,
unsigned int  dataSize 
)

Definition at line 638 of file FUShmBuffer.cc.

References gather_cfg::cout, nextRecoWriteIndex(), postRecoIndexToRead(), postRecoRead(), recoCell(), recoCellPayloadSize_, segmentationMode_, waitRecoWrite(), and evf::FUShmRecoCell::writeInitMsg().

Referenced by edm::FUShmOutputModule::doOutputHeader().

643 {
644  if (dataSize>recoCellPayloadSize_) {
645  cout<<"FUShmBuffer::writeRecoInitMsg() ERROR: buffer overflow."<<endl;
646  return false;
647  }
648 
649  waitRecoWrite();
650  unsigned int iCell=nextRecoWriteIndex();
651  FUShmRecoCell* cell =recoCell(iCell);
652  cell->writeInitMsg(outModId,fuProcessId,fuGuid,data,dataSize);
653  postRecoIndexToRead(iCell);
654  if (segmentationMode_) shmdt(cell);
655  postRecoRead();
656  return true;
657 }
void waitRecoWrite()
Definition: FUShmBuffer.h:254
unsigned int recoCellPayloadSize_
Definition: FUShmBuffer.h:313
FUShmRecoCell * recoCell(unsigned int iCell)
unsigned int nextRecoWriteIndex()
void postRecoIndexToRead(unsigned int index)
void writeInitMsg(unsigned int outModId, unsigned int fuProcessId, unsigned int fuGuid, unsigned char *data, unsigned int dataSize)
tuple cout
Definition: gather_cfg.py:41

Member Data Documentation

unsigned int evf::FUShmBuffer::clientPrcIdOffset_
private

Definition at line 303 of file FUShmBuffer.h.

Referenced by clientPrcId(), FUShmBuffer(), removeClientPrcId(), and setClientPrcId().

unsigned int evf::FUShmBuffer::dqmCellOffset_
private

Definition at line 322 of file FUShmBuffer.h.

Referenced by dqmCell(), dqmCellShmKey(), FUShmBuffer(), and initialize().

unsigned int evf::FUShmBuffer::dqmCellPayloadSize_
private

Definition at line 320 of file FUShmBuffer.h.

Referenced by dqmCell(), FUShmBuffer(), initialize(), and writeDqmEventData().

unsigned int evf::FUShmBuffer::dqmCellTotalSize_
private

Definition at line 321 of file FUShmBuffer.h.

Referenced by dqmCell(), FUShmBuffer(), and initialize().

unsigned int evf::FUShmBuffer::dqmReadIndex_
private

Definition at line 318 of file FUShmBuffer.h.

unsigned int evf::FUShmBuffer::dqmReadLast_
private

Definition at line 291 of file FUShmBuffer.h.

Referenced by postDqmIndexToRead(), and reset().

unsigned int evf::FUShmBuffer::dqmReadNext_
private

Definition at line 290 of file FUShmBuffer.h.

Referenced by nextDqmReadIndex(), and reset().

unsigned int evf::FUShmBuffer::dqmReadOffset_
private

Definition at line 292 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), nextDqmReadIndex(), postDqmIndexToRead(), and reset().

unsigned int evf::FUShmBuffer::dqmStateOffset_
private

Definition at line 299 of file FUShmBuffer.h.

Referenced by dqmState(), FUShmBuffer(), and setDqmState().

unsigned int evf::FUShmBuffer::dqmWriteIndex_
private

Definition at line 317 of file FUShmBuffer.h.

unsigned int evf::FUShmBuffer::dqmWriteLast_
private

Definition at line 288 of file FUShmBuffer.h.

Referenced by postDqmIndexToWrite(), and reset().

unsigned int evf::FUShmBuffer::dqmWriteNext_
private

Definition at line 287 of file FUShmBuffer.h.

Referenced by nextDqmWriteIndex(), and reset().

unsigned int evf::FUShmBuffer::dqmWriteOffset_
private

Definition at line 289 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), nextDqmWriteIndex(), postDqmIndexToWrite(), and reset().

unsigned int evf::FUShmBuffer::evtDiscardOffset_
private

Definition at line 295 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), incEvtDiscard(), rawCellReadyForDiscard(), and setEvtDiscard().

unsigned int evf::FUShmBuffer::evtNumberOffset_
private

Definition at line 296 of file FUShmBuffer.h.

Referenced by evtNumber(), FUShmBuffer(), indexForEvtNumber(), and setEvtNumber().

unsigned int evf::FUShmBuffer::evtPrcIdOffset_
private

Definition at line 297 of file FUShmBuffer.h.

Referenced by evtPrcId(), FUShmBuffer(), and setEvtPrcId().

unsigned int evf::FUShmBuffer::evtStateOffset_
private

Definition at line 294 of file FUShmBuffer.h.

Referenced by evtState(), FUShmBuffer(), and setEvtState().

unsigned int evf::FUShmBuffer::evtTimeStampOffset_
private

Definition at line 298 of file FUShmBuffer.h.

Referenced by evtTimeStamp(), FUShmBuffer(), and setEvtTimeStamp().

unsigned int evf::FUShmBuffer::nClients_
private

Definition at line 301 of file FUShmBuffer.h.

Referenced by nClients(), removeClientPrcId(), reset(), and setClientPrcId().

unsigned int evf::FUShmBuffer::nClientsMax_
private

Definition at line 302 of file FUShmBuffer.h.

Referenced by clientPrcId(), FUShmBuffer(), and setClientPrcId().

unsigned int evf::FUShmBuffer::nDqmCells_
private
unsigned int evf::FUShmBuffer::nRawCells_
private
unsigned int evf::FUShmBuffer::nRecoCells_
private
unsigned int evf::FUShmBuffer::rawCellOffset_
private

Definition at line 308 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), initialize(), rawCell(), and rawCellShmKey().

unsigned int evf::FUShmBuffer::rawCellPayloadSize_
private

Definition at line 306 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), initialize(), and rawCell().

unsigned int evf::FUShmBuffer::rawCellTotalSize_
private

Definition at line 307 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), initialize(), and rawCell().

unsigned int evf::FUShmBuffer::rawDiscardIndex_
private
unsigned int evf::FUShmBuffer::rawReadLast_
private

Definition at line 276 of file FUShmBuffer.h.

Referenced by postRawIndexToRead(), and reset().

unsigned int evf::FUShmBuffer::rawReadNext_
private

Definition at line 275 of file FUShmBuffer.h.

Referenced by nextRawReadIndex(), and reset().

unsigned int evf::FUShmBuffer::rawReadOffset_
private

Definition at line 277 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), nextRawReadIndex(), postRawIndexToRead(), and reset().

unsigned int evf::FUShmBuffer::rawWriteLast_
private

Definition at line 273 of file FUShmBuffer.h.

Referenced by postRawIndexToWrite(), and reset().

unsigned int evf::FUShmBuffer::rawWriteNext_
private

Definition at line 272 of file FUShmBuffer.h.

Referenced by nextRawWriteIndex(), and reset().

unsigned int evf::FUShmBuffer::rawWriteOffset_
private

Definition at line 274 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), nextRawWriteIndex(), postRawIndexToWrite(), and reset().

unsigned int evf::FUShmBuffer::recoCellOffset_
private

Definition at line 315 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), initialize(), recoCell(), and recoCellShmKey().

unsigned int evf::FUShmBuffer::recoCellPayloadSize_
private
unsigned int evf::FUShmBuffer::recoCellTotalSize_
private

Definition at line 314 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), initialize(), and recoCell().

unsigned int evf::FUShmBuffer::recoReadIndex_
private

Definition at line 311 of file FUShmBuffer.h.

unsigned int evf::FUShmBuffer::recoReadLast_
private

Definition at line 284 of file FUShmBuffer.h.

Referenced by postRecoIndexToRead(), and reset().

unsigned int evf::FUShmBuffer::recoReadNext_
private

Definition at line 283 of file FUShmBuffer.h.

Referenced by nextRecoReadIndex(), and reset().

unsigned int evf::FUShmBuffer::recoReadOffset_
private

Definition at line 285 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), nextRecoReadIndex(), postRecoIndexToRead(), and reset().

unsigned int evf::FUShmBuffer::recoWriteIndex_
private

Definition at line 310 of file FUShmBuffer.h.

unsigned int evf::FUShmBuffer::recoWriteLast_
private

Definition at line 281 of file FUShmBuffer.h.

Referenced by postRecoIndexToWrite(), and reset().

unsigned int evf::FUShmBuffer::recoWriteNext_
private

Definition at line 280 of file FUShmBuffer.h.

Referenced by nextRecoWriteIndex(), and reset().

unsigned int evf::FUShmBuffer::recoWriteOffset_
private

Definition at line 282 of file FUShmBuffer.h.

Referenced by FUShmBuffer(), nextRecoWriteIndex(), postRecoIndexToWrite(), and reset().

bool evf::FUShmBuffer::segmentationMode_
private
int evf::FUShmBuffer::semid_
private

Definition at line 270 of file FUShmBuffer.h.

Referenced by initialize(), and semid().

const char * FUShmBuffer::semKeyPath_
staticprivate
Initial value:
=
(getenv("FUSEM_KEYFILE") == NULL ? "/dev/null" : getenv("FUSEM_KEYFILE"))

Definition at line 325 of file FUShmBuffer.h.

Referenced by getSemKey().

int evf::FUShmBuffer::shmid_
private

Definition at line 269 of file FUShmBuffer.h.

Referenced by initialize(), and shmid().

const char * FUShmBuffer::shmKeyPath_
staticprivate
Initial value:
=
(getenv("FUSHM_KEYFILE") == NULL ? "/dev/null" : getenv("FUSHM_KEYFILE"))

Definition at line 324 of file FUShmBuffer.h.

Referenced by getShmDescriptorKey(), getShmKey(), and initialize().