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 40 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::FUShmRecoCell::size(), and evf::FUShmRawCell::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:304
int i
Definition: DBlmapReader.cc:9
unsigned int nRecoCells() const
Definition: FUShmBuffer.h:65
unsigned int rawReadOffset_
Definition: FUShmBuffer.h:278
static unsigned int size(unsigned int payloadSize)
unsigned int recoCellPayloadSize_
Definition: FUShmBuffer.h:314
unsigned int dqmReadOffset_
Definition: FUShmBuffer.h:293
unsigned int evtDiscardOffset_
Definition: FUShmBuffer.h:296
unsigned int nRecoCells_
Definition: FUShmBuffer.h:313
unsigned int dqmStateOffset_
Definition: FUShmBuffer.h:300
unsigned int dqmWriteOffset_
Definition: FUShmBuffer.h:290
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int evtNumberOffset_
Definition: FUShmBuffer.h:297
unsigned int dqmCellOffset_
Definition: FUShmBuffer.h:323
unsigned int evtStateOffset_
Definition: FUShmBuffer.h:295
static unsigned int size(unsigned int payloadSize)
unsigned int recoReadOffset_
Definition: FUShmBuffer.h:286
unsigned int nDqmCells_
Definition: FUShmBuffer.h:320
unsigned int nRawCells() const
Definition: FUShmBuffer.h:64
unsigned int dqmCellPayloadSize_
Definition: FUShmBuffer.h:321
unsigned int rawCellPayloadSize_
Definition: FUShmBuffer.h:307
unsigned int rawWriteOffset_
Definition: FUShmBuffer.h:275
unsigned int dqmCellTotalSize_
Definition: FUShmBuffer.h:322
unsigned int recoCellTotalSize_
Definition: FUShmBuffer.h:315
unsigned int nClientsMax_
Definition: FUShmBuffer.h:303
unsigned int rawCellTotalSize_
Definition: FUShmBuffer.h:308
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:66
unsigned int evtPrcIdOffset_
Definition: FUShmBuffer.h:298
unsigned int recoWriteOffset_
Definition: FUShmBuffer.h:283
static unsigned int size(unsigned int payloadSize)
Definition: FUShmDqmCell.cc:97
unsigned int rawCellOffset_
Definition: FUShmBuffer.h:309
unsigned int recoCellOffset_
Definition: FUShmBuffer.h:316
unsigned int evtTimeStampOffset_
Definition: FUShmBuffer.h:299
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 1389 of file FUShmBuffer.cc.

References clientPrcIdOffset_, getHLTprescales::index, and nClientsMax_.

1390 {
1391  assert(index<nClientsMax_);
1392  pid_t *prcid=(pid_t*)((unsigned long)this+clientPrcIdOffset_);
1393  prcid+=index;
1394  return *prcid;
1395 }
unsigned int clientPrcIdOffset_
Definition: FUShmBuffer.h:304
unsigned int nClientsMax_
Definition: FUShmBuffer.h:303
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 853 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().

860 {
861  // if necessary, release shared memory first!
863  cout<<"FUShmBuffer::createShmBuffer: "
864  <<"REMOVAL OF OLD SHARED MEM SEGMENTS SUCCESSFULL."
865  <<endl;
866 
867  // create bookkeeping shared memory segment
868  int size =sizeof(unsigned int)*7;
869  int shmid=shm_create(FUShmBuffer::getShmDescriptorKey(),size);if(shmid<0)return 0;
870  void*shmAddr=shm_attach(shmid); if(0==shmAddr)return 0;
871 
872  if(1!=shm_nattch(shmid)) {
873  cout<<"FUShmBuffer::createShmBuffer() FAILED: nattch="<<shm_nattch(shmid)<<endl;
874  shmdt(shmAddr);
875  return 0;
876  }
877 
878  unsigned int* p=(unsigned int*)shmAddr;
879  *p++=segmentationMode;
880  *p++=nRawCells;
881  *p++=nRecoCells;
882  *p++=nDqmCells;
883  *p++=rawCellSize;
884  *p++=recoCellSize;
885  *p++=dqmCellSize;
886  shmdt(shmAddr);
887 
888  // create the 'real' shared memory buffer
889  size =FUShmBuffer::size(segmentationMode,
891  rawCellSize,recoCellSize,dqmCellSize);
892  shmid =shm_create(FUShmBuffer::getShmKey(),size); if (shmid<0) return 0;
893  int semid=sem_create(FUShmBuffer::getSemKey(),9); if (semid<0) return 0;
894  shmAddr =shm_attach(shmid); if (0==shmAddr) return 0;
895 
896  if (1!=shm_nattch(shmid)) {
897  cout<<"FUShmBuffer::createShmBuffer FAILED: nattch="<<shm_nattch(shmid)<<endl;
898  shmdt(shmAddr);
899  return 0;
900  }
901  FUShmBuffer* buffer=new(shmAddr) FUShmBuffer(segmentationMode,
903  rawCellSize,recoCellSize,dqmCellSize);
904 
905  cout<<"FUShmBuffer::createShmBuffer(): CREATED shared memory buffer."<<endl;
906  cout<<" segmentationMode="<<segmentationMode<<endl;
907 
908  buffer->initialize(shmid,semid);
909 
910  return buffer;
911 }
unsigned int nRecoCells() const
Definition: FUShmBuffer.h:65
static int shm_nattch(int shmid)
static void * shm_attach(int shmid)
int shmid() const
Definition: FUShmBuffer.h:68
static key_t getShmDescriptorKey()
static bool releaseSharedMemory()
Definition: FUShmBuffer.cc:969
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:64
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:66
int semid() const
Definition: FUShmBuffer.h:69
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:256
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:252
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:306
unsigned int rawCellIndex() const
Definition: FUShmRecoCell.h:23
FUShmRecoCell * recoCell(unsigned int iCell)
void postRecoWrite()
Definition: FUShmBuffer.h:256
void postRecoIndexToWrite(unsigned int index)
void scheduleRawCellForDiscard(unsigned int iCell)
Definition: FUShmBuffer.cc:420
FUShmDqmCell * FUShmBuffer::dqmCell ( unsigned int  iCell)

Definition at line 1577 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().

1578 {
1579  FUShmDqmCell* result(0);
1580 
1581  if (iCell>=nDqmCells_) {
1582  cout<<"FUShmBuffer::dqmCell("<<iCell<<") ERROR: "
1583  <<"iCell="<<iCell<<" >= nDqmCells="<<nDqmCells_<<endl;
1584  return result;
1585  }
1586 
1587  if (segmentationMode_) {
1588  key_t shmkey =dqmCellShmKey(iCell);
1589  int shmid =shm_get(shmkey,dqmCellTotalSize_);
1590  void* cellAddr=shm_attach(shmid);
1591  result=new (cellAddr) FUShmDqmCell(dqmCellPayloadSize_);
1592  }
1593  else {
1594  result=
1595  (FUShmDqmCell*)((unsigned long)this+dqmCellOffset_+iCell*dqmCellTotalSize_);
1596  }
1597 
1598  return result;
1599 }
static void * shm_attach(int shmid)
int shmid() const
Definition: FUShmBuffer.h:68
static int shm_get(key_t key, int size)
unsigned int dqmCellOffset_
Definition: FUShmBuffer.h:323
unsigned int nDqmCells_
Definition: FUShmBuffer.h:320
tuple result
Definition: query.py:137
unsigned int dqmCellPayloadSize_
Definition: FUShmBuffer.h:321
key_t dqmCellShmKey(unsigned int iCell)
unsigned int dqmCellTotalSize_
Definition: FUShmBuffer.h:322
tuple cout
Definition: gather_cfg.py:41
key_t FUShmBuffer::dqmCellShmKey ( unsigned int  iCell)
private

Definition at line 1655 of file FUShmBuffer.cc.

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

Referenced by dqmCell(), and releaseSharedMemory().

