Module: xenomai-forge
Branch: master
Commit: 8a04fef922f6014fe774cc28aa5fa3cff30797a4
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=8a04fef922f6014fe774cc28aa5fa3cff30797a4

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Feb  3 16:46:01 2014 +0100

copperplate/syncobj: introduce scanner for drain list

---

 include/copperplate/syncobj.h |   17 +++++++++++++++--
 lib/alchemy/heap.c            |    2 +-
 lib/alchemy/task.c            |    2 +-
 lib/copperplate/cluster.c     |    4 ++--
 lib/copperplate/eventobj.c    |    2 +-
 lib/psos/rn.c                 |    2 +-
 6 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/include/copperplate/syncobj.h b/include/copperplate/syncobj.h
index 3220fdf..1b14b7a 100644
--- a/include/copperplate/syncobj.h
+++ b/include/copperplate/syncobj.h
@@ -73,12 +73,18 @@ struct syncobj {
        fnref_type(void (*)(struct syncobj *sobj)) finalizer;
 };
 
-#define syncobj_for_each_waiter(sobj, pos)             \
+#define syncobj_for_each_grant_waiter(sobj, pos)               \
        list_for_each_entry(pos, &(sobj)->grant_list, wait_link)
 
-#define syncobj_for_each_waiter_safe(sobj, pos, tmp)   \
+#define syncobj_for_each_grant_waiter_safe(sobj, pos, tmp)     \
        list_for_each_entry_safe(pos, tmp, &(sobj)->grant_list, wait_link)
 
+#define syncobj_for_each_drain_waiter(sobj, pos)               \
+       list_for_each_entry(pos, &(sobj)->drain_list, wait_link)
+
+#define syncobj_for_each_drain_waiter_safe(sobj, pos, tmp)     \
+       list_for_each_entry_safe(pos, tmp, &(sobj)->drain_list, wait_link)
+
 void __syncobj_cleanup_wait(struct syncobj *sobj,
                            struct threadobj *thobj);
 
@@ -176,6 +182,13 @@ static inline int syncobj_count_drain(struct syncobj *sobj)
        return sobj->drain_count;
 }
 
+static inline int syncobj_drain_wait_p(struct syncobj *sobj)
+{
+       __syncobj_check_locked(sobj);
+
+       return !list_empty(&sobj->drain_list);
+}
+
 static inline int syncobj_drain(struct syncobj *sobj)
 {
        int ret = 0;
diff --git a/lib/alchemy/heap.c b/lib/alchemy/heap.c
index a4ab282..63da6c2 100644
--- a/lib/alchemy/heap.c
+++ b/lib/alchemy/heap.c
@@ -417,7 +417,7 @@ int rt_heap_free(RT_HEAP *heap, void *block)
         * We might be releasing a block large enough to satisfy
         * multiple requests, so we iterate over all waiters.
         */
-       syncobj_for_each_waiter_safe(&hcb->sobj, thobj, tmp) {
+       syncobj_for_each_grant_waiter_safe(&hcb->sobj, thobj, tmp) {
                wait = threadobj_get_wait(thobj);
                wait->ptr = heapobj_alloc(&hcb->hobj, wait->size);
                if (wait->ptr)
diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index fbb8cb7..4f2a90c 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -1870,7 +1870,7 @@ int rt_task_reply(int flowid, RT_TASK_MCB *mcb_s)
        if (!syncobj_grant_wait_p(&current->sobj_msg))
                goto done;
 
-       syncobj_for_each_waiter(&current->sobj_msg, thobj) {
+       syncobj_for_each_grant_waiter(&current->sobj_msg, thobj) {
                wait = threadobj_get_wait(thobj);
                if (wait->request.flowid == flowid)
                        goto reply;
diff --git a/lib/copperplate/cluster.c b/lib/copperplate/cluster.c
index f25f30f..a36fd30 100644
--- a/lib/copperplate/cluster.c
+++ b/lib/copperplate/cluster.c
@@ -239,7 +239,7 @@ int syncluster_addobj(struct syncluster *sc, const char 
*name,
         * Wake up all threads waiting for this key to appear in the
         * dictionary.
         */
-       syncobj_for_each_waiter_safe(sc->sobj, thobj, tmp) {
+       syncobj_for_each_grant_waiter_safe(sc->sobj, thobj, tmp) {
                wait = threadobj_get_wait(thobj);
                if (*wait->name == *name && strcmp(wait->name, name) == 0)
                        syncobj_grant_to(sc->sobj, thobj);
@@ -404,7 +404,7 @@ int pvsyncluster_addobj(struct pvsyncluster *sc, const char 
*name,
         * Wake up all threads waiting for this key to appear in the
         * dictionary.
         */
-       syncobj_for_each_waiter_safe(&sc->sobj, thobj, tmp) {
+       syncobj_for_each_grant_waiter_safe(&sc->sobj, thobj, tmp) {
                wait = threadobj_get_wait(thobj);
                if (*wait->name == *name && strcmp(wait->name, name) == 0)
                        syncobj_grant_to(&sc->sobj, thobj);
diff --git a/lib/copperplate/eventobj.c b/lib/copperplate/eventobj.c
index e1ef74f..f1d892d 100644
--- a/lib/copperplate/eventobj.c
+++ b/lib/copperplate/eventobj.c
@@ -215,7 +215,7 @@ int eventobj_post(struct eventobj *evobj, unsigned long 
bits)
        if (!syncobj_grant_wait_p(&evobj->core.sobj))
                goto done;
 
-       syncobj_for_each_waiter_safe(&evobj->core.sobj, thobj, tmp) {
+       syncobj_for_each_grant_waiter_safe(&evobj->core.sobj, thobj, tmp) {
                wait = threadobj_get_wait(thobj);
                waitval = wait->value & bits;
                testval = wait->mode & EVOBJ_ANY ? waitval : wait->value;
diff --git a/lib/psos/rn.c b/lib/psos/rn.c
index 0f2cdb7..ca404ee 100644
--- a/lib/psos/rn.c
+++ b/lib/psos/rn.c
@@ -314,7 +314,7 @@ u_long rn_retseg(u_long rnid, void *segaddr)
        if (!syncobj_grant_wait_p(&rn->sobj))
                goto done;
 
-       syncobj_for_each_waiter_safe(&rn->sobj, thobj, tmp) {
+       syncobj_for_each_grant_waiter_safe(&rn->sobj, thobj, tmp) {
                wait = threadobj_get_wait(thobj);
                size = wait->size;
                if (rn->usedmem + size > rn->length)


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

Reply via email to