[Xenomai-git] Philippe Gerum : cobalt/nucleus: do not propagate thread priority changes from Linux to Xenomai

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 8650192fbf7ebbfba793722eeefa800cc9ea9415
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=8650192fbf7ebbfba793722eeefa800cc9ea9415

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Dec 12 18:29:06 2011 +0100

cobalt/nucleus: do not propagate thread priority changes from Linux to Xenomai

Propagating priority updates caused by the regular
pthread_setschedparam() to the Xenomai domain never made much sense,
and clearly does not make any sense over Cobalt.

Applications using the Cobalt interface should use the wrapped call to
change the priority of a thread within the Xenomai
scheduler. Copperplate-based applications should use the relevant call
provided by their API of choice, which in turn shall invoke Cobalt's
wrapped call to change this priority.

In short, we now require for Xenomai what the glibc started requiring
with the introduction of cached priority levels: changing a thread
priority must be done through our dedicated service, or this won't
work.

---

 include/asm-generic/hal.h  |2 -
 kernel/cobalt/nucleus/shadow.c |   42 
 2 files changed, 0 insertions(+), 44 deletions(-)

diff --git a/include/asm-generic/hal.h b/include/asm-generic/hal.h
index 7b35817..04acab2 100644
--- a/include/asm-generic/hal.h
+++ b/include/asm-generic/hal.h
@@ -301,8 +301,6 @@ static inline void clear_task_nowakeup(struct task_struct 
*p)
 ipipe_catch_event(ipipe_root_domain,IPIPE_EVENT_SIGWAKE,hdlr)
 #define rthal_catch_schedule(hdlr) \
 ipipe_catch_event(ipipe_root_domain,IPIPE_EVENT_SCHEDULE,hdlr)
-#define rthal_catch_setsched(hdlr) \
-ipipe_catch_event(rthal_domain,IPIPE_EVENT_SETSCHED,hdlr)
 #define rthal_catch_losyscall(hdlr)\
 ipipe_catch_event(ipipe_root_domain,IPIPE_EVENT_SYSCALL,hdlr)
 #define rthal_catch_hisyscall(hdlr)\
diff --git a/kernel/cobalt/nucleus/shadow.c b/kernel/cobalt/nucleus/shadow.c
index 2993bd1..ab4ed2d 100644
--- a/kernel/cobalt/nucleus/shadow.c
+++ b/kernel/cobalt/nucleus/shadow.c
@@ -2379,46 +2379,6 @@ static inline void do_sigwake_event(struct task_struct 
*p)
 
 RTHAL_DECLARE_SIGWAKE_EVENT(sigwake_event);
 
-static inline void do_setsched_event(struct task_struct *p, int priority)
-{
-   xnthread_t *thread = xnshadow_thread(p);
-   union xnsched_policy_param param;
-   struct xnsched *sched;
-
-   if (!thread || (p-policy != SCHED_FIFO  p-policy != SCHED_NORMAL))
-   return;
-
-   if (p-policy == SCHED_NORMAL)
-   priority = 0;
-
-   /*
-* Reflect a Linux priority change for a given thread in the
-* Xenomai scheduler.
-*
-* Linux's priority scale is a subset of the core pod's
-* priority scale, so there is no need to bound the priority
-* values when mapping them from Linux - Xenomai.
-*
-* BIG FAT WARNING: Change of scheduling parameters from the
-* Linux side are propagated only to threads that belong to
-* the Xenomai RT scheduling class. Threads from other classes
-* remain unaffected, since we could not map this information
-* 1:1 between Linux and Xenomai.
-*/
-   if (thread-base_class != xnsched_class_rt ||
-   thread-cprio == priority)
-   return;
-
-   param.rt.prio = priority;
-   __xnpod_set_thread_schedparam(thread, xnsched_class_rt, param, 0);
-   sched = xnpod_current_sched();
-
-   if (xnsched_resched_p(sched))
-   xnpod_schedule();
-}
-
-RTHAL_DECLARE_SETSCHED_EVENT(setsched_event);
-
 static inline void do_cleanup_event(struct mm_struct *mm)
 {
struct task_struct *p = current;
@@ -2561,7 +2521,6 @@ void xnshadow_grab_events(void)
rthal_catch_taskexit(taskexit_event);
rthal_catch_sigwake(sigwake_event);
rthal_catch_schedule(schedule_event);
-   rthal_catch_setsched(setsched_event);
rthal_catch_cleanup(cleanup_event);
rthal_catch_return(mayday_event);
 }
@@ -2571,7 +2530,6 @@ void xnshadow_release_events(void)
rthal_catch_taskexit(NULL);
rthal_catch_sigwake(NULL);
rthal_catch_schedule(NULL);
-   rthal_catch_setsched(NULL);
rthal_catch_cleanup(NULL);
rthal_catch_return(NULL);
 }


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/nucleus: remove norm/denorm thread priorities

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: a183fb5647481aaa049ddae3a51c387bd0d16657
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=a183fb5647481aaa049ddae3a51c387bd0d16657

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Dec 12 15:58:53 2011 +0100

cobalt/nucleus: remove norm/denorm thread priorities

We don't need to support normalized/denormalized priorities for
threads, since both Cobalt and RTDM interfaces use the same priority
scale.

All APIs with non-POSIX scales now run in userland, handling
conversions between Cobalt and their own priority scale locally from
the Copperplate interface.

---

 include/cobalt/nucleus/thread.h  |8 
 kernel/cobalt/nucleus/pod.c  |   10 ++
 kernel/cobalt/nucleus/sched-rt.c |   10 +-
 kernel/cobalt/nucleus/sched.c|9 +
 kernel/cobalt/nucleus/shadow.c   |   15 ++-
 5 files changed, 10 insertions(+), 42 deletions(-)

diff --git a/include/cobalt/nucleus/thread.h b/include/cobalt/nucleus/thread.h
index c55bbd7..4775853 100644
--- a/include/cobalt/nucleus/thread.h
+++ b/include/cobalt/nucleus/thread.h
@@ -175,7 +175,6 @@ union xnsched_policy_param;
 struct xnbufd;
 
 struct xnthread_operations {
-   int (*get_denormalized_prio)(struct xnthread *, int coreprio);
unsigned (*get_magic)(void);
 };
 
