コード例 #1
0
static void test_004_002_execute(void) {

  /* [4.2.1] OS_BinSemFlush() is invoked with sem_id set to -1, an
     error is expected.*/
  test_set_step(1);
  {
    int32 err;

    err = OS_BinSemFlush((uint32)-1);
    test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");
  }
}
コード例 #2
0
/*
** Main function
*/
void OS_Application_Startup(void)
{
   uint32 status;
   OS_bin_sem_prop_t  bin_sem_prop;

   OS_API_Init();

   OS_printf("OS Application Startup\n");

   /*
   ** Create the binary semaphore
   */
   status = OS_BinSemCreate( &bin_sem_id, "BinSem1", 1, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Binary Sem\n");
   }
   else
   {
      status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop);
      OS_printf("Binary Sem ID = %d, value = %d\n", (int)bin_sem_id, (int)bin_sem_prop.value);
   }

   /*
   ** Take the semaphore so the value is 0 and the next SemTake call should block
   */
   status = OS_BinSemTake(bin_sem_id);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error calling OS_BinSemTake with bin_sem_id = %d\n",(int)bin_sem_id);
   }
   else
   {
      status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop);
      OS_printf("Initial Binary Sem Take: value = %d\n", (int)bin_sem_prop.value);
   }

   /*
   ** Create the tasks
   */
   status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_STACK_SIZE, TASK_1_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 1\n");
   }
   else
   {
      OS_printf("Created Task 1\n");
   }

   status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, TASK_STACK_SIZE, TASK_2_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 2\n");
   }
   else
   {
      OS_printf("Created Task 2\n");
   }
 
   status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, TASK_STACK_SIZE, TASK_3_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 3\n");
   }
   else
   {
      OS_printf("Created Task 3\n");
   }

   /* 
   ** Delay, then release the semaphore
   */
   OS_TaskDelay(2000); 

   status = OS_BinSemFlush(bin_sem_id);

   OS_printf("Main done!\n");

}