Changes between Version 54 and Version 55 of Developer/SMP


Ignore:
Timestamp:
03/31/14 16:03:43 (10 years ago)
Author:
Sh
Comment:

/* Thread Restart */ Update due to recent thread life cycle changes

Legend:

Unmodified
Added
Removed
Modified
  • Developer/SMP

    v54 v55  
    506506
    507507
    508 The restart of threads other than self is not implemented.
     508The restart of threads is implemented.
    509509==  Future Directions  ==
    510510
    511511
    512 Implement the missing feature.  The difficult path is the restart of executing
    513 remote threads.  Executing remote threads may perform a context switch at any
    514 time.  This would overwrite a newly initialized thread context.  An option is a
    515 post-switch handler that performs a self-restart if necessary.
    516 
    517 Post-switch handlers have some disadvantages:
    518 
    519  *  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.
    520  *  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.
    521  *  Depending on the low-level interrupt support they may execute with interrupts disabled and thus increase the worst-case interrupt latency.
    522  *  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.
    523  *  Per-CPU specific post-switch handlers are an option.  They can use the per-CPU lock which must be obtained in ''_Thread_Dispatch()'' anyway.
     512The restart of threads is implemented via post-switch thread actions.  The post-switch thread actions use the per-CPU lock and have very little overhead if no post-switch actions must be performed.  Most architectures should be updated to use an interrupt epilogue similar to the SPARC to avoid long interrupt disable times.
    524513
    525514Why execute post-switch handlers with interrupts disabled on some architectures
     
    542531interrupt contexts.
    543532
    544 This scheme could be used for all architectures.  Further discussion is
    545 necessary.  An alternative to post-switch handlers is currently unknown.
     533This scheme could be used for all architectures.
    546534=  Thread Delete  =
    547535
     
    14981486
    14991487One approach to do post-switch actions could be to spin on the per-processor
    1500 variable reflecting the executing thread.  This has at least two prob
     1488variable reflecting the executing thread.  This has at least two problems
     1489# it doesn't work if the executing thread wants to alter its own state, and
     1490# this spinning must be done with the scheduler lock held and interrupts disabled, this is a disaster for the interrupt latency,
     1491
     1492The proposed solution is to use an optional action handler which is active in
     1493case the thread execution termination matters.  In _Thread_Dispatch() we have
     1494already the post-switch extensions invoked after a thread switch.
     1495Unfortunately they execute after thread dispatching is enabled again and at
     1496this point the current processor may have already changed due to thread
     1497migration requested by an interrupt.
     1498
     1499We need a context which executes right after the thread context switch on the
     1500current processor, but without the per-processor lock acquired (to prevent lock
     1501order reversal problems and keep the interrupt latency small).  For this we
     1502introduce a post-switch action chain (PSAC).  Each thread will have its own
     1503PSAC control.  The PSAC operations like addition to, removal from and iteration
     1504over the ch