@@ -365,13 +364,6 @@ typedef struct xnhook {
 #define xnthread_get_rescnt(thread)((thread)-hrescnt)
 #endif /* !__XENO_SIM__ */
 
-/* Class-level operations for threads. */
-static inline int xnthread_get_denormalized_prio(struct xnthread *t, int 
coreprio)
-{
-   return t-ops  t-ops-get_denormalized_prio
-   ? t-ops-get_denormalized_prio(t, coreprio) : coreprio;
-}
-
 static inline unsigned xnthread_get_magic(struct xnthread *t)
 {
return t-ops ? t-ops-get_magic() : 0;
diff --git a/kernel/cobalt/nucleus/pod.c b/kernel/cobalt/nucleus/pod.c
index 642ae1b..d8ee29d 100644
--- a/kernel/cobalt/nucleus/pod.c
+++ b/kernel/cobalt/nucleus/pod.c
@@ -226,7 +226,7 @@ void xnpod_fatal_helper(const char *format, ...)
 
while (holder) {
xnthread_t *thread = link2thread(holder, glink);
-   int cprio, dnprio;
+   int cprio;
 
holder = nextq(nkpod-threadq, holder);
 
@@ -234,13 +234,7 @@ void xnpod_fatal_helper(const char *format, ...)
continue;
 
cprio = xnthread_current_priority(thread);
-   dnprio = xnthread_get_denormalized_prio(thread, cprio);
-
-   if (dnprio != cprio)
-   snprintf(pbuf, sizeof(pbuf), %3d(%d),
-cprio, dnprio);
-   else
-   snprintf(pbuf, sizeof(pbuf), %3d, dnprio);
+   snprintf(pbuf, sizeof(pbuf), %3d, cprio);
 
xnlogerr_noprompt(%c%3u  %-6d %-8s %-8Lu %.8lx  %s\n,
  thread == sched-curr ? '' : ' ',
diff --git a/kernel/cobalt/nucleus/sched-rt.c b/kernel/cobalt/nucleus/sched-rt.c
index 71181b7..bbd5319 100644
--- a/kernel/cobalt/nucleus/sched-rt.c
+++ b/kernel/cobalt/nucleus/sched-rt.c
@@ -137,7 +137,6 @@ struct vfile_sched_rt_data {
char name[XNOBJECT_NAME_LEN];
xnticks_t period;
int cprio;
-   int dnprio;
 };
 
 static struct xnvfile_snapshot_ops vfile_sched_rt_ops;
@@ -182,7 +181,6 @@ static int vfile_sched_rt_next(struct 
xnvfile_snapshot_iterator *it,
p-pid = xnthread_user_pid(thread);
memcpy(p-name, thread-name, sizeof(p-name));
p-cprio = thread-cprio;
-   p-dnprio = xnthread_get_denormalized_prio(thread, thread-cprio);
p-period = xnthread_get_period(thread);
 
return 1;
@@ -198,14 +196,8 @@ static int vfile_sched_rt_show(struct 
xnvfile_snapshot_iterator *it,
xnvfile_printf(it, %-3s  %-6s %-8s %-10s %s\n,
   CPU, PID, PRI, PERIOD, NAME);
else {
-   if (p-cprio != p-dnprio)
-   snprintf(pribuf, sizeof(pribuf), %3d(%d),
-p-cprio, p-dnprio);
-   else
-   snprintf(pribuf, sizeof(pribuf), %3d, p-cprio);
-
+   snprintf(pribuf, sizeof(pribuf), %3d, p-cprio);
xntimer_format_time(p-period, ptbuf, sizeof(ptbuf));
-
xnvfile_printf(it, %3u  %-6d %-8s %-10s %s\n,
   p-cpu,
   p-pid,
diff --git a/kernel/cobalt/nucleus/sched.c b/kernel/cobalt/nucleus/sched.c
index d4261b8..83581e5 100644
--- a/kernel/cobalt/nucleus/sched.c
+++ b/kernel/cobalt/nucleus/sched.c
@@ -640,7 +640,6 @@ struct vfile_schedlist_data {
char name[XNOBJECT_NAME_LEN];
char sched_class[XNOBJECT_NAME_LEN];
int cprio;
-   int dnprio;
xnticks_t timeout;
 

[Xenomai-git] Philippe Gerum : lib/cobalt: make ownership check unconditional on unlocking

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 22291ad0ff2e39783206a8d7365a37e3b6927735
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=22291ad0ff2e39783206a8d7365a37e3b6927735

Author: Philippe Gerum r...@xenomai.org
Date:   Wed Dec 14 11:39:54 2011 +0100

lib/cobalt: make ownership check unconditional on unlocking

f1a968696 reduced the amount of runtime checks done for non
ERRORCHECK mutexes, to speed up operations in known-to-be-safe
cases. Unfortunately, several APIs want to combine recursive mutex and
check for lock imbalance upon unlocking, which puts them at odds with
this change.

We introduce back the unconditional check for lock imbalance in
__wrap_pthread_mutex_unlock() to fix this issue, without resorting to
significant overhead in client APIs.

---

 lib/cobalt/mutex.c |   23 +++
 1 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index fb17b16..14fd454 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -289,41 +289,32 @@ int __wrap_pthread_mutex_unlock(pthread_mutex_t *mutex)
((union __xeno_mutex *)mutex)-shadow_mutex;
struct mutex_dat *datp = NULL;
xnhandle_t cur = XN_NO_HANDLE;
-   int err, check;
+   int err;
 
if (unlikely(_mutex-magic != COBALT_MUTEX_MAGIC))
return EINVAL;
 
-   if ((check = _mutex-attr.type == PTHREAD_MUTEX_ERRORCHECK)) {
-   cur = xeno_get_current();
-   if (cur == XN_NO_HANDLE)
-   return EPERM;
+   cur = xeno_get_current();
+   if (cur == XN_NO_HANDLE)
+   return EPERM;
 
-   datp = mutex_get_datp(_mutex);
-   if (xnsynch_fast_owner_check(datp-owner, cur) != 0)
-   return EPERM;
-   }
+   datp = mutex_get_datp(_mutex);
+   if (xnsynch_fast_owner_check(datp-owner, cur) != 0)
+   return EPERM;
 
if (_mutex-lockcnt  1) {
--_mutex-lockcnt;
return 0;
}
 
-   if (!check)
-   datp = mutex_get_datp(_mutex);
-
if ((datp-flags  COBALT_MUTEX_COND_SIGNAL))
goto do_syscall;
 
if (unlikely(xeno_get_current_mode()  XNOTHER))
goto do_syscall;
 
-   if (!check)
-   cur = xeno_get_current();
-
if (likely(xnsynch_fast_release(datp-owner, cur)))
return 0;
-
 do_syscall:
 
do {


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/cobalt: RENICE signal must use regular setschedparam service

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: db0ab20df2cb35f919db16d921682d1a41fbecaa
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=db0ab20df2cb35f919db16d921682d1a41fbecaa

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Dec 12 15:46:22 2011 +0100

lib/cobalt: RENICE signal must use regular setschedparam service

---

 lib/cobalt/sigshadow.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/cobalt/sigshadow.c b/lib/cobalt/sigshadow.c
index 1a75052..51bb659 100644
--- a/lib/cobalt/sigshadow.c
+++ b/lib/cobalt/sigshadow.c
@@ -32,7 +32,7 @@ int xeno_sigwinch_handler(int sig, siginfo_t *si, void *ctxt)
arg = sigshadow_arg(si-si_int);
param.sched_priority = arg;
policy = param.sched_priority  0 ? SCHED_FIFO: SCHED_OTHER;
-   pthread_setschedparam(pthread_self(), policy, param);
+   __STD(pthread_setschedparam(pthread_self(), policy, param));
break;
}
 


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : psos/testsuite: add missing traced section entry

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 496d0e523e59e9517c3265e66fa478297017fb7e
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=496d0e523e59e9517c3265e66fa478297017fb7e

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Dec 13 11:26:56 2011 +0100

psos/testsuite: add missing traced section entry

---

 lib/psos/testsuite/rn-1.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/psos/testsuite/rn-1.c b/lib/psos/testsuite/rn-1.c
index d33cbfd..df35720 100644
--- a/lib/psos/testsuite/rn-1.c
+++ b/lib/psos/testsuite/rn-1.c
@@ -17,6 +17,8 @@ static void alloc_task(u_long a1, u_long a2, u_long a3, 
u_long a4)
int ret, n;
void *buf;
 
+   traceobj_enter(trobj);
+
srandom(0x11223344);
 
for (n = 0;; n++) {
@@ -29,6 +31,8 @@ static void alloc_task(u_long a1, u_long a2, u_long a3, 
u_long a4)
memset(buf, 0xaa, size);
alloc_size += size;
}
+
+   traceobj_exit(trobj);
 }
 
 int main(int argc, char *const argv[])


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/semobj: fix timed wait operation by enabling SEM_RAWCLOCK

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: dd9e91088445ac451087fc956dabc45eaba4816a
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=dd9e91088445ac451087fc956dabc45eaba4816a

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Dec 13 15:57:53 2011 +0100

copperplate/semobj: fix timed wait operation by enabling SEM_RAWCLOCK

---

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

diff --git a/lib/copperplate/semobj.c b/lib/copperplate/semobj.c
index a39933b..ef90a96 100644
--- a/lib/copperplate/semobj.c
+++ b/lib/copperplate/semobj.c
@@ -27,7 +27,7 @@
 int semobj_init(struct semobj *smobj, int flags, int value,
fnref_type(void (*)(struct semobj *smobj)) finalizer)
 {
-   int ret, sem_flags = sem_scope_attribute|SEM_REPORT;
+   int ret, sem_flags = sem_scope_attribute|SEM_REPORT|SEM_RAWCLOCK;
 
if ((flags  SEMOBJ_PRIO) == 0)
sem_flags |= SEM_FIFO;


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : kernel/cobalt: introduce monotonic clock-based sem_timedwait()

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: dad32967e94f5fff4edcffd4a78300442d79f0b9
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=dad32967e94f5fff4edcffd4a78300442d79f0b9

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Dec 13 15:53:03 2011 +0100

kernel/cobalt: introduce monotonic clock-based sem_timedwait()

POSIX mandates that timed waits on semaphores be based on
CLOCK_REALTIME. We introduce a non-standard variant allowing
CLOCK_MONOTONIC to be used instead, if SEM_RAWCLOCK is mentioned in
the creation flags passed to sem_init_np().

---

 include/cobalt/semaphore.h |1 +
 kernel/cobalt/sem.c|   36 
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/include/cobalt/semaphore.h b/include/cobalt/semaphore.h
index c7a29c3..312e73a 100644
--- a/include/cobalt/semaphore.h
+++ b/include/cobalt/semaphore.h
@@ -110,6 +110,7 @@ COBALT_DECL(int, sem_unlink(const char *name));
 #define SEM_PSHARED  0x4
 #define SEM_REPORT   0x8
 #define SEM_WARNDEL  0x10
+#define SEM_RAWCLOCK 0x20
 
 int sem_init_np(sem_t *sem,
int flags,
diff --git a/kernel/cobalt/sem.c b/kernel/cobalt/sem.c
index 6b1918c..e650fac 100644
--- a/kernel/cobalt/sem.c
+++ b/kernel/cobalt/sem.c
@@ -521,26 +521,27 @@ static int sem_trywait(cobalt_sem_t *sem)
 static inline int
 sem_timedwait_internal(cobalt_sem_t *sem, int timed, xnticks_t to)
 {
-   xnthread_t *cur;
-   int err;
-
-   cur = xnpod_current_thread();
+   xntmode_t tmode;
+   xnflags_t info;
+   int ret;
 
-   if ((err = sem_trywait_internal(sem)) != -EAGAIN)
-   return err;
+   ret = sem_trywait_internal(sem);
+   if (ret != -EAGAIN)
+   return ret;
 
-   if (timed)
-   xnsynch_sleep_on(sem-synchbase, to, XN_REALTIME);
-   else
-   xnsynch_sleep_on(sem-synchbase, XN_INFINITE, XN_RELATIVE);
+   if (timed) {
+   tmode = sem-flags  SEM_RAWCLOCK ? XN_ABSOLUTE : XN_REALTIME;
+   info = xnsynch_sleep_on(sem-synchbase, to, tmode);
+   } else
+   info = xnsynch_sleep_on(sem-synchbase, XN_INFINITE, 
XN_RELATIVE);
 
-   if (xnthread_test_info(cur, XNRMID))
+   if (info  XNRMID)
return -EINVAL;
 
-   if (xnthread_test_info(cur, XNBREAK))
+   if (info  XNBREAK)
return -EINTR;
 
-   if (xnthread_test_info(cur, XNTIMEO))
+   if (info  XNTIMEO)
return -ETIMEDOUT;
 
return 0;
@@ -599,8 +600,10 @@ static int sem_wait(cobalt_sem_t *sem)
  *
  * @param sm the semaphore to be decremented;
  *
- * @param abs_timeout the timeout, expressed as an absolute value of the
- * CLOCK_REALTIME clock.
+ * @param abs_timeout the timeout, expressed as an absolute value of
+ * the relevant clock for the semaphore, either CLOCK_MONOTONIC if
+ * SEM_RAWCLOCK was mentioned via sem_init_np(), or CLOCK_REALTIME
+ * otherwise.
  *
  * @retval 0 on success;
  * @retval -1 with @a errno set if:
@@ -987,7 +990,8 @@ int cobalt_sem_init_np(struct __shadow_sem __user *u_sem,
if (__xn_safe_copy_from_user(sm, u_sem, sizeof(sm)))
return -EFAULT;
 
-   if (flags  ~(SEM_FIFO|SEM_PULSE|SEM_PSHARED|SEM_REPORT|SEM_WARNDEL))
+   if (flags  ~(SEM_FIFO|SEM_PULSE|SEM_PSHARED|\
+ SEM_REPORT|SEM_WARNDEL|SEM_RAWCLOCK))
return -EINVAL;
 
err = do_sem_init(sm, flags, value);


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/syncluster: add missing wakeup code in private variant

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: ab521543c480a1c43444e171ec50ae92bb3ddf4a
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=ab521543c480a1c43444e171ec50ae92bb3ddf4a

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Dec 13 16:17:24 2011 +0100

copperplate/syncluster: add missing wakeup code in private variant

---

 lib/copperplate/cluster.c |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/lib/copperplate/cluster.c b/lib/copperplate/cluster.c
index 01e6abf..70d8bd4 100644
--- a/lib/copperplate/cluster.c
+++ b/lib/copperplate/cluster.c
@@ -385,6 +385,8 @@ void pvsyncluster_destroy(struct pvsyncluster *sc)
 int pvsyncluster_addobj(struct pvsyncluster *sc, const char *name,
struct pvclusterobj *cobj)
 {
+   struct syncluster_wait_struct *wait;
+   struct threadobj *thobj, *tmp;
struct syncstate syns;
int ret;
 
@@ -392,7 +394,21 @@ int pvsyncluster_addobj(struct pvsyncluster *sc, const 
char *name,
return __bt(-EINVAL);
 
ret = pvcluster_addobj(sc-c, name, cobj);
+   if (ret)
+   goto out;
 
+   if (!syncobj_pended_p(sc-sobj))
+   goto out;
+   /*
+* Wake up all threads waiting for this key to appear in the
+* dictionary.
+*/
+   syncobj_for_each_waiter_safe(sc-sobj, thobj, tmp) {
+   wait = threadobj_get_wait(thobj);
+   if (*wait-name == *name  strcmp(wait-name, name) == 0)
+   syncobj_wakeup_waiter(sc-sobj, thobj);
+   }
+out:
syncobj_unlock(sc-sobj, syns);
 
return ret;


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/tlsf: do not grow local heaps, fix main pool override

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: fbb0c1c4ee4ed7bcc323c61de6f685ca87949318
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=fbb0c1c4ee4ed7bcc323c61de6f685ca87949318

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Dec 13 17:55:03 2011 +0100

copperplate/tlsf: do not grow local heaps, fix main pool override

The original TLSF implementation attempts to grow local heaps upon
shortage, which does not fit our needs, we want the size mentioned at
pool creation to be a hard limit. This patch enforces this.

Additionally, we fix what looks like a bug in the original
implementation, preventing the main pool pointer to be overriden by
multiple calls to init_memory_pool(), which does not make any sense.
This fix does not remove the race of multiple threads calling
tlsf_alloc() concurrently with no active main pool, but we won't be
hit by this issue (heapobj_pkg_init will do the first tlsf_alloc(),
racelessly).

The several bugs related to multi-threading support found in TLSF tend
to make me nervous. At some point, we should investigate switching to
tlsf.baisoku.org, or provide a home-made version to fix the broken
TLSF interface to avoid these issues.

---

 lib/copperplate/tlsf/tlsf.c |   16 +++-
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/lib/copperplate/tlsf/tlsf.c b/lib/copperplate/tlsf/tlsf.c
index 0d89604..53ee1ce 100644
--- a/lib/copperplate/tlsf/tlsf.c
+++ b/lib/copperplate/tlsf/tlsf.c
@@ -451,7 +451,7 @@ static __inline__ bhdr_t *process_area(void *area, size_t 
size)
 / Begin of the allocator code */
 /**/
 
-static char *mp = NULL; /* Default memory pool. */
+static char *mp; /* Default memory pool. */
 
 /**/
 size_t init_memory_pool(size_t mem_pool_size, void *mem_pool)
@@ -461,24 +461,21 @@ size_t init_memory_pool(size_t mem_pool_size, void 
*mem_pool)
 bhdr_t *b, *ib;
 
 if (!mem_pool || !mem_pool_size || mem_pool_size  sizeof(tlsf_t) + 
BHDR_OVERHEAD * 8) {
-   ERROR_MSG(init_memory_pool (): memory_pool invalid\n);
+   ERROR_MSG(init_memory_pool(): invalid pool\n);
return -1;
 }
 
 if (((unsigned long) mem_pool  PTR_MASK)) {
-   ERROR_MSG(init_memory_pool (): mem_pool must be aligned to a word\n);
+   ERROR_MSG(init_memory_pool(): pool must be aligned to a word\n);
return -1;
 }
 tlsf = (tlsf_t *) mem_pool;
 /* Check if already initialised */
 if (tlsf-tlsf_signature == TLSF_SIGNATURE) {
-   mp = mem_pool;
-   b = GET_NEXT_BLOCK(mp, ROUNDUP_SIZE(sizeof(tlsf_t)));
-   return b-size  BLOCK_SIZE;
+   ERROR_MSG(init_memory_pool(): already initialized\n);
+   return -1;
 }
 
-mp = mem_pool;
-
 /* Zeroing the memory pool */
 memset(mem_pool, 0, sizeof(tlsf_t));
 
@@ -633,6 +630,7 @@ void *tlsf_malloc(size_t size)
if (area == ((void *) ~0))
return NULL;/* Not enough system memory */
init_memory_pool(area_size, area);
+   mp = area;
 }
 #endif
 
@@ -712,7 +710,7 @@ void *malloc_ex(size_t size, void *mem_pool)
so they are not longer valid when the function fails */
 b = FIND_SUITABLE_BLOCK(tlsf, fl, sl);
 #if USE_MMAP || USE_SBRK
-if (!b) {
+if (!b  mem_pool == mp) {/* Don't grow private pools */
size_t area_size;
void *area;
/* Growing the pool size when needed */


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : alchemy/queue: name internal memory pool after queue

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 6cf4540bf823bfe0761455295c3b3cfb9ca052e3
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=6cf4540bf823bfe0761455295c3b3cfb9ca052e3

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Dec 13 19:29:52 2011 +0100

alchemy/queue: name internal memory pool after queue

---

 lib/alchemy/queue.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/alchemy/queue.c b/lib/alchemy/queue.c
index f499234..218f2d1 100644
--- a/lib/alchemy/queue.c
+++ b/lib/alchemy/queue.c
@@ -63,16 +63,17 @@ int rt_queue_create(RT_QUEUE *queue, const char *name,
qcb = xnmalloc(sizeof(*qcb));
if (qcb == NULL)
goto out;
+
+   alchemy_build_name(qcb-name, name, queue_namegen);
/*
 * The message pool has to be part of the main heap for proper
 * sharing between processes.
 */
-   if (heapobj_init_shareable(qcb-hobj, NULL, poolsize)) {
+   if (heapobj_init_shareable(qcb-hobj, qcb-name, poolsize)) {
xnfree(qcb);
goto out;
}
 
-   alchemy_build_name(qcb-name, name, queue_namegen);
qcb-magic = queue_magic;
qcb-mode = mode;
qcb-limit = qlimit;


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/heapobj-malloc: remove preposterous overhead accounting

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: bafba1d74a92d7e49e2eff6c875513c27ebf008c
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=bafba1d74a92d7e49e2eff6c875513c27ebf008c

Author: Philippe Gerum r...@xenomai.org
Date:   Wed Dec 14 10:55:05 2011 +0100

copperplate/heapobj-malloc: remove preposterous overhead accounting

---

 lib/copperplate/heapobj-malloc.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/lib/copperplate/heapobj-malloc.c b/lib/copperplate/heapobj-malloc.c
index fa4db76..a39abe4 100644
--- a/lib/copperplate/heapobj-malloc.c
+++ b/lib/copperplate/heapobj-malloc.c
@@ -23,8 +23,6 @@
 #include copperplate/heapobj.h
 #include copperplate/debug.h
 
-#define MALLOC_BLOCK_OVERHEAD  8
-
 int heapobj_init_private(struct heapobj *hobj, const char *name,
 size_t size, void *mem)
 {
@@ -47,7 +45,6 @@ int heapobj_init_private(struct heapobj *hobj, const char 
*name,
 int heapobj_init_array_private(struct heapobj *hobj, const char *name,
   size_t size, int elems)
 {
-   size += MALLOC_BLOCK_OVERHEAD;
return __bt(heapobj_init_private(hobj, name, size * elems, NULL));
 }
 


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : alchemy/queue: give array hint when available for allocating the pool

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 2019d1538fdf293ba14098b70a3cb656476056ed
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=2019d1538fdf293ba14098b70a3cb656476056ed

Author: Philippe Gerum r...@xenomai.org
Date:   Wed Dec 14 11:13:42 2011 +0100

alchemy/queue: give array hint when available for allocating the pool

---

 lib/alchemy/queue.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/lib/alchemy/queue.c b/lib/alchemy/queue.c
index 218f2d1..0dcd7ce 100644
--- a/lib/alchemy/queue.c
+++ b/lib/alchemy/queue.c
@@ -69,7 +69,14 @@ int rt_queue_create(RT_QUEUE *queue, const char *name,
 * The message pool has to be part of the main heap for proper
 * sharing between processes.
 */
-   if (heapobj_init_shareable(qcb-hobj, qcb-name, poolsize)) {
+   if (qlimit == Q_UNLIMITED)
+   ret = heapobj_init_shareable(qcb-hobj, qcb-name,
+poolsize);
+   else
+   ret = heapobj_init_array_shareable(qcb-hobj, qcb-name,
+  poolsize / qlimit,
+  qlimit);
+   if (ret) {
xnfree(qcb);
goto out;
}


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : powerpc: upgrade I-pipe support to 3.0.13-powerpc-2.13-06, ipipe-3.1.5-powerpc-2.13-06

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 3840bf00aafc11fb7d53b05601a26823e266f644
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=3840bf00aafc11fb7d53b05601a26823e266f644

Author: Philippe Gerum r...@xenomai.org
Date:   Wed Dec 14 10:48:39 2011 +0100

powerpc: upgrade I-pipe support to 3.0.13-powerpc-2.13-06, 
ipipe-3.1.5-powerpc-2.13-06

---

 ...ch = adeos-ipipe-3.0.13-powerpc-2.13-06.patch} |  135 +++-
 ...tch = adeos-ipipe-3.1.5-powerpc-2.13-06.patch} |   80 +++-
 2 files changed, 126 insertions(+), 89 deletions(-)

diff --git 
a/kernel/cobalt/arch/powerpc/patches/adeos-ipipe-3.0.8-powerpc-2.13-04.patch 
b/kernel/cobalt/arch/powerpc/patches/adeos-ipipe-3.0.13-powerpc-2.13-06.patch
similarity index 99%
rename from 
kernel/cobalt/arch/powerpc/patches/adeos-ipipe-3.0.8-powerpc-2.13-04.patch
rename to 
kernel/cobalt/arch/powerpc/patches/adeos-ipipe-3.0.13-powerpc-2.13-06.patch
index d28173e..277581f 100644
--- a/kernel/cobalt/arch/powerpc/patches/adeos-ipipe-3.0.8-powerpc-2.13-04.patch
+++ 
b/kernel/cobalt/arch/powerpc/patches/adeos-ipipe-3.0.13-powerpc-2.13-06.patch
@@ -265,7 +265,7 @@ index bb712c9..8885e9b 100644
   * or should we not care like we do now ? --BenH.
 diff --git a/arch/powerpc/include/asm/ipipe.h 
b/arch/powerpc/include/asm/ipipe.h
 new file mode 100644
-index 000..97c12ea
+index 000..416688f
 --- /dev/null
 +++ b/arch/powerpc/include/asm/ipipe.h
 @@ -0,0 +1,278 @@
@@ -317,10 +317,10 @@ index 000..97c12ea
 +#include asm/paca.h
 +#endif
 +
-+#define IPIPE_ARCH_STRING 2.13-04
++#define IPIPE_ARCH_STRING 2.13-06
 +#define IPIPE_MAJOR_NUMBER2
 +#define IPIPE_MINOR_NUMBER13
-+#define IPIPE_PATCH_NUMBER4
++#define IPIPE_PATCH_NUMBER6
 +
 +#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
 +
@@ -3345,7 +3345,7 @@ index 9f82f49..dfa0441 100644
  NM=$1
  OBJ=$2
 diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
-index 620d792..e6dc326 100644
+index c7e7b8c..a5a47c8 100644
 --- a/arch/powerpc/kernel/setup_32.c
 +++ b/arch/powerpc/kernel/setup_32.c
 @@ -52,6 +52,9 @@ int __initdata boot_cpu_count;
@@ -3359,7 +3359,7 @@ index 620d792..e6dc326 100644
  unsigned long ISA_DMA_THRESHOLD;
  unsigned int DMA_MODE_READ;
 diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
-index a88bf27..ac5a3c3 100644
+index 7867fd1..f4ff1eb 100644
 --- a/arch/powerpc/kernel/setup_64.c
 +++ b/arch/powerpc/kernel/setup_64.c
 @@ -222,8 +222,10 @@ void __init early_setup(unsigned long dt_ptr)
@@ -3386,7 +3386,7 @@ index a88bf27..ac5a3c3 100644
DBG( - setup_system()\n);
  
/* Apply the CPUs-specific and firmware specific fixups to kernel
-@@ -456,6 +464,7 @@ static u64 safe_stack_limit(void)
+@@ -457,6 +465,7 @@ static u64 safe_stack_limit(void)
  #endif
  }
  
@@ -3394,7 +3394,7 @@ index a88bf27..ac5a3c3 100644
  static void __init irqstack_early_init(void)
  {
u64 limit = safe_stack_limit();
-@@ -474,6 +483,9 @@ static void __init irqstack_early_init(void)
+@@ -475,6 +484,9 @@ static void __init irqstack_early_init(void)
THREAD_SIZE, limit));
}
  }
@@ -3404,7 +3404,7 @@ index a88bf27..ac5a3c3 100644
  
  #ifdef CONFIG_PPC_BOOK3E
  static void __init exc_lvl_early_init(void)
-@@ -661,6 +673,10 @@ void __init setup_per_cpu_areas(void)
+@@ -662,6 +674,10 @@ void __init setup_per_cpu_areas(void)
  __per_cpu_offset[cpu] = delta + pcpu_unit_offsets[cpu];
paca[cpu].data_offset = __per_cpu_offset[cpu];
}
@@ -3797,10 +3797,10 @@ index 7c975d4..0c163f2 100644
  {
unsigned long target;
 diff --git a/arch/powerpc/lib/feature-fixups.c 
b/arch/powerpc/lib/feature-fixups.c
-index 0d08d01..2c6e946 100644
+index 7a8a748..8f13a2f 100644
 --- a/arch/powerpc/lib/feature-fixups.c
 +++ b/arch/powerpc/lib/feature-fixups.c
-@@ -29,6 +29,7 @@ struct fixup_entry {
+@@ -31,6 +31,7 @@ struct fixup_entry {
longalt_end_off;
  };
  
@@ -3808,7 +3808,7 @@ index 0d08d01..2c6e946 100644
  static unsigned int *calc_addr(struct fixup_entry *fcur, long offset)
  {
/*
-@@ -39,6 +40,7 @@ static unsigned int *calc_addr(struct fixup_entry *fcur, 
long offset)
+@@ -41,6 +42,7 @@ static unsigned int *calc_addr(struct fixup_entry *fcur, 
long offset)
return (unsigned int *)((unsigned long)fcur + offset);
  }
  
@@ -3816,7 +3816,7 @@ index 0d08d01..2c6e946 100644
  static int patch_alt_instruction(unsigned int *src, unsigned int *dest,
 unsigned int *alt_start, unsigned int *alt_end)
  {
-@@ -62,6 +64,7 @@ static int patch_alt_instruction(unsigned int *src, unsigned 
int *dest,
+@@ -64,6 +66,7 @@ static int patch_alt_instruction(unsigned int *src, unsigned 
int *dest,
return 0;
  }
  
@@ -3824,7 +3824,7 @@ index 0d08d01..2c6e946 100644
  static int patch_feature_section(unsigned long value, struct fixup_entry 
*fcur)
  {
unsigned int *start, 

[Xenomai-git] Philippe Gerum : alchemy/testsuite: fix delays for Cobalt runs

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 36784ff7b4f47e3e07c0837bf33dbfee455f
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=36784ff7b4f47e3e07c0837bf33dbfee455f

Author: Philippe Gerum r...@xenomai.org
Date:   Wed Dec 14 11:14:17 2011 +0100

alchemy/testsuite: fix delays for Cobalt runs

---

 lib/alchemy/testsuite/mq-3.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/alchemy/testsuite/mq-3.c b/lib/alchemy/testsuite/mq-3.c
index 9b70d93..a31e4d8 100644
--- a/lib/alchemy/testsuite/mq-3.c
+++ b/lib/alchemy/testsuite/mq-3.c
@@ -39,7 +39,7 @@ static void main_task(void *arg)
ret = rt_queue_write(q, msg, sizeof(int), Q_URGENT);
traceobj_assert(trobj, ret == -ENOMEM);
 
-   rt_task_sleep(100);
+   rt_task_sleep(1);
 
ret = rt_queue_write(q, msg, sizeof(int), Q_URGENT);
traceobj_assert(trobj, ret == 0);
@@ -79,7 +79,7 @@ static void peer_task(void *arg)
 
traceobj_mark(trobj, 14);
 
-   rt_task_sleep(100);
+   rt_task_sleep(1);
 
traceobj_mark(trobj, 9);
 


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : psos/testsuite, alchemy/testsuite: fix test sequences

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 58d712adeb4ed24e19a576a2eace1e36a4c51381
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=58d712adeb4ed24e19a576a2eace1e36a4c51381

Author: Philippe Gerum r...@xenomai.org
Date:   Wed Dec 14 12:41:55 2011 +0100

psos/testsuite, alchemy/testsuite: fix test sequences

Because the cancellation path taken from threadobj_cancel() might
induce some transient sleep time for the caller, we can't assume a
preemption-less execution.

---

 lib/alchemy/testsuite/task-2.c |4 +---
 lib/psos/testsuite/task-2.c|4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/lib/alchemy/testsuite/task-2.c b/lib/alchemy/testsuite/task-2.c
index 9e0038d..52d5289 100644
--- a/lib/alchemy/testsuite/task-2.c
+++ b/lib/alchemy/testsuite/task-2.c
@@ -8,7 +8,7 @@
 static struct traceobj trobj;
 
 static int tseq[] = {
-   8, 1, 9, 4, 10, 5, 11, 2, 6, 7, 12
+   8, 1, 9, 4, 10, 5, 11, 2, 6, 7
 };
 
 static RT_TASK t_bgnd, t_fgnd;
@@ -99,8 +99,6 @@ int main(int argc, char *const argv[])
ret = rt_sem_v(sem);
traceobj_assert(trobj, ret == 0);
 
-   traceobj_mark(trobj, 12);
-
traceobj_join(trobj);
 
traceobj_verify(trobj, tseq, sizeof(tseq) / sizeof(int));
diff --git a/lib/psos/testsuite/task-2.c b/lib/psos/testsuite/task-2.c
index 014888f..a64f38c 100644
--- a/lib/psos/testsuite/task-2.c
+++ b/lib/psos/testsuite/task-2.c
@@ -7,7 +7,7 @@
 static struct traceobj trobj;
 
 static int tseq[] = {
-   8, 1, 9, 4, 10, 5, 11, 2, 6, 7, 12
+   8, 1, 9, 4, 10, 5, 11, 2, 6, 7
 };
 
 static u_long btid, ftid;
@@ -99,8 +99,6 @@ int main(int argc, char *const argv[])
ret = sm_v(sem_id);
traceobj_assert(trobj, ret == SUCCESS);
 
-   traceobj_mark(trobj, 12);
-
traceobj_join(trobj);
 
traceobj_verify(trobj, tseq, sizeof(tseq) / sizeof(int));


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : alchemy/testsuite: prevent 32bit overflow with time constants

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 1b4cff66bf016be722f68ee0e0220f68abcc9894
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=1b4cff66bf016be722f68ee0e0220f68abcc9894

Author: Philippe Gerum r...@xenomai.org
Date:   Wed Dec 14 14:11:02 2011 +0100

alchemy/testsuite: prevent 32bit overflow with time constants

---

 lib/alchemy/testsuite/alarm-1.c  |4 ++--
 lib/alchemy/testsuite/buffer-1.c |2 +-
 lib/alchemy/testsuite/event-1.c  |2 +-
 lib/alchemy/testsuite/heap-1.c   |2 +-
 lib/alchemy/testsuite/mq-1.c |2 +-
 lib/alchemy/testsuite/mq-2.c |2 +-
 lib/alchemy/testsuite/mq-3.c |4 ++--
 lib/alchemy/testsuite/mutex-1.c  |2 +-
 lib/alchemy/testsuite/sem-1.c|4 ++--
 lib/alchemy/testsuite/task-2.c   |2 +-
 lib/alchemy/testsuite/task-4.c   |2 +-
 lib/alchemy/testsuite/task-6.c   |2 +-
 12 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/lib/alchemy/testsuite/alarm-1.c b/lib/alchemy/testsuite/alarm-1.c
index e29ed4d..83d236d 100644
--- a/lib/alchemy/testsuite/alarm-1.c
+++ b/lib/alchemy/testsuite/alarm-1.c
@@ -37,7 +37,7 @@ static void alarm_handler(void *arg)
}
 
traceobj_mark(trobj, 4);
-   ret = rt_alarm_start(alrm, 2, 2);
+   ret = rt_alarm_start(alrm, 2ULL, 2ULL);
traceobj_assert(trobj, ret == 0);
 }
 
@@ -56,7 +56,7 @@ static void main_task(void *arg)
ret = rt_alarm_create(alrm, ALARM, alarm_handler, alrm);
traceobj_assert(trobj, ret == 0);
 
-   ret = rt_alarm_start(alrm, 2, 2);
+   ret = rt_alarm_start(alrm, 2ULL, 2ULL);
traceobj_assert(trobj, ret == 0);
 
traceobj_mark(trobj, 6);
diff --git a/lib/alchemy/testsuite/buffer-1.c b/lib/alchemy/testsuite/buffer-1.c
index 8d46d8a..f0997bd 100644
--- a/lib/alchemy/testsuite/buffer-1.c
+++ b/lib/alchemy/testsuite/buffer-1.c
@@ -92,7 +92,7 @@ int main(int argc, char *const argv[])
ret = rt_task_start(t_bgnd, background_task, NULL);
traceobj_assert(trobj, ret == 0);
 
-   ret = rt_task_sleep(15);
+   ret = rt_task_sleep(15ULL);
traceobj_assert(trobj, ret == 0);
 
ret = rt_task_delete(t_bgnd);
diff --git a/lib/alchemy/testsuite/event-1.c b/lib/alchemy/testsuite/event-1.c
index 63a0e73..6850f9a 100644
--- a/lib/alchemy/testsuite/event-1.c
+++ b/lib/alchemy/testsuite/event-1.c
@@ -53,7 +53,7 @@ static void foreground_task(void *arg)
traceobj_assert(trobj, flags == 2  n * 2);
}
 
-   rt_task_sleep(100);
+   rt_task_sleep(100ULL);
ret = rt_event_delete(event);
traceobj_assert(trobj, ret == 0);
 
diff --git a/lib/alchemy/testsuite/heap-1.c b/lib/alchemy/testsuite/heap-1.c
index 008f73f..c626d5d 100644
--- a/lib/alchemy/testsuite/heap-1.c
+++ b/lib/alchemy/testsuite/heap-1.c
@@ -58,7 +58,7 @@ static void foreground_task(void *arg)
ret = rt_heap_free(heap, p2);
traceobj_assert(trobj, ret == 0);
 
-   rt_task_sleep(100);
+   rt_task_sleep(100ULL);
 
ret = rt_heap_delete(heap);
traceobj_assert(trobj, ret == 0);
diff --git a/lib/alchemy/testsuite/mq-1.c b/lib/alchemy/testsuite/mq-1.c
index 41b4fc0..4a418b9 100644
--- a/lib/alchemy/testsuite/mq-1.c
+++ b/lib/alchemy/testsuite/mq-1.c
@@ -79,7 +79,7 @@ static void main_task(void *arg)
traceobj_assert(trobj, ret == 0);
traceobj_assert(trobj, info.nmessages == 0);
 
-   ret = rt_queue_read(q, msg, sizeof(msg), 100);
+   ret = rt_queue_read(q, msg, sizeof(msg), 100ULL);
traceobj_assert(trobj, ret == -ETIMEDOUT);
 
ret = rt_queue_delete(q);
diff --git a/lib/alchemy/testsuite/mq-2.c b/lib/alchemy/testsuite/mq-2.c
index 7810275..1b3fce8 100644
--- a/lib/alchemy/testsuite/mq-2.c
+++ b/lib/alchemy/testsuite/mq-2.c
@@ -81,7 +81,7 @@ static void main_task(void *arg)
 
traceobj_mark(trobj, 6);
 
-   rt_task_sleep(1000);
+   rt_task_sleep(1000ULL);
 
traceobj_mark(trobj, 7);
 
diff --git a/lib/alchemy/testsuite/mq-3.c b/lib/alchemy/testsuite/mq-3.c
index a31e4d8..d4c6a78 100644
--- a/lib/alchemy/testsuite/mq-3.c
+++ b/lib/alchemy/testsuite/mq-3.c
@@ -39,7 +39,7 @@ static void main_task(void *arg)
ret = rt_queue_write(q, msg, sizeof(int), Q_URGENT);
traceobj_assert(trobj, ret == -ENOMEM);
 
-   rt_task_sleep(1);
+   rt_task_sleep(1ULL);
 
ret = rt_queue_write(q, msg, sizeof(int), Q_URGENT);
traceobj_assert(trobj, ret == 0);
@@ -79,7 +79,7 @@ static void peer_task(void *arg)
 
traceobj_mark(trobj, 14);
 
-   rt_task_sleep(1);
+   rt_task_sleep(1ULL);
 
traceobj_mark(trobj, 9);
 
diff --git a/lib/alchemy/testsuite/mutex-1.c b/lib/alchemy/testsuite/mutex-1.c
index 2378909..8b9fc22 100644
--- a/lib/alchemy/testsuite/mutex-1.c
+++ b/lib/alchemy/testsuite/mutex-1.c
@@ -35,7 +35,7 @@ 

[Xenomai-git] Philippe Gerum : copperplate/syncobj, threadobj: catch unsafe (unlocked) calls in debug mode

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: ab75a7adf7c9cb8a972aa25438c647f75b7c7814
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=ab75a7adf7c9cb8a972aa25438c647f75b7c7814

Author: Philippe Gerum r...@xenomai.org
Date:   Wed Dec 14 15:36:23 2011 +0100

copperplate/syncobj, threadobj: catch unsafe (unlocked) calls in debug mode

---

 include/copperplate/syncobj.h   |   44 ++
 include/copperplate/threadobj.h |   56 +-
 lib/copperplate/syncobj.c   |   24 
 lib/copperplate/threadobj.c |   44 +++---
 4 files changed, 162 insertions(+), 6 deletions(-)

diff --git a/include/copperplate/syncobj.h b/include/copperplate/syncobj.h
index 3c5fa8b..5112c02 100644
--- a/include/copperplate/syncobj.h
+++ b/include/copperplate/syncobj.h
@@ -26,6 +26,7 @@
 /* syncobj-flags */
 #define SYNCOBJ_FIFO   0x0
 #define SYNCOBJ_PRIO   0x1
+#define SYNCOBJ_LOCKED 0x2
 
 /* threadobj-wait_status */
 #define SYNCOBJ_DELETED0x1
@@ -80,6 +81,41 @@ struct syncobj {
 
 void __syncobj_cleanup_wait(struct syncobj *sobj,
struct threadobj *thobj);
+
+#ifdef __XENO_DEBUG__
+
+static inline void __syncobj_tag_locked(struct syncobj *sobj)
+{
+   sobj-flags |= SYNCOBJ_LOCKED;
+}
+
+static inline void __syncobj_tag_unlocked(struct syncobj *sobj)
+{
+   assert(sobj-flags  SYNCOBJ_LOCKED);
+   sobj-flags = ~SYNCOBJ_LOCKED;
+}
+
+static inline void __syncobj_check_locked(struct syncobj *sobj)
+{
+   assert(sobj-flags  SYNCOBJ_LOCKED);
+}
+
+#else /* !__XENO_DEBUG__ */
+
+static inline void __syncobj_tag_locked(struct syncobj *sobj)
+{
+}
+
+static inline void __syncobj_tag_unlocked(struct syncobj *sobj)
+{
+}
+
+static inline void __syncobj_check_locked(struct syncobj *sobj)
+{
+}
+
+#endif /* !__XENO_DEBUG__ */
+
 #ifdef __cplusplus
 extern C {
 #endif
@@ -111,16 +147,22 @@ int __syncobj_signal_drain(struct syncobj *sobj);
 
 static inline int syncobj_pended_p(struct syncobj *sobj)
 {
+   __syncobj_check_locked(sobj);
+
return !list_empty(sobj-pend_list);
 }
 
 static inline int syncobj_pend_count(struct syncobj *sobj)
 {
+   __syncobj_check_locked(sobj);
+
return sobj-pend_count;
 }
 
 static inline int syncobj_drain_count(struct syncobj *sobj)
 {
+   __syncobj_check_locked(sobj);
+
return sobj-drain_count;
 }
 
@@ -143,6 +185,8 @@ static inline int syncobj_signal_drain(struct syncobj *sobj)
 {
int ret = 0;
 
+   __syncobj_check_locked(sobj);
+
if (sobj-drain_count  0)
ret = __syncobj_signal_drain(sobj);
 
diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h
index 38043e0..1e77e2e 100644
--- a/include/copperplate/threadobj.h
+++ b/include/copperplate/threadobj.h
@@ -84,6 +84,7 @@ struct threadobj_stat {
 #define THREADOBJ_STARTED  0x4 /* threadobj_start() called. */
 #define THREADOBJ_WARMUP   0x8 /* threadobj_prologue() not called yet. 
*/
 #define THREADOBJ_ABORTED  0x10/* cancelled before start. */
+#define THREADOBJ_LOCKED   0x20/* threadobj_lock() granted (debug 
only). */
 #define THREADOBJ_DEBUG0x8000  /* Debug mode enabled. */
 
 #define THREADOBJ_IRQCONTEXT((struct threadobj *)-2UL)
@@ -187,6 +188,40 @@ static inline struct threadobj *threadobj_current(void)
 
 #endif /* !HAVE_TLS */
 
+#ifdef __XENO_DEBUG__
+
+static inline void __threadobj_tag_locked(struct threadobj *thobj)
+{
+   thobj-status |= THREADOBJ_LOCKED;
+}
+
+static inline void __threadobj_tag_unlocked(struct threadobj *thobj)
+{
+   assert(thobj-status  THREADOBJ_LOCKED);
+   thobj-status = ~THREADOBJ_LOCKED;
+}
+
+static inline void __threadobj_check_locked(struct threadobj *thobj)
+{
+   assert(thobj-status  THREADOBJ_LOCKED);
+}
+
+#else /* !__XENO_DEBUG__ */
+
+static inline void __threadobj_tag_locked(struct threadobj *thobj)
+{
+}
+
+static inline void __threadobj_tag_unlocked(struct threadobj *thobj)
+{
+}
+
+static inline void __threadobj_check_locked(struct threadobj *thobj)
+{
+}
+
+#endif /* !__XENO_DEBUG__ */
+
 #ifdef __cplusplus
 extern C {
 #endif
@@ -283,16 +318,33 @@ static inline int threadobj_get_priority(struct threadobj 
*thobj)
 
 static inline int threadobj_lock(struct threadobj *thobj)
 {
-   return write_lock_safe(thobj-lock, thobj-cancel_state);
+   int ret;
+
+   ret = write_lock_safe(thobj-lock, thobj-cancel_state);
+   if (ret)
+   return ret;
+
+   __threadobj_tag_locked(thobj);
+
+   return 0;
 }
 
 static inline int threadobj_trylock(struct threadobj *thobj)
 {
-   return write_trylock_safe(thobj-lock, thobj-cancel_state);
+   int ret;
+
+   ret = write_trylock_safe(thobj-lock, thobj-cancel_state);
+   if (ret)
+   return ret;
+
+   __threadobj_tag_locked(thobj);
+
+   return 0;
 }
 
 static inline int 

[Xenomai-git] Philippe Gerum : cobalt/monitor: fix double-dequeuing upon GRANT+KICK race

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 56c7b8ee683c2f2902050b67c37d82d7176ad524
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=56c7b8ee683c2f2902050b67c37d82d7176ad524

Author: Philippe Gerum r...@xenomai.org
Date:   Wed Dec 14 16:52:26 2011 +0100

cobalt/monitor: fix double-dequeuing upon GRANT+KICK race

---

 kernel/cobalt/monitor.c |7 ++-
 kernel/cobalt/thread.c  |1 +
 kernel/cobalt/thread.h  |1 +
 3 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/kernel/cobalt/monitor.c b/kernel/cobalt/monitor.c
index 4e4ea4f..678ea6c 100644
--- a/kernel/cobalt/monitor.c
+++ b/kernel/cobalt/monitor.c
@@ -202,6 +202,7 @@ static int cobalt_monitor_wakeup(struct cobalt_monitor *mon)
xnsynch_wakeup_this_sleeper(tid-monitor_synch,
p-plink);
removeq(mon-waiters, tid-monitor_link);
+   tid-monitor_queued = 0;
resched = 1;
}
}
@@ -278,6 +279,7 @@ int cobalt_monitor_wait(struct cobalt_monitor_shadow __user 
*u_monsh,
else {
*cur-threadbase.u_mode = ~XNGRANT;
appendq(mon-waiters, cur-monitor_link);
+   cur-monitor_queued = 1;
}
datp-flags |= COBALT_MONITOR_PENDED;
 
@@ -290,8 +292,11 @@ int cobalt_monitor_wait(struct cobalt_monitor_shadow 
__user *u_monsh,
goto out;
}
 
-   if ((event  COBALT_MONITOR_WAITDRAIN) == 0)
+   if ((event  COBALT_MONITOR_WAITDRAIN) == 0 
+   cur-monitor_queued) {
removeq(mon-waiters, cur-monitor_link);
+   cur-monitor_queued = 0;
+   }
 
if (emptyq_p(mon-waiters)  !xnsynch_pended_p(mon-drain))
datp-flags = ~COBALT_MONITOR_PENDED;
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 00086ac..c4120ad 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -451,6 +451,7 @@ static inline int pthread_create(pthread_t *tid, const 
pthread_attr_t * attr)
thread-magic = COBALT_THREAD_MAGIC;
xnsynch_init(thread-monitor_synch, XNSYNCH_FIFO, NULL);
inith(thread-monitor_link);
+   thread-monitor_queued = 0;
thread-sched_policy = thread-attr.policy;
 
cobalt_timer_init_thread(thread);
diff --git a/kernel/cobalt/thread.h b/kernel/cobalt/thread.h
index 162cd42..5c819fb 100644
--- a/kernel/cobalt/thread.h
+++ b/kernel/cobalt/thread.h
@@ -74,6 +74,7 @@ struct cobalt_thread {
/* Monitor wait object and link holder. */
struct xnsynch monitor_synch;
struct xnholder monitor_link;
+   int monitor_queued;
 
 #ifndef __XENO_SIM__
struct cobalt_hkey hkey;


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/syncobj: prevent concurrent locking while a deletion is pending

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: a739260b1d94c0dd15df5f80ddd63d122f2c74ed
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=a739260b1d94c0dd15df5f80ddd63d122f2c74ed

Author: Philippe Gerum r...@xenomai.org
Date:   Wed Dec 14 19:00:44 2011 +0100

copperplate/syncobj: prevent concurrent locking while a deletion is pending

---

 include/copperplate/syncobj.h |3 +++
 lib/copperplate/syncobj.c |9 +
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/include/copperplate/syncobj.h b/include/copperplate/syncobj.h
index 5112c02..e3f0b01 100644
--- a/include/copperplate/syncobj.h
+++ b/include/copperplate/syncobj.h
@@ -41,6 +41,8 @@
 #define SYNCOBJ_BLOCK  0x1
 #define SYNCOBJ_RESUME 0x2
 
+#define SYNCOBJ_MAGIC  0xf9f99f9f
+
 struct threadobj;
 
 struct syncstate {
@@ -63,6 +65,7 @@ struct syncobj_corespec {
 #endif /* CONFIG_XENO_MERCURY */
 
 struct syncobj {
+   unsigned int magic;
int flags;
int release_count;
struct list pend_list;
diff --git a/lib/copperplate/syncobj.c b/lib/copperplate/syncobj.c
index a70a7d2..c3323ea 100644
--- a/lib/copperplate/syncobj.c
+++ b/lib/copperplate/syncobj.c
@@ -223,6 +223,7 @@ void syncobj_init(struct syncobj *sobj, int flags,
sobj-drain_count = 0;
sobj-release_count = 0;
sobj-finalizer = finalizer;
+   sobj-magic = SYNCOBJ_MAGIC;
syncobj_init_corespec(sobj);
 }
 
@@ -232,6 +233,13 @@ int syncobj_lock(struct syncobj *sobj, struct syncstate 
*syns)
 
assert(threadobj_current() != NULL);
 
+   /*
+* This magic prevents concurrent locking while a deletion is
+* in progress, waiting for the release count to drop to zero.
+*/
+   if (sobj-magic != SYNCOBJ_MAGIC)
+   return -EINVAL;
+
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, oldstate);
 
ret = monitor_enter(sobj);
@@ -561,6 +569,7 @@ int syncobj_destroy(struct syncobj *sobj, struct syncstate 
*syns)
 
__syncobj_check_locked(sobj);
 
+   sobj-magic = ~SYNCOBJ_MAGIC;
ret = syncobj_flush(sobj, SYNCOBJ_DELETED);
if (ret == 0) {
/* No thread awaken - we may dispose immediately. */


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/threadobj, lib: fix locking rules of threadobj_set_priority()

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 072601b0d193b86ee50ec7495eed4b91cc6a5357
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=072601b0d193b86ee50ec7495eed4b91cc6a5357

Author: Philippe Gerum r...@xenomai.org
Date:   Thu Dec 15 10:30:15 2011 +0100

copperplate/threadobj, lib: fix locking rules of threadobj_set_priority()

Since threadobj_set_priority() must receive the thread lock on entry,
prior to dropping it before applying the priority change via a
syscall, it might be unable to lock it back before returning to the
caller, in case the thread has exited in the meantime.

Instead of attempting to re-lock the object eventually - bluntly
ignoring the operation status - we should rather behave fully as a
lock-dropping call and document it accordingly. Callers should grab
that lock again in case more changes are required (which none of them
currently want anyway).

---

 lib/alchemy/task.c  |1 -
 lib/copperplate/threadobj.c |   31 +--
 lib/psos/task.c |1 -
 lib/vxworks/taskLib.c   |1 -
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index e21122e..e627a33 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -592,7 +592,6 @@ int rt_task_set_priority(RT_TASK *task, int prio)
goto out;
 
ret = threadobj_set_priority(tcb-thobj, prio);
-   put_alchemy_task(tcb);
 out:
COPPERPLATE_UNPROTECT(svc);
 
diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 79db06f..7dac280 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -272,11 +272,11 @@ int threadobj_unlock_sched(struct threadobj *thobj) /* 
thobj-lock held */
return __bt(-ret);
 }
 
-int threadobj_set_priority(struct threadobj *thobj, int prio) /* thobj-lock 
held */
+int threadobj_set_priority(struct threadobj *thobj, int prio) /* thobj-lock 
held, dropped */
 {
struct sched_param_ex xparam;
pthread_t tid = thobj-tid;
-   int ret, policy;
+   int policy;
 
__threadobj_check_locked(thobj);
 
@@ -297,10 +297,8 @@ int threadobj_set_priority(struct threadobj *thobj, int 
prio) /* thobj-lock hel
 * set.
 */
xparam.sched_priority = prio;
-   ret = pthread_setschedparam_ex(tid, policy, xparam);
-   threadobj_lock(thobj);
 
-   return __bt(-ret);
+   return pthread_setschedparam_ex(tid, policy, xparam);
 }
 
 int threadobj_set_mode(struct threadobj *thobj,
@@ -583,12 +581,14 @@ int threadobj_resume(struct threadobj *thobj) /* 
thobj-lock held */
return __bt(notifier_release(thobj-core.notifier));
 }
 
-int threadobj_lock_sched(struct threadobj *thobj)
+int threadobj_lock_sched(struct threadobj *thobj) /* thobj-lock held */
 {
pthread_t tid = thobj-tid;
struct sched_param param;
int policy, ret;
 
+   __threadobj_check_locked(thobj);
+
assert(thobj == threadobj_current());
 
if (thobj-schedlock_depth++  0)
@@ -606,12 +606,14 @@ int threadobj_lock_sched(struct threadobj *thobj)
return __bt(-pthread_setschedparam(tid, SCHED_RT, param));
 }
 
-int threadobj_unlock_sched(struct threadobj *thobj)
+int threadobj_unlock_sched(struct threadobj *thobj) /* thobj-lock held */
 {
pthread_t tid = thobj-tid;
struct sched_param param;
int policy, ret;
 
+   __threadobj_check_locked(thobj);
+
assert(thobj == threadobj_current());
 
if (thobj-schedlock_depth == 0)
@@ -631,11 +633,13 @@ int threadobj_unlock_sched(struct threadobj *thobj)
return __bt(-ret);
 }
 
-int threadobj_set_priority(struct threadobj *thobj, int prio)
+int threadobj_set_priority(struct threadobj *thobj, int prio) /* thobj-lock 
held, dropped */
 {
pthread_t tid = thobj-tid;
struct sched_param param;
-   int policy, ret;
+   int policy;
+
+   __threadobj_check_locked(thobj);
 
/*
 * We don't actually change the scheduling priority in case
@@ -647,18 +651,16 @@ int threadobj_set_priority(struct threadobj *thobj, int 
prio)
return 0;
}
 
+   thobj-priority = prio;
threadobj_unlock(thobj);
/*
 * Since we released the thread container lock, we now rely on
 * the pthread interface to recheck the tid for existence.
 */
-   thobj-priority = prio;
param.sched_priority = prio;
policy = prio ? SCHED_RT : SCHED_OTHER;
-   ret = pthread_setschedparam(tid, policy, param);
-   threadobj_lock(thobj);
 
-   return __bt(-ret);
+   return pthread_setschedparam(tid, policy, param);
 }
 
 int threadobj_set_mode(struct threadobj *thobj,
@@ -704,8 +706,9 @@ static inline void set_rr(struct threadobj *thobj, struct 
timespec *quantum)
 }
 
 int threadobj_set_rr(struct threadobj *thobj, struct timespec *quantum)
-{
+{  /* thobj-lock held if valid 

[Xenomai-git] Philippe Gerum : cobalt/nucleus: fix thread state label enumeration

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: aaf06b242660e67cca322f3074d4e02f83216def
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=aaf06b242660e67cca322f3074d4e02f83216def

Author: Philippe Gerum r...@xenomai.org
Date:   Thu Dec 15 22:15:11 2011 +0100

cobalt/nucleus: fix thread state label enumeration

---

 include/cobalt/nucleus/thread.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/cobalt/nucleus/thread.h b/include/cobalt/nucleus/thread.h
index 4775853..3176a42 100644
--- a/include/cobalt/nucleus/thread.h
+++ b/include/cobalt/nucleus/thread.h
@@ -82,7 +82,7 @@
   't' - Mode switches trapped.
   'f' - FPU enabled (for kernel threads).
 */
-#define XNTHREAD_STATE_LABELS  SWDRU...X.HbTlr...tf...
+#define XNTHREAD_STATE_LABELS  SWDRUX.HbTlr...tf...
 
 #define XNTHREAD_BLOCK_BITS   
(XNSUSP|XNPEND|XNDELAY|XNDORMANT|XNRELAX|XNMIGRATE|XNHELD)
 #define XNTHREAD_MODE_BITS(XNLOCK|XNRRB|XNASDI|XNTRAPSW)


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/syncobj, lib: fix multiple races caused by deletion

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 7fdbd7579d7780929fd4432e941100b0f8055458
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=7fdbd7579d7780929fd4432e941100b0f8055458

Author: Philippe Gerum r...@xenomai.org
Date:   Thu Dec 15 22:18:05 2011 +0100

copperplate/syncobj, lib: fix multiple races caused by deletion

This patch is a major rework of the syncobj deletion code. Basically,
deleting a synchronization object under heavy use just did not work,
triggering a variety of deadly races.

At this chance, we also fixed several syncobj API services (name
and/or goal), to fit the GRANT/DRAIN semantics introduced by the
Cobalt monitors (but still relevant for Mercury nevertheless).

---

 include/copperplate/syncobj.h |   79 
 lib/alchemy/buffer.c  |   22 +-
 lib/alchemy/event.c   |8 +-
 lib/alchemy/heap.c|8 +-
 lib/alchemy/queue.c   |   16 +-
 lib/alchemy/task.c|   18 +-
 lib/copperplate/cluster.c |   12 +-
 lib/copperplate/semobj.c  |6 +-
 lib/copperplate/syncobj.c |  435 -
 lib/copperplate/threadobj.c   |2 +-
 lib/psos/queue.c  |8 +-
 lib/psos/rn.c |6 +-
 lib/psos/task.c   |4 +-
 lib/vxworks/msgQLib.c |   10 +-
 lib/vxworks/semLib.c  |6 +-
 15 files changed, 318 insertions(+), 322 deletions(-)

diff --git a/include/copperplate/syncobj.h b/include/copperplate/syncobj.h
index e3f0b01..55f3c50 100644
--- a/include/copperplate/syncobj.h
+++ b/include/copperplate/syncobj.h
@@ -29,13 +29,9 @@
 #define SYNCOBJ_LOCKED 0x2
 
 /* threadobj-wait_status */
-#define SYNCOBJ_DELETED0x1
-#define SYNCOBJ_FLUSHED0x2
-#define SYNCOBJ_BROADCAST  0x4
-#define SYNCOBJ_DRAINING   0x8
-
-#define SYNCOBJ_RELEASE_MASK   \
-   (SYNCOBJ_DELETED|SYNCOBJ_FLUSHED|SYNCOBJ_BROADCAST)
+#define SYNCOBJ_FLUSHED0x1
+#define SYNCOBJ_SIGNALED   0x2
+#define SYNCOBJ_DRAINWAIT  0x4
 
 /* threadobj-wait_hook(status) */
 #define SYNCOBJ_BLOCK  0x1
@@ -67,9 +63,9 @@ struct syncobj_corespec {
 struct syncobj {
unsigned int magic;
int flags;
-   int release_count;
-   struct list pend_list;
-   int pend_count;
+   int wait_count;
+   struct list grant_list;
+   int grant_count;
struct list drain_list;
int drain_count;
struct syncobj_corespec core;
@@ -77,10 +73,10 @@ struct syncobj {
 };
 
 #define syncobj_for_each_waiter(sobj, pos) \
-   list_for_each_entry(pos, (sobj)-pend_list, wait_link)
+   list_for_each_entry(pos, (sobj)-grant_list, wait_link)
 
 #define syncobj_for_each_waiter_safe(sobj, pos, tmp)   \
-   list_for_each_entry_safe(pos, tmp, (sobj)-pend_list, wait_link)
+   list_for_each_entry_safe(pos, tmp, (sobj)-grant_list, wait_link)
 
 void __syncobj_cleanup_wait(struct syncobj *sobj,
struct threadobj *thobj);
@@ -123,18 +119,25 @@ static inline void __syncobj_check_locked(struct syncobj 
*sobj)
 extern C {
 #endif
 
+int __syncobj_broadcast_drain(struct syncobj *sobj, int reason);
+
+int __syncobj_broadcast_grant(struct syncobj *sobj, int reason);
+
 void syncobj_init(struct syncobj *sobj, int flags,
  fnref_type(void (*)(struct syncobj *sobj)) finalizer);
 
-int syncobj_pend(struct syncobj *sobj,
+int syncobj_wait_grant(struct syncobj *sobj,
 const struct timespec *timeout,
 struct syncstate *syns);
 
-struct threadobj *syncobj_post(struct syncobj *sobj);
+struct threadobj *syncobj_grant_one(struct syncobj *sobj);
+
+void syncobj_grant_to(struct syncobj *sobj,
+ struct threadobj *thobj);
 
-struct threadobj *syncobj_peek_at_pend(struct syncobj *sobj);
+struct threadobj *syncobj_peek_grant(struct syncobj *sobj);
 
-struct threadobj *syncobj_peek_at_drain(struct syncobj *sobj);
+struct threadobj *syncobj_peek_drain(struct syncobj *sobj);
 
 int syncobj_lock(struct syncobj *sobj,
 struct syncstate *syns);
@@ -146,54 +149,60 @@ int syncobj_wait_drain(struct syncobj *sobj,
   const struct timespec *timeout,
   struct syncstate *syns);
 
-int __syncobj_signal_drain(struct syncobj *sobj);
+int syncobj_flush(struct syncobj *sobj);
+
+int syncobj_destroy(struct syncobj *sobj,
+   struct syncstate *syns);
 
-static inline int syncobj_pended_p(struct syncobj *sobj)
+void syncobj_uninit(struct syncobj *sobj);
+
+static inline int syncobj_grant_wait_p(struct syncobj *sobj)
 {
__syncobj_check_locked(sobj);
 
-   return !list_empty(sobj-pend_list);
+   return !list_empty(sobj-grant_list);
 }
 
-static inline int syncobj_pend_count(struct syncobj *sobj)
+static inline int syncobj_count_grant(struct syncobj *sobj)
 {
__syncobj_check_locked(sobj);
 
-   return sobj-pend_count;
+   return 

[Xenomai-git] Philippe Gerum : copperplate/syncobj: inline syncobj_flush()

2011-12-19 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: e9536b23127e82dea24349b9b0bb188f9cfbd24d
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=e9536b23127e82dea24349b9b0bb188f9cfbd24d

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Dec 19 17:57:44 2011 +0100

copperplate/syncobj: inline syncobj_flush()

---

 include/copperplate/syncobj.h |   15 +--
 lib/copperplate/syncobj.c |   13 -
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/include/copperplate/syncobj.h b/include/copperplate/syncobj.h
index 55f3c50..0fe0d85 100644
--- a/include/copperplate/syncobj.h
+++ b/include/copperplate/syncobj.h
@@ -149,8 +149,6 @@ int syncobj_wait_drain(struct syncobj *sobj,
   const struct timespec *timeout,
   struct syncstate *syns);
 
-int syncobj_flush(struct syncobj *sobj);
-
 int syncobj_destroy(struct syncobj *sobj,
struct syncstate *syns);
 
@@ -201,6 +199,19 @@ static inline int syncobj_grant_all(struct syncobj *sobj)
return ret;
 }
 
+static inline int syncobj_flush(struct syncobj *sobj)
+{
+   __syncobj_check_locked(sobj);
+
+   if (sobj-grant_count  0)
+   __syncobj_broadcast_grant(sobj, SYNCOBJ_FLUSHED);
+
+   if (sobj-drain_count  0)
+   __syncobj_broadcast_drain(sobj, SYNCOBJ_FLUSHED);
+
+   return sobj-wait_count;
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/copperplate/syncobj.c b/lib/copperplate/syncobj.c
index dbd8f5f..24770f3 100644
--- a/lib/copperplate/syncobj.c
+++ b/lib/copperplate/syncobj.c
@@ -313,19 +313,6 @@ int __syncobj_broadcast_drain(struct syncobj *sobj, int 
reason)
return ret;
 }
 
-int syncobj_flush(struct syncobj *sobj)
-{
-   __syncobj_check_locked(sobj);
-
-   if (sobj-grant_count  0)
-   __syncobj_broadcast_grant(sobj, SYNCOBJ_FLUSHED);
-
-   if (sobj-drain_count  0)
-   __syncobj_broadcast_drain(sobj, SYNCOBJ_FLUSHED);
-
-   return sobj-wait_count;
-}
-
 static inline void enqueue_waiter(struct syncobj *sobj,
  struct threadobj *thobj)
 {


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git