From owner-freebsd-current@FreeBSD.ORG Mon Mar 8 17:26:45 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2C35016A4CE; Mon, 8 Mar 2004 17:26:45 -0800 (PST) Received: from purple.csi.cam.ac.uk (purple.csi.cam.ac.uk [131.111.8.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id BA96543D2F; Mon, 8 Mar 2004 17:26:44 -0800 (PST) (envelope-from br260@hermes.cam.ac.uk) Received: from maroon.csi.cam.ac.uk ([131.111.8.2]) by purple.csi.cam.ac.uk with esmtp (Exim 4.20) id 1B0W0y-0007N8-WB; Tue, 09 Mar 2004 01:26:36 +0000 Received: from prayer by maroon.csi.cam.ac.uk with local (Exim 4.24) id 1B0W0y-0004EI-VF; Tue, 09 Mar 2004 01:26:36 +0000 From: Bin Ren To: freebsd-current@freebsd.org Date: 09 Mar 2004 01:26:36 +0000 X-Mailer: Prayer v1.0.9 X-Originating-IP: [131.111.242.109] Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=ISO-8859-1 Message-Id: X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ X-Cam-AntiVirus: No virus found X-Cam-SpamDetails: Not scanned cc: freebsd-hackers@freebsd.org Subject: confusion about kse_create() X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Mar 2004 01:26:45 -0000 Hi, After reading the MAN page and source codes for KSE, I find some parts contradicting. Maybe the MAN page is out-dated. But I want to confirm this. First confusion: In KSE MAN: ---------------------------- ... To become multi-threaded, a process must first invoke kse_create(). The kse_create() system call creates a new KSE (except for the very first invocation; see below). ... ---------------------------- But in src/sys/sys/kern_thread.c: ---------------------------- while (newkg->kg_kses < ncpus) { newke = kse_alloc(); bzero(&newke->ke_startzero, RANGEOF(struct kse, ke_startzero, ke_endzero)); #if 0 mtx_lock_spin(&sched_lock); bcopy(&ke->ke_startcopy, &newke->ke_startcopy, RANGEOF(struct kse, ke_startcopy, ke_endcopy)); mtx_unlock_spin(&sched_lock); #endif mtx_lock_spin(&sched_lock); kse_link(newke, newkg); sched_fork_kse(td->td_kse, newke); /* Add engine */ kse_reassign(newke); mtx_unlock_spin(&sched_lock); } -------------------------- So, apparently, with one invokation of kse_create(), new KSEs are created so that the number of total KSEs equals the number CPUs. Second confusion: In KSE MAN: ----------- as a special case, the first call to kse_create() by this initial thread with newgroup equal to zero does not create a new KSE; instead, it simply associates the current KSE with the supplied KSE mailbox, and no immedi- ate upcall results. However, an upcall will be triggered the next time the thread blocks and the required conditions are met. ----------- In the source codes for kse_create(), I cannot find the corresponding lines. What am I missing here? Thanks so much in advance! -- Bin