这篇教程C++ test_wait_threads函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中test_wait_threads函数的典型用法代码示例。如果您正苦于以下问题:C++ test_wait_threads函数的具体用法?C++ test_wait_threads怎么用?C++ test_wait_threads使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了test_wait_threads函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: dyn2_executestatic void dyn2_execute(void) { int i; tprio_t prio = chThdGetPriority(); /* Adding the WAs to the pool. */ for (i = 0; i < 4; i++) chPoolFree(&mp1, wa[i]); /* Starting threads from the memory pool. */ threads[0] = chThdCreateFromMemoryPool(&mp1, prio-1, thread, "A"); threads[1] = chThdCreateFromMemoryPool(&mp1, prio-2, thread, "B"); threads[2] = chThdCreateFromMemoryPool(&mp1, prio-3, thread, "C"); threads[3] = chThdCreateFromMemoryPool(&mp1, prio-4, thread, "D"); threads[4] = chThdCreateFromMemoryPool(&mp1, prio-5, thread, "E"); test_assert(1, (threads[0] != NULL) && (threads[1] != NULL) && (threads[2] != NULL) && (threads[3] != NULL) && (threads[4] == NULL), "thread creation failed"); /* Claiming the memory from terminated threads. */ test_wait_threads(); test_assert_sequence(2, "ABCD"); /* Now the pool must be full again. */ for (i = 0; i < 4; i++) test_assert(3, chPoolAlloc(&mp1) != NULL, "pool list empty"); test_assert(4, chPoolAlloc(&mp1) == NULL, "pool list not empty");}
开发者ID:Amirelecom,项目名称:brush-v1,代码行数:31,
示例2: test_003_001_executestatic void test_003_001_execute(void) { systime_t time; msg_t msg; /* [3.1.1] The function chThdSuspendTimeoutS() is invoked, the thread is remotely resumed with message @p MSG_OK. On return the message and the state of the reference are tested.*/ test_set_step(1); { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread1, "A"); chSysLock(); msg = chThdSuspendTimeoutS(&tr1, TIME_INFINITE); chSysUnlock(); test_assert(NULL == tr1, "not NULL"); test_assert(MSG_OK == msg,"wrong returned message"); test_wait_threads(); } /* [3.1.2] The function chThdSuspendTimeoutS() is invoked, the thread is not resumed so a timeout must occur. On return the message and the state of the reference are tested.*/ test_set_step(2); { chSysLock(); time = chVTGetSystemTimeX(); msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000)); chSysUnlock(); test_assert_time_window(time + MS2ST(1000), time + MS2ST(1000) + CH_CFG_ST_TIMEDELTA + 1, "out of time window"); test_assert(NULL == tr1, "not NULL"); test_assert(MSG_TIMEOUT == msg, "wrong returned message"); }}
开发者ID:KTannenberg,项目名称:ChibiOS,代码行数:34,
示例3: bmk4_executestatic void bmk4_execute(void) { Thread *tp; uint32_t n; tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread4, NULL); n = 0; test_wait_tick(); test_start_timer(1000); do { chSysLock(); chSchWakeupS(tp, RDY_OK); chSchWakeupS(tp, RDY_OK); chSchWakeupS(tp, RDY_OK); chSchWakeupS(tp, RDY_OK); chSysUnlock(); n += 4;#if defined(SIMULATOR) ChkIntSources();#endif } while (!test_timer_done); chSysLock(); chSchWakeupS(tp, RDY_TIMEOUT); chSysUnlock(); test_wait_threads(); test_print("--- Score : "); test_printn(n * 2); test_println(" ctxswc/S");}
开发者ID:Amirelecom,项目名称:brush-v1,代码行数:29,
示例4: bmk7_executestatic void bmk7_execute(void) { uint32_t n; threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread3, NULL); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+4, thread3, NULL); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread3, NULL); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+2, thread3, NULL); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+1, thread3, NULL); n = 0; test_wait_tick(); test_start_timer(1000); do { chSemReset(&sem1, 0); n++;#if defined(SIMULATOR) ChkIntSources();#endif } while (!test_timer_done); test_terminate_threads(); chSemReset(&sem1, 0); test_wait_threads(); test_print("--- Score : "); test_printn(n); test_print(" reschedules/S, "); test_printn(n * 6); test_println(" ctxswc/S");}
开发者ID:Amirelecom,项目名称:brush-v1,代码行数:29,
示例5: test_005_007_executestatic void test_005_007_execute(void) { /* [5.7.1] Starting the five threads with increasing priority, the threads will queue on the condition variable.*/ test_set_step(1); { tprio_t prio = chThdGetPriorityX(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread6, "E"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread6, "D"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread6, "C"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread6, "B"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread6, "A"); } /* [5.7.2] Atomically signaling the condition variable five times then waiting for the threads to terminate in priority order, the order is tested.*/ test_set_step(2); { chSysLock(); chCondSignalI(&c1); chCondSignalI(&c1); chCondSignalI(&c1); chCondSignalI(&c1); chCondSignalI(&c1); chSchRescheduleS(); chSysUnlock(); test_wait_threads(); test_assert_sequence("ABCDE", "invalid sequence"); }}
开发者ID:AlexShiLucky,项目名称:ChibiOS,代码行数:31,
示例6: rt_test_005_002_executestatic void rt_test_005_002_execute(void) { /* [5.2.1] Five threads are created with mixed priority levels (not increasing nor decreasing). Threads enqueue on a semaphore initialized to zero.*/ test_set_step(1); { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+1, thread1, "B"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread1, "C"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+4, thread1, "D"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+2, thread1, "E"); } /* [5.2.2] The semaphore is signaled 5 times. The thread activation sequence is tested.*/ test_set_step(2); { chSemSignal(&sem1); chSemSignal(&sem1); chSemSignal(&sem1); chSemSignal(&sem1); chSemSignal(&sem1); test_wait_threads();#if CH_CFG_USE_SEMAPHORES_PRIORITY test_assert_sequence("ADCEB", "invalid sequence");#else test_assert_sequence("ABCDE", "invalid sequence");#endif }}
开发者ID:mabl,项目名称:ChibiOS,代码行数:31,
示例7: test_005_003_executestatic void test_005_003_execute(void) { systime_t time; /* [5.3.1] Getting the system time for test duration measurement.*/ test_set_step(1); { time = test_wait_tick(); } /* [5.3.2] The five contenders threads are created and let run atomically, the goals sequence is tested, the threads must complete in priority order.*/ test_set_step(2); { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread3LL, 0); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread3L, 0); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread3M, 0); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread3H, 0); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread3HH, 0); test_wait_threads(); test_assert_sequence("ABCDE", "invalid sequence"); } /* [5.3.3] Testing that all threads completed within the specified time windows (110mS...110mS+ALLOWED_DELAY).*/ test_set_step(3); { test_assert_time_window(time + MS2ST(110), time + MS2ST(110) + ALLOWED_DELAY, "out of time window"); }}
开发者ID:AlexShiLucky,项目名称:ChibiOS,代码行数:31,
示例8: test_006_001_executestatic void test_006_001_execute(void) { thread_t *tp; msg_t msg; /* [6.1.1] Starting the messenger thread.*/ test_set_step(1); { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() + 1, msg_thread1, chThdGetSelfX()); } /* [6.1.2] Waiting for four messages then testing the receive order.*/ test_set_step(2); { unsigned i; for (i = 0; i < 4; i++) { tp = chMsgWait(); msg = chMsgGet(tp); chMsgRelease(tp, msg); test_emit_token(msg); } test_wait_threads(); test_assert_sequence("ABCD", "invalid sequence"); }}
开发者ID:KTannenberg,项目名称:ChibiOS,代码行数:27,
示例9: dyn1_executestatic void dyn1_execute(void) { size_t n, sz; void *p1; tprio_t prio = chThdGetPriority(); (void)chHeapStatus(&heap1, &sz); /* Starting threads from the heap. */ threads[0] = chThdCreateFromHeap(&heap1, THD_WA_SIZE(THREADS_STACK_SIZE), prio-1, thread, "A"); threads[1] = chThdCreateFromHeap(&heap1, THD_WA_SIZE(THREADS_STACK_SIZE), prio-2, thread, "B"); /* Allocating the whole heap in order to make the thread creation fail.*/ (void)chHeapStatus(&heap1, &n); p1 = chHeapAlloc(&heap1, n); threads[2] = chThdCreateFromHeap(&heap1, THD_WA_SIZE(THREADS_STACK_SIZE), prio-3, thread, "C"); chHeapFree(p1); test_assert(1, (threads[0] != NULL) && (threads[1] != NULL) && (threads[2] == NULL) && (threads[3] == NULL) && (threads[4] == NULL), "thread creation failed"); /* Claiming the memory from terminated threads. */ test_wait_threads(); test_assert_sequence(2, "AB"); /* Heap status checked again.*/ test_assert(3, chHeapStatus(&heap1, &n) == 1, "heap fragmented"); test_assert(4, n == sz, "heap size changed");}
开发者ID:Amirelecom,项目名称:brush-v1,代码行数:33,
示例10: mtx4_executestatic void mtx4_execute(void) { tprio_t p, p1, p2; p = chThdGetPriorityX(); p1 = p + 1; p2 = p + 2; threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "B"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "A"); chMtxLock(&m2); test_assert(1, chThdGetPriorityX() == p, "wrong priority level"); chThdSleepMilliseconds(100); test_assert(2, chThdGetPriorityX() == p1, "wrong priority level"); chMtxLock(&m1); test_assert(3, chThdGetPriorityX() == p1, "wrong priority level"); chThdSleepMilliseconds(100); test_assert(4, chThdGetPriorityX() == p2, "wrong priority level"); chMtxUnlock(&m1); test_assert(5, chThdGetPriorityX() == p1, "wrong priority level"); chThdSleepMilliseconds(100); test_assert(6, chThdGetPriorityX() == p1, "wrong priority level"); chMtxUnlockAll(); test_assert(7, chThdGetPriorityX() == p, "wrong priority level"); test_wait_threads(); /* Test repeated in order to cover chMtxUnlockS().*/ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "D"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "C"); chMtxLock(&m2); test_assert(8, chThdGetPriorityX() == p, "wrong priority level"); chThdSleepMilliseconds(100); test_assert(9, chThdGetPriorityX() == p1, "wrong priority level"); chMtxLock(&m1); test_assert(10, chThdGetPriorityX() == p1, "wrong priority level"); chThdSleepMilliseconds(100); test_assert(11, chThdGetPriorityX() == p2, "wrong priority level"); chSysLock(); chMtxUnlockS(&m1); chSchRescheduleS(); chSysUnlock(); test_assert(12, chThdGetPriorityX() == p1, "wrong priority level"); chThdSleepMilliseconds(100); test_assert(13, chThdGetPriorityX() == p1, "wrong priority level"); chMtxUnlockAll(); test_assert(14, chThdGetPriorityX() == p, "wrong priority level"); test_wait_threads();}
开发者ID:MultiCalorNV,项目名称:verventa-web_Int,代码行数:46,
示例11: queues1_executestatic void queues1_execute(void) { unsigned i; size_t n; /* Initial empty state */ test_assert_lock(1, chIQIsEmptyI(&iq), "not empty"); /* Queue filling */ chSysLock(); for (i = 0; i < TEST_QUEUES_SIZE; i++) chIQPutI(&iq, 'A' + i); chSysUnlock(); test_assert_lock(2, chIQIsFullI(&iq), "still has space"); test_assert_lock(3, chIQPutI(&iq, 0) == Q_FULL, "failed to report Q_FULL"); /* Queue emptying */ for (i = 0; i < TEST_QUEUES_SIZE; i++) test_emit_token(chIQGet(&iq)); test_assert_lock(4, chIQIsEmptyI(&iq), "still full"); test_assert_sequence(5, "ABCD"); /* Queue filling again */ chSysLock(); for (i = 0; i < TEST_QUEUES_SIZE; i++) chIQPutI(&iq, 'A' + i); chSysUnlock(); /* Reading the whole thing */ n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); test_assert_lock(7, chIQIsEmptyI(&iq), "still full"); /* Queue filling again */ chSysLock(); for (i = 0; i < TEST_QUEUES_SIZE; i++) chIQPutI(&iq, 'A' + i); chSysUnlock(); /* Partial reads */ n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); test_assert(8, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); test_assert_lock(10, chIQIsEmptyI(&iq), "still full"); /* Testing reset */ chSysLock(); chIQPutI(&iq, 0); chIQResetI(&iq); chSysUnlock(); test_assert_lock(11, chIQGetFullI(&iq) == 0, "still full"); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL); test_assert_lock(12, chIQGetFullI(&iq) == 0, "not empty"); test_wait_threads(); /* Timeout */ test_assert(13, chIQGetTimeout(&iq, 10) == Q_TIMEOUT, "wrong timeout return");}
开发者ID:Tambralinga,项目名称:ChibiOS,代码行数:58,
示例12: thd1_executestatic void thd1_execute(void) { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A"); test_wait_threads(); test_assert_sequence(1, "ABCDE");}
开发者ID:Koensw,项目名称:Robot-PWS,代码行数:10,
示例13: mtx8_executestatic void mtx8_execute(void) { tprio_t prio = chThdGetPriority(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread11, "A"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "C"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread12, "B"); chCondSignal(&c1); chCondSignal(&c1); test_wait_threads(); test_assert_sequence(1, "ABC");}
开发者ID:ColonelPanic42,项目名称:ChibiOS-RPi,代码行数:11,
示例14: test_002_002_executestatic void test_002_002_execute(void) { /* [2.2.1] Creating 5 threads with increasing priority, execution sequence is tested.*/ test_set_step(1); { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A"); test_wait_threads(); test_assert_sequence("ABCDE", "invalid sequence"); } /* [2.2.2] Creating 5 threads with decreasing priority, execution sequence is tested.*/ test_set_step(2); { threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D"); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E"); test_wait_threads(); test_assert_sequence("ABCDE", "invalid sequence"); } /* [2.2.3] Creating 5 threads with pseudo-random priority, execution sequence is tested.*/ test_set_step(3); { threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D"); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C"); test_wait_threads(); test_assert_sequence("ABCDE", "invalid sequence"); }}
开发者ID:KTannenberg,项目名称:ChibiOS,代码行数:41,
示例15: mtx7_executestatic void mtx7_execute(void) { tprio_t prio = chThdGetPriority(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread10, "B"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread10, "A"); chCondBroadcast(&c1); test_wait_threads(); test_assert_sequence(1, "ABCDE");}
开发者ID:ColonelPanic42,项目名称:ChibiOS-RPi,代码行数:12,
示例16: mtx2_executestatic void mtx2_execute(void) { systime_t time; test_wait_tick(); time = chTimeNow(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread2H, 0); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-2, thread2M, 0); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread2L, 0); test_wait_threads(); test_assert_sequence(1, "ABC"); test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + ALLOWED_DELAY);}
开发者ID:ColonelPanic42,项目名称:ChibiOS-RPi,代码行数:12,
示例17: bmk2_executestatic void bmk2_execute(void) { uint32_t n; threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL); n = msg_loop_test(threads[0]); test_wait_threads(); test_print("--- Score : "); test_printn(n); test_print(" msgs/S, "); test_printn(n << 1); test_println(" ctxswc/S");}
开发者ID:Amirelecom,项目名称:brush-v1,代码行数:12,
示例18: test_005_009_executestatic void test_005_009_execute(void) { tprio_t prio; /* [5.9.1] Reading current base priority.*/ test_set_step(1); { prio = chThdGetPriorityX(); } /* [5.9.2] Thread A is created at priority P(+1), it locks M2, locks M1 and goes to wait on C1.*/ test_set_step(2); { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread8, "A"); } /* [5.9.3] Thread C is created at priority P(+2), it enqueues on M1 and boosts TA priority at P(+2).*/ test_set_step(3); { threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread6, "C"); } /* [5.9.4] Thread B is created at priority P(+3), it enqueues on M2 and boosts TA priority at P(+3).*/ test_set_step(4); { threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread9, "B"); } /* [5.9.5] Signaling C1: TA wakes up, unlocks M1 and priority goes to P(+2). TB locks M1, unlocks M1 and completes. TA unlocks M2 and priority goes to P(+1). TC waits on C1. TA completes.*/ test_set_step(5); { chCondSignal(&c1); } /* [5.9.6] Signaling C1: TC wakes up, unlocks M1 and completes.*/ test_set_step(6); { chCondSignal(&c1); } /* [5.9.7] Checking the order of operations.*/ test_set_step(7); { test_wait_threads(); test_assert_sequence("ABC", "invalid sequence"); }}
开发者ID:AlexShiLucky,项目名称:ChibiOS,代码行数:51,
示例19: mtx3_executestatic void mtx3_execute(void) { systime_t time; test_wait_tick(); time = chTimeNow(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread3LL, 0); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread3L, 0); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread3M, 0); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread3H, 0); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread3HH, 0); test_wait_threads(); test_assert_sequence(1, "ABCDE"); test_assert_time_window(2, time + MS2ST(110), time + MS2ST(110) + ALLOWED_DELAY);}
开发者ID:ColonelPanic42,项目名称:ChibiOS-RPi,代码行数:14,
示例20: mtx1_executestatic void mtx1_execute(void) { tprio_t prio = chThdGetPriority(); /* Because priority inheritance.*/ chMtxLock(&m1); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread1, "E"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread1, "D"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A"); chMtxUnlock(); test_wait_threads(); test_assert(1, prio == chThdGetPriority(), "wrong priority level"); test_assert_sequence(2, "ABCDE");}
开发者ID:ColonelPanic42,项目名称:ChibiOS-RPi,代码行数:14,
示例21: thd2_executestatic void thd2_execute(void) { threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D"); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B"); /* Done this way for coverage of chThdCreateI() and chThdResume().*/ chSysLock(); threads[2] = chThdCreateI(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C"); chSysUnlock(); chThdResume(threads[2]); test_wait_threads(); test_assert_sequence(1, "ABCDE");}
开发者ID:Koensw,项目名称:Robot-PWS,代码行数:14,
示例22: queues2_executestatic void queues2_execute(void) { unsigned i; size_t n; /* Initial empty state */ test_assert_lock(1, chOQIsEmptyI(&oq), "not empty"); /* Queue filling */ for (i = 0; i < TEST_QUEUES_SIZE; i++) chOQPut(&oq, 'A' + i); test_assert_lock(2, chOQIsFullI(&oq), "still has space"); /* Queue emptying */ for (i = 0; i < TEST_QUEUES_SIZE; i++) { char c; chSysLock(); c = chOQGetI(&oq); chSysUnlock(); test_emit_token(c); } test_assert_lock(3, chOQIsEmptyI(&oq), "still full"); test_assert_sequence(4, "ABCD"); test_assert_lock(5, chOQGetI(&oq) == Q_EMPTY, "failed to report Q_EMPTY"); /* Writing the whole thing */ n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); test_assert_lock(7, chOQIsFullI(&oq), "not full"); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread2, NULL); test_assert_lock(8, chOQGetFullI(&oq) == TEST_QUEUES_SIZE, "not empty"); test_wait_threads(); /* Testing reset */ chSysLock(); chOQResetI(&oq); chSysUnlock(); test_assert_lock(9, chOQGetFullI(&oq) == 0, "still full"); /* Partial writes */ n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); test_assert(10, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); test_assert(11, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); test_assert_lock(12, chOQIsFullI(&oq), "not full"); /* Timeout */ test_assert(13, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return");}
开发者ID:Tambralinga,项目名称:ChibiOS,代码行数:49,
示例23: execute_test/* * Test suite execution. */static void execute_test(const struct testcase *tcp) { int i; /* Initialization */ clear_tokens(); local_fail = FALSE; for (i = 0; i < MAX_THREADS; i++) threads[i] = NULL; if (tcp->setup != NULL) tcp->setup(); tcp->execute(); if (tcp->teardown != NULL) tcp->teardown(); test_wait_threads();}
开发者ID:Tambralinga,项目名称:ChibiOS,代码行数:20,
示例24: mtx6_executestatic void mtx6_execute(void) { tprio_t prio = chThdGetPriority(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread10, "B"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread10, "A"); chSysLock(); chCondSignalI(&c1); chCondSignalI(&c1); chCondSignalI(&c1); chCondSignalI(&c1); chCondSignalI(&c1); chSchRescheduleS(); chSysUnlock(); test_wait_threads(); test_assert_sequence(1, "ABCDE");}
开发者ID:ColonelPanic42,项目名称:ChibiOS-RPi,代码行数:19,
示例25: rt_test_005_003_executestatic void rt_test_005_003_execute(void) { unsigned i; systime_t target_time; msg_t msg; /* [5.3.1] Testing special case TIME_IMMEDIATE.*/ test_set_step(1); { msg = chSemWaitTimeout(&sem1, TIME_IMMEDIATE); test_assert(msg == MSG_TIMEOUT, "wrong wake-up message"); test_assert(queue_isempty(&sem1.queue), "queue not empty"); test_assert(sem1.cnt == 0, "counter not zero"); } /* [5.3.2] Testing non-timeout condition.*/ test_set_step(2); { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, thread2, 0); msg = chSemWaitTimeout(&sem1, TIME_MS2I(500)); test_wait_threads(); test_assert(msg == MSG_OK, "wrong wake-up message"); test_assert(queue_isempty(&sem1.queue), "queue not empty"); test_assert(sem1.cnt == 0, "counter not zero"); } /* [5.3.3] Testing timeout condition.*/ test_set_step(3); { target_time = chTimeAddX(test_wait_tick(), TIME_MS2I(5 * 50)); for (i = 0; i < 5; i++) { test_emit_token('A' + i); msg = chSemWaitTimeout(&sem1, TIME_MS2I(50)); test_assert(msg == MSG_TIMEOUT, "wrong wake-up message"); test_assert(queue_isempty(&sem1.queue), "queue not empty"); test_assert(sem1.cnt == 0, "counter not zero"); } test_assert_sequence("ABCDE", "invalid sequence"); test_assert_time_window(target_time, chTimeAddX(target_time, ALLOWED_DELAY), "out of time window"); }}
开发者ID:mabl,项目名称:ChibiOS,代码行数:43,
示例26: sem1_executestatic void sem1_execute(void) { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread1, "A"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+1, thread1, "B"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread1, "C"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+4, thread1, "D"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+2, thread1, "E"); chSemSignal(&sem1); chSemSignal(&sem1); chSemSignal(&sem1); chSemSignal(&sem1); chSemSignal(&sem1); test_wait_threads();#if CH_USE_SEMAPHORES_PRIORITY test_assert_sequence(1, "ADCEB");#else test_assert_sequence(1, "ABCDE");#endif}
开发者ID:Nitrokey,项目名称:nitrokey-start-firmware,代码行数:19,
示例27: bmk8_executestatic void bmk8_execute(void) { uint32_t n; n = 0; test_wait_tick(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n); chThdSleepSeconds(1); test_terminate_threads(); test_wait_threads(); test_print("--- Score : "); test_printn(n); test_println(" ctxswc/S");}
开发者ID:Amirelecom,项目名称:brush-v1,代码行数:20,
示例28: rt_test_005_004_executestatic void rt_test_005_004_execute(void) { /* [5.4.1] A thread is created, it goes to wait on the semaphore.*/ test_set_step(1); { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, "A"); } /* [5.4.2] The semaphore counter is increased by two, it is then tested to be one, the thread must have completed.*/ test_set_step(2); { chSysLock(); chSemAddCounterI(&sem1, 2); chSchRescheduleS(); chSysUnlock(); test_wait_threads(); test_assert_lock(chSemGetCounterI(&sem1) == 1, "invalid counter"); test_assert_sequence("A", "invalid sequence"); }}
开发者ID:mabl,项目名称:ChibiOS,代码行数:21,
示例29: sem2_executestatic void sem2_execute(void) { int i; systime_t target_time; msg_t msg; /* * Testing special case TIME_IMMEDIATE. */ msg = chSemWaitTimeout(&sem1, TIME_IMMEDIATE); test_assert(1, msg == RDY_TIMEOUT, "wrong wake-up message"); test_assert(2, isempty(&sem1.s_queue), "queue not empty"); test_assert(3, sem1.s_cnt == 0, "counter not zero"); /* * Testing not timeout condition. */ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1, thread2, 0); msg = chSemWaitTimeout(&sem1, MS2ST(500)); test_wait_threads(); test_assert(4, msg == RDY_OK, "wrong wake-up message"); test_assert(5, isempty(&sem1.s_queue), "queue not empty"); test_assert(6, sem1.s_cnt == 0, "counter not zero"); /* * Testing timeout condition. */ test_wait_tick(); target_time = chTimeNow() + MS2ST(5 * 500); for (i = 0; i < 5; i++) { test_emit_token('A' + i); msg = chSemWaitTimeout(&sem1, MS2ST(500)); test_assert(7, msg == RDY_TIMEOUT, "wrong wake-up message"); test_assert(8, isempty(&sem1.s_queue), "queue not empty"); test_assert(9, sem1.s_cnt == 0, "counter not zero"); } test_assert_sequence(10, "ABCDE"); test_assert_time_window(11, target_time, target_time + ALLOWED_DELAY);}
开发者ID:Nitrokey,项目名称:nitrokey-start-firmware,代码行数:39,
示例30: test_005_008_executestatic void test_005_008_execute(void) { /* [5.8.1] Starting the five threads with increasing priority, the threads will queue on the condition variable.*/ test_set_step(1); { tprio_t prio = chThdGetPriorityX(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread6, "E"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread6, "D"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread6, "C"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread6, "B"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread6, "A"); } /* [5.8.2] Broarcasting on the condition variable then waiting for the threads to terminate in priority order, the order is tested.*/ test_set_step(2); { chCondBroadcast(&c1); test_wait_threads(); test_assert_sequence("ABCDE", "invalid sequence"); }}
开发者ID:AlexShiLucky,项目名称:ChibiOS,代码行数:23,
注:本文中的test_wait_threads函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ test_waitsig函数代码示例 C++ test_validate函数代码示例 |