diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-06-10 08:48:54 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-06-22 14:36:40 +0200 |
commit | 77ff5599e0d8e6d91190a379be21a332f83252b0 (patch) | |
tree | 339e28b236beb9e606322cb801d7340e2e44f8bf /testsuites | |
parent | score: Delete unused _Scheduler_Priority_compare() (diff) | |
download | rtems-77ff5599e0d8e6d91190a379be21a332f83252b0.tar.bz2 |
score: Introduce map priority scheduler operation
Introduce map/unmap priority scheduler operations to map thread priority
values from/to the user domain to/from the scheduler domain. Use the
map priority operation to validate the thread priority. The EDF
schedulers use this new operation to distinguish between normal
priorities and priorities obtain through a job release.
Update #2173.
Update #2556.
Diffstat (limited to 'testsuites')
-rw-r--r-- | testsuites/psxtests/psxautoinit01/init.c | 4 | ||||
-rw-r--r-- | testsuites/smptests/Makefile.am | 1 | ||||
-rw-r--r-- | testsuites/smptests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/smptests/smppsxmutex01/Makefile.am | 19 | ||||
-rw-r--r-- | testsuites/smptests/smppsxmutex01/init.c | 184 | ||||
-rw-r--r-- | testsuites/smptests/smppsxmutex01/smppsxmutex01.doc | 12 | ||||
-rw-r--r-- | testsuites/smptests/smppsxmutex01/smppsxmutex01.scn | 2 | ||||
-rw-r--r-- | testsuites/smptests/smpscheduler02/init.c | 35 |
8 files changed, 256 insertions, 2 deletions
diff --git a/testsuites/psxtests/psxautoinit01/init.c b/testsuites/psxtests/psxautoinit01/init.c index fb70a1e63e..f22cb1dc9d 100644 --- a/testsuites/psxtests/psxautoinit01/init.c +++ b/testsuites/psxtests/psxautoinit01/init.c @@ -54,12 +54,16 @@ void *POSIX_Init( mutex1 = PTHREAD_MUTEX_INITIALIZER; mutex2 = PTHREAD_MUTEX_INITIALIZER; puts( "Init - pthread_mutex_getprioceiling - auto initialize - OK" ); + prioceiling = 1; sc = pthread_mutex_getprioceiling( &mutex1, &prioceiling ); fatal_posix_service_status( sc, 0, "mutex getprioceiling OK" ); + rtems_test_assert( prioceiling == 0 ); puts( "Init - pthread_mutex_getprioceiling - auto initialize - EINVAL" ); + prioceiling = 1; sc = pthread_mutex_getprioceiling( &mutex2, &prioceiling ); fatal_posix_service_status( sc, EINVAL, "mutex getprioceiling EINVAL" ); + rtems_test_assert( prioceiling == 1 ); puts( "Init - pthread_mutex_destroy - OK" ); sc = pthread_mutex_destroy( &mutex1 ); diff --git a/testsuites/smptests/Makefile.am b/testsuites/smptests/Makefile.am index 9cefd268f1..66c2780260 100644 --- a/testsuites/smptests/Makefile.am +++ b/testsuites/smptests/Makefile.am @@ -45,6 +45,7 @@ SUBDIRS += smpwakeafter01 if HAS_POSIX SUBDIRS += smppsxaffinity01 SUBDIRS += smppsxaffinity02 +SUBDIRS += smppsxmutex01 SUBDIRS += smppsxsignal01 endif endif diff --git a/testsuites/smptests/configure.ac b/testsuites/smptests/configure.ac index 2ea9eec214..2e702522a5 100644 --- a/testsuites/smptests/configure.ac +++ b/testsuites/smptests/configure.ac @@ -57,6 +57,7 @@ AM_CONDITIONAL(HAS_CPUSET,test x"${ac_cv_header_sys_cpuset_h}" = x"yes") # Explicitly list all Makefiles here AC_CONFIG_FILES([Makefile +smppsxmutex01/Makefile smpstrongapa01/Makefile smp01/Makefile smp02/Makefile diff --git a/testsuites/smptests/smppsxmutex01/Makefile.am b/testsuites/smptests/smppsxmutex01/Makefile.am new file mode 100644 index 0000000000..0b09b16bd9 --- /dev/null +++ b/testsuites/smptests/smppsxmutex01/Makefile.am @@ -0,0 +1,19 @@ +rtems_tests_PROGRAMS = smppsxmutex01 +smppsxmutex01_SOURCES = init.c + +dist_rtems_tests_DATA = smppsxmutex01.scn smppsxmutex01.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(smppsxmutex01_OBJECTS) +LINK_LIBS = $(smppsxmutex01_LDLIBS) + +smppsxmutex01$(EXEEXT): $(smppsxmutex01_OBJECTS) $(smppsxmutex01_DEPENDENCIES) + @rm -f smppsxmutex01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/smptests/smppsxmutex01/init.c b/testsuites/smptests/smppsxmutex01/init.c new file mode 100644 index 0000000000..761b5b9d51 --- /dev/null +++ b/testsuites/smptests/smppsxmutex01/init.c @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include <errno.h> +#include <pthread.h> + +#include <rtems.h> +#include <rtems/libcsupport.h> + +#include "tmacros.h" + +const char rtems_test_name[] = "SMPPSXMUTEX 1"; + +#define SCHED_A rtems_build_name(' ', ' ', ' ', 'A') + +#define SCHED_B rtems_build_name(' ', ' ', ' ', 'B') + +typedef struct { + pthread_t thread_b; + pthread_mutexattr_t mtx_attr; + pthread_mutex_t mtx_a; + pthread_mutex_t mtx_b; +} test_context; + +static test_context test_instance; + +static void *thread_b(void *arg) +{ + test_context *ctx; + rtems_id scheduler_b_id; + rtems_status_code sc; + int prio_ceiling; + int eno; + + ctx = arg; + + rtems_test_assert(rtems_get_current_processor() == 0); + + sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_task_set_scheduler(pthread_self(), scheduler_b_id); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + rtems_test_assert(rtems_get_current_processor() == 1); + + eno = pthread_mutex_init(&ctx->mtx_b, &ctx->mtx_attr); + rtems_test_assert(eno == 0); + + eno = pthread_mutex_getprioceiling(&ctx->mtx_b, &prio_ceiling); + rtems_test_assert(eno == 0); + rtems_test_assert(prio_ceiling == 254); + + eno = pthread_mutex_lock(&ctx->mtx_b); + rtems_test_assert(eno == 0); + + eno = pthread_mutex_unlock(&ctx->mtx_b); + rtems_test_assert(eno == 0); + + eno = pthread_mutex_destroy(&ctx->mtx_b); + rtems_test_assert(eno == 0); + + eno = pthread_mutex_getprioceiling(&ctx->mtx_a, &prio_ceiling); + rtems_test_assert(eno == 0); + rtems_test_assert(prio_ceiling == 126); + + eno = pthread_mutex_lock(&ctx->mtx_a); + rtems_test_assert(eno == EINVAL); + + return ctx; +} + +static void test(test_context *ctx) +{ + uint32_t cpu_count; + int prio_ceiling; + int eno; + + cpu_count = rtems_get_processor_count(); + + rtems_test_assert(rtems_get_current_processor() == 0); + + eno = pthread_mutexattr_init(&ctx->mtx_attr); + rtems_test_assert(eno == 0); + + eno = pthread_mutexattr_setprotocol(&ctx->mtx_attr, PTHREAD_PRIO_PROTECT); + rtems_test_assert(eno == 0); + + eno = pthread_mutex_init(&ctx->mtx_a, &ctx->mtx_attr); + rtems_test_assert(eno == 0); + + eno = pthread_mutex_getprioceiling(&ctx->mtx_a, &prio_ceiling); + rtems_test_assert(eno == 0); + rtems_test_assert(prio_ceiling == 126); + + eno = pthread_mutex_lock(&ctx->mtx_a); + rtems_test_assert(eno == 0); + + eno = pthread_mutex_unlock(&ctx->mtx_a); + rtems_test_assert(eno == 0); + + if (cpu_count > 1) { + void *exit_code; + + eno = pthread_create(&ctx->thread_b, NULL, thread_b, ctx); + rtems_test_assert(eno == 0); + + exit_code = NULL; + eno = pthread_join(ctx->thread_b, &exit_code); + rtems_test_assert(eno == 0); + rtems_test_assert(exit_code == ctx); + } + + eno = pthread_mutex_destroy(&ctx->mtx_a); + rtems_test_assert(eno == 0); + + eno = pthread_mutexattr_destroy(&ctx->mtx_attr); + rtems_test_assert(eno == 0); +} + +static void *POSIX_Init(void *arg) +{ + rtems_resource_snapshot snapshot; + + TEST_BEGIN(); + + rtems_resource_snapshot_take(&snapshot); + + test(&test_instance); + + rtems_test_assert(rtems_resource_snapshot_check(&snapshot)); + + TEST_END(); + rtems_test_exit(0); +} + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 +#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2 + +#define CONFIGURE_SMP_APPLICATION + +#define CONFIGURE_SMP_MAXIMUM_PROCESSORS 2 + +#define CONFIGURE_SCHEDULER_PRIORITY_SMP + +#include <rtems/scheduler.h> + +RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP(a, 128); + +RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP(b, 256); + +#define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_PRIORITY_SMP(a, SCHED_A), \ + RTEMS_SCHEDULER_CONTROL_PRIORITY_SMP(b, SCHED_B) \ + +#define CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS \ + RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \ + RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL) + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/smptests/smppsxmutex01/smppsxmutex01.doc b/testsuites/smptests/smppsxmutex01/smppsxmutex01.doc new file mode 100644 index 0000000000..dd255daeda --- /dev/null +++ b/testsuites/smptests/smppsxmutex01/smppsxmutex01.doc @@ -0,0 +1,12 @@ +This file describes the directives and concepts tested by this test set. + +test set name: smppsxmutex01 + +directives: + + - pthread_mutex_lock() + +concepts: + + - Ensure that priority ceiling mutexes work only in their dedicated scheduler + instance. diff --git a/testsuites/smptests/smppsxmutex01/smppsxmutex01.scn b/testsuites/smptests/smppsxmutex01/smppsxmutex01.scn new file mode 100644 index 0000000000..e4c8a1a3ef --- /dev/null +++ b/testsuites/smptests/smppsxmutex01/smppsxmutex01.scn @@ -0,0 +1,2 @@ +*** BEGIN OF TEST SMPPSXMUTEX 1 *** +*** END OF TEST SMPPSXMUTEX 1 *** diff --git a/testsuites/smptests/smpscheduler02/init.c b/testsuites/smptests/smpscheduler02/init.c index 479e468147..52b3f61816 100644 --- a/testsuites/smptests/smpscheduler02/init.c +++ b/testsuites/smptests/smpscheduler02/init.c @@ -35,6 +35,8 @@ const char rtems_test_name[] = "SMPSCHEDULER 2"; static rtems_id main_task_id; +static rtems_id sema_id; + static void task(rtems_task_argument arg) { rtems_status_code sc; @@ -45,6 +47,9 @@ static void task(rtems_task_argument arg) rtems_test_assert(sched_get_priority_min(SCHED_RR) == 1); rtems_test_assert(sched_get_priority_max(SCHED_RR) == 126); + sc = rtems_semaphore_obtain(sema_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT); + rtems_test_assert(sc == RTEMS_NOT_DEFINED); + sc = rtems_event_transient_send(main_task_id); rtems_test_assert(sc == RTEMS_SUCCESSFUL); @@ -61,6 +66,7 @@ static void test(void) rtems_id scheduler_a_id; rtems_id scheduler_b_id; rtems_id scheduler_c_id; + rtems_task_priority prio; cpu_set_t cpuset; cpu_set_t first_cpu; cpu_set_t second_cpu; @@ -95,6 +101,27 @@ static void test(void) sc = rtems_scheduler_ident(SCHED_C, &scheduler_c_id); rtems_test_assert(sc == RTEMS_UNSATISFIED); + sc = rtems_semaphore_create( + SCHED_A, + 1, + RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING, + 1, + &sema_id + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + prio = 2; + sc = rtems_semaphore_set_priority(sema_id, scheduler_a_id, prio, &prio); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + rtems_test_assert(prio == 1); + + if (cpu_count > 1) { + prio = 1; + sc = rtems_semaphore_set_priority(sema_id, scheduler_b_id, prio, &prio); + rtems_test_assert(sc == RTEMS_NOT_DEFINED); + rtems_test_assert(prio == 2); + } + CPU_ZERO(&cpuset); sc = rtems_scheduler_get_processor_set( scheduler_a_id, @@ -182,6 +209,9 @@ static void test(void) sc = rtems_task_delete(task_id); rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_semaphore_delete(sema_id); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); } #else /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */ @@ -212,6 +242,9 @@ static void Init(rtems_task_argument arg) #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_MAXIMUM_TASKS 2 +#define CONFIGURE_MAXIMUM_SEMAPHORES 1 + #define CONFIGURE_SMP_APPLICATION /* Lets see when the first RTEMS system hits this limit */ @@ -269,8 +302,6 @@ RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP(c); RTEMS_SCHEDULER_ASSIGN_NO_SCHEDULER, \ RTEMS_SCHEDULER_ASSIGN(2, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL) -#define CONFIGURE_MAXIMUM_TASKS 2 - #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |