diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2022-07-18 09:41:39 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2022-07-28 07:52:59 +0200 |
commit | 31036f1dc8a963fb0bc3fc103f63028988314fea (patch) | |
tree | b321873d02cf2acebf775a3d4fe9b73766525ce7 /testsuites/smptests/smppsxmutex01/init.c | |
parent | aarch64/versal: Support DDRMC0 region 0 and 1 (diff) | |
download | rtems-31036f1dc8a963fb0bc3fc103f63028988314fea.tar.bz2 |
score: Use priority inheritance for thread join
Threads may join the thread termination of another thread using the
pthread_join() or rtems_task_delete() directives. The thread cancel operation
used a special case priority boosting mechanism implemented by
_Thread_Raise_real_priority(). The problem was that this approach
* is not transitive,
* does not account for priority adjustments of the calling task
while waiting for the join,
* does not support clustered scheduling, and
* does not detect deadlocks.
All these problems are fixed by using a priority inheritance thread queue for
the join operation.
Close #4679.
Diffstat (limited to '')
-rw-r--r-- | testsuites/smptests/smppsxmutex01/init.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/testsuites/smptests/smppsxmutex01/init.c b/testsuites/smptests/smppsxmutex01/init.c index f5aacb42d8..0022e81b5f 100644 --- a/testsuites/smptests/smppsxmutex01/init.c +++ b/testsuites/smptests/smppsxmutex01/init.c @@ -55,25 +55,11 @@ static test_context test_instance; static void *thread_b(void *arg) { test_context *ctx; - rtems_id scheduler_b_id; - rtems_status_code sc; - rtems_task_priority prio; int prio_ceiling; int eno; ctx = arg; - rtems_test_assert(rtems_scheduler_get_processor() == 0); - - sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - - sc = rtems_task_set_priority(pthread_self(), RTEMS_CURRENT_PRIORITY, &prio); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - - sc = rtems_task_set_scheduler(pthread_self(), scheduler_b_id, prio); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - rtems_test_assert(rtems_scheduler_get_processor() == 1); eno = pthread_mutex_init(&ctx->mtx_b, &ctx->mtx_attr); @@ -132,8 +118,24 @@ static void test(test_context *ctx) rtems_test_assert(eno == 0); if (cpu_count > 1) { + rtems_id scheduler_a_id; + rtems_id scheduler_b_id; + rtems_status_code sc; + rtems_task_priority prio; void *exit_code; + sc = rtems_scheduler_ident(SCHED_A, &scheduler_a_id); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_task_set_priority(pthread_self(), RTEMS_CURRENT_PRIORITY, &prio); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_task_set_scheduler(pthread_self(), scheduler_b_id, prio); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + eno = pthread_create(&ctx->thread_b, NULL, thread_b, ctx); rtems_test_assert(eno == 0); @@ -141,6 +143,9 @@ static void test(test_context *ctx) eno = pthread_join(ctx->thread_b, &exit_code); rtems_test_assert(eno == 0); rtems_test_assert(exit_code == ctx); + + sc = rtems_task_set_scheduler(pthread_self(), scheduler_a_id, prio); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); } eno = pthread_mutex_destroy(&ctx->mtx_a); |