[Xenomai-git] Philippe Gerum : cobalt/thread: introduce local information flags
Module: xenomai-3 Branch: master Commit: c35b5bbfabefb41ddeef490c204bdd9aee1b0bbb URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c35b5bbfabefb41ddeef490c204bdd9aee1b0bbb Author: Philippe Gerum Date: Fri Jul 3 10:00:25 2015 +0200 cobalt/thread: introduce local information flags thread->local_info receives information bits which may be updated only by the thread concerned. Therefore, there is no need for serialization when changing this data. --- include/cobalt/kernel/thread.h | 18 +- include/cobalt/uapi/kernel/thread.h | 13 - kernel/cobalt/sched.c |4 ++-- kernel/cobalt/thread.c | 29 - 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index cc2e32c..ef7de04 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -85,10 +85,11 @@ struct xnthread_personality { }; struct xnthread { - struct xnarchtcb tcb; /* Architecture-dependent block */ + struct xnarchtcb tcb; /* Architecture-dependent block */ __u32 state;/* Thread state flags */ __u32 info; /* Thread information flags */ + __u32 local_info; /* Local thread information flags */ struct xnsched *sched; /* Thread scheduler */ struct xnsched_class *sched_class; /* Current scheduling class */ @@ -222,6 +223,21 @@ static inline void xnthread_clear_info(struct xnthread *thread, int bits) thread->info &= ~bits; } +static inline int xnthread_test_localinfo(struct xnthread *curr, int bits) +{ + return curr->local_info & bits; +} + +static inline void xnthread_set_localinfo(struct xnthread *curr, int bits) +{ + curr->local_info |= bits; +} + +static inline void xnthread_clear_localinfo(struct xnthread *curr, int bits) +{ + curr->local_info &= ~bits; +} + static inline struct xnarchtcb *xnthread_archtcb(struct xnthread *thread) { return &thread->tcb; diff --git a/include/cobalt/uapi/kernel/thread.h b/include/cobalt/uapi/kernel/thread.h index 474271f..c053472 100644 --- a/include/cobalt/uapi/kernel/thread.h +++ b/include/cobalt/uapi/kernel/thread.h @@ -27,7 +27,7 @@ * @{ */ -/* State flags */ +/* State flags (shared) */ #define XNSUSP0x0001 /**< Suspended. */ #define XNPEND0x0002 /**< Sleep-wait for a resource. */ @@ -61,7 +61,7 @@ * @{ */ -/* Information flags */ +/* Information flags (shared) */ #define XNTIMEO 0x0001 /**< Woken up due to a timeout condition */ #define XNRMID0x0002 /**< Pending on a removed resource */ @@ -70,9 +70,12 @@ #define XNWAKEN 0x0010 /**< Thread waken up upon resource availability */ #define XNROBBED 0x0020 /**< Robbed from resource ownership */ #define XNCANCELD 0x0040 /**< Cancellation request is pending */ -#define XNMOVED 0x0080 /**< CPU migration in primary mode occurred */ -#define XNPIALERT 0x1000 /**< Priority inversion alert (SIGDEBUG sent) */ -#define XNLBALERT 0x2000 /**< Scheduler lock break alert (SIGDEBUG sent) */ +#define XNPIALERT 0x0080 /**< Priority inversion alert (SIGDEBUG sent) */ + +/* Local information flags (private to current thread) */ + +#define XNMOVED 0x0001 /**< CPU migration in primary mode occurred */ +#define XNLBALERT 0x0002 /**< Scheduler lock break alert (SIGDEBUG sent) */ /** @} */ diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c index 9a0bc4f..4900817 100644 --- a/kernel/cobalt/sched.c +++ b/kernel/cobalt/sched.c @@ -337,7 +337,7 @@ void ___xnsched_unlock(struct xnsched *sched) return; if (--curr->lock_count == 0) { - xnthread_clear_info(curr, XNLBALERT); + xnthread_clear_localinfo(curr, XNLBALERT); sched->lflags &= ~XNINLOCK; xnsched_run(); } @@ -349,7 +349,7 @@ void ___xnsched_unlock_fully(struct xnsched *sched) struct xnthread *curr = sched->curr; curr->lock_count = 0; - xnthread_clear_info(curr, XNLBALERT); + xnthread_clear_localinfo(curr, XNLBALERT); sched->lflags &= ~XNINLOCK; xnsched_run(); } diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 07a39b6..8ab2dd8 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -174,6 +174,7 @@ int __xnthread_init(struct xnthread *thread, thread->sched = sched; thread->state = flags; thread->info = 0; + thread->local_info = 0; thread->lock_count = 0; thread->rrperiod = XN_INFINITE; thread->wchan = NULL; @@ -984,9 +985,11 @@ out: return; lock_break: + /* NOTE: thread is current */ if (xnthread_test_state(thread, XNWARN) && - !xnthread_test_info(thread, XNLBALERT)) { - xnthread_set_info(thread, XNLBALERT | XNKICK
[Xenomai-git] Philippe Gerum : cobalt/thread: introduce local information flags
Module: xenomai-3 Branch: next Commit: c35b5bbfabefb41ddeef490c204bdd9aee1b0bbb URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c35b5bbfabefb41ddeef490c204bdd9aee1b0bbb Author: Philippe Gerum Date: Fri Jul 3 10:00:25 2015 +0200 cobalt/thread: introduce local information flags thread->local_info receives information bits which may be updated only by the thread concerned. Therefore, there is no need for serialization when changing this data. --- include/cobalt/kernel/thread.h | 18 +- include/cobalt/uapi/kernel/thread.h | 13 - kernel/cobalt/sched.c |4 ++-- kernel/cobalt/thread.c | 29 - 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index cc2e32c..ef7de04 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -85,10 +85,11 @@ struct xnthread_personality { }; struct xnthread { - struct xnarchtcb tcb; /* Architecture-dependent block */ + struct xnarchtcb tcb; /* Architecture-dependent block */ __u32 state;/* Thread state flags */ __u32 info; /* Thread information flags */ + __u32 local_info; /* Local thread information flags */ struct xnsched *sched; /* Thread scheduler */ struct xnsched_class *sched_class; /* Current scheduling class */ @@ -222,6 +223,21 @@ static inline void xnthread_clear_info(struct xnthread *thread, int bits) thread->info &= ~bits; } +static inline int xnthread_test_localinfo(struct xnthread *curr, int bits) +{ + return curr->local_info & bits; +} + +static inline void xnthread_set_localinfo(struct xnthread *curr, int bits) +{ + curr->local_info |= bits; +} + +static inline void xnthread_clear_localinfo(struct xnthread *curr, int bits) +{ + curr->local_info &= ~bits; +} + static inline struct xnarchtcb *xnthread_archtcb(struct xnthread *thread) { return &thread->tcb; diff --git a/include/cobalt/uapi/kernel/thread.h b/include/cobalt/uapi/kernel/thread.h index 474271f..c053472 100644 --- a/include/cobalt/uapi/kernel/thread.h +++ b/include/cobalt/uapi/kernel/thread.h @@ -27,7 +27,7 @@ * @{ */ -/* State flags */ +/* State flags (shared) */ #define XNSUSP0x0001 /**< Suspended. */ #define XNPEND0x0002 /**< Sleep-wait for a resource. */ @@ -61,7 +61,7 @@ * @{ */ -/* Information flags */ +/* Information flags (shared) */ #define XNTIMEO 0x0001 /**< Woken up due to a timeout condition */ #define XNRMID0x0002 /**< Pending on a removed resource */ @@ -70,9 +70,12 @@ #define XNWAKEN 0x0010 /**< Thread waken up upon resource availability */ #define XNROBBED 0x0020 /**< Robbed from resource ownership */ #define XNCANCELD 0x0040 /**< Cancellation request is pending */ -#define XNMOVED 0x0080 /**< CPU migration in primary mode occurred */ -#define XNPIALERT 0x1000 /**< Priority inversion alert (SIGDEBUG sent) */ -#define XNLBALERT 0x2000 /**< Scheduler lock break alert (SIGDEBUG sent) */ +#define XNPIALERT 0x0080 /**< Priority inversion alert (SIGDEBUG sent) */ + +/* Local information flags (private to current thread) */ + +#define XNMOVED 0x0001 /**< CPU migration in primary mode occurred */ +#define XNLBALERT 0x0002 /**< Scheduler lock break alert (SIGDEBUG sent) */ /** @} */ diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c index 9a0bc4f..4900817 100644 --- a/kernel/cobalt/sched.c +++ b/kernel/cobalt/sched.c @@ -337,7 +337,7 @@ void ___xnsched_unlock(struct xnsched *sched) return; if (--curr->lock_count == 0) { - xnthread_clear_info(curr, XNLBALERT); + xnthread_clear_localinfo(curr, XNLBALERT); sched->lflags &= ~XNINLOCK; xnsched_run(); } @@ -349,7 +349,7 @@ void ___xnsched_unlock_fully(struct xnsched *sched) struct xnthread *curr = sched->curr; curr->lock_count = 0; - xnthread_clear_info(curr, XNLBALERT); + xnthread_clear_localinfo(curr, XNLBALERT); sched->lflags &= ~XNINLOCK; xnsched_run(); } diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 07a39b6..8ab2dd8 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -174,6 +174,7 @@ int __xnthread_init(struct xnthread *thread, thread->sched = sched; thread->state = flags; thread->info = 0; + thread->local_info = 0; thread->lock_count = 0; thread->rrperiod = XN_INFINITE; thread->wchan = NULL; @@ -984,9 +985,11 @@ out: return; lock_break: + /* NOTE: thread is current */ if (xnthread_test_state(thread, XNWARN) && - !xnthread_test_info(thread, XNLBALERT)) { - xnthread_set_info(thread, XNLBALERT | XNKICKED
[Xenomai-git] Philippe Gerum : cobalt/thread: introduce local information flags
Module: xenomai-3 Branch: next Commit: 7ccda01bf400a5ca802b7b0d1399e3bebb8bcc05 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7ccda01bf400a5ca802b7b0d1399e3bebb8bcc05 Author: Philippe Gerum Date: Fri Jul 3 10:00:25 2015 +0200 cobalt/thread: introduce local information flags thread->local_info receives information bits which may be updated only by the thread concerned. Therefore, there is no need for serialization when changing this data. --- include/cobalt/kernel/thread.h | 18 +- include/cobalt/uapi/kernel/thread.h | 13 - kernel/cobalt/sched.c |4 ++-- kernel/cobalt/thread.c | 29 - 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index cc2e32c..ef7de04 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -85,10 +85,11 @@ struct xnthread_personality { }; struct xnthread { - struct xnarchtcb tcb; /* Architecture-dependent block */ + struct xnarchtcb tcb; /* Architecture-dependent block */ __u32 state;/* Thread state flags */ __u32 info; /* Thread information flags */ + __u32 local_info; /* Local thread information flags */ struct xnsched *sched; /* Thread scheduler */ struct xnsched_class *sched_class; /* Current scheduling class */ @@ -222,6 +223,21 @@ static inline void xnthread_clear_info(struct xnthread *thread, int bits) thread->info &= ~bits; } +static inline int xnthread_test_localinfo(struct xnthread *curr, int bits) +{ + return curr->local_info & bits; +} + +static inline void xnthread_set_localinfo(struct xnthread *curr, int bits) +{ + curr->local_info |= bits; +} + +static inline void xnthread_clear_localinfo(struct xnthread *curr, int bits) +{ + curr->local_info &= ~bits; +} + static inline struct xnarchtcb *xnthread_archtcb(struct xnthread *thread) { return &thread->tcb; diff --git a/include/cobalt/uapi/kernel/thread.h b/include/cobalt/uapi/kernel/thread.h index 6c714f7..5606d52 100644 --- a/include/cobalt/uapi/kernel/thread.h +++ b/include/cobalt/uapi/kernel/thread.h @@ -27,7 +27,7 @@ * @{ */ -/* State flags */ +/* State flags (shared) */ #define XNSUSP0x0001 /**< Suspended. */ #define XNPEND0x0002 /**< Sleep-wait for a resource. */ @@ -61,7 +61,7 @@ * @{ */ -/* Information flags */ +/* Information flags (shared) */ #define XNTIMEO 0x0001 /**< Woken up due to a timeout condition */ #define XNRMID0x0002 /**< Pending on a removed resource */ @@ -70,9 +70,12 @@ #define XNWAKEN 0x0010 /**< Thread waken up upon resource availability */ #define XNROBBED 0x0020 /**< Robbed from resource ownership */ #define XNCANCELD 0x0040 /**< Cancellation request is pending */ -#define XNMOVED 0x0080 /**< CPU migration in primary mode occurred */ -#define XNPIALERT 0x1000 /**< Priority inversion alert (SIGDEBUG sent) */ -#define XNLBALERT 0x2000 /**< Scheduler lock break alert (SIGDEBUG sent) */ +#define XNPIALERT 0x0080 /**< Priority inversion alert (SIGDEBUG sent) */ + +/* Local information flags (private to current thread) */ + +#define XNMOVED 0x0001 /**< CPU migration in primary mode occurred */ +#define XNLBALERT 0x0002 /**< Scheduler lock break alert (SIGDEBUG sent) */ /** @} */ diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c index 73965e7..b9eff80 100644 --- a/kernel/cobalt/sched.c +++ b/kernel/cobalt/sched.c @@ -328,7 +328,7 @@ void ___xnsched_unlock(struct xnsched *sched) return; if (--curr->lock_count == 0) { - xnthread_clear_info(curr, XNLBALERT); + xnthread_clear_localinfo(curr, XNLBALERT); xnsched_run(); } } @@ -339,7 +339,7 @@ void ___xnsched_unlock_fully(struct xnsched *sched) struct xnthread *curr = sched->curr; curr->lock_count = 0; - xnthread_clear_info(curr, XNLBALERT); + xnthread_clear_localinfo(curr, XNLBALERT); xnsched_run(); } EXPORT_SYMBOL_GPL(___xnsched_unlock_fully); diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 541e8b1..5b00ad1 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -174,6 +174,7 @@ int __xnthread_init(struct xnthread *thread, thread->sched = sched; thread->state = flags; thread->info = 0; + thread->local_info = 0; thread->lock_count = 0; thread->rrperiod = XN_INFINITE; thread->wchan = NULL; @@ -983,9 +984,11 @@ out: return; lock_break: + /* NOTE: thread is current */ if (xnthread_test_state(thread, XNWARN) && - !xnthread_test_info(thread, XNLBALERT)) { - xnthread_set_info(thread, XNLBALERT | XNKICKED); + !xnthread_test_lo