void TimerFunction(uint32 timer_id) { int32 status; OS_bin_sem_prop_t bin_sem_prop; timer_counter++; status = OS_BinSemGive(bin_sem_id); /* ** Note: The timer callback function in RTEMS runs as an ISR ** so calls that block cannot be made. */ #ifndef _RTEMS_OS_ status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop); if ( bin_sem_prop.value > 1 ) { OS_printf("Error: Binary sem value > 1 ( in timer):%d !\n",(int)bin_sem_prop.value); exit(-1); } else if ( bin_sem_prop.value < -1 ) { OS_printf("Error: Binary sem value < -1 ( in timer):%d !\n",(int)bin_sem_prop.value); exit(-1); } #endif }
static void test_004_003_execute(void) { /* [4.3.1] OS_BinSemGive() is invoked with sem_id set to -1, an error is expected.*/ test_set_step(1); { int32 err; err = OS_BinSemGive((uint32)-1); test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); } }