Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Oct 2005 20:17:36 +0100
From:      Konstantinos Boukis <konstantinos.boukis@kcl.ac.uk>
To:        Daniel Eischen <deischen@freebsd.org>
Cc:        freebsd-threads@freebsd.org
Subject:   Re: kernel upcall documentation
Message-ID:  <1129922256.43593ed0727ef@impmail.kcl.ac.uk>
In-Reply-To: <Pine.GSO.4.43.0510211418280.2605-100000@sea.ntplx.net>
References:  <Pine.GSO.4.43.0510211418280.2605-100000@sea.ntplx.net>

next in thread | previous in thread | raw e-mail | index | archive | help
In Clark’s and Kohler’s definition for upcall, the function that initiates it
waits for the upcalled function to finish its operation so as to resume. I
could indeed employ a mechanism with signals between the kernel and the
userland process but that would break the above definition since the kernel
after wakeup() will continue its operation without waiting the userland process
to finish (OK, I could then put the kernel thread to sleep and resume it from
the userland, but this seems to me very sloppy programming).
 
Anyway, just out of curiosity, is there a way for a kernel thread to invoke the
userland function pointed by ku_func? (provided that a mailbox is already
assigned to the kse from a userland kse_create invocation)

Quoting Daniel Eischen <deischen@freebsd.org>:
> On Fri, 21 Oct 2005, Konstantinos Boukis wrote:
> 
> > Well, to be honest I managed to bypass the NULL fd_cdir problem by
> assigning a
> > temporary valid filedesc to curthread->td_proc->p_fd just before the
> invocation
> > to linker_load_module.
> > However I am curious to see the upcall solution as well. When I read that:
> > "When a thread blocks in the kernel, the (virtual) cpu is reallocated to
> > another newly created context (thread) and it is allowed to proceed back
> > to userland and runs a known routine with a known pointer as its
> > argument." (from
> > http://lists.freebsd.org/pipermail/freebsd-threads/2003-July/001018.html)
> > I understood that when a kernel thread blocks it makes an upcall to
> userland and
> > it calls the ku_func function. When ku_func accomplishes its operation then
> the
> > kernel thread is resumed so as to comply with the upcall definition of
> clark's
> > "The structuring of systems using upcalls" and Kohler's "the click modular
> > router". So, have I got it right or I am missing something?
> 
> These set of functions are meant for user threading, not kernel
> initiated threading.  I don't know what Clark and Kohler describe,
> but these functions were specifically made for allowing thread
> libraries to be written.  If you want userland to do something
> based on a kernel event, traditionally userland calls into the
> kernel and waits for the event, then does whatever it needs to
> when the event occurs.
> 
> -- 
> DE
> 
> 


-- 
Konstantinos Boukis
konstantinos.boukis@kcl.ac.uk
 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1129922256.43593ed0727ef>