Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Changes between Version 26 and Version 27 of Developer/SMP


Ignore:
Timestamp:
01/13/14 16:03:26 (10 years ago)
Author:
Sh
Comment:

/* Thread Restart */

Legend:

Unmodified
Added
Removed
Modified
  • Developer/SMP

    v26 v27  
    403403application-level threads in global resources - not the full task, only that
    404404''protected'' execution - in accord with <ref name="BurnsWellings2013"/>.
    405 = = Task Variables  ==
     405=  Task Variables  =
    406406
    407407==  Status  ==
     
    412412of the executing thread.  For Newlib the access to the re-entrancy structure is
    413413now performed via ''__getreent()'',  see also ''__DYNAMIC_REENT__'' in Newlib.
    414 =  === Future Directions ====
     414==  Future Directions  ==
    415415
    416416
     
    418418 *  Fix file system environment.
    419419 *  Fix C++ support.
    420 
    421 === Non-Preempt Mode for Mutual Exclusion ===
    422 
    423 
    424 ==== Status ====
     420=  Non-Preempt Mode for Mutual Exclusion  =
     421
     422==  Status  ==
    425423
    426424
     
    429427a mode change request is issued.  The alternatives are mutexes and condition
    430428variables.
    431 
    432 ==== Future Directions ====
     429==  Future Directions  ==
    433430
    434431
     
    437434 *  Fix the block device cache ''bdbuf''.
    438435 *  Fix C++ support.
    439 
    440 === Thread Restart ===
    441 
    442 
    443 === Thread Delete ===
    444 
    445 
    446 === Semaphores and Mutexes ===
     436=  Thread Restart  =
     437
     438==  Status  ==
     439
     440
     441The restart of threads other than self is not implemented.
     442==  Future Directions  ==
     443
     444
     445Implement the missing feature.  The difficult path is the restart of executing
     446remote threads.  Executing remote threads may perform a context switch at any
     447time.  This would overwrite a newly initialized thread context.  An option is a
     448post-switch handler that performs a self-restart if necessary.
     449
     450Post-switch handlers have some disadvantages:
     451
     452 *  They add a function call via function pointer overhead to every invocation of ''_Thread_Dispatch()''.  Post-switch handlers have to check on every invocation if they have something to do.
     453 *  Currently post-switch handlers are only used for signal management.  Some work was done to install post-switch handlers only on demand since performance measurements showed that they are indeed a problem.
     454 *  Depending on the low-level interrupt support they may execute with interrupts disabled and thus increase the worst-case interrupt latency.
     455 *  Dynamic add/remove of post-switch handlers is problematic since in this case some lock strategy must be used which makes ''_Thread_Dispatch()'' more complex and has an execution overhead.
     456 *  Per-CPU specific post-switch handlers are an option.  They can use the per-CPU lock which must be obtained in ''_Thread_Dispatch()'' anyway.
     457
     458Why execute post-switch handlers with interrupts disabled on some architectures
     459(e.g. ARM and PowerPC)?  The most common interrupt handling sequence looks like
     460this:
     461
     462[wiki:File:rtems-smp-isr-1.png File:rtems-smp-isr-1.png]
     463
     464In this sequence it is not possible to enable interrupts around the
     465''_Thread_Dispatch()'' call.  This could lead to an unlimited number of interrupt
     466contexts saved on the thread stack.  To overcome this issue some architectures
     467use a flag variable that indicates this particular execution environment (e.g.
     468the SPARC).  Here the sequence looks like this:
     469
     470[wiki:File:rtems-smp-isr-2.png File:rtems-smp-isr-2.png]
     471
     472The ISR thread dispatch disable flag must be part of the thread context.  The
     473context switch will save/restore the per-CPU ISR dispatch disable flag to/from
     474the thread context.  Each thread stack must have space for at least two
     475interrupt contexts.
     476
     477This scheme could be used for all architectures.  Further discussion is
     478necessary.  An alternative to post-switch handlers is currently unknown.
     479= = Thread Delete  ==
     480
     481=  == Semaphores and Mutexes ===
    447482
    448483