1656 {
1657  if (iCell>=nDqmCells_) {
1658  cout<<"FUShmBuffer::dqmCellShmKey() ERROR: "
1659  <<"iCell>=nDqmCells: "<<iCell<<">="<<nDqmCells_<<endl;
1660  return -1;
1661  }
1662  return shmKey(iCell,dqmCellOffset_);
1663 }
unsigned int dqmCellOffset_
Definition: FUShmBuffer.h:323
unsigned int nDqmCells_
Definition: FUShmBuffer.h:320
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 1349 of file FUShmBuffer.cc.

References dqmStateOffset_, getHLTprescales::index, and nDqmCells_.

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

1350 {
1351  assert(index<nDqmCells_);
1352  dqm::State_t *pstate=(dqm::State_t*)((unsigned long)this+dqmStateOffset_);
1353  pstate+=index;
1354  return *pstate;
1355 }
unsigned int dqmStateOffset_
Definition: FUShmBuffer.h:300
unsigned int nDqmCells_
Definition: FUShmBuffer.h:320
unsigned int FUShmBuffer::evtNumber ( unsigned int  index)

Definition at line 1359 of file FUShmBuffer.cc.

References evtNumberOffset_, getHLTprescales::index, and nRawCells_.

Referenced by indexForEvtNumber(), and setEvtNumber().

