static void rt_test_005_005_execute(void) { /* [5.5.1] An higher priority thread is created that performs non-atomical wait and signal operations on a semaphore.*/ test_set_step(1); { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread3, 0); } /* [5.5.2] The function chSemSignalWait() is invoked by specifying the same semaphore for the wait and signal phases. The counter value must be one on exit.*/ test_set_step(2); { chSemSignalWait(&sem1, &sem1); test_assert(queue_isempty(&sem1.queue), "queue not empty"); test_assert(sem1.cnt == 0, "counter not zero"); } /* [5.5.3] The function chSemSignalWait() is invoked again by specifying the same semaphore for the wait and signal phases. The counter value must be one on exit.*/ test_set_step(3); { chSemSignalWait(&sem1, &sem1); test_assert(queue_isempty(&sem1.queue), "queue not empty"); test_assert(sem1.cnt == 0, "counter not zero"); } }
static void sem3_execute(void) { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread3, 0); chSemSignalWait(&sem1, &sem1); test_assert(1, isempty(&sem1.s_queue), "queue not empty"); test_assert(2, sem1.s_cnt == 0, "counter not zero"); chSemSignalWait(&sem1, &sem1); test_assert(3, isempty(&sem1.s_queue), "queue not empty"); test_assert(4, sem1.s_cnt == 0, "counter not zero"); }
msg_t CounterSemaphore::signalWait(CounterSemaphore *ssem, CounterSemaphore *wsem) { return chSemSignalWait(&ssem->sem, &wsem->sem); }
msg_t Semaphore::SignalWait(Semaphore *ssem, Semaphore *wsem) { return chSemSignalWait(&ssem->sem, &wsem->sem); }