Esempio n. 1
0
// Copy packet from the front of the pktList.  Wait for nonEmpty
// if the buffer is empty.  Leave the packet where it is.
APacket ABuffer::PeekPacket()
{
  HEnterSection(lock);
  while (pktList.size()==0) {
    HWaitSignal(notEmpty, lock);
  }
  APacket p = pktList.front();
  HLeaveSection(lock);
  return p;
}
Esempio n. 2
0
TASKTYPE TASKMOD test3(void * hp)
{
	HEnterSection(t3_lock);
	printf("Test 3 - waiting for Signal\n"); fflush(stdout);
	HWaitSignal(t3_signal,t3_lock);
	printf("Test 3 - Signal Received\n"); fflush(stdout);
	HLeaveSection(t3_lock);
	HExitThread(0);
	return 0;
}
Esempio n. 3
0
void ABuffer::PopPacket()
{
  HEnterSection(lock);
  while (pktList.size()==0) {
    HWaitSignal(notEmpty, lock);
  }
  pktList.pop_front();
  HLeaveSection(lock);
  HSendSignal(notFull);
  SendBufferEvents();
}
Esempio n. 4
0
// Get packet p from the front of the pktList.  Wait for nonEmpty
// if the buffer is empty.
APacket ABuffer::GetPacket()
{
  HEnterSection(lock);
  while (pktList.size()==0) {
    HWaitSignal(notEmpty, lock);
  }
  APacket p = pktList.front();
  pktList.pop_front();
  HLeaveSection(lock);
  HSendSignal(notFull);
  return p;
}
Esempio n. 5
0
// Push packet p onto the end of the pktList.  Wait for nonFull
// if the buffer is full
void ABuffer::PutPacket(APacket p)
{
  assert(filter == AnyPacket || p.GetKind() == filter);
  HEnterSection(lock);
  while (bsize!=0 && int(pktList.size())>= bsize) {
    HWaitSignal(notFull, lock);
  }
  pktList.push_back(p);
  HLeaveSection(lock);
  HSendSignal(notEmpty);
  SendBufferEvents();
}
Esempio n. 6
0
void bput(char c)
{
	HPauseThread(pdel);
	printf("<%c",c); fflush(stdout);
	HEnterSection(lock);
	while (used>=bsize) {
		printf("!");
		HWaitSignal(notfull,lock);
	}
	buf[inx] = c; inx++; used++;
	if (inx == bsize) inx = 0;
	HSendSignal(notempty);
	HLeaveSection(lock);
	printf(">"); fflush(stdout);
}
Esempio n. 7
0
char bget()
{
	int c;
	HPauseThread(cdel); printf("{");   fflush(stdout);
	HEnterSection(lock);
	while (used==0) {
		printf("?");
		HWaitSignal(notempty,lock);
	}
	c = buf[outx]; outx++; --used;
	if (outx == bsize) outx = 0;
	HSendSignal(notfull);
	HLeaveSection(lock);
	printf("%c}",c); fflush(stdout);
	return c;
}
Esempio n. 8
0
// Push packet p onto the end of the pktList.  Wait for nonFull
// if the buffer is full
void ABuffer::PutPacket(APacket p)
{
  assert(filter == AnyPacket || p.GetKind() == filter);
  
  for (ABufferListenerList::iterator l = listenerList.begin(); l != listenerList.end(); l++) {
    ABufferListener *listener = *l;
    listener->ABufferReceivedPacket(*this, p);
  }
  
  HEnterSection(lock);
  while (bsize!=0 && int(pktList.size())>= bsize) {
    HWaitSignal(notFull, lock);
  }
  pktList.push_back(p);
  HLeaveSection(lock);
  HSendSignal(notEmpty);
  SendBufferEvents();
}