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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue May  7 12:07:38 2013 +0200

alchemy/task: enforce suspend nesting count

---

 lib/alchemy/task.c |   11 ++++++++---
 lib/alchemy/task.h |    1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index aecbb13..783a1cc 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -222,6 +222,7 @@ static int create_tcb(struct alchemy_task **tcbp, RT_TASK 
*task,
        CPU_ZERO(&tcb->affinity);
 
        tcb->safecount = 0;
+       tcb->suspends = 0;
        syncobj_init(&tcb->sobj_safe, 0, fnref_null);
        syncobj_init(&tcb->sobj_msg, SYNCOBJ_PRIO, fnref_null);
        tcb->flowgen = 0;
@@ -922,7 +923,9 @@ int rt_task_suspend(RT_TASK *task)
        if (tcb == NULL)
                goto out;
 
-       ret = threadobj_suspend(&tcb->thobj);
+       if (tcb->suspends++ == 0)
+               ret = threadobj_suspend(&tcb->thobj);
+
        put_alchemy_task(tcb);
 out:
        COPPERPLATE_UNPROTECT(svc);
@@ -934,7 +937,7 @@ int rt_task_resume(RT_TASK *task)
 {
        struct alchemy_task *tcb;
        struct service svc;
-       int ret;
+       int ret = 0;
 
        COPPERPLATE_PROTECT(svc);
 
@@ -942,7 +945,9 @@ int rt_task_resume(RT_TASK *task)
        if (tcb == NULL)
                goto out;
 
-       ret = threadobj_resume(&tcb->thobj);
+       if (tcb->suspends > 0 && --tcb->suspends == 0)
+               ret = threadobj_resume(&tcb->thobj);
+
        put_alchemy_task(tcb);
 out:
        COPPERPLATE_UNPROTECT(svc);
diff --git a/lib/alchemy/task.h b/lib/alchemy/task.h
index 7f39130..4c4d7c2 100644
--- a/lib/alchemy/task.h
+++ b/lib/alchemy/task.h
@@ -33,6 +33,7 @@ struct alchemy_task {
        int mode;
        cpu_set_t affinity;
        int safecount;
+       int suspends;
        struct syncobj sobj_safe;
        struct syncobj sobj_msg;
        int flowgen;


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

Reply via email to