> Date: Fri, 13 Dec 2013 19:42:17 -0800
> From: Philip Guenther <guent...@gmail.com>
> 
> Testing whether a process is (currently) done by checking whether the 
> process's thread list has a single item.  This is currently done in just 
> two places, but I expect to need this in more places, so let's abstract 
> that into an inline function.
> 
> Philip Guenther
> 
> 
> Index: sys/proc.h
> ===================================================================
> RCS file: /cvs/src/sys/sys/proc.h,v
> retrieving revision 1.172
> diff -u -p -r1.172 proc.h
> --- sys/proc.h        25 Oct 2013 04:42:48 -0000      1.172
> +++ sys/proc.h        14 Dec 2013 03:33:43 -0000
> @@ -523,6 +523,13 @@ int      single_thread_set(struct proc *, enu
>  void single_thread_clear(struct proc *, int);
>  int  single_thread_check(struct proc *, int);
>  
> +static __inline int
> +process_is_multithreaded(struct process *pr)
> +{
> +     struct proc *p = TAILQ_FIRST(&pr->ps_threads);
> +     return (p != NULL && TAILQ_NEXT(p, p_thr_link) != NULL);
> +}

Not entirely the same how the checks are currently done.  But it
should be equivalent.  Will the ps_threads list ever be empty in an
observable way?

Reply via email to