439 | | |
440 | | === Thread Restart === |
441 | | |
442 | | |
443 | | === Thread Delete === |
444 | | |
445 | | |
446 | | === Semaphores and Mutexes === |
| 436 | = Thread Restart = |
| 437 | |
| 438 | == Status == |
| 439 | |
| 440 | |
| 441 | The restart of threads other than self is not implemented. |
| 442 | == Future Directions == |
| 443 | |
| 444 | |
| 445 | Implement the missing feature. The difficult path is the restart of executing |
| 446 | remote threads. Executing remote threads may perform a context switch at any |
| 447 | time. This would overwrite a newly initialized thread context. An option is a |
| 448 | post-switch handler that performs a self-restart if necessary. |
| 449 | |
| 450 | Post-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 | |
| 458 | Why execute post-switch handlers with interrupts disabled on some architectures |
| 459 | (e.g. ARM and PowerPC)? The most common interrupt handling sequence looks like |
| 460 | this: |
| 461 | |
| 462 | [wiki:File:rtems-smp-isr-1.png File:rtems-smp-isr-1.png] |
| 463 | |
| 464 | In this sequence it is not possible to enable interrupts around the |
| 465 | ''_Thread_Dispatch()'' call. This could lead to an unlimited number of interrupt |
| 466 | contexts saved on the thread stack. To overcome this issue some architectures |
| 467 | use a flag variable that indicates this particular execution environment (e.g. |
| 468 | the SPARC). Here the sequence looks like this: |
| 469 | |
| 470 | [wiki:File:rtems-smp-isr-2.png File:rtems-smp-isr-2.png] |
| 471 | |
| 472 | The ISR thread dispatch disable flag must be part of the thread context. The |
| 473 | context switch will save/restore the per-CPU ISR dispatch disable flag to/from |
| 474 | the thread context. Each thread stack must have space for at least two |
| 475 | interrupt contexts. |
| 476 | |
| 477 | This scheme could be used for all architectures. Further discussion is |
| 478 | necessary. An alternative to post-switch handlers is currently unknown. |
| 479 | = = Thread Delete == |
| 480 | |
| 481 | = == Semaphores and Mutexes === |