diff options
Diffstat (limited to 'include/linux/sched')
-rw-r--r-- | include/linux/sched/signal.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 3b28cff24cc1..3499c1a8b929 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -707,15 +707,26 @@ bool same_thread_group(struct task_struct *p1, struct task_struct *p2) return p1->signal == p2->signal; } -static inline struct task_struct *next_thread(const struct task_struct *p) +/* + * returns NULL if p is the last thread in the thread group + */ +static inline struct task_struct *__next_thread(struct task_struct *p) +{ + return list_next_or_null_rcu(&p->signal->thread_head, + &p->thread_node, + struct task_struct, + thread_node); +} + +static inline struct task_struct *next_thread(struct task_struct *p) { - return list_entry_rcu(p->thread_group.next, - struct task_struct, thread_group); + return __next_thread(p) ?: p->group_leader; } static inline int thread_group_empty(struct task_struct *p) { - return list_empty(&p->thread_group); + return thread_group_leader(p) && + list_is_last(&p->thread_node, &p->signal->thread_head); } #define delay_group_leader(p) \ |