1360 {
1361  assert(index<nRawCells_);
1362  unsigned int *pevt=(unsigned int*)((unsigned long)this+evtNumberOffset_);
1363  pevt+=index;
1364  return *pevt;
1365 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int evtNumberOffset_
Definition: FUShmBuffer.h:297
pid_t FUShmBuffer::evtPrcId ( unsigned int  index)

Definition at line 1369 of file FUShmBuffer.cc.

References evtPrcIdOffset_, getHLTprescales::index, and nRawCells_.

1370 {
1371  assert(index<nRawCells_);
1372  pid_t *prcid=(pid_t*)((unsigned long)this+evtPrcIdOffset_);
1373  prcid+=index;
1374  return *prcid;
1375 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int evtPrcIdOffset_
Definition: FUShmBuffer.h:298
evt::State_t FUShmBuffer::evtState ( unsigned int  index)
time_t FUShmBuffer::evtTimeStamp ( unsigned int  index)

Definition at line 1379 of file FUShmBuffer.cc.

References evtTimeStampOffset_, getHLTprescales::index, and nRawCells_.

1380 {
1381  assert(index<nRawCells_);
1382  time_t *ptstmp=(time_t*)((unsigned long)this+evtTimeStampOffset_);
1383  ptstmp+=index;
1384  return *ptstmp;
1385 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int evtTimeStampOffset_
Definition: FUShmBuffer.h:299
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:25
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:306
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:28
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:25
key_t FUShmBuffer::getSemKey ( )
static

Definition at line 1093 of file FUShmBuffer.cc.

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

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

1094 {
1095  key_t result=getuid()*1000+SEM_KEYID;
1096  if (result==(key_t)-1) cout<<"FUShmBuffer::getSemKey: ftok() failed "
1097  <<"for file "<<semKeyPath_<<"!"<<endl;
1098  return result;
1099 }
static const char * semKeyPath_
Definition: FUShmBuffer.h:326
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 915 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().

916 {
917  // get bookkeeping shared memory segment
918  int size =sizeof(unsigned int)*7;
919  int shmid =shm_get(FUShmBuffer::getShmDescriptorKey(),size);if(shmid<0)return 0;
920  void* shmAddr=shm_attach(shmid); if (0==shmAddr) return 0;
921 
922  unsigned int *p=(unsigned int*)shmAddr;
923  bool segmentationMode=*p++;
924  unsigned int nRawCells =*p++;
925  unsigned int nRecoCells =*p++;
926  unsigned int nDqmCells =*p++;
927  unsigned int rawCellSize =*p++;
928  unsigned int recoCellSize =*p++;
929  unsigned int dqmCellSize =*p++;
930  shmdt(shmAddr);
931 
932  cout<<"FUShmBuffer::getShmBuffer():"
933  <<" segmentationMode="<<segmentationMode
934  <<" nRawCells="<<nRawCells
935  <<" nRecoCells="<<nRecoCells
936  <<" nDqmCells="<<nDqmCells
937  <<" rawCellSize="<<rawCellSize
938  <<" recoCellSize="<<recoCellSize
939  <<" dqmCellSize="<<dqmCellSize
940  <<endl;
941 
942  // get the 'real' shared memory buffer
943  size =FUShmBuffer::size(segmentationMode,
944  nRawCells,nRecoCells,nDqmCells,
945  rawCellSize,recoCellSize,dqmCellSize);
946  shmid =shm_get(FUShmBuffer::getShmKey(),size); if (shmid<0) return 0;
947  int semid=sem_get(FUShmBuffer::getSemKey(),9); if (semid<0) return 0;
948  shmAddr =shm_attach(shmid); if (0==shmAddr) return 0;
949 
950  if (0==shm_nattch(shmid)) {
951  cout<<"FUShmBuffer::getShmBuffer() FAILED: nattch="<<shm_nattch(shmid)<<endl;
952  return 0;
953  }
954 
955  FUShmBuffer* buffer=new(shmAddr) FUShmBuffer(segmentationMode,
956  nRawCells,nRecoCells,nDqmCells,
957  rawCellSize,recoCellSize,dqmCellSize);
958 
959  cout<<"FUShmBuffer::getShmBuffer(): shared memory buffer RETRIEVED."<<endl;
960  cout<<" segmentationMode="<<segmentationMode<<endl;
961 
962  buffer->setClientPrcId(getpid());
963 
964  return buffer;
965 }
unsigned int nRecoCells() const
Definition: FUShmBuffer.h:65
static int shm_nattch(int shmid)
static void * shm_attach(int shmid)
int shmid() const
Definition: FUShmBuffer.h:68
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:64
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:66
int semid() const
Definition: FUShmBuffer.h:69
key_t FUShmBuffer::getShmDescriptorKey ( )
static

Definition at line 1073 of file FUShmBuffer.cc.

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

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

1074 {
1075  key_t result=getuid()*1000+SHM_DESCRIPTOR_KEYID;
1076  if (result==(key_t)-1) cout<<"FUShmBuffer::getShmDescriptorKey: failed "
1077  <<"for file "<<shmKeyPath_<<"!"<<endl;
1078  return result;
1079 }
static const char * shmKeyPath_
Definition: FUShmBuffer.h:325
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 1083 of file FUShmBuffer.cc.

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

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

1084 {
1085  key_t result=getuid()*1000+SHM_KEYID;
1086  if (result==(key_t)-1) cout<<"FUShmBuffer::getShmKey: ftok() failed "
1087  <<"for file "<<shmKeyPath_<<"!"<<endl;
1088  return result;
1089 }
#define SHM_KEYID
Definition: FUShmBuffer.cc:31
static const char * shmKeyPath_
Definition: FUShmBuffer.h:325
tuple result
Definition: query.py:137
tuple cout
Definition: gather_cfg.py:41
int FUShmBuffer::incEvtDiscard ( unsigned int  index)
private

Definition at line 1438 of file FUShmBuffer.cc.

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

Referenced by writeRecoEventData().

1439 {
1440  int result = 0;
1441  assert(index<nRawCells_);
1442  unsigned int *pcount=(unsigned int*)((unsigned long)this+evtDiscardOffset_);
1443  pcount+=index;
1444  lock();
1445  (*pcount)++;
1446  result = *pcount;
1447  unlock();
1448  return result;
1449 }
unsigned int evtDiscardOffset_
Definition: FUShmBuffer.h:296
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
tuple result
Definition: query.py:137
unsigned int FUShmBuffer::indexForEvtNumber ( unsigned int  evtNumber)
private

Definition at line 1327 of file FUShmBuffer.cc.

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

Referenced by writeRecoEventData().

1328 {
1329  unsigned int *pevt=(unsigned int*)((unsigned long)this+evtNumberOffset_);
1330  for (unsigned int i=0;i<nRawCells_;i++) {
1331  if ((*pevt++)==evtNumber) return i;
1332  }
1333  assert(false);
1334  return 0xffffffff;
1335 }
int i
Definition: DBlmapReader.cc:9
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int evtNumberOffset_
Definition: FUShmBuffer.h:297
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::FUShmRecoCell::initialize(), evf::FUShmDqmCell::initialize(), evf::FUShmRawCell::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:314
int shmid() const
Definition: FUShmBuffer.h:68
unsigned int nRecoCells_
Definition: FUShmBuffer.h:313
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int dqmCellOffset_
Definition: FUShmBuffer.h:323
void initialize(unsigned int index)
Definition: FUShmRawCell.cc:75
FUShmRawCell * rawCell(unsigned int iCell)
unsigned int nDqmCells_
Definition: FUShmBuffer.h:320
static const char * shmKeyPath_
Definition: FUShmBuffer.h:325
FUShmRecoCell * recoCell(unsigned int iCell)
unsigned int dqmCellPayloadSize_
Definition: FUShmBuffer.h:321
unsigned int rawCellPayloadSize_
Definition: FUShmBuffer.h:307
unsigned int dqmCellTotalSize_
Definition: FUShmBuffer.h:322
unsigned int recoCellTotalSize_
Definition: FUShmBuffer.h:315
unsigned int rawCellTotalSize_
Definition: FUShmBuffer.h:308
static int shm_create(key_t key, int size)
unsigned int rawCellOffset_
Definition: FUShmBuffer.h:309
unsigned int recoCellOffset_
Definition: FUShmBuffer.h:316
FUShmDqmCell * dqmCell(unsigned int iCell)
int semid() const
Definition: FUShmBuffer.h:69
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:69
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:69
unsigned int evf::FUShmBuffer::nClients ( ) const
inline

Definition at line 70 of file FUShmBuffer.h.

References nClients_.

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

Definition at line 66 of file FUShmBuffer.h.

References nDqmCells_.

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

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

Definition at line 1306 of file FUShmBuffer.cc.

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

Referenced by dqmCellToRead().

1307 {
1309 }
unsigned int dqmReadOffset_
Definition: FUShmBuffer.h:293
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int nDqmCells_
Definition: FUShmBuffer.h:320
unsigned int dqmReadNext_
Definition: FUShmBuffer.h:291
unsigned int FUShmBuffer::nextDqmWriteIndex ( )
private

Definition at line 1299 of file FUShmBuffer.cc.

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

Referenced by writeDqmEmptyEvent(), and writeDqmEventData().

1300 {
1302 }
unsigned int dqmWriteNext_
Definition: FUShmBuffer.h:288
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int dqmWriteOffset_
Definition: FUShmBuffer.h:290
unsigned int nDqmCells_
Definition: FUShmBuffer.h:320
unsigned int FUShmBuffer::nextIndex ( unsigned int  offset,
unsigned int  nCells,
unsigned int &  iNext 
)
private

Definition at line 1213 of file FUShmBuffer.cc.

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

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

1216 {
1217  lock();
1218  unsigned int* pindex=(unsigned int*)((unsigned long)this+offset);
1219  pindex+=iNext;
1220  iNext=(iNext+1)%nCells;
1221  unsigned int result=*pindex;
1222  unlock();
1223  return result;
1224 }
tuple result
Definition: query.py:137
unsigned int offset(bool)
unsigned int FUShmBuffer::nextRawReadIndex ( )
private

Definition at line 1250 of file FUShmBuffer.cc.

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

Referenced by rawCellToRead().

1251 {
1253 }
unsigned int rawReadOffset_
Definition: FUShmBuffer.h:278
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int rawReadNext_
Definition: FUShmBuffer.h:276
unsigned int FUShmBuffer::nextRawWriteIndex ( )
private

Definition at line 1243 of file FUShmBuffer.cc.

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

Referenced by rawCellToWrite().

1244 {
1246 }
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int rawWriteNext_
Definition: FUShmBuffer.h:273
unsigned int rawWriteOffset_
Definition: FUShmBuffer.h:275
unsigned int FUShmBuffer::nextRecoReadIndex ( )
private

Definition at line 1278 of file FUShmBuffer.cc.

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

Referenced by recoCellToRead().

1279 {
1281 }
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int nRecoCells_
Definition: FUShmBuffer.h:313
unsigned int recoReadOffset_
Definition: FUShmBuffer.h:286
unsigned int recoReadNext_
Definition: FUShmBuffer.h:284
unsigned int FUShmBuffer::nextRecoWriteIndex ( )
private

Definition at line 1271 of file FUShmBuffer.cc.

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

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

1272 {
1274 }
unsigned int nextIndex(unsigned int offset, unsigned int nCells, unsigned int &iNext)
unsigned int nRecoCells_
Definition: FUShmBuffer.h:313
unsigned int recoWriteNext_
Definition: FUShmBuffer.h:281
unsigned int recoWriteOffset_
Definition: FUShmBuffer.h:283
unsigned int evf::FUShmBuffer::nRawCells ( ) const
inline

Definition at line 64 of file FUShmBuffer.h.

References nRawCells_.

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

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

Definition at line 65 of file FUShmBuffer.h.

References nRecoCells_.

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

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

Definition at line 1320 of file FUShmBuffer.cc.

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

Referenced by writeDqmEmptyEvent(), and writeDqmEventData().

1321 {
1323 }
unsigned int dqmReadLast_
Definition: FUShmBuffer.h:292
unsigned int dqmReadOffset_
Definition: FUShmBuffer.h:293
unsigned int nDqmCells_
Definition: FUShmBuffer.h:320
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void FUShmBuffer::postDqmIndexToWrite ( unsigned int  index)
private

Definition at line 1313 of file FUShmBuffer.cc.

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

Referenced by discardDqmCell().

1314 {
1316 }
unsigned int dqmWriteLast_
Definition: FUShmBuffer.h:289
unsigned int dqmWriteOffset_
Definition: FUShmBuffer.h:290
unsigned int nDqmCells_
Definition: FUShmBuffer.h:320
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void evf::FUShmBuffer::postDqmRead ( )
inlineprivate

Definition at line 262 of file FUShmBuffer.h.

References sem_post().

Referenced by writeDqmEmptyEvent(), and writeDqmEventData().

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

Definition at line 260 of file FUShmBuffer.h.

References sem_post().

Referenced by discardDqmCell().

260 { 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 1228 of file FUShmBuffer.cc.

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

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

1232 {
1233  lock();
1234  unsigned int* pindex=(unsigned int*)((unsigned long)this+offset);
1235  pindex+=iLast;
1236  *pindex=index;
1237  iLast=(iLast+1)%nCells;
1238  unlock();
1239 }
unsigned int offset(bool)
void evf::FUShmBuffer::postRawDiscard ( )
inlineprivate
void evf::FUShmBuffer::postRawDiscarded ( )
inlineprivate
void FUShmBuffer::postRawIndexToRead ( unsigned int  index)
private

Definition at line 1264 of file FUShmBuffer.cc.

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

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

1265 {
1267 }
unsigned int rawReadOffset_
Definition: FUShmBuffer.h:278
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int rawReadLast_
Definition: FUShmBuffer.h:277
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void FUShmBuffer::postRawIndexToWrite ( unsigned int  index)
private

Definition at line 1257 of file FUShmBuffer.cc.

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

Referenced by releaseRawCell().

1258 {
1260 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int rawWriteOffset_
Definition: FUShmBuffer.h:275
unsigned int rawWriteLast_
Definition: FUShmBuffer.h:274
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void evf::FUShmBuffer::postRawRead ( )
inlineprivate

Definition at line 250 of file FUShmBuffer.h.

References sem_post().

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

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

Definition at line 248 of file FUShmBuffer.h.

References sem_post().

Referenced by releaseRawCell().

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

Definition at line 1292 of file FUShmBuffer.cc.

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

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

1293 {
1295 }
unsigned int nRecoCells_
Definition: FUShmBuffer.h:313
unsigned int recoReadOffset_
Definition: FUShmBuffer.h:286
unsigned int recoReadLast_
Definition: FUShmBuffer.h:285
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void FUShmBuffer::postRecoIndexToWrite ( unsigned int  index)
private

Definition at line 1285 of file FUShmBuffer.cc.

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

Referenced by discardOrphanedRecoCell(), and discardRecoCell().

1286 {
1288 }
unsigned int nRecoCells_
Definition: FUShmBuffer.h:313
unsigned int recoWriteLast_
Definition: FUShmBuffer.h:282
unsigned int recoWriteOffset_
Definition: FUShmBuffer.h:283
void postIndex(unsigned int index, unsigned int offset, unsigned int nCells, unsigned int &iLast)
void evf::FUShmBuffer::postRecoRead ( )
inlineprivate

Definition at line 258 of file FUShmBuffer.h.

References sem_post().

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

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

Definition at line 256 of file FUShmBuffer.h.

References sem_post().

Referenced by discardOrphanedRecoCell(), and discardRecoCell().

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

Definition at line 845 of file FUShmBuffer.cc.

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

846 {
848  cout<<"dqm evt "<<index<<" in state '"<<state<<"'."<<endl;
849 }
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 823 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().

824 {
826  std::string stateName;
827  if (state==evt::EMPTY) stateName="EMPTY";
828  else if (state==evt::STOP) stateName="STOP";
829  else if (state==evt::RAWWRITING) stateName="RAWWRITING";
830  else if (state==evt::RAWWRITTEN) stateName="RAWRITTEN";
831  else if (state==evt::RAWREADING) stateName="RAWREADING";
832  else if (state==evt::RAWREAD) stateName="RAWREAD";
833  else if (state==evt::PROCESSING) stateName="PROCESSING";
834  else if (state==evt::PROCESSED) stateName="PROCESSED";
835  else if (state==evt::RECOWRITING)stateName="RECOWRITING";
836  else if (state==evt::RECOWRITTEN)stateName="RECOWRITTEN";
837  else if (state==evt::SENDING) stateName="SENDING";
838  else if (state==evt::SENT) stateName="SENT";
839  else if (state==evt::DISCARDING) stateName="DISCARDING";
840  cout<<"evt "<<index<<" in state '"<<stateName<<"'."<<endl;
841 }
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 1525 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().

1526 {
1527  FUShmRawCell* result(0);
1528 
1529  if (iCell>=nRawCells_) {
1530  cout<<"FUShmBuffer::rawCell("<<iCell<<") ERROR: "
1531  <<"iCell="<<iCell<<" >= nRawCells()="<<nRawCells_<<endl;
1532  return result;
1533  }
1534 
1535  if (segmentationMode_) {
1536  key_t shmkey =rawCellShmKey(iCell);
1537  int shmid =shm_get(shmkey,rawCellTotalSize_);
1538  void* cellAddr=shm_attach(shmid);
1539  result=new (cellAddr) FUShmRawCell(rawCellPayloadSize_);
1540  }
1541  else {
1542  result=
1543  (FUShmRawCell*)((unsigned long)this+rawCellOffset_+iCell*rawCellTotalSize_);
1544  }
1545 
1546  return result;
1547 }
static void * shm_attach(int shmid)
int shmid() const
Definition: FUShmBuffer.h:68
static int shm_get(key_t key, int size)
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
tuple result
Definition: query.py:137
key_t rawCellShmKey(unsigned int iCell)
unsigned int rawCellPayloadSize_
Definition: FUShmBuffer.h:307
unsigned int rawCellTotalSize_
Definition: FUShmBuffer.h:308
tuple cout
Definition: gather_cfg.py:41
unsigned int rawCellOffset_
Definition: FUShmBuffer.h:309
bool FUShmBuffer::rawCellReadyForDiscard ( unsigned int  index)
private

Definition at line 1603 of file FUShmBuffer.cc.

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

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

1604 {
1605  assert(index<nRawCells_);
1606  unsigned int *pcount=(unsigned int*)((unsigned long)this+evtDiscardOffset_);
1607  pcount+=index;
1608  lock();
1609  assert(*pcount>0);
1610  --(*pcount);
1611  bool result=(*pcount==0);
1612  unlock();
1613  return result;
1614 }
unsigned int evtDiscardOffset_
Definition: FUShmBuffer.h:296
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
tuple result
Definition: query.py:137
key_t FUShmBuffer::rawCellShmKey ( unsigned int  iCell)
private

Definition at line 1631 of file FUShmBuffer.cc.

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

Referenced by rawCell(), and releaseSharedMemory().

1632 {
1633  if (iCell>=nRawCells_) {
1634  cout<<"FUShmBuffer::rawCellShmKey() ERROR: "
1635  <<"iCell>=nRawCells: "<<iCell<<">="<<nRawCells_<<endl;
1636  return -1;
1637  }
1638  return shmKey(iCell,rawCellOffset_);
1639 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
tuple cout
Definition: gather_cfg.py:41
unsigned int rawCellOffset_
Definition: FUShmBuffer.h:309
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::PROCESSED, rawCell(), rawDiscardIndex_, evf::evt::SENT, setEvtState(), evf::utils::state, evf::evt::STOP, evf::evt::USEDLS, 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::USEDLS);
362  if (state!=evt::EMPTY
363  && state!=evt::USEDLS
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:279
void waitRawDiscarded()
Definition: FUShmBuffer.h:253
char state
Definition: procUtils.cc:75
unsigned int index() const
Definition: FUShmRawCell.h:25
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 1551 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().

1552 {
1553  FUShmRecoCell* result(0);
1554 
1555  if (iCell>=nRecoCells_) {
1556  cout<<"FUShmBuffer::recoCell("<<iCell<<") ERROR: "
1557  <<"iCell="<<iCell<<" >= nRecoCells="<<nRecoCells_<<endl;
1558  return result;
1559  }
1560 
1561  if (segmentationMode_) {
1562  key_t shmkey =recoCellShmKey(iCell);
1563  int shmid =shm_get(shmkey,recoCellTotalSize_);
1564  void* cellAddr=shm_attach(shmid);
1565  result=new (cellAddr) FUShmRecoCell(recoCellPayloadSize_);
1566  }
1567  else {
1568  result=
1569  (FUShmRecoCell*)((unsigned long)this+recoCellOffset_+iCell*recoCellTotalSize_);
1570  }
1571 
1572  return result;
1573 }
key_t recoCellShmKey(unsigned int iCell)
static void * shm_attach(int shmid)
unsigned int recoCellPayloadSize_
Definition: FUShmBuffer.h:314
int shmid() const
Definition: FUShmBuffer.h:68
unsigned int nRecoCells_
Definition: FUShmBuffer.h:313
static int shm_get(key_t key, int size)
tuple result
Definition: query.py:137
unsigned int recoCellTotalSize_
Definition: FUShmBuffer.h:315
tuple cout
Definition: gather_cfg.py:41
unsigned int recoCellOffset_
Definition: FUShmBuffer.h:316
key_t FUShmBuffer::recoCellShmKey ( unsigned int  iCell)
private

Definition at line 1643 of file FUShmBuffer.cc.

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

Referenced by recoCell(), and releaseSharedMemory().

1644 {
1645  if (iCell>=nRecoCells_) {
1646  cout<<"FUShmBuffer::recoCellShmKey() ERROR: "
1647  <<"iCell>=nRecoCells: "<<iCell<<">="<<nRecoCells_<<endl;
1648  return -1;
1649  }
1650  return shmKey(iCell,recoCellOffset_);
1651 }
unsigned int nRecoCells_
Definition: FUShmBuffer.h:313
tuple cout
Definition: gather_cfg.py:41
key_t shmKey(unsigned int iCell, unsigned int offset)
unsigned int recoCellOffset_
Definition: FUShmBuffer.h:316
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:306
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(), postRawIndexToWrite(), postRawWrite(), evf::evt::RAWWRITING, segmentationMode_, setEvtDiscard(), setEvtNumber(), setEvtPrcId(), setEvtState(), setEvtTimeStamp(), evf::utils::state, evf::evt::STOP, and evf::evt::USEDLS.

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  ||state==evt::USEDLS
516  )) std::cout << "=================releaseRawCell state " << state
517  << std::endl;
518 
519  assert(
520  state==evt::DISCARDING
521  ||state==evt::RAWWRITING
522  ||state==evt::EMPTY
523  ||state==evt::STOP
524  // ||state==evt::LUMISECTION
525  ||state==evt::USEDLS
526  );
527  setEvtState(cell->index(),evt::EMPTY);
528  setEvtDiscard(cell->index(),0);
529  setEvtNumber(cell->index(),0xffffffff);
530  setEvtPrcId(cell->index(),0);
531  setEvtTimeStamp(cell->index(),0);
532  cell->clear();
533  postRawIndexToWrite(cell->index());
534  if (segmentationMode_) shmdt(cell);
535  postRawWrite();
536 }
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:25
tuple cout
Definition: gather_cfg.py:41
bool setEvtDiscard(unsigned int index, unsigned int discard)
bool FUShmBuffer::releaseSharedMemory ( )
static

Definition at line 969 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::FUShmRecoCell::size(), evf::FUShmRawCell::size(), size(), and stor::utils::sleep().

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

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

Definition at line 1509 of file FUShmBuffer.cc.

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

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

1510 {
1511  lock();
1512  pid_t *prcid=(pid_t*)((unsigned long)this+clientPrcIdOffset_);
1513  unsigned int iClient(0);
1514  while (iClient<=nClients_&&(*prcid)!=prcId) { prcid++; iClient++; }
1515  assert(iClient!=nClients_);
1516  pid_t* next=prcid; next++;
1517  while (iClient<nClients_-1) { *prcid=*next; prcid++; next++; iClient++; }
1518  nClients_--;
1519  unlock();
1520  return true;
1521 }
unsigned int clientPrcIdOffset_
Definition: FUShmBuffer.h:304
unsigned int nClients_
Definition: FUShmBuffer.h:302
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:288
unsigned int rawReadOffset_
Definition: FUShmBuffer.h:278
unsigned int dqmReadLast_
Definition: FUShmBuffer.h:292
unsigned int dqmReadOffset_
Definition: FUShmBuffer.h:293
unsigned int dqmWriteLast_
Definition: FUShmBuffer.h:289
unsigned int nRecoCells_
Definition: FUShmBuffer.h:313
unsigned int dqmWriteOffset_
Definition: FUShmBuffer.h:290
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int recoWriteLast_
Definition: FUShmBuffer.h:282
unsigned int recoWriteNext_
Definition: FUShmBuffer.h:281
bool setEvtNumber(unsigned int index, unsigned int evtNumber)
unsigned int recoReadOffset_
Definition: FUShmBuffer.h:286
unsigned int nDqmCells_
Definition: FUShmBuffer.h:320
bool setEvtState(unsigned int index, evt::State_t state)
unsigned int rawWriteNext_
Definition: FUShmBuffer.h:273
unsigned int recoReadLast_
Definition: FUShmBuffer.h:285
unsigned int rawReadNext_
Definition: FUShmBuffer.h:276
unsigned int rawReadLast_
Definition: FUShmBuffer.h:277
unsigned int rawWriteOffset_
Definition: FUShmBuffer.h:275
bool setEvtTimeStamp(unsigned int index, time_t timeStamp)
unsigned int rawWriteLast_
Definition: FUShmBuffer.h:274
unsigned int dqmReadNext_
Definition: FUShmBuffer.h:291
void sem_init(int isem, int value)
unsigned int recoWriteOffset_
Definition: FUShmBuffer.h:283
unsigned int nClients_
Definition: FUShmBuffer.h:302
unsigned int recoReadNext_
Definition: FUShmBuffer.h:284
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, evf::evt::USEDLS, 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);
433  if (state==evt::LUMISECTION) setEvtState(iCell,evt::USEDLS);
435  }
436  else postRawDiscard();
437 }
void waitRawDiscard()
Definition: FUShmBuffer.h:251
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:252
unsigned int rawDiscardIndex_
Definition: FUShmBuffer.h:279
char state
Definition: procUtils.cc:75
void postRawDiscarded()
Definition: FUShmBuffer.h:254
void FUShmBuffer::scheduleRawCellForDiscardServerSide ( unsigned int  iCell)

