Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Mar 2004 17:45:55 -0800 (PST)
From:      Julian Elischer <julian@elischer.org>
To:        Bin Ren <br260@cam.ac.uk>
Cc:        freebsd-current@freebsd.org
Subject:   Re: confusion about kse_create()
Message-ID:  <Pine.BSF.4.21.0403081741180.51038-100000@InterJet.elischer.org>
In-Reply-To: <E1B0W0y-0004EI-VF.--66ba19aa39e163665c92627628a21d3f3204e620@maroon.csi.cam.ac.uk>

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


On 9 Mar 2004, Bin Ren wrote:

> Hi,
> 
> After reading the MAN page and source codes for KSE, I find some parts 
> contradicting. Maybe the MAN page is out-dated. But I want to confirm this.
> 
> First confusion:
> 
> In KSE MAN:
> ----------------------------
> ...
>     To become multi-threaded, a process must first invoke kse_create().  The
>     kse_create() system call creates a new KSE (except for the very first
>     invocation; see below).
> ...
> ----------------------------
> 
> But in src/sys/sys/kern_thread.c:
> ----------------------------
>                 while (newkg->kg_kses < ncpus) {
>                         newke = kse_alloc();
>                         bzero(&newke->ke_startzero, RANGEOF(struct kse,
>                               ke_startzero, ke_endzero));
> #if 0
>                         mtx_lock_spin(&sched_lock);
>                         bcopy(&ke->ke_startcopy, &newke->ke_startcopy,
>                               RANGEOF(struct kse, ke_startcopy, 
> ke_endcopy));
>                         mtx_unlock_spin(&sched_lock);
> #endif
>                         mtx_lock_spin(&sched_lock);
>                         kse_link(newke, newkg);
>                         sched_fork_kse(td->td_kse, newke);
>                         /* Add engine */
>                         kse_reassign(newke);
>                         mtx_unlock_spin(&sched_lock);
>                 }
> --------------------------
> So, apparently, with one invokation of kse_create(), new KSEs are created
> so that the number of total KSEs equals the number CPUs.
> 

yes teh code was changed so that the KSEs are preallocated (it's cheap,
they are small). The structure that is actually allocated then is what
is called an "upcall", (actually can be thought of as an "upcall
token".  (You can not do an upcall unless you have one).

The two structures are somewhat confused in the documentation because
originally teh KSE WAS the upcall and from the userland it appears as if
that is still true. NOmenclature needs to be cleared up here I'm afraid.





> 
> Second confusion:
> 
> In KSE MAN:
> -----------
>      as a special case, the first call to kse_create() by this initial 
> thread
>      with newgroup equal to zero does not create a new KSE; instead, it 
> simply
>      associates the current KSE with the supplied KSE mailbox, and no 
> immedi-
>      ate upcall results.  However, an upcall will be triggered the next time
>      the thread blocks and the required conditions are met.
> -----------
> 
> In the source codes for kse_create(), I cannot find the corresponding lines.
> 
> What am I missing here?
> Thanks so much in advance!

The first call does allocate an upcall token now, and NCPU KSE's are
allocated, however no upcall is scheduled.

> 
> -- Bin
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
> 



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