<div dir="ltr">Hi,<div><br></div><div>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 <a href="https://people.mpi-sws.org/~bbb/papers/pdf/rtss14f.pdf">paper</a> 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.</div><div><br></div><div>Also, the same test can be accessed from this link: <a href="https://github.com/richidubey/rtems/blob/Strong-APA-v1.3/testsuites/smptests/smpstrongapa01/init.c">https://github.com/richidubey/rtems/blob/Strong-APA-v1.3/testsuites/smptests/smpstrongapa01/init.c</a></div><div><br></div><div>Thanks,</div><div>Richi.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 19, 2020 at 9:18 PM Richi Dubey <<a href="mailto:richidubey@gmail.com">richidubey@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">---<br>
testsuites/smptests/smpstrongapa01/init.c | 85 +++++++++++++----------<br>
1 file changed, 49 insertions(+), 36 deletions(-)<br>
<br>
diff --git a/testsuites/smptests/smpstrongapa01/init.c b/testsuites/smptests/smpstrongapa01/init.c<br>
index bf8bc05231..89cc6404b9 100644<br>
--- a/testsuites/smptests/smpstrongapa01/init.c<br>
+++ b/testsuites/smptests/smpstrongapa01/init.c<br>
@@ -1,38 +1,40 @@<br>
/*<br>
- * Copyright (c) 2016, 2017 embedded brains GmbH. All rights reserved.<br>
+ * Copyright (c) 2020 Richi Dubey <br>
+ * All rights reserved.<br>
*<br>
- * embedded brains GmbH<br>
- * Dornierstr. 4<br>
- * 82178 Puchheim<br>
- * Germany<br>
- * <<a href="mailto:rtems@embedded-brains.de" target="_blank">rtems@embedded-brains.de</a>><br>
+ * <a href="mailto:richidubey@gmail.com" target="_blank">richidubey@gmail.com</a><br>
*<br>
* The license and distribution terms for this file may be<br>
* found in the file LICENSE in this distribution or at<br>
* <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a>.<br>
*/<br>
-<br>
#ifdef HAVE_CONFIG_H<br>
#include "config.h"<br>
#endif<br>
<br>
-#include "tmacros.h"<br>
+#include <tmacros.h><br>
<br>
#include <rtems.h><br>
<br>
const char rtems_test_name[] = "SMPSTRONGAPA 1";<br>
<br>
-#define CPU_COUNT 4<br>
+#define CPU_COUNT 3<br>
<br>
-#define TASK_COUNT (3 * CPU_COUNT)<br>
+#define TASK_COUNT 4<br>
<br>
#define P(i) (UINT32_C(2) + i)<br>
<br>
#define ALL ((UINT32_C(1) << CPU_COUNT) - 1)<br>
<br>
-#define IDLE UINT8_C(255)<br>
+#define A(cpu0, cpu1, cpu2) ((cpu2 << 2) | (cpu1 << 1) | cpu0)<br>
<br>
-#define NAME rtems_build_name('S', 'A', 'P', 'A')<br>
+typedef enum {<br>
+ T0,<br>
+ T1,<br>
+ T2,<br>
+ T3,<br>
+ IDLE<br>
+} task_index;<br>
<br>
typedef struct {<br>
enum {<br>
@@ -43,7 +45,7 @@ typedef struct {<br>
KIND_UNBLOCK<br>
} kind;<br>
<br>
- size_t index;<br>
+ task_index index;<br>
<br>
struct {<br>
rtems_task_priority priority;<br>
@@ -65,54 +67,62 @@ typedef struct {<br>
KIND_RESET, \<br>
0, \<br>
{ 0 }, \<br>
- { IDLE, IDLE, IDLE, IDLE } \<br>
+ { IDLE, IDLE, IDLE} \<br>
}<br>
<br>
-#define SET_PRIORITY(index, prio, cpu0, cpu1, cpu2, cpu3) \<br>
+#define SET_PRIORITY(index, prio, cpu0, cpu1, cpu2) \<br>
{ \<br>
KIND_SET_PRIORITY, \<br>
index, \<br>
{ .priority = prio }, \<br>
- { cpu0, cpu1, cpu2, cpu3 } \<br>
+ { cpu0, cpu1, cpu2 } \<br>
}<br>
<br>
-#define SET_AFFINITY(index, aff, cpu0, cpu1, cpu2, cpu3) \<br>
+#define SET_AFFINITY(index, aff, cpu0, cpu1, cpu2) \<br>
{ \<br>
KIND_SET_AFFINITY, \<br>
index, \<br>
{ .cpu_set = aff }, \<br>
- { cpu0, cpu1, cpu2, cpu3 } \<br>
+ { cpu0, cpu1, cpu2 } \<br>
}<br>
<br>
-#define BLOCK(index, cpu0, cpu1, cpu2, cpu3) \<br>
+#define BLOCK(index, cpu0, cpu1, cpu2) \<br>
{ \<br>
KIND_BLOCK, \<br>
index, \<br>
{ 0 }, \<br>
- { cpu0, cpu1, cpu2, cpu3 } \<br>
+ { cpu0, cpu1, cpu2 } \<br>
}<br>
<br>
-#define UNBLOCK(index, cpu0, cpu1, cpu2, cpu3) \<br>
+#define UNBLOCK(index, cpu0, cpu1, cpu2) \<br>
{ \<br>
KIND_UNBLOCK, \<br>
index, \<br>
{ 0 }, \<br>
- { cpu0, cpu1, cpu2, cpu3 } \<br>
+ { cpu0, cpu1, cpu2 } \<br>
}<br>
<br>
static const test_action test_actions[] = {<br>
RESET,<br>
- UNBLOCK( 0, 0, IDLE, IDLE, IDLE),<br>
- UNBLOCK( 1, 0, 1, IDLE, IDLE),<br>
- UNBLOCK( 2, 0, 1, 2, IDLE),<br>
- UNBLOCK( 3, 0, 1, 2, 3),<br>
- UNBLOCK( 5, 0, 1, 2, 3),<br>
- SET_PRIORITY( 3, P(4), 0, 1, 2, 3),<br>
- SET_PRIORITY( 5, P(3), 0, 1, 2, 5),<br>
- BLOCK( 5, 0, 1, 2, 3),<br>
- SET_AFFINITY( 5, ALL, 0, 1, 2, 3),<br>
- RESET,<br>
- UNBLOCK( 0, 0, IDLE, IDLE, IDLE),<br>
+ UNBLOCK( T0, T0, IDLE, IDLE),<br>
+ UNBLOCK( T1, T0, T1, IDLE),<br>
+ UNBLOCK( T2, T0, T1, T2),<br>
+ UNBLOCK( T3, T0, T1, T2),<br>
+ SET_PRIORITY( T0, P(0), T0, T1, T2),<br>
+ SET_PRIORITY( T1, P(1), T0, T1, T2),<br>
+ SET_PRIORITY( T3, P(3), T0, T1, T2),<br>
+ /*<br>
+ * Introduce Task 2 intially with lowest priority to imitate late arrival<br>
+ */<br>
+ SET_PRIORITY( T2, P(4), T0, T1, T3), <br>
+ SET_AFFINITY( T0, ALL, T0, T1, T3),<br>
+ SET_AFFINITY( T1, A(0, 1, 1), T0, T1, T3),<br>
+ SET_AFFINITY( T2, A(1, 0, 0), T0, T1, T3),<br>
+ SET_AFFINITY( T3, A(0, 1, 1), T0, T1, T3),<br>
+ /*<br>
+ * Show that higher priority task gets dislodged from its processor<br>
+ */<br>
+ SET_PRIORITY( T2, P(2), T2, T1, T0),<br>
RESET<br>
};<br>
<br>
@@ -182,7 +192,7 @@ static void check_cpu_allocations(test_context *ctx, const test_action *action)<br>
size_t i;<br>
<br>
for (i = 0; i < CPU_COUNT; ++i) {<br>
- size_t e;<br>
+ task_index e;<br>
const Per_CPU_Control *c;<br>
const Thread_Control *h;<br>
<br>
@@ -279,7 +289,7 @@ static void test(void)<br>
<br>
for (i = 0; i < TASK_COUNT; ++i) {<br>
sc = rtems_task_create(<br>
- NAME,<br>
+ rtems_build_name(' ', ' ', 'T', '0' + i),<br>
P(i),<br>
RTEMS_MINIMUM_STACK_SIZE,<br>
RTEMS_DEFAULT_MODES,<br>
@@ -292,7 +302,10 @@ static void test(void)<br>
rtems_test_assert(sc == RTEMS_SUCCESSFUL);<br>
}<br>
<br>
- sc = rtems_timer_create(NAME, &ctx->timer_id);<br>
+ sc = rtems_timer_create(<br>
+ rtems_build_name('A', 'C', 'T', 'N'),<br>
+ &ctx->timer_id<br>
+ );<br>
rtems_test_assert(sc == RTEMS_SUCCESSFUL);<br>
<br>
sc = rtems_timer_fire_after(ctx->timer_id, 1, timer, ctx);<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div>