From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 5 16:55:09 2011 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 CF71D106566C for ; Wed, 5 Oct 2011 16:55:09 +0000 (UTC) (envelope-from cattaneo.riccardo@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 5B8E38FC13 for ; Wed, 5 Oct 2011 16:55:09 +0000 (UTC) Received: by wyj26 with SMTP id 26so2591301wyj.13 for ; Wed, 05 Oct 2011 09:55:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; bh=/2mDLR9SqIxXj6HVI/+AKJbeh+I6hyPQnfI/PzrBbR4=; b=Zh2L7Sbax49h0EtW7dp2KuCDEBQmWnKOm28xhfktfJreQVrtUUKGB2SrpX7nLgvZew PsIjgEl9xdzh5AvELwcCNgRpufmPRoTugK+WgPn/A2GusuzvTaRnApfIIJY8MvsMaOvt mKDvP9iDRR3ePunfspmOT+K0OsqOoPxq/2EdA= Received: by 10.227.208.20 with SMTP id ga20mr366765wbb.10.1317833708226; Wed, 05 Oct 2011 09:55:08 -0700 (PDT) Received: from [192.168.0.9] (micro.elet.polimi.it. [131.175.127.118]) by mx.google.com with ESMTPS id i29sm3849611wbp.22.2011.10.05.09.54.59 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Oct 2011 09:55:02 -0700 (PDT) From: Riccardo Cattaneo Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Wed, 5 Oct 2011 18:54:57 +0200 Message-Id: <127B21EE-2730-4463-8921-B79CCE2B5ECB@gmail.com> To: freebsd-hackers@freebsd.org Mime-Version: 1.0 (Apple Message framework v1244.3) X-Mailer: Apple Mail (2.1244.3) Subject: 4.4BSD timeslice management 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: Wed, 05 Oct 2011 16:55:09 -0000 Hello, I'm looking into the code of 4.4BSD scheduler (and related files) of = FreeBSD version 7.2-RELEASE on an amd64 machine in order to understand = how to manage time slices. I'm trying to dynamically change the length = of the time slice on a thread by thread basis to "give more priority" or = "less priority" to threads. In function sched_clock (sched_4bsd.c) I found a piece of code in which = thread's flags are added with TDF_NEEDRESCHED when the time slice = (quantum) expires but I failed to notice any point in the code that = actually preempt the thread. Adding a per-thread parameter (e.g., in struct thread) I could set = TDF_NEEDRESCHED when the dynamic time slice expires but how can I be = sure the thread gets preempted? Where can I set a per-thread parameter = (maybe after cpu_switch?!)? Is there a timer periodically calling a sort = of context switch function or the context switches happen only when = triggered by the kernel code? Thanks Riccardo Cattaneo=