Esempio n. 1
0
void SuiteMulticast::Receiver()
{
    iPortLock.Wait();
    SocketUdpMulticast recv(0, Endpoint(iPort, kMulticastAddress));
    iPort = recv.Port();
    iPortLock.Signal();

    iSender.Signal(); // signal ready to begin receiving

    Bwh buf(kBufBytes);
    Brn exp = iExp.Split(4);
    while(1) {
        recv.Receive(buf);
        TUint num = *((TUint32*)buf.Ptr());
        if(num == kQuit) {
            break;
        }
        Brn exp2 = exp.Split(0, num);
        Brn buf2 = buf.Split(4);
        TEST(buf2 == exp2);
        iSender.Signal();
    }

    iSender.Signal();
}
void CarThread::ThreadFunc()
{
     Thread::ThreadFunc();
     int i, j;

     for (i = 1; i <= No_of_rides; i++) {               
          for (j = 1; j <= Capacity; j++)  
               Queue.Signal();          // allow CAPACITY passengers to check in
          Boarding.Wait();              // wait for boarding to complete

          // print on boarding passenger names
          cout << "The car is running for the " << i 
               << " time with passengers ";
          for (j = 0; j < Capacity; j++) 
               cout << " " << On_board_passenger_ID[j];
          cout << endl;
          Delay();                      // ride for a while

          On_board_passenger_counter = 0;  // start unloading passengers            
          for (j = 1; j <= Capacity; j++) {
               Riding.Signal();         // release a passenger
               Unloading.Wait();        // wait until this passenger is done
          }
          // definitely, the car is empty and goes for the next run
     }
     // done here and show messages
     cout << "The car is shot-off for maintenance" << endl;
     
     Exit();
}
Esempio n. 3
0
void SemaphoreThread::Run()
{
    // we use iWaitsGuard to synchronise our two threads in the absense of reliable thread priorities
    // its unfortunate that we have to rely on correct behaviour from a semaphore to test a semaphore...
    iWaitsGuard.Signal();
    iSem.Wait();
    iWaits++;
    iWaitsGuard.Signal();
    iSem.Wait();
    iWaits++;
    iSem.Wait();
    iWaits++;
    iSem.Wait();
    iWaits++;
    iWaitsGuard.Signal();
    iSem.Wait();
}
Esempio n. 4
0
// WaitForSignal_Thread
//------------------------------------------------------------------------------
/*static*/ uint32_t TestSemaphore::WaitForSignal_Thread( void * userData )
{
    Semaphore * s = reinterpret_cast< Semaphore * >( userData );
    for ( size_t i=0; i<100; ++i )
    {
        s->Signal();
    }
    return 0;
}
Esempio n. 5
0
void CpDevices::Added(CpDevice& aDevice)
{
    iLock.Wait();
    const Brx& udn = aDevice.Udn();
    if (udn == gNameDevice1 || udn == gNameDevice1_1 || udn == gNameDevice1_2 || udn == gNameDevice2) {
        iList.push_back(&aDevice);
        aDevice.AddRef();
    }
    if ((TUint)iList.size() == iTargetCount) {
        iSem.Signal();
    }
    iLock.Signal();
}
void PassengerThread::TakeRide()
{
     strstream *Space;

     Space = Filler(3);       // build leading spaces
     
     Queue.Wait();            // join the queue for a ride
     CheckIn.Wait();          // time to check in

     // save my name and increase the counter
     On_board_passenger_ID[On_board_passenger_counter] = passenger_Id;
     On_board_passenger_counter++;
     cout << Space->str() << ThreadName.str() 
          <<" is on board the car" << endl;

     // if I am the last one to be on board, boarding completes and the car is full
     if (On_board_passenger_counter == Capacity)  
          Boarding.Signal();   
     CheckIn.Signal();        // allow next passenger to check in
     Riding.Wait();           // I am riding in the car
     Unloading.Signal();      // get off the car
}
Esempio n. 7
0
void SuiteThreadFunctor::Run()
{
    try {
        TEST(iFunctor->TryWait() == false);
        iFunctor->Signal();
        TEST(iFunctor->TryWait() == true);
        iFunctor->CheckCurrentForKill();
        iFunctor->Kill();
        TEST_THROWS(iFunctor->CheckCurrentForKill(), ThreadKill);
        TEST_THROWS(iFunctor->Wait(), ThreadKill);
        TEST_THROWS(iFunctor->TryWait(), ThreadKill);
    }
    catch(ThreadKill&) {
        ASSERT(0);
    }
    iSem->Signal();
}
Esempio n. 8
0
void SuiteAlive::Disabled()
{
    iSem.Signal();
}
Esempio n. 9
0
void DeviceList::TimerExpired()
{
    iPollStop.Signal();
}
Esempio n. 10
0
void DeviceList::InitialNotificationComplete()
{
    iSem.Signal();
}
Esempio n. 11
0
void SuiteListen::TimerExpired()
{
    iSem.Signal();
}
Esempio n. 12
0
	~CriticalSection(void)
	{
		_sem.Signal();
	}