Date: Thu, 10 Aug 2006 10:23:59 -0500 From: Brooks Davis <brooks@one-eyed-alien.net> To: Divacky Roman <xdivac02@stud.fit.vutbr.cz> Cc: hackers@freebsd.org Subject: Re: SoC: help with LISTs and killing procs Message-ID: <20060810152359.GA21318@lor.one-eyed-alien.net> In-Reply-To: <20060810151616.GA17109@stud.fit.vutbr.cz> References: <20060810151616.GA17109@stud.fit.vutbr.cz>
next in thread | previous in thread | raw e-mail | index | archive | help
--cNdxnHkX5QqsyA0e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 10, 2006 at 05:16:17PM +0200, Divacky Roman wrote: > hi >=20 > I am doing this: >=20 > (pseudocode) > LIST_FOREACH_SAFE(em, &td_em->shared->threads, threads, tmp_em) { >=20 > kill(em, SIGKILL); > } >=20 > kill(SIGKILL) calls exit() which calls my exit_hook() >=20 > my exit_hook() does LIST_REMOVE(em, threads). >=20 > the problem is that this is not synchronous so I am getting a panic by IN= VARIANTS > that "Bad link elm prev->next !=3D elm". This is because I list 1st item = in the list > I call kill on it, then process 2nd list, then scheduler preempts my code= and calls > exit() on the first proc which removes the first entry and bad things hap= pen.=20 >=20 > I see this possible solutions: >=20 > make this synchronous, it can be done by something like: >=20 > .... > kill(em, SIGKILL); > wait_for_proc_to_vanish(); >=20 > pls. tell me what do you think about this solution and if its correct wha= t is the wait_for_proc_to_vanish() >=20 > maybe there's some better solution, pls tell me. It sounds like you need a lock protecting the list. If you held it over the whole loop you could signal all processes before the exit_hook could remove any. -- Brooks --cNdxnHkX5QqsyA0e Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFE20+OXY6L6fI4GtQRArGnAJ9bYoA/FKM2i/nC9ruQOgf0eBqVeACggCp3 LYDzzW882nN0kTqY59TqoqI= =wWhk -----END PGP SIGNATURE----- --cNdxnHkX5QqsyA0e--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060810152359.GA21318>