示例#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
文件: test3.c 项目: piopodg/rados
void test_init(void)
{
   os_task_create(&task1, 1, task1_stack, sizeof(task1_stack), task1_proc, NULL);
   os_task_create(&task2, 1, task2_stack, sizeof(task2_stack), task2_proc, NULL);

   /* frequent ticks help test race conditions.  The best would be to call tick
    * ISR every instruction, 1ms tick should be optimal */
   test_setuptick(NULL, 1000000);

}
示例#3
0
void setup()
{
	ebox_init();
	
	uart1.begin(9600);
	uart1.printf("\r\nuart1 9600 ok!");
    uart1.printf("\r\ncpu:%d",cpu_calculate_per_sec);
    PB8.mode(OUTPUT_PP);
	os_init();
	os_task_create(task_1,&TASK_1_STK[TASK_1_STK_SIZE-1],TASK1_PRIO);
	os_task_create(task_2,&TASK_2_STK[TASK_2_STK_SIZE-1],TASK2_PRIO);
	os_task_create(task_3,&TASK_3_STK[TASK_3_STK_SIZE-1],TASK3_PRIO);
	
	os_start();

}
示例#4
0
文件: test_mtx.c 项目: rosly/rados
void test_init(void)
{
   os_task_create(
      &task_coordinator, OS_CONFIG_PRIOCNT - 1,
      coordinator_stack, sizeof(coordinator_stack),
      test_coordinator, NULL);
}
示例#5
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;
}
示例#6
0
文件: test_sem.c 项目: rosly/rados
void test_init(void)
{
   test_setuptick(NULL, 300000000);

   os_task_create(
      &task_main, OS_CONFIG_PRIOCNT - 1,
      task_main_stack, sizeof(task_main_stack),
      task_main_proc, NULL);
}
示例#7
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;
}
示例#8
0
void demo_application_init(void)
{
	tffa_uint32 stack_address;

	stack_address = os_task_alloc_task_stack(DEMO_APPLICATION_TASK0_STACK_SIZE);
	ptask0 = os_task_create(
				os_task0,
				stack_address,
				DEMO_APPLICATION_TASK0_STACK_SIZE,
				0,
				OS_TASK_STATE_RUNNING);

	stack_address = os_task_alloc_task_stack(DEMO_APPLICATION_TASK1_STACK_SIZE);
	ptask1 = os_task_create(
			os_task1,
			stack_address,
			DEMO_APPLICATION_TASK1_STACK_SIZE,
			1,
			OS_TASK_STATE_RUNNING);

	stack_address = os_task_alloc_task_stack(DEMO_APPLICATION_TASK2_STACK_SIZE);
	ptask2 = os_task_create(
			os_task2,
			stack_address,
			DEMO_APPLICATION_TASK2_STACK_SIZE,
			2,
			OS_TASK_STATE_RUNNING);

	stack_address = os_task_alloc_task_stack(DEMO_APPLICATION_TASK3_STACK_SIZE);
	ptask3 = os_task_create(
			os_task3,
			stack_address,
			DEMO_APPLICATION_TASK3_STACK_SIZE,
			3,
			OS_TASK_STATE_RUNNING);
}
示例#9
0
文件: test4.c 项目: rosly/rados
void test_init(void)
{
   uint16_t i;

   os_waitqueue_create(&wq);
   for (i = 0; i < TEST_TASK_CNT; i++) {
      os_task_create(&(task_def[i].task), 1, task_def[i].stack,
         sizeof(task_def[i].stack),
         task_proc, (void*)(&(task_def[i].cnt)));
   }

   /* frequent ticks help test race conditions.  The best would be to call tick
    * ISR every instruction, 1ms tick should be optimal */
   test_setuptick(tick_clbck, 1000000);
}
示例#10
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;
}
示例#11
0
文件: test11.c 项目: rosly/rados
void test_init(void)
{
   os_task_create(&task1, 1, task1_stack, sizeof(task1_stack), task1_proc, NULL);
   os_task_create(&task2, 1, task2_stack, sizeof(task2_stack), task2_proc, NULL);
}