All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] [PATCH 0 of 3 v2] Xenomai-forge thread_obj: unset __THREAD_S_SAFE when not needed
@ 2013-10-21 14:09 Kim De Mey
  2013-10-21 14:09 ` [Xenomai] [PATCH 1 of 3 v2] Xenomai-forge thread_obj: Do not set " Kim De Mey
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kim De Mey @ 2013-10-21 14:09 UTC (permalink / raw)
  To: xenomai

Adjusted patches after feedback & suggestions:

PATCH 1: Setting the __THREAD_S_SAFE for thobj->status is done later 
only when necessary.

PATCH 2: Add warning when pipe() system call fails + assert on return 
value of notifier_init().

PATCH 3: Extends task-9 with 3 more test loops (of which two make the
error that PATCH 1 solves occur). 


 lib/copperplate/notifier.c  |   5 ++++-
 lib/copperplate/threadobj.c |   6 ++++--
 lib/psos/testsuite/task-9.c |  38 ++++++++++++++++++++++++++++++++++++--
 3 files changed, 44 insertions(+), 5 deletions(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Xenomai] [PATCH 1 of 3 v2] Xenomai-forge thread_obj: Do not set __THREAD_S_SAFE when not needed
  2013-10-21 14:09 [Xenomai] [PATCH 0 of 3 v2] Xenomai-forge thread_obj: unset __THREAD_S_SAFE when not needed Kim De Mey
@ 2013-10-21 14:09 ` Kim De Mey
  2013-10-21 14:09 ` [Xenomai] [PATCH 2 of 3 v2] Xenomai-forge notifier_init: warning on failed pipe Kim De Mey
  2013-10-21 14:09 ` [Xenomai] [PATCH 3 of 3 v2] Xenomai-forge extend psos testsuite task-9 Kim De Mey
  2 siblings, 0 replies; 4+ messages in thread
From: Kim De Mey @ 2013-10-21 14:09 UTC (permalink / raw)
  To: xenomai

Do not set __THREAD_S_SAFE for thobj->status when the priority
of the task is lower than the priority of the current task.

Signed-off-by: Kim De Mey <kim.demey@gmail.com>

