コード例 #1
0
ファイル: test2.c プロジェクト: piopodg/rados
void test_init(void)
{
   memset(&task_data[0], 0, sizeof(task_data_t));
   memset(&task_data[1], 0, sizeof(task_data_t));
   os_sem_create(&(task_data[0].sem), 0);
   os_sem_create(&(task_data[1].sem), 0);
   os_task_create(&task1, 1, task1_stack, sizeof(task1_stack), task_proc, (void*)0);
   os_task_create(&task2, 1, task2_stack, sizeof(task2_stack), task_proc, (void*)1);
}
コード例 #2
0
ファイル: test_sem.c プロジェクト: rosly/rados
int testcase_1(void)
{
   int ret;
   uint8_t i;

   /* clear out memory */
   memset(worker_tasks, 0, sizeof(worker_tasks));

   /* create tasks */
   for (i = 0; i < TEST_TASKS; i++) {
      worker_tasks[i].idx = i + 1;
      os_sem_create(&(worker_tasks[i].sem), 0);
      os_task_create(
         &(worker_tasks[i].task), os_min(i + 1, OS_CONFIG_PRIOCNT - 1),
         worker_tasks[i].task1_stack, sizeof(worker_tasks[i].task1_stack),
         task_proc, &(worker_tasks[i]));
   }

   /* join tasks and collect the results */
   ret = 0;
   for (i = 0; i < TEST_TASKS; i++) {
      ret = os_task_join(&(worker_tasks[i].task));
      test_assert(0 == ret);
      ret = worker_tasks[i].result ? 0 : 1;
      test_assert(0 == ret);
   }

   return ret;
}
コード例 #3
0
ファイル: test_sem.c プロジェクト: rosly/rados
int testcase_regresion(void)
{
   /* regresion test - two tasks hanged on semaphore, higher prioritized with
    * timeout, once timeout expire signalize the semaphore to wake up the low
    * prioritized, in case of bug low priority task will be not woken up because
    * issing priomax update in task_queue */
   os_sem_create(&(worker_tasks[0].sem), 0);
   os_task_create(
      &(worker_tasks[0].task), 1,
      worker_tasks[0].task1_stack, sizeof(worker_tasks[0].task1_stack),
      test1_task_proc1, NULL);
   os_task_create(
      &(worker_tasks[1].task), 2,
      worker_tasks[1].task1_stack, sizeof(worker_tasks[1].task1_stack),
      test1_task_proc2, NULL);
   /* finish the test */
   os_task_join(&(worker_tasks[0].task));
   os_task_join(&(worker_tasks[1].task));

   return 0;
}
コード例 #4
0
ファイル: os_sem.c プロジェクト: Greeeg/uWatch
Sem_t sem_counting_create( uint8_t max, uint8_t initial ) {
    return os_sem_create( max, initial );
}
コード例 #5
0
ファイル: os_sem.c プロジェクト: Greeeg/uWatch
Sem_t sem_bin_create( uint8_t initial ) {
    return os_sem_create( 1, initial );
}
コード例 #6
0
ファイル: test_mtx.c プロジェクト: rosly/rados
/**
 * Test coordinator, runs all test in unit
 */
