All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-core] [PATCH v2 1/4] POSIX: Fix SCHED_RR thread creation
Date: Tue, 17 Feb 2009 18:04:19 +0100	[thread overview]
Message-ID: <20090217170419.1425.15313.stgit@domain.hid> (raw)
In-Reply-To: <20090217170418.1425.56126.stgit@domain.hid>

SCHED_RR threads created via pthread_create do not receive the
round-robin property at kernel side. Fix this by pushing the policy as
an additional argument to __pse51_thread_create down to the kernel.
Moreover, enforce SCHED_FIFO for the Linux part of those threads.

Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---

 ksrc/skins/posix/syscall.c |    4 ++--
 src/skins/posix/thread.c   |   11 ++++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/ksrc/skins/posix/syscall.c b/ksrc/skins/posix/syscall.c
index 99c2a16..3480142 100644
--- a/ksrc/skins/posix/syscall.c
+++ b/ksrc/skins/posix/syscall.c
@@ -167,7 +167,7 @@ static int __pthread_create(struct pt_regs *regs)
 	   calling context. */
 
 	pthread_attr_init(&attr);
-	attr.policy = p->policy;
+	attr.policy = __xn_reg_arg2(regs);
 	attr.detachstate = PTHREAD_CREATE_DETACHED;
 	attr.schedparam_ex.sched_priority = p->rt_priority;
 	attr.fp = 1;
@@ -179,7 +179,7 @@ static int __pthread_create(struct pt_regs *regs)
 		return -err;	/* Conventionally, our error codes are negative. */
 
 	err = xnshadow_map(&k_tid->threadbase, NULL,
-			   (unsigned long __user *)__xn_reg_arg2(regs));
+			   (unsigned long __user *)__xn_reg_arg3(regs));
 
 	if (!err && !__pthread_hash(&hkey, k_tid))
 		err = -ENOMEM;
diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c
index f32c7e1..4cf4e1c 100644
--- a/src/skins/posix/thread.c
+++ b/src/skins/posix/thread.c
@@ -192,6 +192,9 @@ static void *__pthread_trampoline(void *arg)
 
 	param.sched_priority = iargs->prio;
 	policy = iargs->policy;
+	if (policy == SCHED_RR)
+		/* Restrict round-robin scheduling to the Xenomai domain. */
+		policy = SCHED_FIFO;
 	parent_prio = iargs->parent_prio;
 	mode_buf = xeno_init_current_mode();
 
@@ -203,8 +206,8 @@ static void *__pthread_trampoline(void *arg)
 
 	/* Do _not_ inline the call to pthread_self() in the syscall
 	   macro: this trashes the syscall regs on some archs. */
-	err = XENOMAI_SKINCALL2(__pse51_muxid, __pse51_thread_create, tid,
-				mode_buf);
+	err = XENOMAI_SKINCALL3(__pse51_muxid, __pse51_thread_create, tid,
+				iargs->policy, mode_buf);
 	iargs->ret = -err;
 
 	/* We must save anything we'll need to use from *iargs on our own
@@ -221,9 +224,7 @@ static void *__pthread_trampoline(void *arg)
 	__real_sem_post(&iargs->sync);
 
 	if (!err) {
-		/* Broken pthread libs ignore some of the thread attribute specs
-		   passed to pthread_create(3), so we force the scheduling policy
-		   once again here. */
+		/* Adjust to final Linux policy and priority. */
 		__real_pthread_setschedparam(tid, policy, &param);
 
 		/* If the thread running pthread_create runs with the same



  parent reply	other threads:[~2009-02-17 17:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-17 17:04 [Xenomai-core] [PATCH v2 0/4] Various fixes and cleanups Jan Kiszka
2009-02-17 17:04 ` [Xenomai-core] [PATCH v2 2/4] Mark libs nodlopen on initial-exec TLS Jan Kiszka
2009-02-17 17:04 ` [Xenomai-core] [PATCH v2 3/4] Add --enable-dlopen-skins configure switch Jan Kiszka
2009-02-17 17:04 ` Jan Kiszka [this message]
2009-02-17 17:15   ` [Xenomai-core] [PATCH v2 1/4] POSIX: Fix SCHED_RR thread creation Gilles Chanteperdrix
2009-02-17 17:28     ` Jan Kiszka
2009-02-17 17:37       ` Gilles Chanteperdrix
2009-02-17 17:47         ` Jan Kiszka
2009-02-17 17:50           ` Gilles Chanteperdrix
2009-02-17 17:57             ` Jan Kiszka
2009-02-17 18:17               ` Gilles Chanteperdrix
2009-02-17 18:19                 ` Jan Kiszka
2009-02-17 18:21                   ` Gilles Chanteperdrix
2009-02-17 18:41                     ` Jan Kiszka
2009-02-17 23:48                       ` Jan Kiszka
2009-02-18  7:51                         ` Jan Kiszka
2009-02-17 17:04 ` [Xenomai-core] [PATCH v2 4/4] POSIX: Do not auto-shadow main with dlopen enabled Jan Kiszka
2009-02-25 10:04 ` [Xenomai-core] [PATCH v2 0/4] Various fixes and cleanups Jan Kiszka
2009-02-25 11:19   ` Philippe Gerum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090217170419.1425.15313.stgit@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.