Definition at line 441 of file FUShmBuffer.cc.

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

442 {
443  waitRawDiscard();
444  if (rawCellReadyForDiscard(iCell)) {
445  rawDiscardIndex_=iCell;
446  evt::State_t state=evtState(iCell);
447  if(state!=evt::LUMISECTION && state!=evt::EMPTY && state!=evt::USEDLS) setEvtState(iCell,evt::PROCESSED);
448  if(state==evt::LUMISECTION) setEvtState(iCell,evt::USEDLS);
450  }
451  else postRawDiscard();
452 }
void waitRawDiscard()
Definition: FUShmBuffer.h:251
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:252
unsigned int rawDiscardIndex_
Definition: FUShmBuffer.h:279
char state
Definition: procUtils.cc:75
void postRawDiscarded()
Definition: FUShmBuffer.h:254
void FUShmBuffer::scheduleRawEmptyCellForDiscard ( )

Definition at line 594 of file FUShmBuffer.cc.

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

Referenced by FUShmReader::fillRawData().

595 {
597  rawDiscardIndex_=cell->index();
598  setEvtState(cell->index(),evt::STOP);
599  cell->setEventTypeStopper();
600  setEvtNumber(cell->index(),0xffffffff);
601  setEvtPrcId(cell->index(),0);
602  setEvtTimeStamp(cell->index(),0);
604 }
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:279
FUShmRawCell * rawCellToWrite()
Definition: FUShmBuffer.cc:290
bool setEvtTimeStamp(unsigned int index, time_t timeStamp)
unsigned int index() const
Definition: FUShmRawCell.h:25
void postRawDiscarded()
Definition: FUShmBuffer.h:254
void setEventTypeStopper()
Definition: FUShmRawCell.h:65
void FUShmBuffer::scheduleRawEmptyCellForDiscard ( FUShmRawCell cell)

