[Xenomai-git] Philippe Gerum : cobalt/posix/sem: silence false warning

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 96c4bbd5135ee73282cc3760e09ea7b986454b04
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=96c4bbd5135ee73282cc3760e09ea7b986454b04

Author: Philippe Gerum r...@xenomai.org
Date:   Fri May  9 10:35:24 2014 +0200

cobalt/posix/sem: silence false warning

---

 kernel/cobalt/posix/sem.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/posix/sem.c b/kernel/cobalt/posix/sem.c
index 8d6b4ed..2d64785 100644
--- a/kernel/cobalt/posix/sem.c
+++ b/kernel/cobalt/posix/sem.c
@@ -411,9 +411,9 @@ static inline int
 sem_wait_inner(xnhandle_t handle, int timed,
   const struct timespec __user *u_ts)
 {
+   struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
int pull_ts = 1, ret, info;
struct cobalt_sem *sem;
-   struct timespec ts;
xntmode_t tmode;
spl_t s;
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : alchemy/task: require local thread for rt_task_set_periodic()

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 5da01c2394043387f94eed5bbc6d01b3f597ad6c
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=5da01c2394043387f94eed5bbc6d01b3f597ad6c

Author: Philippe Gerum r...@xenomai.org
Date:   Wed May  7 12:25:27 2014 +0200

alchemy/task: require local thread for rt_task_set_periodic()

We enforce process locality for target threads since Cobalt wants this
for pthread_make_periodic_np(), although Mercury would accept remote
threads.

This seems an acceptable limitation compared to introducing a new
Cobalt API for supporting a somewhat weird feature (i.e. controlling
periodic behavior of remote threads).

---

 doc/asciidoc/MIGRATION.adoc |3 +++
 lib/alchemy/task.c  |   33 -
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/doc/asciidoc/MIGRATION.adoc b/doc/asciidoc/MIGRATION.adoc
index 3eb5dc9..fc2f88b 100644
--- a/doc/asciidoc/MIGRATION.adoc
+++ b/doc/asciidoc/MIGRATION.adoc
@@ -676,6 +676,9 @@ Cobalt. However, it does not return -EWOULDBLOCK anymore.
 [TIP]
 A tickless clock has a period of one nanosecond.
 
+- Unlike with Xenomai 2.x, the target task to +rt_task_set_periodic()+
+  must be local to the current process.
+
 .Mutexes
 
 - For consistency with the standard glibc implementation, deleting a
diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index fc88218..e8bc542 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -755,13 +755,13 @@ undo:
  * rt_task_wait_period() to sleep until the next periodic release
  * point in the processor timeline is reached.
  *
- * @param task The descriptor address of the periodic task.
- * If @a task is NULL, the current task is made periodic.
+ * @param task The descriptor address of the periodic task.  If @a
+ * task is NULL, the current task is made periodic. @a task must
+ * belong the current process.
  *
  * @param idate The initial (absolute) date of the first release
- * point, expressed in clock ticks (see note). @a task will be delayed
- * until this point is reached. If @a idate is equal to TM_NOW, the
- * current system date is used.
+ * point, expressed in clock ticks (see note).  If @a idate is equal
+ * to TM_NOW, the current system date is used.
  *
  * @param period The period of the task, expressed in clock ticks (see
  * note). Passing TM_INFINITE stops the task's periodic timer if
@@ -799,20 +799,27 @@ int rt_task_set_periodic(RT_TASK *task, RTIME idate, 
RTIME period)
 
CANCEL_DEFER(svc);
 
-   tcb = find_alchemy_task_or_self(task, ret);
+   clockobj_ticks_to_timespec(alchemy_clock, idate, its);
+   clockobj_ticks_to_timespec(alchemy_clock, period, pts);
+
+   tcb = get_alchemy_task_or_self(task, ret);
if (tcb == NULL)
goto out;
 
-   clockobj_ticks_to_timespec(alchemy_clock, idate, its);
-   clockobj_ticks_to_timespec(alchemy_clock, period, pts);
/*
-* We may be scheduled out as a result of this call, so we
-* can't grab the target thread lock. However, since
-* threadobj_set_periodic() has to be called lock-free, we
-* expect it to be robust and properly deal with cancellation
-* points (CANCEL_DEFER() put us in deferred mode).
+* XXX: we enforce locality since Cobalt wants this for
+* pthread_make_periodic_np(), although Mercury would accept
+* remote threads. This seems an acceptable limitation
+* compared to introducing a new Cobalt API for supporting a
+* somewhat weird feature.
 */
+   if (!threadobj_local_p(tcb-thobj)) {
+   ret = -EINVAL;
+   goto out;
+   }
+
ret = threadobj_set_periodic(tcb-thobj, its, pts);
+   put_alchemy_task(tcb);
 out:
CANCEL_RESTORE(svc);
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/threadobj: require local thread for threadobj_set_rr()

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 97ad7eebc5ff701462c118b128e2d38e199e4d7b
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=97ad7eebc5ff701462c118b128e2d38e199e4d7b

Author: Philippe Gerum r...@xenomai.org
Date:   Wed May  7 12:25:27 2014 +0200

copperplate/threadobj: require local thread for threadobj_set_rr()

We enforce process locality for target threads since both Cobalt and
Mercury need this internally.

This seems an acceptable limitation compared to introducing a
significantly more complex implementation only for supporting a
somewhat weird feature (i.e. controlling the round-robin state of
remote threads).

---

 lib/copperplate/threadobj.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 0d3274f..1908d86 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -1316,6 +1316,16 @@ int threadobj_set_rr(struct threadobj *thobj, const 
struct timespec *quantum)
__threadobj_check_locked(thobj);
 
/*
+* XXX: we enforce locality since both Cobalt and Mercury need
+* this for set_rr(). This seems an acceptable limitation
+* compared to introducing a significantly more complex
+* implementation only for supporting a somewhat weird feature
+* (i.e. controlling the round-robin state of remote threads).
+*/
+   if (!threadobj_local_p(thobj))
+   return -EINVAL;
+
+   /*
 * It makes no sense to enable/disable round-robin while
 * holding the scheduler lock. Prevent this, which makes our
 * logic simpler in the Mercury case with respect to tracking


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/threadobj: introduce remote agent for thread operations

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: e0791de259582a36e3aa780fe5db34202bc3fd5c
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=e0791de259582a36e3aa780fe5db34202bc3fd5c

Author: Philippe Gerum r...@xenomai.org
Date:   Mon May 12 14:36:25 2014 +0200

copperplate/threadobj: introduce remote agent for thread operations

In shared multi-processing mode, cancelling remote threads or updating
their scheduling parameters require going through an agent thread,
running on the process they belong to.

This patch series introduces such mechanism, so that
threadobj_cancel() and threadobj_set_priority() work transparently,
regardless of whether or not the target thread runs in the current
process.

CAUTION: remote operations are implemented by a fully asynchronous
protocol. The status returned to a caller for an operation affecting a
remote thread, tells whether the request was successfully sent to the
agent, but does not reflect the final operation status in the remote
process. The remote agent will issue a warning message in case of
failure to carry out an operation though.

---

 include/boilerplate/ancillaries.h|7 +-
 include/boilerplate/compiler.h   |4 +
 include/cobalt/boilerplate/signal.h  |2 +
 include/copperplate/heapobj.h|9 +
 include/copperplate/threadobj.h  |1 +
 include/mercury/boilerplate/signal.h |5 +-
 lib/alchemy/task.c   |8 +-
 lib/copperplate/internal.c   |   37 +---
 lib/copperplate/internal.h   |   14 +-
 lib/copperplate/threadobj.c  |  332 --
 lib/copperplate/timerobj.c   |3 +-
 lib/psos/task.c  |3 +-
 lib/vxworks/taskLib.c|3 +-
 lib/vxworks/testsuite/task-2.c   |   14 +-
 14 files changed, 343 insertions(+), 99 deletions(-)

diff --git a/include/boilerplate/ancillaries.h 
b/include/boilerplate/ancillaries.h
index 9d5818f..107a5f8 100644
--- a/include/boilerplate/ancillaries.h
+++ b/include/boilerplate/ancillaries.h
@@ -22,6 +22,7 @@
 #include time.h
 #include pthread.h
 #include boilerplate/signal.h
+#include boilerplate/compiler.h
 
 extern struct timespec __init_date;
 
@@ -55,12 +56,12 @@ void __printout(const char *name,
const char *header,
const char *fmt, va_list ap);
 
-void __panic(const char *name,
-const char *fmt, va_list ap);
+void __noreturn __panic(const char *name,
+   const char *fmt, va_list ap);
 
 void early_panic(const char *fmt, ...);
 
-void panic(const char *fmt, ...);
+void __noreturn panic(const char *fmt, ...);
 
 void __warning(const char *name,
   const char *fmt, va_list ap);
diff --git a/include/boilerplate/compiler.h b/include/boilerplate/compiler.h
index e3fe413..85e8846 100644
--- a/include/boilerplate/compiler.h
+++ b/include/boilerplate/compiler.h
@@ -31,4 +31,8 @@
 #define unlikely(x)__builtin_expect(!!(x), 0)
 #endif
 
+#ifndef __noreturn
+#define __noreturn __attribute__((__noreturn__))
+#endif
+
 #endif /* _BOILERPLATE_COMPILER_H */
diff --git a/include/cobalt/boilerplate/signal.h 
b/include/cobalt/boilerplate/signal.h
index 4807a51..b7d5ffe 100644
--- a/include/cobalt/boilerplate/signal.h
+++ b/include/cobalt/boilerplate/signal.h
@@ -20,6 +20,8 @@
 
 #include cobalt/signal.h
 
+#define SIGAGENT   (SIGRTMIN + 12) /* Request to remote agent */
+
 #define SIGSAFE_LOCK_ENTRY(__safelock) \
do {\
push_cleanup_lock(__safelock);  \
diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h
index 6b5617c..495d72c 100644
--- a/include/copperplate/heapobj.h
+++ b/include/copperplate/heapobj.h
@@ -185,9 +185,15 @@ extern struct hash_table *__main_catalog;
 extern struct sysgroup *__main_sysgroup;
 
 struct sysgroup_memspec {
+   /** next member in sysgroup list. */
struct holder next;
 };
 
+struct agent_memspec {
+   /** Agent pid in owner process. */
+   pid_t pid;
+};
+
 static inline void *mainheap_ptr(memoff_t off)
 {
return off ? (void *)__memptr(__main_heap, off) : NULL;
@@ -315,6 +321,9 @@ char *xnstrdup(const char *ptr);
 struct sysgroup_memspec {
 };
 
+struct agent_memspec {
+};
+
 /*
  * Whether an object is laid in some shared heap. Never if pshared
  * mode is disabled.
diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h
index fd87829..fa9b226 100644
--- a/include/copperplate/threadobj.h
+++ b/include/copperplate/threadobj.h
@@ -185,6 +185,7 @@ struct threadobj {
struct traceobj *tracer;
sem_t *cancel_sem;
struct sysgroup_memspec memspec;
+   struct agent_memspec agent;
struct backtrace_data btd;
 };
 
diff --git a/include/mercury/boilerplate/signal.h 
b/include/mercury/boilerplate/signal.h
index 914c02c..f25c618 100644
--- 

[Xenomai-git] Philippe Gerum : cobalt/posix/thread: fix build error w/ SCHED_WEAK disabled

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: f201f9c01ef513b55d496ceee16542eee6318dde
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=f201f9c01ef513b55d496ceee16542eee6318dde

Author: Philippe Gerum r...@xenomai.org
Date:   Fri May  9 10:36:08 2014 +0200

cobalt/posix/thread: fix build error w/ SCHED_WEAK disabled

---

 kernel/cobalt/posix/thread.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index fde356f..c336fbb 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -1276,7 +1276,7 @@ int cobalt_sched_max_prio(int policy)
 #ifdef CONFIG_XENO_OPT_SCHED_WEAK
ret = XNSCHED_FIFO_MAX_PRIO;
 #else
-   ret 0;
+   ret = 0;
 #endif
break;
default:


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/notifier: signal suspended thread directly

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 97e243b81194de9cc4cc6ef9d0232f61e5f609e0
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=97e243b81194de9cc4cc6ef9d0232f61e5f609e0

Author: Philippe Gerum r...@xenomai.org
Date:   Wed May  7 16:07:27 2014 +0200

copperplate/notifier: signal suspended thread directly

The notifier will remain dedicated to supporting thread-directed
suspend/resume operations eventually, and there is no gain in issuing
a signaled message compared to solely signaling the target thread.

Therefore we drop the pipe formerly used to trigger a fasync
notification on the read side, replacing it by direct signaling of the
target thread.

This patch is a slightly updated version of Matthias Schneider's
proposal:
http://www.xenomai.org/pipermail/xenomai/2014-May/030822.html

---

 include/copperplate/notifier.h |3 +-
 lib/copperplate/notifier.c |  105 ++--
 2 files changed, 17 insertions(+), 91 deletions(-)

diff --git a/include/copperplate/notifier.h b/include/copperplate/notifier.h
index 13bf588..61e2ec4 100644
--- a/include/copperplate/notifier.h
+++ b/include/copperplate/notifier.h
@@ -23,8 +23,7 @@
 
 struct notifier {
pid_t owner;
-   int psfd[2];
-   int pwfd[2];
+   int waitfd[2];
struct pvholder link;
 };
 
diff --git a/lib/copperplate/notifier.c b/lib/copperplate/notifier.c
index 4b3988a..0e8c832 100644
--- a/lib/copperplate/notifier.c
+++ b/lib/copperplate/notifier.c
@@ -36,65 +36,24 @@ static struct sigaction notifier_old_sa;
 
 static void notifier_sighandler(int sig, siginfo_t *siginfo, void *uc)
 {
-   int ret, matched = 0;
struct notifier *nf;
pid_t tid;
-   char c;
 
tid = copperplate_get_tid();
 
if (pvlist_empty(notifier_list))
-   goto hand_over;
+   goto ouch;
 
/* We may NOT alter the notifier list, but only scan it. */
pvlist_for_each_entry(nf, notifier_list, link) {
-   if (nf-psfd[0] != siginfo-si_fd)
-   continue;
-
-   matched = 1;
-   /*
-* Paranoid: misdirected notifications should never
-* happen with F_SETOWN_EX invoked for the
-* notification fildes.
-*/
-   if (nf-owner != tid)
-   continue;
-
-   for (;;) {
-   ret = read(nf-psfd[0], c, 1); 
-   if (ret  0)
-   notifier_wait(nf);
-   else if (ret == 0 || errno != EINTR)
-   break;
+   if (nf-owner == tid) {
+   notifier_wait(nf);
+   return;
}
-
-   return;
-   }
-
-   /*
-* Paranoid: we may have received a valid notification on the
-* wrong thread: bail out silently, assuming the recipient
-* will find out eventually.
-*/
-   if (matched)
-   return;
-
-hand_over:
-   if (notifier_old_sa.sa_sigaction) {
-   /*
-* This is our best effort to relay any unprocessed
-* event to the user-defined handler for SIGNOTIFY we
-* might have overriden in notifier_pkg_init(). The
-* application code should set this handler prior to
-* calling copperplate_init(), so that we know about it. The
-* signal setup flags will be ours however
-* (i.e. SA_SIGINFO + BSD semantics).
-*/
-   notifier_old_sa.sa_sigaction(sig, siginfo, uc);
-   return;
}
-
-   panic(received spurious notification on thread[%d] [sig=%d, code=%d, 
fd=%d],
+ouch:
+   panic(received spurious notification on thread[%d] 
+ (sig=%d, code=%d, fd=%d),
  tid, sig, siginfo-si_code, siginfo-si_fd);
 }
 
@@ -116,19 +75,11 @@ static void unlock_notifier_list(sigset_t *oset)
 
 int notifier_init(struct notifier *nf, pid_t pid)
 {
-   struct f_owner_ex owner;
sigset_t oset;
-   int fd, ret;
-
-   if (pipe(nf-psfd)  0) {
-   ret = -errno;
-   goto fail;
-   }
+   int ret;
 
-   if (pipe(nf-pwfd)  0) {
+   if (pipe(nf-waitfd)  0) {
ret = -errno;
-   close(nf-psfd[0]);
-   close(nf-psfd[1]);
goto fail;
}
 
@@ -140,23 +91,6 @@ int notifier_init(struct notifier *nf, pid_t pid)
unlock_notifier_list(oset);
pop_cleanup_lock(notifier_lock);
 
-   fd = nf-psfd[0];
-   fcntl(fd, F_SETSIG, SIGNOTIFY);
-   owner.type = F_OWNER_TID;
-   owner.pid = nf-owner;
-   fcntl(fd, F_SETOWN_EX, owner);
-   fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC | O_NONBLOCK);
-   fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
-   /*
-* 

[Xenomai-git] Philippe Gerum : cobalt/thread: fix leakage of XNKICKED status

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 7c333b78a809b78f72bfc07d05f9236a182a2b82
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=7c333b78a809b78f72bfc07d05f9236a182a2b82

Author: Philippe Gerum r...@xenomai.org
Date:   Thu May  8 13:09:20 2014 +0200

cobalt/thread: fix leakage of XNKICKED status

Considering the following scenario, on a multi-core system:

1. kernel@CPU0 sends regular linux signal to preempted thread@CPU1
2. thread@CPU1 kicked in ready state (XNREADY|XNKICKED) in sigwake
3. thread@CPU1 regains CPU, invokes linux/lostage syscall next
4. thread@CPU1 relaxes prior to running syscall handler
5. thread@CPU1 skips prepare_for_signal() because in relaxed mode
6. thread@CPU1 handles regular signal on its way back to userland

= XNKICKED set, signal_pending(thread) cleared.

7. thread@CPU1 invokes syscall requiring primary mode (hardens at first pass)
8. thread@CPU1 runs blocking Xenomai syscall, fails due to XNKICKED
9. thread@CPU1 skips prepare_for_signal() because signal_pending() false
10. goto 7

Oops.

The fix is to make sure that a kicked thread about to relax (which
means suspend Xenomai-wise) clears the XNKICKED bit right before
suspending, since it will necessarily traverse the regular signal
handling code on its way back to userland, prior to returning from a
blocking Xenomai service.

---

 kernel/cobalt/thread.c |   20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 7e4c9de..5887be9 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -810,18 +810,16 @@ void xnthread_suspend(struct xnthread *thread, int mask,
 
/*
 * If attempting to suspend a runnable thread which is pending
-* a forced switch to secondary mode, just raise the break
-* condition and return immediately.
+* a forced switch to secondary mode (XNKICKED), just raise
+* the XNBREAK status and return immediately, except if we
+* are precisely doing such switch by applying XNRELAX.
 *
-* We may end up suspending a kicked thread that has been
-* preempted on its relaxing path, which is a perfectly valid
-* situation: we just ignore the signal notification in
-* primary mode, and rely on the wakeup call pending for that
-* task in the root context, to collect and act upon the
-* pending Linux signal (see handle_sigwake_event()).
+* In the latter case, we also make sure to clear XNKICKED,
+* since we won't go through prepare_for_signal() once
+* relaxed.
 */
-   if ((oldstate  XNTHREAD_BLOCK_BITS) == 0) {
-   if ((mask  XNRELAX) == 0) {
+   if (likely((oldstate  XNTHREAD_BLOCK_BITS) == 0)) {
+   if (likely((mask  XNRELAX) == 0)) {
if (xnthread_test_info(thread, XNKICKED))
goto abort;
if (thread == sched-curr 
@@ -829,7 +827,7 @@ void xnthread_suspend(struct xnthread *thread, int mask,
goto abort;
}
xnthread_clear_info(thread,
-   XNRMID|XNTIMEO|XNBREAK|XNWAKEN|XNROBBED);
+   
XNRMID|XNTIMEO|XNBREAK|XNWAKEN|XNROBBED|XNKICKED);
}
 
/*


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/notifier: merge into threadobj building block

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 03e9b28941d9d6c4d57e0d5e396931539fe01d77
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=03e9b28941d9d6c4d57e0d5e396931539fe01d77

Author: Philippe Gerum r...@xenomai.org
Date:   Thu May  8 17:35:46 2014 +0200

copperplate/notifier: merge into threadobj building block

Now that the suspend/resume mechanism for Mercury is trivially simple,
just merge it into the threadobj implementation where it belongs to.

---

 include/copperplate/Makefile.am |1 -
 include/copperplate/Makefile.in |1 -
 include/copperplate/notifier.h  |   55 -
 include/copperplate/threadobj.h |2 -
 lib/copperplate/Makefile.am |1 -
 lib/copperplate/Makefile.in |   50 ---
 lib/copperplate/notifier.c  |  103 ---
 lib/copperplate/threadobj.c |   89 +
 8 files changed, 90 insertions(+), 212 deletions(-)

diff --git a/include/copperplate/Makefile.am b/include/copperplate/Makefile.am
index f721ff8..89b92ff 100644
--- a/include/copperplate/Makefile.am
+++ b/include/copperplate/Makefile.am
@@ -8,7 +8,6 @@ includesub_HEADERS =\
heapobj.h   \
init.h  \
semobj.h\
-   notifier.h  \
reference.h \
registry.h  \
syncobj.h   \
diff --git a/include/copperplate/Makefile.in b/include/copperplate/Makefile.in
index cc060cc..1db15f5 100644
--- a/include/copperplate/Makefile.in
+++ b/include/copperplate/Makefile.in
@@ -345,7 +345,6 @@ includesub_HEADERS = \
heapobj.h   \
init.h  \
semobj.h\
-   notifier.h  \
reference.h \
registry.h  \
syncobj.h   \
diff --git a/include/copperplate/notifier.h b/include/copperplate/notifier.h
deleted file mode 100644
index 011accf..000
--- a/include/copperplate/notifier.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2008 Philippe Gerum r...@xenomai.org.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
- */
-
-#ifndef _COPPERPLATE_NOTIFIER_H
-#define _COPPERPLATE_NOTIFIER_H
-
-#include boilerplate/list.h
-
-struct notifier {
-   pid_t owner;
-   struct pvholder link;
-};
-
-#ifdef __cplusplus
-extern C {
-#endif
-
-int notifier_init(struct notifier *nf, pid_t pid);
-
-static inline void notifier_destroy(struct notifier *nf)
-{
-}
-
-void notifier_destroy(struct notifier *nf);
-
-void notifier_signal(struct notifier *nf);
-
-void notifier_wait(void);
-
-void notifier_disable(struct notifier *nf);
-
-void notifier_release(struct notifier *nf);
-
-void notifier_pkg_init(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _COPPERPLATE_NOTIFIER_H */
diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h
index 754de3d..fd87829 100644
--- a/include/copperplate/threadobj.h
+++ b/include/copperplate/threadobj.h
@@ -77,14 +77,12 @@ void threadobj_save_timeout(struct threadobj_corespec 
*corespec,
 #else  /* CONFIG_XENO_MERCURY */
 
 #include sys/time.h
-#include copperplate/notifier.h
 
 struct threadobj_corespec {
pthread_cond_t grant_sync;
int policy_unlocked;
int prio_unlocked;
timer_t rr_timer;
-   struct notifier notifier;
struct timespec wakeup;
ticks_t period;
/** Timeout reported by sysregd. */
diff --git a/lib/copperplate/Makefile.am b/lib/copperplate/Makefile.am
index 17ebeb4..2664e53 100644
--- a/lib/copperplate/Makefile.am
+++ b/lib/copperplate/Makefile.am
@@ -46,7 +46,6 @@ clean-local:
 libcopperplate_la_LIBADD = libversion.la
 
 if XENO_MERCURY
-libcopperplate_la_SOURCES += notifier.c
 libcopperplate_la_LIBADD += ../boilerplate/libboilerplate.la
 endif
 
diff --git a/lib/copperplate/Makefile.in b/lib/copperplate/Makefile.in
index a9b360e..0a948fe 100644
--- a/lib/copperplate/Makefile.in
+++ b/lib/copperplate/Makefile.in
@@ -79,17 +79,16 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-@XENO_MERCURY_TRUE@am__append_1 = notifier.c
-@XENO_MERCURY_TRUE@am__append_2 = ../boilerplate/libboilerplate.la

[Xenomai-git] Philippe Gerum : copperplate/threadobj: drop useless check from round-robin handler

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 068f1951d5a59aba1f7cc4727ac374e3f5e523c2
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=068f1951d5a59aba1f7cc4727ac374e3f5e523c2

Author: Philippe Gerum r...@xenomai.org
Date:   Thu May  8 15:13:46 2014 +0200

copperplate/threadobj: drop useless check from round-robin handler

Only threads currently undergoing the RR scheduling will receive
SIGRRB, so there is no point in re-checking this fact in the
handler. Besides, such test was racy, since thobj-status must be
accessed under lock.

---

 lib/copperplate/threadobj.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 8508444..7a7f970 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -396,15 +396,12 @@ static void unblock_sighandler(int sig)
 
 static void roundrobin_handler(int sig)
 {
-   struct threadobj *current = threadobj_current();
-
/*
 * We do manual round-robin over SCHED_FIFO(RT) to allow for
 * multiple arbitrary time slices (i.e. vs the kernel
 * pre-defined and fixed one).
 */
-   if (current  (current-status  __THREAD_S_RR) != 0)
-   sched_yield();
+   sched_yield();
 }
 
 static inline void pkg_init_corespec(void)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/threadobj: enable signaling remote processes

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 579e9a94266c6275f32da53878e9d5a6e177feb2
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=579e9a94266c6275f32da53878e9d5a6e177feb2

Author: Philippe Gerum r...@xenomai.org
Date:   Tue May  6 19:42:23 2014 +0200

copperplate/threadobj: enable signaling remote processes

When shared multi-processing is enabled for Copperplate, we may end up
signaling threads running in sibling processes from the same
session. Make sure to invoke the proper signaling service for this
purpose.

Copperplate requires thread-directed semantics for all signals used
internally:

- over Cobalt, sending a pseudo-signal - e.g. SIGRELS, SIGSUSP,
  SIGRESM - is always considered as a thread-specific operation by the
  core, and won't fall back as a best-effort, group-directed call
  even with the kill(2) replacement.

- over Mercury, we use the low-level syscall() interface for issuing
  tkill() to threads which belong to a remote process, since the
  native kernel performs group-oriented signal delivery with the
  regular kill(2) and sigqueue(2) interfaces.

---

 lib/copperplate/internal.c  |   14 --
 lib/copperplate/internal.h  |2 ++
 lib/copperplate/threadobj.c |   22 +-
 3 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/lib/copperplate/internal.c b/lib/copperplate/internal.c
index 86e69af..16513e9 100644
--- a/lib/copperplate/internal.c
+++ b/lib/copperplate/internal.c
@@ -17,6 +17,7 @@
  */
 
 #include sys/types.h
+#include sys/syscall.h
 #include stdio.h
 #include stdlib.h
 #include stdarg.h
@@ -25,7 +26,6 @@
 #include signal.h
 #include errno.h
 #include limits.h
-#include linux/unistd.h
 #include boilerplate/ancillaries.h
 #include copperplate/clockobj.h
 #include copperplate/threadobj.h
@@ -41,7 +41,7 @@ static void *thread_trampoline(void *arg);
 pid_t copperplate_get_tid(void)
 {
/*
-* XXX: The nucleus maintains a hash table indexed on
+* The nucleus maintains a hash table indexed on
 * task_pid_vnr() values for mapped shadows. This is what
 * __NR_gettid retrieves as well in Cobalt mode.
 */
@@ -120,6 +120,11 @@ static inline int finish_wait_corespec(struct 
corethread_attributes *cta)
return __bt(copperplate_renice_thread(pthread_self(), cta-prio));
 }
 
+int copperplate_kill_tid(pid_t tid, int sig)
+{
+   return __RT(kill(tid, sig)) ? -errno : 0;
+}
+
 #else /* CONFIG_XENO_MERCURY */
 
 int copperplate_probe_node(unsigned int id)
@@ -127,6 +132,11 @@ int copperplate_probe_node(unsigned int id)
return kill((pid_t)id, 0) == 0;
 }
 
+int copperplate_kill_tid(pid_t tid, int sig)
+{
+   return syscall(__NR_tkill, tid, sig) ? -errno : 0;
+}
+
 int copperplate_create_thread(struct corethread_attributes *cta,
  pthread_t *tid)
 {
diff --git a/lib/copperplate/internal.h b/lib/copperplate/internal.h
index 9146d31..d195ac0 100644
--- a/lib/copperplate/internal.h
+++ b/lib/copperplate/internal.h
@@ -77,6 +77,8 @@ extern C {
 
 pid_t copperplate_get_tid(void);
 
+int copperplate_kill_tid(pid_t tid, int sig);
+
 int copperplate_probe_node(unsigned int id);
 
 int copperplate_create_thread(struct corethread_attributes *cta,
diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 9a4cf0b..8f76618 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -142,27 +142,29 @@ static inline void threadobj_cancel_corespec(struct 
threadobj *thobj) /* thobj-
 * than the caller of threadobj_cancel()), but will receive
 * the following cancellation request asap.
 */
-   __RT(pthread_kill(thobj-tid, SIGDEMT));
+   __RT(kill(thobj-pid, SIGDEMT));
 }
 
 int threadobj_suspend(struct threadobj *thobj) /* thobj-lock held */
 {
-   pthread_t tid = thobj-tid;
+   pid_t pid = thobj-pid;
int ret;
 
__threadobj_check_locked(thobj);
 
thobj-status |= __THREAD_S_SUSPENDED;
-   threadobj_unlock(thobj);
-   ret = __RT(pthread_kill(tid, SIGSUSP));
-   threadobj_lock(thobj);
+   if (thobj == threadobj_current()) {
+   threadobj_unlock(thobj);
+   ret = __RT(kill(pid, SIGSUSP));
+   threadobj_lock(thobj);
+   } else
+   ret = __RT(kill(pid, SIGSUSP));
 
return __bt(-ret);
 }
 
 int threadobj_resume(struct threadobj *thobj) /* thobj-lock held */
 {
-   pthread_t tid = thobj-tid;
int ret;
 
__threadobj_check_locked(thobj);
@@ -171,9 +173,7 @@ int threadobj_resume(struct threadobj *thobj) /* 
thobj-lock held */
return 0;
 
thobj-status = ~__THREAD_S_SUSPENDED;
-   threadobj_unlock(thobj);
-   ret = __RT(pthread_kill(tid, SIGRESM));
-   threadobj_lock(thobj);
+   ret = __RT(kill(thobj-pid, SIGRESM));
 
return __bt(-ret);
 }
@@ -1255,6 +1255,10 @@ int threadobj_unblock(struct threadobj *thobj) /* 
thobj-lock held */
   

[Xenomai-git] Philippe Gerum : cobalt/signal: fix memory leakage

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 72c842c7c129c91784a7157e58890f46708dcc33
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=72c842c7c129c91784a7157e58890f46708dcc33

Author: Philippe Gerum r...@xenomai.org
Date:   Wed May  7 11:53:20 2014 +0200

cobalt/signal: fix memory leakage

Make sure the signal data (struct cobalt_sigpending) is freed when
cobalt_signal_send() decides not to queue it.

---

 kernel/cobalt/posix/mqueue.c |3 ++-
 kernel/cobalt/posix/signal.c |   32 
 kernel/cobalt/posix/signal.h |2 ++
 3 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index 395eaf2..a3154d1 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -657,7 +657,8 @@ cobalt_mq_finish_send(mqd_t fd, cobalt_mq_t *mq, struct 
cobalt_msg *msg)
sigp = cobalt_signal_alloc();
if (sigp) {
cobalt_copy_siginfo(SI_MESGQ, 
sigp-si, mq-si);
-   cobalt_signal_send(mq-target, sigp, 0);
+   if (cobalt_signal_send(mq-target, 
sigp, 0) = 0)
+   cobalt_signal_free(sigp);
}
mq-target = NULL;
}
diff --git a/kernel/cobalt/posix/signal.c b/kernel/cobalt/posix/signal.c
index 15171e1..d24cbf9 100644
--- a/kernel/cobalt/posix/signal.c
+++ b/kernel/cobalt/posix/signal.c
@@ -89,9 +89,7 @@ deliver:
 * have to release the sigpending data right away before
 * leaving.
 */
-   if ((void *)sigp = sigpending_mem 
-   (void *)sigp  sigpending_mem + __SIGPOOL_SIZE)
-   list_add_tail(sigp-next, sigpending_pool);
+   cobalt_signal_free(sigp);
 
return 1;
 }
@@ -106,17 +104,16 @@ int cobalt_signal_send(struct cobalt_thread *thread,
/* Can we deliver this signal immediately? */
ret = cobalt_signal_deliver(thread, sigp, group);
if (ret)
-   return 0;   /* Yep, done. */
+   return ret; /* Yep, done. */
 
/*
 * Nope, attempt to queue it. We start by calling any Cobalt
 * extension for queuing the signal first.
 */
if (cobalt_call_extension(signal_queue, thread-extref, ret, sigp)) {
-   if (ret  0)
-   return ret; /* Error. */
-   if (ret  0)
-   return 0; /* Queuing done. */
+   if (ret)
+   /* Queuing done remotely or error. */
+   return ret;
}
 
sig = sigp-si.si_signo;
@@ -133,7 +130,7 @@ int cobalt_signal_send(struct cobalt_thread *thread,
sigaddset(thread-sigpending, sig);
list_add_tail(sigp-next, sigq);
 
-   return 0;
+   return 1;
 }
 EXPORT_SYMBOL_GPL(cobalt_signal_send);
 
@@ -166,6 +163,14 @@ struct cobalt_sigpending *cobalt_signal_alloc(void)
 }
 EXPORT_SYMBOL_GPL(cobalt_signal_alloc);
 
+void cobalt_signal_free(struct cobalt_sigpending *sigp)
+{  /* nklocked, IRQs off */
+   if ((void *)sigp = sigpending_mem 
+   (void *)sigp  sigpending_mem + __SIGPOOL_SIZE)
+   list_add_tail(sigp-next, sigpending_pool);
+}
+EXPORT_SYMBOL_GPL(cobalt_signal_free);
+
 void cobalt_signal_flush(struct cobalt_thread *thread)
 {
struct cobalt_sigpending *sigp, *tmp;
@@ -461,7 +466,8 @@ int __cobalt_kill(struct cobalt_thread *thread, int sig, 
int group) /* nklocked,
sigp-si.si_code = SI_USER;
sigp-si.si_pid = current-pid;
sigp-si.si_uid = get_current_uuid();
-   cobalt_signal_send(thread, sigp, group);
+   if (cobalt_signal_send(thread, sigp, group) = 0)
+   cobalt_signal_free(sigp);
}
resched:
xnsched_run();
@@ -525,8 +531,10 @@ int cobalt_sigqueue(pid_t pid, int sig,
sigp-si.si_pid = current-pid;
sigp-si.si_uid = get_current_uuid();
sigp-si.si_value = val;
-   cobalt_signal_send(thread, sigp, 1);
-   xnsched_run();
+   if (cobalt_signal_send(thread, sigp, 1) = 0)
+   cobalt_signal_free(sigp);
+   else
+   xnsched_run();
}
break;
default:
diff --git a/kernel/cobalt/posix/signal.h b/kernel/cobalt/posix/signal.h
index 9ad3c9e..ed2f387 100644
--- a/kernel/cobalt/posix/signal.h
+++ b/kernel/cobalt/posix/signal.h
@@ -63,6 +63,8 @@ int cobalt_signal_send_pid(pid_t pid,
 
 struct cobalt_sigpending *cobalt_signal_alloc(void);
 
+void 

[Xenomai-git] Philippe Gerum : copperplate/notifier: enable notifying remote threads

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 8723e45601586e8a73583e33fe3bcea296f23d44
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=8723e45601586e8a73583e33fe3bcea296f23d44

Author: Philippe Gerum r...@xenomai.org
Date:   Wed May  7 18:12:07 2014 +0200

copperplate/notifier: enable notifying remote threads

In shared multi-processing mode, we may have to suspend/resume threads
which belong to sibling processes from the same Copperplate session.

To this end, we drop the local pipe previously used for waiting for
the resume event. The suspended thread now waits for SIGRESM directly
via sigsuspend(), which is async-signal-safe.

As a side-effect, a suspended thread won't be allowed to handle any
blockable signal but SIGRESM until it is resumed, which follows the
principle of least astonishment.

---

 include/copperplate/notifier.h   |7 +-
 include/mercury/boilerplate/signal.h |9 ++-
 lib/copperplate/notifier.c   |  133 --
 lib/copperplate/threadobj.c  |   28 ---
 4 files changed, 61 insertions(+), 116 deletions(-)

diff --git a/include/copperplate/notifier.h b/include/copperplate/notifier.h
index 61e2ec4..011accf 100644
--- a/include/copperplate/notifier.h
+++ b/include/copperplate/notifier.h
@@ -23,7 +23,6 @@
 
 struct notifier {
pid_t owner;
-   int waitfd[2];
struct pvholder link;
 };
 
@@ -33,11 +32,15 @@ extern C {
 
 int notifier_init(struct notifier *nf, pid_t pid);
 
+static inline void notifier_destroy(struct notifier *nf)
+{
+}
+
 void notifier_destroy(struct notifier *nf);
 
 void notifier_signal(struct notifier *nf);
 
-void notifier_wait(const struct notifier *nf);
+void notifier_wait(void);
 
 void notifier_disable(struct notifier *nf);
 
diff --git a/include/mercury/boilerplate/signal.h 
b/include/mercury/boilerplate/signal.h
index df131fa..914c02c 100644
--- a/include/mercury/boilerplate/signal.h
+++ b/include/mercury/boilerplate/signal.h
@@ -24,15 +24,16 @@
 #define sigev_notify_thread_id  _sigev_un._tid
 #endif
 
-#define SIGNOTIFY  (SIGRTMIN + 8) /* Internal notification */
-#define SIGRELS(SIGRTMIN + 9) /* Syscall abort */
-#define SIGRRB (SIGRTMIN + 10) /* Round-robin event */
+#define SIGSUSP(SIGRTMIN + 8)
+#define SIGRESM(SIGRTMIN + 9)
+#define SIGRELS(SIGRTMIN + 10) /* Syscall abort */
+#define SIGRRB (SIGRTMIN + 11) /* Round-robin event */
 
 #define SIGSAFE_LOCK_ENTRY(__safelock) \
do {\
sigset_t __safeset, __oldsafeset;   \
sigemptyset(__safeset);\
-   sigaddset(__safeset, SIGNOTIFY);   \
+   sigaddset(__safeset, SIGSUSP); \
pthread_sigmask(SIG_BLOCK, __safeset, __oldsafeset);  \
push_cleanup_lock(__safelock);  \
write_lock(__safelock);
diff --git a/lib/copperplate/notifier.c b/lib/copperplate/notifier.c
index 0e8c832..0f02059 100644
--- a/lib/copperplate/notifier.c
+++ b/lib/copperplate/notifier.c
@@ -18,140 +18,69 @@
 
 #include signal.h
 #include memory.h
-#include unistd.h
-#include fcntl.h
-#include assert.h
 #include errno.h
 #include copperplate/notifier.h
-#include boilerplate/lock.h
 #include boilerplate/signal.h
-#include copperplate/debug.h
 #include internal.h
 
-static DEFINE_PRIVATE_LIST(notifier_list);
-
-static pthread_mutex_t notifier_lock;
-
-static struct sigaction notifier_old_sa;
-
-static void notifier_sighandler(int sig, siginfo_t *siginfo, void *uc)
+static void suspend_sighandler(int sig)
 {
-   struct notifier *nf;
-   pid_t tid;
-
-   tid = copperplate_get_tid();
-
-   if (pvlist_empty(notifier_list))
-   goto ouch;
-
-   /* We may NOT alter the notifier list, but only scan it. */
-   pvlist_for_each_entry(nf, notifier_list, link) {
-   if (nf-owner == tid) {
-   notifier_wait(nf);
-   return;
-   }
-   }
-ouch:
-   panic(received spurious notification on thread[%d] 
- (sig=%d, code=%d, fd=%d),
- tid, sig, siginfo-si_code, siginfo-si_fd);
+   notifier_wait();
 }
 
-static void lock_notifier_list(sigset_t *oset)
+static void resume_sighandler(int sig)
 {
-   sigset_t set;
-
-   sigemptyset(set);
-   sigaddset(set, SIGNOTIFY);
-   pthread_sigmask(SIG_BLOCK, set, oset);
-   write_lock(notifier_lock);
-}
-
-static void unlock_notifier_list(sigset_t *oset)
-{
-   pthread_sigmask(SIG_SETMASK, oset, NULL);
-   write_unlock(notifier_lock);
+   /* nop */
 }
 
 int notifier_init(struct notifier *nf, pid_t pid)
 {
-   sigset_t oset;
-   int ret;
-
-   if (pipe(nf-waitfd)  0) {
-

[Xenomai-git] Philippe Gerum : cobalt/posix: drop open coded thread hash lookups

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 0db01001c7ca4a6698f71b091a02a07128124be4
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=0db01001c7ca4a6698f71b091a02a07128124be4

Author: Philippe Gerum r...@xenomai.org
Date:   Sat May  3 10:37:26 2014 +0200

cobalt/posix: drop open coded thread hash lookups

---

 kernel/cobalt/posix/thread.c |   14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 6365c92..17330c4 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -1083,22 +1083,16 @@ int cobalt_thread_set_name_np(unsigned long pth, const 
char __user *u_name)
 
 int cobalt_thread_probe_np(pid_t pid)
 {
-   struct global_thread_hash *gslot;
-   u32 hash;
-   int ret;
+   struct cobalt_thread *thread;
+   int ret = 0;
spl_t s;
 
-   hash = jhash2((u32 *)pid, sizeof(pid) / sizeof(u32), 0);
-
trace_cobalt_pthread_probe(pid);
 
xnlock_get_irqsave(nklock, s);
 
-   gslot = global_index[hash  (PTHREAD_HSLOTS - 1)];
-   while (gslot  gslot-pid != pid)
-   gslot = gslot-next;
-
-   ret = gslot ? 0 : -ESRCH;
+   if (cobalt_thread_find(pid) == NULL)
+   ret = -ESRCH;
 
xnlock_put_irqrestore(nklock, s);
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : alchemy/task: require local task for rt_task_slice()

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 122492cd9589e90dfc8bb4c146af57d03c7e4be4
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=122492cd9589e90dfc8bb4c146af57d03c7e4be4

Author: Philippe Gerum r...@xenomai.org
Date:   Wed May  7 12:44:43 2014 +0200

alchemy/task: require local task for rt_task_slice()

This follows the restriction imposed on the target scope for calling
threadobj_set_rr().

---

 doc/asciidoc/MIGRATION.adoc |3 ++-
 lib/alchemy/task.c  |3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/doc/asciidoc/MIGRATION.adoc b/doc/asciidoc/MIGRATION.adoc
index fc2f88b..ea44796 100644
--- a/doc/asciidoc/MIGRATION.adoc
+++ b/doc/asciidoc/MIGRATION.adoc
@@ -748,7 +748,8 @@ Instead, the application decides about the server priority 
instead of
 the real-time core applying implicit dynamic boosts.
 
 - +rt_task_slice()+ now returns -EINVAL if the caller currently holds
-  the scheduler lock.
+  the scheduler lock, or attempts to change the round-robin settings
+  of a thread which does not belong to the current process.
 
 - T_CPU disappears from the +rt_task_create()+ mode flags. The new
   +rt_task_set_affinity()+ service is available for setting the CPU
diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index e8bc542..b47b02a 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -1309,7 +1309,8 @@ out:
  * round-robin scheduling for an Alchemy task.
  *
  * @param task The descriptor address of the task to update. If @a
- * task is NULL, the time credit of the current task is changed.
+ * task is NULL, the time credit of the current task is changed. @a
+ * task must belong to the current process.
  *
  * @param quantum The round-robin quantum for the task expressed in
  * clock ticks (see note).


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : doc/migration: document non-restartable mode for Cobalt/ select(2)

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 5ed462024c8b4cf56314f67ed195d2fd9d61895c
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=5ed462024c8b4cf56314f67ed195d2fd9d61895c

Author: Philippe Gerum r...@xenomai.org
Date:   Tue May 13 15:32:10 2014 +0200

doc/migration: document non-restartable mode for Cobalt/select(2)

---

 doc/asciidoc/MIGRATION.adoc |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/doc/asciidoc/MIGRATION.adoc b/doc/asciidoc/MIGRATION.adoc
index 48b33ac..e6fa554 100644
--- a/doc/asciidoc/MIGRATION.adoc
+++ b/doc/asciidoc/MIGRATION.adoc
@@ -606,9 +606,14 @@ int pthread_make_periodic_np(pthread_t thread, clockid_t 
clk_id,
 - +mq_send()+ now enforces a maximum priority value for messages
   (32768).
 
-.Real-time suitable STDIO
+.POSIX I/O services
 
-The former +include/rtdk.h+ header is gone in Xenomai
+- Cobalt's select(2) service is not automatically restarted anymore
+  upon Linux signal receipt, conforming to the POSIX standard (see man
+  signal(7)). In such an event, -1 is returned and errno is set to
+  EINTR.
+
+- The former +include/rtdk.h+ header is gone in Xenomai
 3.x. Applications should include +include/stdio.h+ instead.
 Similarly, the real-time suitable STDIO routines are now part of
 +libcobalt+.


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : doc/migration: document non-restartable mode for Cobalt/ select(2)

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 776cf8009fda62dee2d648a196bb859f2aadd1ee
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=776cf8009fda62dee2d648a196bb859f2aadd1ee

Author: Philippe Gerum r...@xenomai.org
Date:   Tue May 13 15:32:10 2014 +0200

doc/migration: document non-restartable mode for Cobalt/select(2)

---

 doc/asciidoc/MIGRATION.adoc |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/doc/asciidoc/MIGRATION.adoc b/doc/asciidoc/MIGRATION.adoc
index 48b33ac..e6fa554 100644
--- a/doc/asciidoc/MIGRATION.adoc
+++ b/doc/asciidoc/MIGRATION.adoc
@@ -606,9 +606,14 @@ int pthread_make_periodic_np(pthread_t thread, clockid_t 
clk_id,
 - +mq_send()+ now enforces a maximum priority value for messages
   (32768).
 
-.Real-time suitable STDIO
+.POSIX I/O services
 
-The former +include/rtdk.h+ header is gone in Xenomai
+- Cobalt's select(2) service is not automatically restarted anymore
+  upon Linux signal receipt, conforming to the POSIX standard (see man
+  signal(7)). In such an event, -1 is returned and errno is set to
+  EINTR.
+
+- The former +include/rtdk.h+ header is gone in Xenomai
 3.x. Applications should include +include/stdio.h+ instead.
 Similarly, the real-time suitable STDIO routines are now part of
 +libcobalt+.


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/posix/clock: kernel tracepoints (WIP)

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 2e7fa3bec156c61089da0cc669385b6591bb78d2
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=2e7fa3bec156c61089da0cc669385b6591bb78d2

Author: Philippe Gerum r...@xenomai.org
Date:   Tue May 13 18:06:23 2014 +0200

cobalt/posix/clock: kernel tracepoints (WIP)

---

 kernel/cobalt/posix/clock.c|   24 +++---
 kernel/cobalt/trace/cobalt-posix.h |   86 
 2 files changed, 104 insertions(+), 6 deletions(-)

diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
index 68383a7..951daf8 100644
--- a/kernel/cobalt/posix/clock.c
+++ b/kernel/cobalt/posix/clock.c
@@ -60,6 +60,7 @@
 #include internal.h
 #include thread.h
 #include clock.h
+#include trace/events/cobalt-posix.h
 
 static struct xnclock *external_clocks[COBALT_MAX_EXTCLOCKS];
 
@@ -177,6 +178,8 @@ int cobalt_clock_getres(clockid_t clock_id, struct timespec 
__user *u_ts)
if (u_ts  __xn_safe_copy_to_user(u_ts, ts, sizeof(ts)))
return -EFAULT;
 
+   trace_cobalt_clock_getres(clock_id, ts);
+
return 0;
 }
 
@@ -184,7 +187,7 @@ int cobalt_clock_gettime(clockid_t clock_id, struct 
timespec __user *u_ts)
 {
struct timespec ts;
xnticks_t ns;
-   int ret = 0;
+   int ret;
 
switch (clock_id) {
case CLOCK_REALTIME:
@@ -208,13 +211,15 @@ int cobalt_clock_gettime(clockid_t clock_id, struct 
timespec __user *u_ts)
if (__xn_safe_copy_to_user(u_ts, ts, sizeof(*u_ts)))
return -EFAULT;
 
-   return ret;
+   trace_cobalt_clock_gettime(clock_id, ts);
+
+   return 0;
 }
 
 int cobalt_clock_settime(clockid_t clock_id, const struct timespec __user 
*u_ts)
 {
struct timespec ts;
-   int _ret, ret = 0;
+   int _ret, ret;
xnticks_t now;
spl_t s;
 
@@ -233,11 +238,13 @@ int cobalt_clock_settime(clockid_t clock_id, const struct 
timespec __user *u_ts)
break;
default:
_ret = do_ext_clock(clock_id, set_time, ret, ts);
-   if (_ret)
-   ret = _ret;
+   if (_ret || ret)
+   return _ret ?: ret;
}
 
-   return ret;
+   trace_cobalt_clock_settime(clock_id, ts);
+
+   return 0;
 }
 
 int cobalt_clock_nanosleep(clockid_t clock_id, int flags,
@@ -256,6 +263,8 @@ int cobalt_clock_nanosleep(clockid_t clock_id, int flags,
if (__xn_safe_copy_from_user(rqt, u_rqt, sizeof(rqt)))
return -EFAULT;
 
+   trace_cobalt_clock_nanosleep(clock_id, flags, rqt);
+
if (clock_id != CLOCK_MONOTONIC 
clock_id != CLOCK_MONOTONIC_RAW 
clock_id != CLOCK_REALTIME)
@@ -325,12 +334,15 @@ int cobalt_clock_register(struct xnclock *clock, 
clockid_t *clk_id)
clock-id = nr;
*clk_id = __COBALT_CLOCK_CODE(clock-id);
 
+   trace_cobalt_clock_register(clock-name, *clk_id);
+
return 0;
 }
 EXPORT_SYMBOL_GPL(cobalt_clock_register);
 
 void cobalt_clock_deregister(struct xnclock *clock)
 {
+   trace_cobalt_clock_deregister(clock-name, clock-id);
clear_bit(clock-id, cobalt_clock_extids);
smp_mb__after_clear_bit();
external_clocks[clock-id] = NULL;
diff --git a/kernel/cobalt/trace/cobalt-posix.h 
b/kernel/cobalt/trace/cobalt-posix.h
index ece465f..66dc7b0 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -572,6 +572,92 @@ TRACE_EVENT(cobalt_psem_unlink,
TP_printk(name=%s, __get_str(name))
 );
 
+DECLARE_EVENT_CLASS(cobalt_clock_timespec,
+   TP_PROTO(clockid_t clk_id, const struct timespec *val),
+   TP_ARGS(clk_id, val),
+
+   TP_STRUCT__entry(
+   __field(clockid_t, clk_id)
+   __timespec_fields(val)
+   ),
+
+   TP_fast_assign(
+   __entry-clk_id = clk_id;
+   __assign_timespec(val, val);
+   ),
+
+   TP_printk(clock_id=%d timeval=(%ld.%09ld),
+ __entry-clk_id,
+ __timespec_args(val)
+   )
+);
+
+DEFINE_EVENT(cobalt_clock_timespec, cobalt_clock_getres,
+   TP_PROTO(clockid_t clk_id, const struct timespec *res),
+   TP_ARGS(clk_id, res)
+);
+
+DEFINE_EVENT(cobalt_clock_timespec, cobalt_clock_gettime,
+   TP_PROTO(clockid_t clk_id, const struct timespec *time),
+   TP_ARGS(clk_id, time)
+);
+
+DEFINE_EVENT(cobalt_clock_timespec, cobalt_clock_settime,
+   TP_PROTO(clockid_t clk_id, const struct timespec *time),
+   TP_ARGS(clk_id, time)
+);
+
+#define cobalt_print_timer_flags(__flags)  \
+   __print_flags(__flags, |, \
+ {TIMER_ABSTIME, TIMER_ABSTIME})
+
+TRACE_EVENT(cobalt_clock_nanosleep,
+   TP_PROTO(clockid_t clk_id, int flags, const struct timespec *time),
+   TP_ARGS(clk_id, flags, time),
+
+   TP_STRUCT__entry(
+   __field(clockid_t, clk_id)
+  

[Xenomai-git] Philippe Gerum : scripts/prepare-kernel: avoid extraneous symlinks to include/cobalt/kernel/rtdm

2014-05-13 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 9af2448c92ab2d1f3d68811a5aa089eb76affa54
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=9af2448c92ab2d1f3d68811a5aa089eb76affa54

Author: Philippe Gerum r...@xenomai.org
Date:   Tue May 13 18:13:51 2014 +0200

scripts/prepare-kernel: avoid extraneous symlinks to include/cobalt/kernel/rtdm

---

 scripts/prepare-kernel.sh |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 195a492..ef0ce3b 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -446,7 +446,7 @@ patch_link r n kernel/cobalt/include/asm-generic/xenomai 
include/asm-generic/xen
 patch_link n m kernel/cobalt/posix kernel/xenomai/posix
 patch_link n m kernel/cobalt/rtdm kernel/xenomai/rtdm
 patch_link r m kernel/drivers drivers/xenomai
-patch_link r n include/cobalt/kernel include/xenomai/cobalt/kernel
+patch_link n n include/cobalt/kernel include/xenomai/cobalt/kernel
 patch_link r n include/cobalt/kernel/rtdm include/xenomai/rtdm
 patch_link r n include/cobalt/uapi include/xenomai/cobalt/uapi
 patch_link r n include/rtdm/uapi include/xenomai/rtdm/uapi


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git