summaryrefslogtreecommitdiffstats
path: root/testsuites/smptests/smpmigration02
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-06-30 14:08:18 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-07-01 11:51:49 +0200
commitc0bd0064ac41f0602c0abfe494dbe140d7c5282f (patch)
treeaaa200033234cf2d3833305f13565171521b0d26 /testsuites/smptests/smpmigration02
parentscore: Workaround for #2751 (diff)
downloadrtems-c0bd0064ac41f0602c0abfe494dbe140d7c5282f.tar.bz2
rtems: Fix rtems_task_set_scheduler() API
Task priorities are only valid within a scheduler instance. The rtems_task_set_scheduler() directive moves a task from one scheduler instance to another using the current priority of the thread. However, the current task priority of the source scheduler instance is undefined in the target scheduler instance. Add a third parameter to specify the priority. Close #2749.
Diffstat (limited to 'testsuites/smptests/smpmigration02')
-rw-r--r--testsuites/smptests/smpmigration02/init.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/testsuites/smptests/smpmigration02/init.c b/testsuites/smptests/smpmigration02/init.c
index 3af8283518..193d5992e7 100644
--- a/testsuites/smptests/smpmigration02/init.c
+++ b/testsuites/smptests/smpmigration02/init.c
@@ -46,20 +46,32 @@ typedef struct {
static test_context test_instance;
+static rtems_task_priority migration_task_prio(uint32_t task_index)
+{
+ return task_index > 0 ? PRIO_LOW : PRIO_HIGH;
+}
+
static void migration_task(rtems_task_argument arg)
{
test_context *ctx = &test_instance;
- rtems_status_code sc;
+ uint32_t task_index = arg;
+ rtems_task_priority prio = migration_task_prio(task_index);
uint32_t cpu_count = rtems_get_processor_count();
uint32_t cpu_index = rtems_get_current_processor();
while (true) {
+ rtems_status_code sc;
+
cpu_index = (cpu_index + 1) % cpu_count;
- sc = rtems_task_set_scheduler(RTEMS_SELF, ctx->scheduler_ids[cpu_index]);
+ sc = rtems_task_set_scheduler(
+ RTEMS_SELF,
+ ctx->scheduler_ids[cpu_index],
+ prio
+ );
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
- ++ctx->counters[arg].value;
+ ++ctx->counters[task_index].value;
rtems_test_assert(cpu_index == rtems_get_current_processor());
}
@@ -77,7 +89,7 @@ static void test_migrations(test_context *ctx)
sc = rtems_task_create(
rtems_build_name('T', 'A', 'S', 'K'),
- task_index > 0 ? PRIO_LOW : PRIO_HIGH,
+ 255,
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES,
@@ -85,7 +97,11 @@ static void test_migrations(test_context *ctx)
);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
- sc = rtems_task_set_scheduler(task_id, ctx->scheduler_ids[task_index % cpu_count]);
+ sc = rtems_task_set_scheduler(
+ task_id,
+ ctx->scheduler_ids[task_index % cpu_count],
+ migration_task_prio(task_index)
+ );
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
sc = rtems_task_start(task_id, migration_task, task_index);
@@ -163,7 +179,8 @@ static void test_double_migration(test_context *ctx)
sc = rtems_task_set_scheduler(
task_id,
- ctx->scheduler_ids[cpu_other_index]
+ ctx->scheduler_ids[cpu_other_index],
+ 2
);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -189,7 +206,8 @@ static void test_double_migration(test_context *ctx)
sc = rtems_task_set_scheduler(
RTEMS_SELF,
- ctx->scheduler_ids[cpu_other_index]
+ ctx->scheduler_ids[cpu_other_index],
+ 1
);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -207,7 +225,8 @@ static void test_double_migration(test_context *ctx)
sc = rtems_task_set_scheduler(
RTEMS_SELF,
- ctx->scheduler_ids[cpu_self_index]
+ ctx->scheduler_ids[cpu_self_index],
+ 1
);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);