kernel upcall documentation

Konstantinos Boukis konstantinos.boukis at kcl.ac.uk
Fri Oct 21 12:18:13 PDT 2005


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 at 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 at kcl.ac.uk
 



More information about the freebsd-threads mailing list