Date: Fri, 20 Feb 2004 00:47:33 +1100 From: Tim Robbins <tjr@freebsd.org> To: Mike Makonnen <mtm@identd.net> Cc: freebsd-threads@freebsd.org Subject: Re: libthr patch Message-ID: <20040219134733.GA38023@cat.robbins.dropbear.id.au> In-Reply-To: <20040219062850.GC1074@mobile.acs-et.com> References: <20040219062850.GC1074@mobile.acs-et.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Feb 19, 2004 at 09:28:50AM +0300, Mike Makonnen wrote: > Index: sys/kern/kern_thr.c [...] > +int > +thr_wake(struct thread *td, struct thr_wake_args *uap) > + /* thr_id_t id */ > +{ > + PROC_LOCK(((struct thread *)uap->id)->td_proc); > + ((struct thread *)uap->id)->td_lthrflags |= LTF_THRWAKEUP; > + PROC_UNLOCK(((struct thread *)uap->id)->td_proc); > + wakeup_one((void *)uap->id); > + return (0); > +} [...] Make sure you fix thr_wake() to check that uap->id is valid before you commit this patch. Something like this would be safer but slower: struct thread *td1; PROC_LOCK(td->td_proc); FOREACH_THREAD_IN_PROC(td->td_proc, td1) if (td1 == (struct thread *)uap->id) break; if (td1 == NULL) { PROC_UNLOCK(td->td_proc); return (ESRCH); } td1->td_lthrflags |= LTF_THRWAKEUP; wakeup_one(td1); PROC_UNLOCK(td->td_proc); return (0); (I'm not sure that it's safe to call wakeup_one() on a thread pointer that isn't curthread without holding the proc lock, so I changed that too.) Tim
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040219134733.GA38023>