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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Jun  8 18:05:26 2013 +0200

nucleus/thread: introduce private data extension

Cobalt-based extensions may not want to control the allocation of the
thread control block of each new thread, but would rather leave this
to the Cobalt API.

This situation makes difficult to attach private extension data to
TCBs, unless a generic private data pointer is made available into
each control block.

---

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

diff --git a/include/cobalt/nucleus/thread.h b/include/cobalt/nucleus/thread.h
index 1d9c5a7..b697619 100644
--- a/include/cobalt/nucleus/thread.h
+++ b/include/cobalt/nucleus/thread.h
@@ -287,6 +287,9 @@ typedef struct xnthread {
 
        struct pt_regs *regs;           /* Current register frame */
        struct xnthread_user_window *u_window;  /* Data visible from userland. 
*/
+
+       void *privdata;                         /* Private data for extension */
+
 #ifdef CONFIG_XENO_OPT_DEBUG
        const char *exe_path;   /* Executable path */
        u32 proghash;           /* Hash value for exe_path */
@@ -341,6 +344,7 @@ typedef struct xnhook {
 #define xnthread_inc_rescnt(thread)        ({ (thread)->hrescnt++; })
 #define xnthread_dec_rescnt(thread)        ({ --(thread)->hrescnt; })
 #define xnthread_get_rescnt(thread)        ((thread)->hrescnt)
+#define xnthread_private(thread)           ((thread)->privdata)
 
 static inline unsigned xnthread_get_magic(struct xnthread *t)
 {
diff --git a/kernel/cobalt/nucleus/thread.c b/kernel/cobalt/nucleus/thread.c
index 44b59b1..815a432 100644
--- a/kernel/cobalt/nucleus/thread.c
+++ b/kernel/cobalt/nucleus/thread.c
@@ -179,7 +179,7 @@ int xnthread_init(struct xnthread *thread,
        /* These will be filled by xnpod_start_thread() */
        thread->imode = 0;
        thread->entry = NULL;
-       thread->cookie = 0;
+       thread->cookie = NULL;
 
        inith(&thread->glink);
        initph(&thread->rlink);
@@ -187,6 +187,8 @@ int xnthread_init(struct xnthread *thread,
        thread->selector = NULL;
        initpq(&thread->claimq);
 
+       thread->privdata = NULL;
+
        thread->sched = sched;
        thread->init_class = sched_class;
        thread->base_class = NULL; /* xnsched_set_policy() will set it. */


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

Reply via email to