本文整理汇总了C++中chThdGetPriority函数的典型用法代码示例。如果您正苦于以下问题:C++ chThdGetPriority函数的具体用法?C++ chThdGetPriority怎么用?C++ chThdGetPriority使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chThdGetPriority函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mtx5_execute
static void mtx5_execute(void) {
bool_t b;
tprio_t prio;
prio = chThdGetPriority();
b = chMtxTryLock(&m1);
test_assert(1, b, "already locked");
b = chMtxTryLock(&m1);
test_assert(2, !b, "not locked");
chSysLock();
chMtxUnlockS();
chSysUnlock();
test_assert(3, isempty(&m1.m_queue), "queue not empty");
test_assert(4, m1.m_owner == NULL, "still owned");
test_assert(5, chThdGetPriority() == prio, "wrong priority level");
chMtxLock(&m1);
chMtxUnlockAll();
test_assert(6, isempty(&m1.m_queue), "queue not empty");
test_assert(7, m1.m_owner == NULL, "still owned");
}
开发者ID:ColonelPanic42,项目名称:ChibiOS-RPi,代码行数:25,代码来源:testmtx.c
示例2: bmk7_execute
static 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,代码来源:testbmk.c
示例3: thread1
static msg_t thread1(BaseSequentialStream *chp) {
systime_t time = chTimeNow();
/*
* Thread-specific parameters
*/
chRegSetThreadName("t1");
static int d = 300;
static int w = 75000;
volatile uint32_t i, n;
while(1) {
if(chThdShouldTerminate())
return 0;
palSetPad(GPIOD, GPIOD_LED3);
/*
* Deadline for current execution of this task
*/
time += d;
chprintf(chp, "%s N %d %d %d %d\r\n", chRegGetThreadName(chThdSelf()), chThdGetPriority(),
chTimeNow(), time, chThdGetTicks(chThdSelf()));
/*
* Do some "work"
*/
for(i = 0; i < w; i ++) {
n = i / 3;
}
chprintf(chp, "%s X %d %d %d %d\r\n", chRegGetThreadName(chThdSelf()), chThdGetPriority(),
chTimeNow(), time, chThdGetTicks(chThdSelf()));
palClearPad(GPIOD, GPIOD_LED3);
/*
* Yield control of CPU until the deadline (which is also beginning of next period)
*/
chThdSleepUntil(time);
}
return 0;
}
开发者ID:JizhouZhang,项目名称:stm32f4-labs,代码行数:35,代码来源:main.c
示例4: thd1_execute
static 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,代码来源:testthd.c
示例5: mtx2_execute
static 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,代码来源:testmtx.c
示例6: thd2_execute
static 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,代码来源:testthd.c
示例7: mtx1_execute
static 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,代码来源:testmtx.c
示例8: mtx3_execute
static 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,代码来源:testmtx.c
示例9: bmk4_execute
static 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,代码来源:testbmk.c
示例10: bmk3_execute
static void bmk3_execute(void) {
uint32_t n;
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL);
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-2, thread2, NULL);
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread2, NULL);
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-4, thread2, NULL);
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-5, thread2, 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,代码行数:16,代码来源:testbmk.c
示例11: dyn3_execute
static void dyn3_execute(void) {
Thread *tp;
tprio_t prio = chThdGetPriority();
/* Testing references increase/decrease and final detach.*/
tp = chThdCreateFromHeap(&heap1, WA_SIZE, prio-1, thread, "A");
test_assert(1, tp->p_refs == 1, "wrong initial reference counter");
chThdAddRef(tp);
test_assert(2, tp->p_refs == 2, "references increase failure");
chThdRelease(tp);
test_assert(3, tp->p_refs == 1, "references decrease failure");
/* Verify the new threads count.*/
test_assert(4, regfind(tp), "thread missing from registry");
test_assert(5, regfind(tp), "thread disappeared");
/* Detach and let the thread execute and terminate.*/
chThdRelease(tp);
test_assert(6, tp->p_refs == 0, "detach failure");
test_assert(7, tp->p_state == THD_STATE_READY, "invalid state");
test_assert(8, regfind(tp), "thread disappeared");
test_assert(9, regfind(tp), "thread disappeared");
chThdSleepMilliseconds(50); /* The thread just terminates. */
test_assert(10, tp->p_state == THD_STATE_FINAL, "invalid state");
/* Clearing the zombie by scanning the registry.*/
test_assert(11, regfind(tp), "thread disappeared");
test_assert(12, !regfind(tp), "thread still in registry");
}
开发者ID:Amirelecom,项目名称:brush-v1,代码行数:29,代码来源:testdyn.c
示例12: msg1_execute
static void msg1_execute(void) {
msg_t msg;
/*
* Testing the whole messages loop.
*/
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() + 1,
thread, chThdSelf());
chMsgRelease(msg = chMsgWait());
test_emit_token(msg);
chMsgRelease(msg = chMsgWait());
test_emit_token(msg);
chMsgRelease(msg = chMsgWait());
test_emit_token(msg);
test_assert_sequence(1, "ABC");
/*
* Testing message fetch using chMsgGet().
* Note, the following is valid because the sender has higher priority than
* the receiver.
*/
msg = chMsgGet();
test_assert(1, msg != 0, "no message");
chMsgRelease(0);
test_assert(2, msg == 'D', "wrong message");
/*
* Must not have pending messages.
*/
msg = chMsgGet();
test_assert(3, msg == 0, "unknown message");
}
开发者ID:Amirelecom,项目名称:brush-v1,代码行数:32,代码来源:testmsg.c
示例13: dyn1_execute
static 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,代码来源:testdyn.c
示例14: dyn2_execute
static 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,代码来源:testdyn.c
示例15: thd3_execute
static void thd3_execute(void) {
tprio_t prio, p1;
prio = chThdGetPriority();
p1 = chThdSetPriority(prio + 1);
test_assert(1, p1 == prio,
"unexpected returned priority level");
test_assert(2, chThdGetPriority() == prio + 1,
"unexpected priority level");
p1 = chThdSetPriority(p1);
test_assert(3, p1 == prio + 1,
"unexpected returned priority level");
test_assert(4, chThdGetPriority() == prio,
"unexpected priority level");
#if CH_USE_MUTEXES || defined(__DOXYGEN__)
/* Simulates a priority boost situation (p_prio > p_realprio).*/
chSysLock();
chThdSelf()->p_prio += 2;
chSysUnlock();
test_assert(5, chThdGetPriority() == prio + 2,
"unexpected priority level");
/* Tries to raise but below the boost level. */
p1 = chThdSetPriority(prio + 1);
test_assert(6, p1 == prio,
"unexpected returned priority level");
test_assert(7, chThdSelf()->p_prio == prio + 2,
"unexpected priority level");
test_assert(8, chThdSelf()->p_realprio == prio + 1,
"unexpected returned real priority level");
/* Tries to raise above the boost level. */
p1 = chThdSetPriority(prio + 3);
test_assert(9, p1 == prio + 1,
"unexpected returned priority level");
test_assert(10, chThdSelf()->p_prio == prio + 3,
"unexpected priority level");
test_assert(11, chThdSelf()->p_realprio == prio + 3,
"unexpected real priority level");
chSysLock();
chThdSelf()->p_prio = prio;
chThdSelf()->p_realprio = prio;
chSysUnlock();
#endif
}
开发者ID:Koensw,项目名称:Robot-PWS,代码行数:47,代码来源:testthd.c
示例16: queues1_execute
static 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, chThdGetPriority()+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:0x00f,项目名称:ChibiOS,代码行数:58,代码来源:testqueues.c
示例17: sem1_execute
static 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,代码来源:testsem.c
示例18: bmk8_execute
static 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,代码来源:testbmk.c
示例19: mtx8_execute
static 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,代码来源:testmtx.c
示例20: sem3_execute
static void sem3_execute(void) {
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread3, 0);
chSemSignalWait(&sem1, &sem1);
test_assert(1, isempty(&sem1.s_queue), "queue not empty");
test_assert(2, sem1.s_cnt == 0, "counter not zero");
chSemSignalWait(&sem1, &sem1);
test_assert(3, isempty(&sem1.s_queue), "queue not empty");
test_assert(4, sem1.s_cnt == 0, "counter not zero");
}
开发者ID:Nitrokey,项目名称:nitrokey-start-firmware,代码行数:11,代码来源:testsem.c
注:本文中的chThdGetPriority函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论