Definition at line 608 of file FUShmBuffer.cc.

References evf::FUShmRawCell::index(), postRawDiscard(), postRawDiscarded(), rawCellReadyForDiscard(), rawDiscardIndex_, removeClientPrcId(), segmentationMode_, and waitRawDiscard().

609 {
610  waitRawDiscard();
611  if (rawCellReadyForDiscard(cell->index())) {
612  rawDiscardIndex_=cell->index();
613  // as this function is called by the reader, the state and type should
614  // already be correct
615  // setEvtState(cell->index(),evt::STOP);
616  // cell->setEventType(evt::STOPPER);
617  // setEvtNumber(cell->index(),0xffffffff);
618  // setEvtPrcId(cell->index(),0);
619  // setEvtTimeStamp(cell->index(),0);
620  removeClientPrcId(getpid());
621  if (segmentationMode_) shmdt(cell);
623  }
624  else postRawDiscard();
625 }
bool removeClientPrcId(pid_t prcId)
void waitRawDiscard()
Definition: FUShmBuffer.h:251
bool rawCellReadyForDiscard(unsigned int index)
void postRawDiscard()
Definition: FUShmBuffer.h:252
unsigned int rawDiscardIndex_
Definition: FUShmBuffer.h:279
unsigned int index() const
Definition: FUShmRawCell.h:25
void postRawDiscarded()
Definition: FUShmBuffer.h:254
void FUShmBuffer::scheduleRawEmptyCellForDiscardServerSide ( FUShmRawCell cell)

Definition at line 628 of file FUShmBuffer.cc.

References evf::FUShmRawCell::index(), postRawDiscard(), postRawDiscarded(), rawCellReadyForDiscard(), rawDiscardIndex_, and segmentationMode_.

