DragonFly kernel List (threaded) for 2008-09
DragonFly BSD
DragonFly kernel List (threaded) for 2008-09
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Threads


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Sep 2008 21:37:45 -0700 (PDT)

:Hi Everyone,
:             I had few doubts regarding the following things. 
:1. Is it correct that a process can have multiple LWPs and for each LWP
:   there is a LWKT created?

    Yes.

:2. The function crit_enter is called so that preemption is disabled, but
:   it says synchronous switching and blocking, what does this mean?

    It means that the thread can go to sleep (aka call tsleep()) while
    holding a critical section.  It can also explicitly yield to another
    thread.  The critical section will be atomically released when the
    thread is switched away and re-acquired when the thread is switched
    back in.

    The preemption protection only applies to the current cpu,
    interrupts and threads may continue to run on other cpus.

:3. Can anyone suggest some documentation regarding, when to use MPLOCK?
:
:             Thanks and looking forward for the reply.
:Mayur

    The answer to this depends on the context.  What kind of code are
    we talking about here, the usched_*() functions?

    If we are talking about the usched API, it is expected to be MP-SAFE,
    meaning it cannot make assumptions as to the state of the MP lock
    and in general should not try to acquire or release it.  Any global
    queues (shared amoungst all the cpus) would have to be protected with
    spin locks.

    Taking usched_bsd4.c as an example, it does call rel_mplock() once
    at the beginning of sched_thread(), but only because that thread
    is started with the MP lock held.  We could clean that up and start
    the thread without it held.  It then uses the bsd4_spin spin-lock
    in places where it accesses the global data structures.

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]