From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 10 15:16:24 2006 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CF06516A4DA for ; Thu, 10 Aug 2006 15:16:24 +0000 (UTC) (envelope-from xdivac02@stud.fit.vutbr.cz) Received: from eva.fit.vutbr.cz (eva.fit.vutbr.cz [147.229.10.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3D6EC43D46 for ; Thu, 10 Aug 2006 15:16:23 +0000 (GMT) (envelope-from xdivac02@stud.fit.vutbr.cz) Received: from eva.fit.vutbr.cz (localhost [127.0.0.1]) by eva.fit.vutbr.cz (envelope-from xdivac02@eva.fit.vutbr.cz) (8.13.7/8.13.7) with ESMTP id k7AFGH5S018054 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Thu, 10 Aug 2006 17:16:17 +0200 (CEST) Received: (from xdivac02@localhost) by eva.fit.vutbr.cz (8.13.7/8.13.3/Submit) id k7AFGHWf018053 for hackers@freebsd.org; Thu, 10 Aug 2006 17:16:17 +0200 (CEST) Date: Thu, 10 Aug 2006 17:16:17 +0200 From: Divacky Roman To: hackers@freebsd.org Message-ID: <20060810151616.GA17109@stud.fit.vutbr.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2i X-Scanned-By: MIMEDefang 2.54 on 147.229.10.14 Cc: Subject: SoC: help with LISTs and killing procs X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Aug 2006 15:16:24 -0000 hi I am doing this: (pseudocode) LIST_FOREACH_SAFE(em, &td_em->shared->threads, threads, tmp_em) { kill(em, SIGKILL); } kill(SIGKILL) calls exit() which calls my exit_hook() my exit_hook() does LIST_REMOVE(em, threads). the problem is that this is not synchronous so I am getting a panic by INVARIANTS that "Bad link elm prev->next != 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 happen. I see this possible solutions: make this synchronous, it can be done by something like: .... kill(em, SIGKILL); wait_for_proc_to_vanish(); pls. tell me what do you think about this solution and if its correct what is the wait_for_proc_to_vanish() maybe there's some better solution, pls tell me. thnx a lot roman ---------------------- www.liberalnistrana.cz