629 {
630  // waitRawDiscard();
631  if (rawCellReadyForDiscard(cell->index())) {
632  rawDiscardIndex_=cell->index();
633  // setEvtState(cell->index(),evt::STOP);
634  // cell->setEventType(evt::STOPPER);
635  // setEvtNumber(cell->index(),0xffffffff);
636  // setEvtPrcId(cell->index(),0);
637  // setEvtTimeStamp(cell->index(),0);
638  // removeClientPrcId(getpid());
639  if (segmentationMode_) shmdt(cell);
641  }
642  else postRawDiscard();
643 }
bool rawCellReadyForDiscard(unsigned int index)
void postRawDiscard()
Definition: FUShmBuffer.h:252
unsigned int rawDiscardIndex_
Definition: FUShmBuffer.h:279
unsigned int index() const
Definition: FUShmRawCell.h:25
void postRawDiscarded()
Definition: FUShmBuffer.h:254
int FUShmBuffer::sem_create ( key_t  key,
int  nsem 
)
static

Definition at line 1173 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

Referenced by createShmBuffer().

1174 {
1175  int semid=semget(key,nsem,IPC_CREAT|0666);
1176  if (semid<0) {
1177  int err=errno;
1178  cout<<"FUShmBuffer::sem_create(key="<<key<<",nsem="<<nsem<<") failed: "
1179  <<strerror(err)<<endl;
1180  }
1181  return semid;
1182 }
list key
Definition: combine.py:13
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:69
int FUShmBuffer::sem_destroy ( int  semid)
static

Definition at line 1199 of file FUShmBuffer.cc.

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

Referenced by releaseSharedMemory().

1200 {
1201  int result=semctl(semid,0,IPC_RMID);
1202  if (result==-1) cout<<"FUShmBuffer::sem_destroy(semid="<<semid<<") failed."<<endl;
1203  return result;
1204 }
tuple result
Definition: query.py:137
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:69
int FUShmBuffer::sem_get ( key_t  key,
int  nsem 
)
static

Definition at line 1186 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

Referenced by getShmBuffer(), and releaseSharedMemory().

1187 {
1188  int semid=semget(key,nsem,0666);
1189  if (semid<0) {
1190  int err=errno;
1191  cout<<"FUShmBuffer::sem_get(key="<<key<<",nsem="<<nsem<<") failed: "
1192  <<strerror(err)<<endl;
1193  }
1194  return semid;
1195 }
list key
Definition: combine.py:13
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:69
void FUShmBuffer::sem_init ( int  isem,
int  value 
)
private

Definition at line 1667 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

Referenced by reset().

1668 {
1669  if (semctl(semid(),isem,SETVAL,value)<0) {
1670  cout<<"FUShmBuffer: FATAL ERROR in semaphore initialization."<<endl;
1671  }
1672 }
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:69
void FUShmBuffer::sem_post ( int  isem)
private

Definition at line 1691 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

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

1692 {
1693  struct sembuf sops[1];
1694  sops[0].sem_num=isem;
1695  sops[0].sem_op = 1;
1696  sops[0].sem_flg= 0;
1697  if (semop(semid(),sops,1)==-1) {
1698  cout<<"FUShmBuffer: ERROR in semaphore operation sem_post."<<endl;
1699  }
1700 }
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:69
void FUShmBuffer::sem_print ( )

Definition at line 801 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

Referenced by FUShmReader::fillRawData(), and reset().

802 {
803  cout<<"--> current sem values:"
804  <<endl
805  <<" lock="<<semctl(semid(),0,GETVAL)
806  <<endl
807  <<" wraw="<<semctl(semid(),1,GETVAL)
808  <<" rraw="<<semctl(semid(),2,GETVAL)
809  <<endl
810  <<" wdsc="<<semctl(semid(),3,GETVAL)
811  <<" rdsc="<<semctl(semid(),4,GETVAL)
812  <<endl
813  <<" wrec="<<semctl(semid(),5,GETVAL)
814  <<" rrec="<<semctl(semid(),6,GETVAL)
815  <<endl
816  <<" wdqm="<<semctl(semid(),7,GETVAL)
817  <<" rdqm="<<semctl(semid(),8,GETVAL)
818  <<endl;
819 }
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:69
int FUShmBuffer::sem_wait ( int  isem)
private

Definition at line 1676 of file FUShmBuffer.cc.

References gather_cfg::cout, and semid().

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

1677 {
1678  struct sembuf sops[1];
1679  sops[0].sem_num=isem;
1680  sops[0].sem_op = -1;
1681  sops[0].sem_flg= 0;
1682  if (semop(semid(),sops,1)==-1) {
1683  cout<<"FUShmBuffer: ERROR in semaphore operation sem_wait."<<endl;
1684  return -1;
1685  }
1686  return 0;
1687 }
tuple cout
Definition: gather_cfg.py:41
int semid() const
Definition: FUShmBuffer.h:69
int evf::FUShmBuffer::semid ( ) const
inline
bool FUShmBuffer::setClientPrcId ( pid_t  prcId)
private

Definition at line 1492 of file FUShmBuffer.cc.

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

Referenced by getShmBuffer().

1493 {
1494  lock();
1495  assert(nClients_<nClientsMax_);
1496  pid_t *prcid=(pid_t*)((unsigned long)this+clientPrcIdOffset_);
1497  for (unsigned int i=0;i<nClients_;i++) {
1498  if ((*prcid)==prcId) { unlock(); return false; }
1499  prcid++;
1500  }
1501  nClients_++;
1502  *prcid=prcId;
1503  unlock();
1504  return true;
1505 }
unsigned int clientPrcIdOffset_
Definition: FUShmBuffer.h:304
int i
Definition: DBlmapReader.cc:9
unsigned int nClientsMax_
Definition: FUShmBuffer.h:303
unsigned int nClients_
Definition: FUShmBuffer.h:302
bool FUShmBuffer::setDqmState ( unsigned int  index,
dqm::State_t  state 
)

Definition at line 1412 of file FUShmBuffer.cc.

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

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

1413 {
1414  assert(index<nDqmCells_);
1415  dqm::State_t *pstate=(dqm::State_t*)((unsigned long)this+dqmStateOffset_);
1416  pstate+=index;
1417  lock();
1418  *pstate=state;
1419  unlock();
1420  return true;
1421 }
unsigned int dqmStateOffset_
Definition: FUShmBuffer.h:300
unsigned int nDqmCells_
Definition: FUShmBuffer.h:320
char state
Definition: procUtils.cc:75
bool FUShmBuffer::setEvtDiscard ( unsigned int  index,
unsigned int  discard 
)
private

Definition at line 1425 of file FUShmBuffer.cc.

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

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

1426 {
1427  assert(index<nRawCells_);
1428  unsigned int *pcount=(unsigned int*)((unsigned long)this+evtDiscardOffset_);
1429  pcount+=index;
1430  lock();
1431  *pcount=discard;
1432  unlock();
1433  return true;
1434 }
unsigned int evtDiscardOffset_
Definition: FUShmBuffer.h:296
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
bool FUShmBuffer::setEvtNumber ( unsigned int  index,
unsigned int  evtNumber 
)
private

Definition at line 1453 of file FUShmBuffer.cc.

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

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

