Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Oct 2002 12:05:44 -0700 (PDT)
From:      Julian Elischer <julian@elischer.org>
To:        Igor Sysoev <is@rambler-co.ru>
Cc:        arch@FreeBSD.ORG
Subject:   Re: Scheduler framework.
Message-ID:  <Pine.BSF.4.21.0210091155050.37238-100000@InterJet.elischer.org>
In-Reply-To: <Pine.BSF.4.21.0210092252010.2501-100000@is>

next in thread | previous in thread | raw e-mail | index | archive | help


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0210091155050.37238-100000>