---

 lib/copperplate/threadobj.c |  3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -926,7 +926,7 @@ int threadobj_start(struct threadobj *th
 	if (thobj->status & __THREAD_S_STARTED)
 		return 0;
 
-	thobj->status |= __THREAD_S_STARTED|__THREAD_S_SAFE;
+	thobj->status |= __THREAD_S_STARTED;
 	__RT(pthread_cond_signal(&thobj->barrier));
 
 	if (current && thobj->priority <= current->priority)
@@ -943,6 +943,7 @@ int threadobj_start(struct threadobj *th
 	 */
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
 
+	thobj->status |= __THREAD_S_SAFE;
 	wait_on_barrier(thobj, __THREAD_S_ACTIVE);
 	thobj->status &= ~__THREAD_S_SAFE;
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Xenomai] [PATCH 2 of 3 v2] Xenomai-forge notifier_init: warning on failed pipe
  2013-10-21 14:09 [Xenomai] [PATCH 0 of 3 v2] Xenomai-forge thread_obj: unset __THREAD_S_SAFE when not needed Kim De Mey
  2013-10-21 14:09 ` [Xenomai] [PATCH 1 of 3 v2] Xenomai-forge thread_obj: Do not set " Kim De Mey
@ 2013-10-21 14:09 ` Kim De Mey
  2013-10-21 14:09 ` [Xenomai] [PATCH 3 of 3 v2] Xenomai-forge extend psos testsuite task-9 Kim De Mey
  2 siblings, 0 replies; 4+ messages in thread
From: Kim De Mey @ 2013-10-21 14:09 UTC (permalink / raw)
  To: xenomai

Give a warning if one of the pipe() system calls fails. To indicate that there
is an underlying problem. Also add an assert on the notifier_init return
value in threadobj_setup_coresp.

Signed-off-by: Kim De Mey <kim.demey@gmail.com>

---

 lib/copperplate/notifier.c  |  5 ++++-
 lib/copperplate/threadobj.c |  3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/copperplate/notifier.c b/lib/copperplate/notifier.c
--- a/lib/copperplate/notifier.c
+++ b/lib/copperplate/notifier.c
@@ -143,10 +143,13 @@ int notifier_init(struct notifier *nf,
 	sigset_t oset;
 	int fd;
 
-	if (pipe(nf->psfd) < 0)
+	if (pipe(nf->psfd) < 0) {
+		warning("failed to create file descriptors");
 		return __bt(-errno);
+	}
 
 	if (pipe(nf->pwfd) < 0) {
+		warning("failed to create file descriptors");
 		__STD(close(nf->psfd[0]));
 		__STD(close(nf->psfd[1]));
 		return __bt(-errno);
diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -449,7 +449,8 @@ static inline int threadobj_setup_coresp
 	int ret;
 
 	prctl(PR_SET_NAME, (unsigned long)thobj->name, 0, 0, 0);
-	notifier_init(&thobj->core.notifier, notifier_callback, 1);
+	ret = notifier_init(&thobj->core.notifier, notifier_callback, 1);
+	assert(ret == 0);
 	thobj->core.period = 0;
 
 	/*


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Xenomai] [PATCH 3 of 3 v2] Xenomai-forge extend psos testsuite task-9
  2013-10-21 14:09 [Xenomai] [PATCH 0 of 3 v2] Xenomai-forge thread_obj: unset __THREAD_S_SAFE when not needed Kim De Mey
  2013-10-21 14:09 ` [Xenomai] [PATCH 1 of 3 v2] Xenomai-forge thread_obj: Do not set " Kim De Mey
  2013-10-21 14:09 ` [Xenomai] [PATCH 2 of 3 v2] Xenomai-forge notifier_init: warning on failed pipe Kim De Mey
@ 2013-10-21 14:09 ` Kim De Mey
  2 siblings, 0 replies; 4+ messages in thread
From: Kim De Mey @ 2013-10-21 14:09 UTC (permalink / raw)
  To: xenomai

Extend the task-9 test with different root task priorities and
with both incrementing and decrementing priorities for the test tasks.

Signed-off-by: Kim De Mey <kim.demey@gmail.com>

---

 lib/psos/testsuite/task-9.c |  38 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/lib/psos/testsuite/task-9.c b/lib/psos/testsuite/task-9.c
--- a/lib/psos/testsuite/task-9.c
+++ b/lib/psos/testsuite/task-9.c
@@ -14,7 +14,7 @@ static void test_task(u_long a0, u_long 
 	traceobj_exit(&trobj);
 }
 
-static void root_task(u_long a0, u_long a1, u_long a2, u_long a3)
+static void root_task(u_long increment, u_long a1, u_long a2, u_long a3)
 {
 	u_long args[] = { 1, 2, 3, 4 }, ret, tid;
 	int n;
@@ -22,7 +22,10 @@ static void root_task(u_long a0, u_long 
 	traceobj_enter(&trobj);
 
 	for (n = 0; n < 512; n++) {
-		ret = t_create ("TEST", (n % MAX_PRIO) + 2,100000, 0, 0, &tid);
+		if(increment)
+			ret = t_create ("TEST", (n % MAX_PRIO) + 2,100000, 0, 0, &tid);
+		else
+			ret = t_create ("TEST", MAX_PRIO - (n % MAX_PRIO) + 1,100000, 0, 0, &tid);
 		traceobj_assert(&trobj, ret == SUCCESS);
 		ret = t_start(tid, T_PREEMPT, test_task, args);
 		traceobj_assert(&trobj, ret == SUCCESS);
@@ -39,6 +42,7 @@ int main(int argc, char *const argv[])
 
 	traceobj_init(&trobj, argv[0], 0);
 
+	// Low priority root task, loop incr. priority test tasks
 	ret = t_create("root", 3, 0, 0, 0, &tid);
 	traceobj_assert(&trobj, ret == SUCCESS);
 
@@ -47,5 +51,35 @@ int main(int argc, char *const argv[])
 
 	traceobj_join(&trobj);
 
+	// Low priority root task, loop decr. priority test tasks
+	args[0] = 0;
+	ret = t_create("root", 3, 0, 0, 0, &tid);
+	traceobj_assert(&trobj, ret == SUCCESS);
+
+	ret = t_start(tid, 0, root_task, args);
+	traceobj_assert(&trobj, ret == SUCCESS);
+
+	traceobj_join(&trobj);
+
+	// High priority root task, loop incr. priority test tasks
+	args[0] = 1;
+	ret = t_create("root", 90, 0, 0, 0, &tid);
+	traceobj_assert(&trobj, ret == SUCCESS);
+
+	ret = t_start(tid, 0, root_task, args);
+	traceobj_assert(&trobj, ret == SUCCESS);
+
+	traceobj_join(&trobj);
+
+	// High priority root task, loop decr. priority test tasks 
+	args[0] = 0;
+	ret = t_create("root", 90, 0, 0, 0, &tid);
+	traceobj_assert(&trobj, ret == SUCCESS);
+
+	ret = t_start(tid, 0, root_task, args);
+	traceobj_assert(&trobj, ret == SUCCESS);
+	
+	traceobj_join(&trobj);
+
 	exit(0);
 }


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-21 14:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-21 14:09 [Xenomai] [PATCH 0 of 3 v2] Xenomai-forge thread_obj: unset __THREAD_S_SAFE when not needed Kim De Mey
2013-10-21 14:09 ` [Xenomai] [PATCH 1 of 3 v2] Xenomai-forge thread_obj: Do not set " Kim De Mey
2013-10-21 14:09 ` [Xenomai] [PATCH 2 of 3 v2] Xenomai-forge notifier_init: warning on failed pipe Kim De Mey
2013-10-21 14:09 ` [Xenomai] [PATCH 3 of 3 v2] Xenomai-forge extend psos testsuite task-9 Kim De Mey

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.