From owner-freebsd-arch Wed Oct 9 12:20:42 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0D17C37B401 for ; Wed, 9 Oct 2002 12:20:41 -0700 (PDT) Received: from sccrmhc01.attbi.com (sccrmhc01.attbi.com [204.127.202.61]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D1B743E3B for ; Wed, 9 Oct 2002 12:20:40 -0700 (PDT) (envelope-from julian@elischer.org) Received: from InterJet.elischer.org ([12.232.206.8]) by sccrmhc01.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20021009192039.GOPB29655.sccrmhc01.attbi.com@InterJet.elischer.org>; Wed, 9 Oct 2002 19:20:39 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id MAA46976; Wed, 9 Oct 2002 12:05:47 -0700 (PDT) Date: Wed, 9 Oct 2002 12:05:44 -0700 (PDT) From: Julian Elischer To: Igor Sysoev Cc: arch@FreeBSD.ORG Subject: Re: Scheduler framework. In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 9 Oct 2002, Igor Sysoev wrote: > On Wed, 9 Oct 2002, Julian Elischer wrote: > > > > > If a thread mailbox IS provided: > > > > the syscall is entered. > > > > the thread blocks. A second thread is invoked and attached > > > > to the KSE, which is disconnected from the original thread. > > > > > > Sorry, where did this second thread come from ? > > > > there is a thread_allocator that allocates threads on demand. > > > > Actually the process ahs a couple of spare threads "Up its sleave" > > so it doesn't have to go to teh thread allocator every time.. > > As I understand this second thread has user-level context and > its context pointed by tm_context.uc_link of blocked thread mailbox. > Am I right ? The first thread has a user context.. the second thread has no user context, so we manufacture one. This makes the second thread jump into user space, much like exec() jumps in to user space, except that we don't jump to start() (or whatever it is called) but to the userland thread scheduler. We have a special stack for that upcall as well. In userspace the second thread will convert to another thread, with a different stack. When it does a syscall it is now in the same category as thread 1. if it blocks, then: if thread 1 is ready to run we will switch back to thread 1. It will run until it wants to go back to userland at which point it writes its context back to its mailbox and allows an upcall to happen. If thread 1 was NOT ready to run then we will allocate thread 3 which will upcall on the upcall stack, (as it is not being used any more). tm_context is where a completed syscall writes its state before an upcall reports that it has finished. > > If it's so then can several threads use the same second thread context ? no > > Igor Sysoev > http://sysoev.ru > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message