1454 {
1455  assert(index<nRawCells_);
1456  unsigned int *pevt=(unsigned int*)((unsigned long)this+evtNumberOffset_);
1457  pevt+=index;
1458  lock();
1459  *pevt=evtNumber;
1460  unlock();
1461  return true;
1462 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int evtNumberOffset_
Definition: FUShmBuffer.h:297
unsigned int evtNumber(unsigned int index)
bool FUShmBuffer::setEvtPrcId ( unsigned int  index,
pid_t  prcId 
)
private

Definition at line 1466 of file FUShmBuffer.cc.

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

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

1467 {
1468  assert(index<nRawCells_);
1469  pid_t* prcid=(pid_t*)((unsigned long)this+evtPrcIdOffset_);
1470  prcid+=index;
1471  lock();
1472  *prcid=prcId;
1473  unlock();
1474  return true;
1475 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
unsigned int evtPrcIdOffset_
Definition: FUShmBuffer.h:298
bool FUShmBuffer::setEvtState ( unsigned int  index,
evt::State_t  state 
)
bool FUShmBuffer::setEvtTimeStamp ( unsigned int  index,
time_t  timeStamp 
)
private

Definition at line 1479 of file FUShmBuffer.cc.

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

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

1480 {
1481  assert(index<nRawCells_);
1482  time_t *ptstmp=(time_t*)((unsigned long)this+evtTimeStampOffset_);
1483  ptstmp+=index;
1484  lock();
1485  *ptstmp=timeStamp;
1486  unlock();
1487  return true;
1488 }
unsigned int nRawCells_
Definition: FUShmBuffer.h:306
std::string timeStamp(TimePoint_t)
Definition: Utils.cc:23
unsigned int evtTimeStampOffset_
Definition: FUShmBuffer.h:299
void * FUShmBuffer::shm_attach ( int  shmid)
static

Definition at line 1141 of file FUShmBuffer.cc.

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

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

1142 {
1143  void* result=shmat(shmid,NULL,0);
1144  if (0==result) {
1145  int err=errno;
1146  cout<<"FUShmBuffer::shm_attach("<<shmid<<") failed: "
1147  <<strerror(err)<<endl;
1148  }
1149  return result;
1150 }
int shmid() const
Definition: FUShmBuffer.h:68
#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 1103 of file FUShmBuffer.cc.

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

Referenced by createShmBuffer(), and initialize().

1104 {
1105  // first check and possibly remove existing segment with same id
1106  int shmid=shmget(key,1,0644);//using minimal size any segment with key "key" will be connected
1107  if(shmid!=-1){
1108  // an existing segment was found, remove it
1109  shmid_ds shmstat;
1110  int result=shmctl(shmid,IPC_STAT,&shmstat);
1111  cout << "FUShmBuffer found segment for key 0x " << hex << key << dec
1112  << " created by process " << shmstat.shm_cpid << " owned by "
1113  << shmstat.shm_perm.uid << " permissions "
1114  << hex << shmstat.shm_perm.mode << dec << endl;
1115  result=shmctl(shmid,IPC_RMID,&shmstat);
1116  }
1117  shmid=shmget(key,size,IPC_CREAT|0644);
1118  if (shmid==-1) {
1119  int err=errno;
1120  cout<<"FUShmBuffer::shm_create("<<key<<","<<size<<") failed: "
1121  <<strerror(err)<<endl;
1122  }
1123  return shmid;
1124 }
int shmid() const
Definition: FUShmBuffer.h:68
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 1163 of file FUShmBuffer.cc.

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

Referenced by releaseSharedMemory().

1164 {
1165  shmid_ds shmstat;
1166  int result=shmctl(shmid,IPC_RMID,&shmstat);
1167  if (result==-1) cout<<"FUShmBuffer::shm_destroy(shmid="<<shmid<<") failed."<<endl;
1168  return result;
1169 }
int shmid() const
Definition: FUShmBuffer.h:68
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 1128 of file FUShmBuffer.cc.

References gather_cfg::cout, and shmid().

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

1129 {
1130  int shmid=shmget(key,size,0644);
1131  if (shmid==-1) {
1132  int err=errno;
1133  cout<<"FUShmBuffer::shm_get("<<key<<","<<size<<") failed: "
1134  <<strerror(err)<<endl;
1135  }
1136  return shmid;
1137 }
int shmid() const
Definition: FUShmBuffer.h:68
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 1154 of file FUShmBuffer.cc.

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

1155 {
1156  shmid_ds shmstat;
1157  shmctl(shmid,IPC_STAT,&shmstat);
1158  return shmstat.shm_nattch;
1159 }
int shmid() const
Definition: FUShmBuffer.h:68
int evf::FUShmBuffer::shmid ( ) const
inline
key_t FUShmBuffer::shmKey ( unsigned int  iCell,
unsigned int  offset 
)
private

Definition at line 1618 of file FUShmBuffer.cc.

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

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

1619 {
1620  if (!segmentationMode_) {
1621  cout<<"FUShmBuffer::shmKey() ERROR: only valid in segmentationMode!"<<endl;
1622  return -1;
1623  }
1624  key_t* addr=(key_t*)((unsigned long)this+offset);
1625  for (unsigned int i=0;i<iCell;i++) ++addr;
1626  return *addr;
1627 }
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 1038 of file FUShmBuffer.cc.

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

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

1045 {
1046  unsigned int offset=
1047  sizeof(FUShmBuffer)+
1048  sizeof(unsigned int)*4*nRawCells+
1049  sizeof(evt::State_t)*nRawCells+
1050  sizeof(dqm::State_t)*nDqmCells;
1051 
1052  unsigned int rawCellTotalSize=FUShmRawCell::size(rawCellSize);
1053  unsigned int recoCellTotalSize=FUShmRecoCell::size(recoCellSize);
1054  unsigned int dqmCellTotalSize=FUShmDqmCell::size(dqmCellSize);
1055 
1056  unsigned int realSize =
1057  (segmentationMode) ?
1058  offset
1059  +sizeof(key_t)*(nRawCells+nRecoCells+nDqmCells)
1060  :
1061  offset
1062  +rawCellTotalSize*nRawCells
1063  +recoCellTotalSize*nRecoCells
1064  +dqmCellTotalSize*nDqmCells;
1065 
1066  unsigned int result=realSize/0x10*0x10 + (realSize%0x10>0)*0x10;
1067 
1068  return result;
1069 }
unsigned int nRecoCells() const
Definition: FUShmBuffer.h:65
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:64
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:66
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 261 of file FUShmBuffer.h.

References sem_wait().

Referenced by dqmCellToRead().

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

Definition at line 259 of file FUShmBuffer.h.

References sem_wait().

Referenced by writeDqmEmptyEvent(), and writeDqmEventData().

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

Definition at line 251 of file FUShmBuffer.h.

References sem_wait().

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

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

Definition at line 253 of file FUShmBuffer.h.

References sem_wait().

Referenced by rawCellToDiscard().

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

Definition at line 249 of file FUShmBuffer.h.

References sem_wait().

Referenced by rawCellToRead().

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

Definition at line 247 of file FUShmBuffer.h.

References sem_wait().

Referenced by rawCellToWrite().

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

Definition at line 257 of file FUShmBuffer.h.

References sem_wait().

Referenced by recoCellToRead().

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

Definition at line 255 of file FUShmBuffer.h.

References sem_wait().

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

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

Definition at line 581 of file FUShmBuffer.cc.

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

582 {
583  waitDqmWrite();
584  unsigned int iCell=nextDqmWriteIndex();
585  FUShmDqmCell* cell=dqmCell(iCell);
586  cell->clear();
587  postDqmIndexToRead(iCell);
588  if (segmentationMode_) shmdt(cell);
589  postDqmRead();
590 }
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 772 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().

779 {
780  if (dataSize>dqmCellPayloadSize_) {
781  cout<<"FUShmBuffer::writeDqmEventData() ERROR: buffer overflow."<<endl;
782  return false;
783  }
784 
785  waitDqmWrite();
786  unsigned int iCell=nextDqmWriteIndex();
787  FUShmDqmCell* cell=dqmCell(iCell);
788  dqm::State_t state=dqmState(iCell);
789  assert(state==dqm::EMPTY);
790  setDqmState(iCell,dqm::WRITING);
791  cell->writeData(runNumber,evtAtUpdate,folderId,fuProcessId,fuGuid,data,dataSize);
792  setDqmState(iCell,dqm::WRITTEN);
793  postDqmIndexToRead(iCell);
794  if (segmentationMode_) shmdt(cell);
795  postDqmRead();
796  return true;
797 }
void postDqmIndexToRead(unsigned int index)
unsigned int dqmCellPayloadSize_
Definition: FUShmBuffer.h:321
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 702 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(), runTheMatrix_dev::raw, rawCell(), dt_dqm_sourceclient_common_cff::reco, recoCell(), evf::evt::RECOWRITING, evf::evt::RECOWRITTEN, segmentationMode_, setEvtDiscard(), setEvtState(), waitRecoWrite(), and evf::FUShmRecoCell::writeErrorEvent().

Referenced by FUShmReader::~FUShmReader().

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

Definition at line 540 of file FUShmBuffer.cc.

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

541 {
543  evt::State_t state=evtState(cell->index());
544  assert(state==evt::RAWWRITING);
545  setEvtState(cell->index(),evt::STOP);
546  cell->setEventTypeStopper();
547  postRawIndexToRead(cell->index());
548  if (segmentationMode_) shmdt(cell);
549  postRawRead();
550 }
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:25
void setEventTypeStopper()
Definition: FUShmRawCell.h:65
void FUShmBuffer::writeRawLumiSectionEvent ( unsigned int  ls)

Definition at line 553 of file FUShmBuffer.cc.

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

554 {
556  cell->setLumiSection(ls);
557  evt::State_t state=evtState(cell->index());
558  assert(state==evt::RAWWRITING);
560  cell->setEventTypeEol();
561  postRawIndexToRead(cell->index());
562  if (segmentationMode_) shmdt(cell);
563  postRawRead();
564 }
void postRawIndexToRead(unsigned int index)
evt::State_t evtState(unsigned int index)
void setEventTypeEol()
Definition: FUShmRawCell.h:61
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:25
void setLumiSection(unsigned int)
void FUShmBuffer::writeRecoEmptyEvent ( )

Definition at line 568 of file FUShmBuffer.cc.

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

569 {
570  waitRecoWrite();
571  unsigned int iCell=nextRecoWriteIndex();
572  FUShmRecoCell* cell =recoCell(iCell);
573  cell->clear();
574  postRecoIndexToRead(iCell);
575  if (segmentationMode_) shmdt(cell);
576  postRecoRead();
577 }
void waitRecoWrite()
Definition: FUShmBuffer.h:255
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 670 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().

677 {
678  if (dataSize>recoCellPayloadSize_) {
679  cout<<"FUShmBuffer::writeRecoEventData() ERROR: buffer overflow."<<endl;
680  return false;
681  }
682 
683  waitRecoWrite();
684  unsigned int iCell=nextRecoWriteIndex();
685  FUShmRecoCell* cell =recoCell(iCell);
686  unsigned int rawCellIndex=indexForEvtNumber(evtNumber);
687  //evt::State_t state=evtState(rawCellIndex);
688  //assert(state==evt::PROCESSING||state==evt::RECOWRITING||state==evt::SENT);
689  setEvtState(rawCellIndex,evt::RECOWRITING);
690  incEvtDiscard(rawCellIndex);
691  cell->writeEventData(rawCellIndex,runNumber,evtNumber,outModId,
692  fuProcessId,fuGuid,data,dataSize);
693  setEvtState(rawCellIndex,evt::RECOWRITTEN);
694  postRecoIndexToRead(iCell);
695  if (segmentationMode_) shmdt(cell);
696  postRecoRead();
697  return true;
698 }
int incEvtDiscard(unsigned int index)
void waitRecoWrite()
Definition: FUShmBuffer.h:255
unsigned int recoCellPayloadSize_
Definition: FUShmBuffer.h:314
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 647 of file FUShmBuffer.cc.

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

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

652 {
653  if (dataSize>recoCellPayloadSize_) {
654  cout<<"FUShmBuffer::writeRecoInitMsg() ERROR: buffer overflow."<<endl;
655  return false;
656  }
657 
658  waitRecoWrite();
659  unsigned int iCell=nextRecoWriteIndex();
660  FUShmRecoCell* cell =recoCell(iCell);
661  cell->writeInitMsg(outModId,fuProcessId,fuGuid,data,dataSize);
662  postRecoIndexToRead(iCell);
663  if (segmentationMode_) shmdt(cell);
664  postRecoRead();
665  return true;
666 }
void waitRecoWrite()
Definition: FUShmBuffer.h:255
unsigned int recoCellPayloadSize_
Definition: FUShmBuffer.h:314
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 304 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::dqmCellOffset_
private

Definition at line 323 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::dqmCellPayloadSize_
private

Definition at line 321 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::dqmCellTotalSize_
private

Definition at line 322 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::dqmReadIndex_
private

Definition at line 319 of file FUShmBuffer.h.

unsigned int evf::FUShmBuffer::dqmReadLast_
private

Definition at line 292 of file FUShmBuffer.h.

Referenced by postDqmIndexToRead(), and reset().

unsigned int evf::FUShmBuffer::dqmReadNext_
private

Definition at line 291 of file FUShmBuffer.h.

Referenced by nextDqmReadIndex(), and reset().

unsigned int evf::FUShmBuffer::dqmReadOffset_
private

Definition at line 293 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::dqmStateOffset_
private

Definition at line 300 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::dqmWriteIndex_
private

Definition at line 318 of file FUShmBuffer.h.

unsigned int evf::FUShmBuffer::dqmWriteLast_
private

Definition at line 289 of file FUShmBuffer.h.

Referenced by postDqmIndexToWrite(), and reset().

unsigned int evf::FUShmBuffer::dqmWriteNext_
private

Definition at line 288 of file FUShmBuffer.h.

Referenced by nextDqmWriteIndex(), and reset().

unsigned int evf::FUShmBuffer::dqmWriteOffset_
private

Definition at line 290 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::evtDiscardOffset_
private

Definition at line 296 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::evtNumberOffset_
private

Definition at line 297 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::evtPrcIdOffset_
private

Definition at line 298 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::evtStateOffset_
private

Definition at line 295 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::evtTimeStampOffset_
private

Definition at line 299 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::nClients_
private

Definition at line 302 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::nClientsMax_
private

Definition at line 303 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 309 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::rawCellPayloadSize_
private

Definition at line 307 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::rawCellTotalSize_
private

Definition at line 308 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 277 of file FUShmBuffer.h.

Referenced by postRawIndexToRead(), and reset().

unsigned int evf::FUShmBuffer::rawReadNext_
private

Definition at line 276 of file FUShmBuffer.h.

Referenced by nextRawReadIndex(), and reset().

unsigned int evf::FUShmBuffer::rawReadOffset_
private

Definition at line 278 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::rawWriteLast_
private

Definition at line 274 of file FUShmBuffer.h.

Referenced by postRawIndexToWrite(), and reset().

unsigned int evf::FUShmBuffer::rawWriteNext_
private

Definition at line 273 of file FUShmBuffer.h.

Referenced by nextRawWriteIndex(), and reset().

unsigned int evf::FUShmBuffer::rawWriteOffset_
private

Definition at line 275 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::recoCellOffset_
private

Definition at line 316 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 315 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::recoReadIndex_
private

Definition at line 312 of file FUShmBuffer.h.

unsigned int evf::FUShmBuffer::recoReadLast_
private

Definition at line 285 of file FUShmBuffer.h.

Referenced by postRecoIndexToRead(), and reset().

unsigned int evf::FUShmBuffer::recoReadNext_
private

Definition at line 284 of file FUShmBuffer.h.

Referenced by nextRecoReadIndex(), and reset().

unsigned int evf::FUShmBuffer::recoReadOffset_
private

Definition at line 286 of file FUShmBuffer.h.

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

unsigned int evf::FUShmBuffer::recoWriteIndex_
private

Definition at line 311 of file FUShmBuffer.h.

unsigned int evf::FUShmBuffer::recoWriteLast_
private

Definition at line 282 of file FUShmBuffer.h.

Referenced by postRecoIndexToWrite(), and reset().

unsigned int evf::FUShmBuffer::recoWriteNext_
private

Definition at line 281 of file FUShmBuffer.h.

Referenced by nextRecoWriteIndex(), and reset().

unsigned int evf::FUShmBuffer::recoWriteOffset_
private

Definition at line 283 of file FUShmBuffer.h.

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

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

Definition at line 271 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 326 of file FUShmBuffer.h.

Referenced by getSemKey().

int evf::FUShmBuffer::shmid_
private

Definition at line 270 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 325 of file FUShmBuffer.h.

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