From owner-freebsd-hackers@FreeBSD.ORG Mon Sep 12 14:41:56 2005 Return-Path: X-Original-To: freebsd-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 0B9FA16A41F for ; Mon, 12 Sep 2005 14:41:56 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from comsys.ntu-kpi.kiev.ua (comsys.ntu-kpi.kiev.ua [195.245.194.142]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7B92943D45 for ; Mon, 12 Sep 2005 14:41:37 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from pm514-9.comsys.ntu-kpi.kiev.ua (pm514-9.comsys.ntu-kpi.kiev.ua [10.18.54.109]) (authenticated bits=0) by comsys.ntu-kpi.kiev.ua (8.12.10/8.12.10) with ESMTP id j8CEmv82012942 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 12 Sep 2005 17:48:58 +0300 (EEST) Received: by pm514-9.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1000) id 9CD411A3; Mon, 12 Sep 2005 17:38:26 +0300 (EEST) Date: Mon, 12 Sep 2005 17:38:26 +0300 From: Andrey Simonenko To: Zlatan Ibrahimovic Message-ID: <20050912143826.GA401@pm514-9.comsys.ntu-kpi.kiev.ua> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.0.1 X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on comsys.ntu-kpi.kiev.ua X-Virus-Scanned: ClamAV 0.82/1049/Wed Aug 31 10:19:01 2005 on comsys.ntu-kpi.kiev.ua X-Virus-Status: Clean Cc: freebsd-hackers@freebsd.org Subject: Re: clock software interrupt 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: Mon, 12 Sep 2005 14:41:56 -0000 On Sat, Sep 10, 2005 at 09:34:48PM +0200, Zlatan Ibrahimovic wrote: > Hi folks, > I've seen clock software interrupt thread (referring to clk_ithd in > kern/kern_intr.c); watching to manpages I read that priority is used > as vector for that thread. My question is how can I call this software > handler? There's no track in the IDT for the associated handler... > (ia32, for better check see i386/i386/exception.s). The softclock() function is registered as an another one handler for SWI_CLOCK by calling the swi_add() function. Since clk_ithd is NULL at the moment when swi_add() for softclock() handler is called, interrupt thread is created for SWI_CLOCK in swi_addr() by the ithread_create() function. An interrupt thread is a special kthread and interrupt threads run ithread_loop() function as the main function for kthread. Interrupt handler for the softclock() function is returned in softclock_ih. The simplified idea of ithread_loop() is the following: if there is the request for some handler, then process this request by requested handler else voluntary switch context. Another one handler for SWI_CLOCK is siopoll(). If you run "ps auxw | grep clock" you will see two handlers for swi5 (SWI_CLOCK). When hardclock() decides that softclock() should be called is schedules clk_ithd ithread via handler softclock_ih by calling swi_sched().