From owner-freebsd-hackers@FreeBSD.ORG Mon May 11 10:06:04 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 63A84106566B for ; Mon, 11 May 2009 10:06:04 +0000 (UTC) (envelope-from brampton@gmail.com) Received: from mail-fx0-f216.google.com (mail-fx0-f216.google.com [209.85.220.216]) by mx1.freebsd.org (Postfix) with ESMTP id E958D8FC13 for ; Mon, 11 May 2009 10:06:03 +0000 (UTC) (envelope-from brampton@gmail.com) Received: by fxm12 with SMTP id 12so2586933fxm.43 for ; Mon, 11 May 2009 03:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=EuywAZaTO0y8/uKfv5pBMDl2XZ1MDooMLPpi2Z6JnSI=; b=n5KGwBNKCNzz9oSZYc1BOBNluXm8yxBZjJ4mLeTCg1BBbC/O9wvjd2vaZpwYqCwAEP fAsIsl3tL8d0/OgPgl4P8flcD7G0mmM9QVykRizqCICXoesz+hEtVYnn54dMONgWO3Fw uxhjxq0NdT27XJyvJqSvwbARmL14v1Uu01WzI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=HCTq7p1w0sLIr1CnIEM+AbWLoVAoTprJO1tahvCfQS10cTCTIRU6n3aIJWmOo4uzGR gzaYH3j+8VLnlS9E5hEK2tQJubf5faGo8KmazIjJ8206BnSYOckDQW9iMOakei5Gd8HF asVEdQ2J1LV6OozvxkH4a/OBZuD8K3DJoNpkw= MIME-Version: 1.0 Sender: brampton@gmail.com Received: by 10.223.103.133 with SMTP id k5mr3517571fao.23.1242036362643; Mon, 11 May 2009 03:06:02 -0700 (PDT) In-Reply-To: References: Date: Mon, 11 May 2009 11:06:02 +0100 X-Google-Sender-Auth: 32c470f204c16f2e Message-ID: From: Andrew Brampton To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Ryan Stone Subject: Re: kthreads and sched_relinquish 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, 11 May 2009 10:06:04 -0000 2009/5/8 Ryan Stone : > Your kernel thread likely has a higher priority than userspace threads. > > Ryan Stone > Thanks for your reply Ryan. So that I understand this correctly, if I had two kernel threads, one with a high priority, and one with a low priority, and both are PRI_TIMESHARE, then the high priority thread will run uninterrupted until it sleeps? Or is it that kernel threads trumps userspace threads? >From my experience in userspace, all threads will get a chance to run, even if there is a higher priority thread ready to run. The exact problem I am having is that this code (written by someone else) has implemented their own spin locks (which of course does not sleep), so when the lower priority user thread obtains the lock, and higher priority thread sometimes gets rescheduled before the user thread has released the lock. Now the high priority thread spins forever waiting for it to be released, which doesn't seem to give the lower thread a chance. Of course the correct solution to this is to remove these custom built spin locks and start to use the locking mechanisms provided by FreeBSD. While I've started to do that, I wanted to explore this more for my general understanding. thanks Andrew