[PATCH] Add Strong APA test
Gedare Bloom
gedare at rtems.org
Wed Aug 19 16:38:41 UTC 2020
Hi Richi,
On Wed, Aug 19, 2020 at 9:52 AM Richi Dubey <richidubey at gmail.com> wrote:
>
> Hi,
>
> I would request someone to please verify if this patch looks correct since I am testing my code on this test. The logic is taken from the paper and I was wondering if the reset function is handled correctly in this test because I still have a little hard time understanding how (and why) we are reordering the idle threads. Please let me know if there's anything that looks astray.
>
The test logic makes sense to me. The only question I have is whether
SET_PRIORITY( T2,P(2), T2, T1, T0),
could also be
SET_PRIORITY( T2,P(2), T2, T0, T1),
I don't know these tests well enough to say for sure about what
reset() is doing. It looks to be suspending every task, resuming 1
task on every CPU, and then suspending that task (assuming there is
only 1 runnable non-idle task on each CPU, and therefore executing ==
heir).
> Also, the same test can be accessed from this link: https://github.com/richidubey/rtems/blob/Strong-APA-v1.3/testsuites/smptests/smpstrongapa01/init.c
>
> Thanks,
> Richi.
>
> On Wed, Aug 19, 2020 at 9:18 PM Richi Dubey <richidubey at gmail.com> wrote:
>>
>> ---
>> testsuites/smptests/smpstrongapa01/init.c | 85 +++++++++++++----------
>> 1 file changed, 49 insertions(+), 36 deletions(-)
>>
>> diff --git a/testsuites/smptests/smpstrongapa01/init.c b/testsuites/smptests/smpstrongapa01/init.c
>> index bf8bc05231..89cc6404b9 100644
>> --- a/testsuites/smptests/smpstrongapa01/init.c
>> +++ b/testsuites/smptests/smpstrongapa01/init.c
>> @@ -1,38 +1,40 @@
>> /*
>> - * Copyright (c) 2016, 2017 embedded brains GmbH. All rights reserved.
>> + * Copyright (c) 2020 Richi Dubey
>> + * All rights reserved.
>> *
>> - * embedded brains GmbH
>> - * Dornierstr. 4
>> - * 82178 Puchheim
>> - * Germany
>> - * <rtems at embedded-brains.de>
>> + * richidubey at gmail.com
>> *
>> * 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 "tmacros.h"
>> +#include <tmacros.h>
>>
>> #include <rtems.h>
>>
>> const char rtems_test_name[] = "SMPSTRONGAPA 1";
>>
>> -#define CPU_COUNT 4
>> +#define CPU_COUNT 3
>>
>> -#define TASK_COUNT (3 * CPU_COUNT)
>> +#define TASK_COUNT 4
>>
>> #define P(i) (UINT32_C(2) + i)
>>
>> #define ALL ((UINT32_C(1) << CPU_COUNT) - 1)
>>
>> -#define IDLE UINT8_C(255)
>> +#define A(cpu0, cpu1, cpu2) ((cpu2 << 2) | (cpu1 << 1) | cpu0)
>>
>> -#define NAME rtems_build_name('S', 'A', 'P', 'A')
>> +typedef enum {
>> + T0,
>> + T1,
>> + T2,
>> + T3,
>> + IDLE
>> +} task_index;
>>
>> typedef struct {
>> enum {
>> @@ -43,7 +45,7 @@ typedef struct {
>> KIND_UNBLOCK
>> } kind;
>>
>> - size_t index;
>> + task_index index;
>>
>> struct {
>> rtems_task_priority priority;
>> @@ -65,54 +67,62 @@ typedef struct {
>> KIND_RESET, \
>> 0, \
>> { 0 }, \
>> - { IDLE, IDLE, IDLE, IDLE } \
>> + { IDLE, IDLE, IDLE} \
>> }
>>
>> -#define SET_PRIORITY(index, prio, cpu0, cpu1, cpu2, cpu3) \
>> +#define SET_PRIORITY(index, prio, cpu0, cpu1, cpu2) \
>> { \
>> KIND_SET_PRIORITY, \
>> index, \
>> { .priority = prio }, \
>> - { cpu0, cpu1, cpu2, cpu3 } \
>> + { cpu0, cpu1, cpu2 } \
>> }
>>
>> -#define SET_AFFINITY(index, aff, cpu0, cpu1, cpu2, cpu3) \
>> +#define SET_AFFINITY(index, aff, cpu0, cpu1, cpu2) \
>> { \
>> KIND_SET_AFFINITY, \
>> index, \
>> { .cpu_set = aff }, \
>> - { cpu0, cpu1, cpu2, cpu3 } \
>> + { cpu0, cpu1, cpu2 } \
>> }
>>
>> -#define BLOCK(index, cpu0, cpu1, cpu2, cpu3) \
>> +#define BLOCK(index, cpu0, cpu1, cpu2) \
>> { \
>> KIND_BLOCK, \
>> index, \
>> { 0 }, \
>> - { cpu0, cpu1, cpu2, cpu3 } \
>> + { cpu0, cpu1, cpu2 } \
>> }
>>
>> -#define UNBLOCK(index, cpu0, cpu1, cpu2, cpu3) \
>> +#define UNBLOCK(index, cpu0, cpu1, cpu2) \
>> { \
>> KIND_UNBLOCK, \
>> index, \
>> { 0 }, \
>> - { cpu0, cpu1, cpu2, cpu3 } \
>> + { cpu0, cpu1, cpu2 } \
>> }
>>
>> static const test_action test_actions[] = {
>> RESET,
>> - UNBLOCK( 0, 0, IDLE, IDLE, IDLE),
>> - UNBLOCK( 1, 0, 1, IDLE, IDLE),
>> - UNBLOCK( 2, 0, 1, 2, IDLE),
>> - UNBLOCK( 3, 0, 1, 2, 3),
>> - UNBLOCK( 5, 0, 1, 2, 3),
>> - SET_PRIORITY( 3, P(4), 0, 1, 2, 3),
>> - SET_PRIORITY( 5, P(3), 0, 1, 2, 5),
>> - BLOCK( 5, 0, 1, 2, 3),
>> - SET_AFFINITY( 5, ALL, 0, 1, 2, 3),
>> - RESET,
>> - UNBLOCK( 0, 0, IDLE, IDLE, IDLE),
>> + UNBLOCK( T0, T0, IDLE, IDLE),
>> + UNBLOCK( T1, T0, T1, IDLE),
>> + UNBLOCK( T2, T0, T1, T2),
>> + UNBLOCK( T3, T0, T1, T2),
>> + SET_PRIORITY( T0, P(0), T0, T1, T2),
>> + SET_PRIORITY( T1, P(1), T0, T1, T2),
>> + SET_PRIORITY( T3, P(3), T0, T1, T2),
>> + /*
>> + * Introduce Task 2 intially with lowest priority to imitate late arrival
>> + */
>> + SET_PRIORITY( T2, P(4), T0, T1, T3),
>> + SET_AFFINITY( T0, ALL, T0, T1, T3),
>> + SET_AFFINITY( T1, A(0, 1, 1), T0, T1, T3),
>> + SET_AFFINITY( T2, A(1, 0, 0), T0, T1, T3),
>> + SET_AFFINITY( T3, A(0, 1, 1), T0, T1, T3),
>> + /*
>> + * Show that higher priority task gets dislodged from its processor
>> + */
>> + SET_PRIORITY( T2, P(2), T2, T1, T0),
>> RESET
>> };
>>
>> @@ -182,7 +192,7 @@ static void check_cpu_allocations(test_context *ctx, const test_action *action)
>> size_t i;
>>
>> for (i = 0; i < CPU_COUNT; ++i) {
>> - size_t e;
>> + task_index e;
>> const Per_CPU_Control *c;
>> const Thread_Control *h;
>>
>> @@ -279,7 +289,7 @@ static void test(void)
>>
>> for (i = 0; i < TASK_COUNT; ++i) {
>> sc = rtems_task_create(
>> - NAME,
>> + rtems_build_name(' ', ' ', 'T', '0' + i),
>> P(i),
>> RTEMS_MINIMUM_STACK_SIZE,
>> RTEMS_DEFAULT_MODES,
>> @@ -292,7 +302,10 @@ static void test(void)
>> rtems_test_assert(sc == RTEMS_SUCCESSFUL);
>> }
>>
>> - sc = rtems_timer_create(NAME, &ctx->timer_id);
>> + sc = rtems_timer_create(
>> + rtems_build_name('A', 'C', 'T', 'N'),
>> + &ctx->timer_id
>> + );
>> rtems_test_assert(sc == RTEMS_SUCCESSFUL);
>>
>> sc = rtems_timer_fire_after(ctx->timer_id, 1, timer, ctx);
>> --
>> 2.17.1
>>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
More information about the devel
mailing list