From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 1 02:38:38 2004 Return-Path: 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 43BFD16A4CE for ; Wed, 1 Sep 2004 02:38:38 +0000 (GMT) Received: from hotmail.com (bay17-dav7.bay17.hotmail.com [64.4.43.187]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2B42E43D49 for ; Wed, 1 Sep 2004 02:38:38 +0000 (GMT) (envelope-from yangshazhou@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 31 Aug 2004 19:34:45 -0700 Received: from 61.187.16.2 by bay17-dav7.bay17.hotmail.com with DAV; Wed, 01 Sep 2004 02:34:45 +0000 X-Originating-IP: [61.187.16.2] X-Originating-Email: [yangshazhou@hotmail.com] X-Sender: yangshazhou@hotmail.com From: To: Date: Wed, 1 Sep 2004 10:31:57 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Message-ID: X-OriginalArrivalTime: 01 Sep 2004 02:34:45.0462 (UTC) FILETIME=[3E4E0F60:01C48FCC] X-Mailman-Approved-At: Wed, 01 Sep 2004 12:32:54 +0000 Subject: What's what on the scheduler in FreeBSD 5.x X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2004 02:38:38 -0000 Hi all, I've very interested in scheduler implementation. I got some opinions on FreeBSD5's scheduler from source codes and articles. And I presented here, waiting for critism, for I'm new to FreeBSD. KSE 1.an implementation of SA (Scheduler activation), two-level co-operating scheduling of kernel and userland. 2.One process can own multiple KSEG, each with different schedule policy and diffferent priority. 3.KSE load kernel thread and userland thread to run, as a virtual CPU. Scheduler's choosing policy is based on the KSE-loaded thread's priority, the highest gets running and the KSEs with the same priority get round-robin. 4.The userland scheduler can implement more reasonable, more complex policy. But now, it's quite simple. Time Slice 1.Actually No time-slice. It's some periodic functions to make threads be preemptied. 2.roundrobin() works every 100ms. Other periodic functions sleep longer till run, eg, 1s for schedcpu(). Then we can conclude roundrobin() can invoke a schedule action every 100ms, re-selecting better KSEs to run. That's the same effect as constant 100ms time slice. 3.100ms is a reasonable value, maybe coming from experience. sysctl can change it as wish. Priority 1.The principle is lower response time as well as higher through-put. 2.The behaviour of kg_estcpu is the key: threads long-running will be punished, ready threads long-waiting will get promotion, and the long-sleeping threads get promotion when awaken too. 3.Priorities are stored in KSEGs, and will be updated to threads momently. At the same time, the system update (according to kg_estcpu and other factors) the priorities of all of the threads every 1 second. Threads will be re-sort in run queue then. Interactive process 1.The characters for interactive processes: sleep more and longer. 2.CPU-intensive processes run longer, be punished; The promotion will be enlarged when sleep time extends some certain value. 3.No influence from sleep times till now. Real-time 1.No realtime support basically. Realtime processes have higher priority, and that's all. The same implemention in scheduling algorithm. 2.No kernel pre-emptive support. Multi-processor 1.4BSD scheduler, the default: Giant lock, no CPU-affinity, no SMT/NUMA support/optimizing. 2.ULE scheduler, the one especially for SMP: multi-runqueue, supporting CPU-affinity and thread transfer according to load. Strangely, no load-balance as 'pull' told in ULE's document, no kseq-group (multi logic CPUs mapped to the same kseq), and then actually no SMT/NUMA support too, which are all promised in the document.