int test_coordinator(void *OS_UNUSED(param))
{
   uint16_t i;

/* scenario 1 */
   os_mtx_create(&test_mtx[0]);
   test_atomic[0] = 0;
   test_atomic[1] = -1;
   for (i = 0; i < 4; i++) {
      /* created task will be not scheduled because current task has the highest
       * available priority */
      os_task_create(
         &task_worker[i], 1,
         task_stack[i], sizeof(task_stack[i]),
         test_scen1_worker, (void*)(uintptr_t)i);
   }
   /* scheduler will kick in after following call */
   for (i = 0; i < 4; i++)
      os_task_join(&task_worker[i]);

/* scenario 2 */
   os_taskproc_t scen2_worker_proc[] =
   { test_scen2_workerH, test_scen2_workerM, test_scen2_workerL };
   os_mtx_create(&test_mtx[0]);
   test_atomic[0] = 0;
   for (i = 0; i < 3; i++) {
      os_sem_create(&test_sem[i], 0);
      /* created task will be not scheduled because current task has the highest
       * available priority */
      os_task_create(
         &task_worker[i], 3 - i,
         task_stack[i], sizeof(task_stack[i]),
         scen2_worker_proc[i], (void*)(uintptr_t)i);
   }
   /* scheduler will kick in after following call */
   for (i = 0; i < 3; i++)
      os_task_join(&task_worker[i]);

/* scenario 3 */
   os_taskproc_t scen3_worker_proc[] = {
      test_scen3_workerH,
      test_scen3_workerM,
      test_scen3_workerLM,
      test_scen3_workerL
   };
   os_sem_create(&test_sem[0], 0);
   os_sem_create(&test_sem[1], 0);
   os_mtx_create(&test_mtx[0]);
   os_mtx_create(&test_mtx[1]);
   test_atomic[0] = 0;
   for (i = 0; i < 4; i++) {
      /* created task will be not scheduled because current task has the highest
       * available priority */
      os_task_create(
         &task_worker[i], OS_CONFIG_PRIOCNT - 1 - i,
         task_stack[i], sizeof(task_stack[i]),
         scen3_worker_proc[i], (void*)(uintptr_t)i);
   }
   /* scheduler will kick in after following call */
   for (i = 0; i < 4; i++)
      os_task_join(&task_worker[i]);
   test_assert(14 == test_atomic[0]);

/* scenario 4 */
   os_taskproc_t scen4_worker_proc[] = {
      test_scen4_workerH,
      test_scen4_workerHM,
      test_scen4_workerM,
      test_scen4_workerL
   };
   os_sem_create(&test_sem[0], 0);
   os_sem_create(&test_sem[1], 0);
   os_sem_create(&test_sem[2], 0);
   os_mtx_create(&test_mtx[0]);
   os_mtx_create(&test_mtx[1]);
   os_mtx_create(&test_mtx[2]);
   test_atomic[0] = 0;
   for (i = 0; i < 4; i++) {
      /* created task will be not scheduled because current task has the highest
       * available priority */
      os_task_create(
         &task_worker[i], OS_CONFIG_PRIOCNT - 1 - i,
         task_stack[i], sizeof(task_stack[i]),
         scen4_worker_proc[i], (void*)(uintptr_t)i);
   }
   /* scheduler will kick in after following call */
   for (i = 0; i < 4; i++)
      os_task_join(&task_worker[i]);
   test_assert(18 == test_atomic[0]);

/* scenario 5 */
   os_taskproc_t scen5_worker_proc[] = {
      test_scen5_workerH,
      test_scen5_workerM,
      test_scen5_workerL
   };
   os_sem_create(&test_sem[0], 0);
   os_sem_create(&test_sem[1], 0);
   os_mtx_create(&test_mtx[0]);
   os_mtx_create(&test_mtx[1]);
   test_atomic[0] = 0;
   for (i = 0; i < 3; i++) {
      /* created task will be not scheduled because current task has the highest
       * available priority */
      os_task_create(
         &task_worker[i], OS_CONFIG_PRIOCNT - 1 - i,
         task_stack[i], sizeof(task_stack[i]),
         scen5_worker_proc[i], (void*)(uintptr_t)i);
   }
   /* scheduler will kick in after following call */
   for (i = 0; i < 3; i++)
      os_task_join(&task_worker[i]);
   test_assert(10 == test_atomic[0]);

/* scenario 6 */
   os_taskproc_t scen6_worker_proc[] = {
      test_scen6_workerH,
      test_scen6_workerM,
      test_scen6_workerL
   };
   os_sem_create(&test_sem[0], 0);
   os_sem_create(&test_sem[1], 0);
   os_mtx_create(&test_mtx[0]);
   os_mtx_create(&test_mtx[1]);
   test_atomic[0] = 0;
   for (i = 0; i < 3; i++) {
      /* created task will be not scheduled because current task has the highest
       * available priority */
      os_task_create(
         &task_worker[i], OS_CONFIG_PRIOCNT - 1 - i,
         task_stack[i], sizeof(task_stack[i]),
         scen6_worker_proc[i], (void*)(uintptr_t)i);
   }
   /* scheduler will kick in after following call */
   for (i = 0; i < 3; i++)
      os_task_join(&task_worker[i]);
   test_assert(10 == test_atomic[0]);

   test_result(0);
   return 0;
}
コード例 #7
0
ファイル: onlp_util.c プロジェクト: capveg/ONLP
void
onlp_api_lock_init(void)
{
    onlp_api_lock__ = os_sem_create(1);
}