confusion about kse_create()

From: Bin Ren (br260_at_cam.ac.uk)
Date: 03/09/04

  • Next message: Julian Elischer: "Re: confusion about kse_create()"
    To: freebsd-current@freebsd.org
    Date: 09 Mar 2004 01:26:36 +0000
    
    

    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.

    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!

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


  • Next message: Julian Elischer: "Re: confusion about kse_create()"

    Relevant Pages

    • confusion about kse_create()
      ... In KSE MAN: ... ate upcall results. ... the thread blocks and the required conditions are met. ... In the source codes for kse_create, I cannot find the corresponding lines. ...
      (freebsd-current)
    • Re: confusion about kse_create()
      ... > In KSE MAN: ... is called an "upcall", (actually can be thought of as an "upcall ... > In the source codes for kse_create, I cannot find the corresponding lines. ... The first call does allocate an upcall token now, ...
      (freebsd-current)
    • Re: confusion about kse_create()
      ... > In KSE MAN: ... is called an "upcall", (actually can be thought of as an "upcall ... > In the source codes for kse_create, I cannot find the corresponding lines. ... The first call does allocate an upcall token now, ...
      (freebsd-hackers)