summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/smp.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* score: Fix SMP startupSebastian Huber2014-05-071-1/+3
|
* score: Implement forced thread migrationSebastian Huber2014-05-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation of task migration in RTEMS has some implications with respect to the interrupt latency. It is crucial to preserve the system invariant that a task can execute on at most one processor in the system at a time. This is accomplished with a boolean indicator in the task context. The processor architecture specific low-level task context switch code will mark that a task context is no longer executing and waits that the heir context stopped execution before it restores the heir context and resumes execution of the heir task. So there is one point in time in which a processor is without a task. This is essential to avoid cyclic dependencies in case multiple tasks migrate at once. Otherwise some supervising entity is necessary to prevent life-locks. Such a global supervisor would lead to scalability problems so this approach is not used. Currently the thread dispatch is performed with interrupts disabled. So in case the heir task is currently executing on another processor then this prolongs the time of disabled interrupts since one processor has to wait for another processor to make progress. It is difficult to avoid this issue with the interrupt latency since interrupts normally store the context of the interrupted task on its stack. In case a task is marked as not executing we must not use its task stack to store such an interrupt context. We cannot use the heir stack before it stopped execution on another processor. So if we enable interrupts during this transition we have to provide an alternative task independent stack for this time frame. This issue needs further investigation.
* score: Delete _SMP_Test_message_default_handlerSebastian Huber2014-05-071-7/+1
| | | | | A default handler is not necessary. The test message sender must ensure that a handler is installed.
* score: Use atomic operations for SMP messagesSebastian Huber2014-05-051-5/+2
|
* score: Add SMP test message handlerSebastian Huber2014-05-051-0/+8
| | | | | This handler can be used to test the inter-processor interrupt implementation.
* score: SMP_FATAL_SCHEDULER_WITHOUT_PROCESSORSSebastian Huber2014-05-051-16/+0
| | | | | Avoid the SMP_FATAL_SCHEDULER_WITHOUT_PROCESSORS fatal error and make it a run-time error in rtems_scheduler_ident() and _Scheduler_Get_by_id().
* score: Use common names for per-CPU variablesSebastian Huber2014-04-221-23/+23
| | | | | | | | | | | | | | | | Use "cpu" for an arbitrary Per_CPU_Control variable. Use "cpu_self" for the Per_CPU_Control of the current processor. Use "cpu_index" for an arbitrary processor index. Use "cpu_index_self" for the processor index of the current processor. Use "cpu_count" for the processor count obtained via _SMP_Get_processor_count(). Use "cpu_max" for the processor maximum obtained by rtems_configuration_get_maximum_processors().
* score: Add clustered/partitioned schedulingSebastian Huber2014-04-151-13/+66
| | | | | | | | | | | | | | | Clustered/partitioned scheduling helps to control the worst-case latencies in the system. The goal is to reduce the amount of shared state in the system and thus prevention of lock contention. Modern multi-processor systems tend to have several layers of data and instruction caches. With clustered/partitioned scheduling it is possible to honour the cache topology of a system and thus avoid expensive cache synchronization traffic. We have clustered scheduling in case the set of processors of a system is partitioned into non-empty pairwise-disjoint subsets. These subsets are called clusters. Clusters with a cardinality of one are partitions. Each cluster is owned by exactly one scheduler instance.
* score: SMP initialization changesSebastian Huber2014-04-141-6/+27
| | | | | | | | | | | | | | | | | Add and use _CPU_SMP_Start_processor(). Add and use _CPU_SMP_Finalize_initialization(). This makes most _CPU_SMP_Initialize() functions a bit simpler since we can calculate the minimum value of the count of processors requested by the application configuration and the count of physically or virtually available processors in the high-level code. The CPU port has now the ability to signal a processor start failure. With the support for clustered/partitioned scheduling the presence of particular processors can be configured to be optional or mandatory. There will be a fatal error only in case mandatory processors are not present. The CPU port may use a timeout to monitor the start of a processor.
* Change all references of rtems.com to rtems.org.Chris Johns2014-03-211-1/+1
|
* score: Delete _Assert_Thread_dispatching_repressedSebastian Huber2014-03-191-1/+1
| | | | | | | | Add _Debug_Is_thread_dispatching_allowed(). This makes it possible to assert the opposite. Use _ISR_Disable_without_giant()/_ISR_Enable_without_giant() to avoid misleading secondary assertion failures.
* score: Add SMP lock profiling supportSebastian Huber2014-03-141-1/+1
|
* score: Add local context to SMP lock APISebastian Huber2014-03-111-4/+3
| | | | | | | | | | | Add a local context structure to the SMP lock API for acquire and release pairs. This context can be used to store the ISR level and profiling information. It may be later used to enable more sophisticated lock algorithms, e.g. MCS locks. There is only one lock that cannot be used with a local context. This is the per-CPU lock since here we would have to transfer the local context through a context switch which is very complicated.
* score: Add and use _Giant_Drop()Sebastian Huber2014-03-061-0/+8
| | | | New test smptests/smpfatal03.
* score: SMP initialization and shutdown changesSebastian Huber2014-03-061-54/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Rename _SMP_Request_other_cores_to_perform_first_context_switch() into _SMP_Request_start_multitasking() since this requests now a multitasking start on all configured and available processors. The name corresponds _Thread_Start_multitasking() and _SMP_Start_multitasking_on_secondary_processor() actions issued in response to this request. Move in source file to right place. Rename PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING into PER_CPU_STATE_READY_TO_START_MULTITASKING. Rename PER_CPU_STATE_BEGIN_MULTITASKING into PER_CPU_STATE_REQUEST_START_MULTITASKING. Rename _SMP_Request_other_cores_to_shutdown() into _SMP_Request_shutdown(). Add a per-CPU state lock to protect all changes. This was necessary to offer a controlled shutdown of the system (atomic read/writes alone are not sufficient for this kind of synchronization). Add documentation for Per_CPU_State. Delete debug output. New tests smptests/smpfatal01 and smptests/smpfatal02.
* score: _SMP_Inter_processor_interrupt_handler()Sebastian Huber2014-02-191-41/+0
| | | | | Inline _SMP_Inter_processor_interrupt_handler() to avoid function call overhead. Remove debug output.
* score: Wait for per-CPU state changes laterSebastian Huber2014-02-191-9/+5
| | | | | | Wait for per-CPU changes into PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING later. There is no need to delay the initialization of the main processor at this point.
* score: Initialize per-CPU locksSebastian Huber2014-02-191-0/+6
|
* score: Move _SMP_Handler_initialize()Sebastian Huber2014-02-191-0/+22
|
* score: Rename rtems_smp_process_interrupt()Sebastian Huber2014-02-191-2/+1
| | | | | | Rename rtems_smp_process_interrupt() into _SMP_Inter_processor_interrupt_handler(). Delete unused header file <rtems/bspsmp.h>.
* score: Rename rtems_smp_secondary_cpu_initialize()Sebastian Huber2014-02-191-1/+1
| | | | | | Rename rtems_smp_secondary_cpu_initialize() into _SMP_Start_multitasking_on_secondary_processor(). Move declaration to <rtems/score/smpimpl.h>.
* score: Add and use <rtems/score/smpimpl.h>Sebastian Huber2014-02-191-1/+1
| | | | | Collect SMP implementation specific parts in the <rtems/score/smpimpl.h> header file.
* score: Delete bsp_smp_broadcast_interrupt()Sebastian Huber2014-02-191-8/+4
| | | | | | Since the per-CPU SMP lock must be acquired and released to send the message a single interrupt broadcast operations offers no benefits. If synchronization is required, then a SMP barrier must be used anyway.
* score: Rename bsp_smp_initialize()Sebastian Huber2014-02-191-1/+1
| | | | | Rename bsp_smp_initialize() into _CPU_SMP_Initialize() since every CPU port must supply this function.
* score: Rename RTEMS_BSP_SMP_SHUTDOWNSebastian Huber2014-02-191-4/+4
| | | | | Rename RTEMS_BSP_SMP_SHUTDOWN in SMP_MESSAGE_SHUTDOWN since SMP messages have nothing to do with the BSP. Use UINT32_C() instead of casts.
* score: Add RTEMS_FATAL_SOURCE_SMPSebastian Huber2014-02-191-5/+2
| | | | | | Use rtems_fatal() instead of _CPU_Fatal_halt() to shutdown processors in SMP configurations since this allows intervention of BSP or application specific fatal extensions.
* score: Move _SMP_Request_other_cores_to_shutdown()Sebastian Huber2014-02-191-8/+14
| | | | | | Move _SMP_Request_other_cores_to_shutdown() invocation from rtems_shutdown_executive() to _Internal_error_Occurred() to allow a proper shutdown on SMP configurations even in the error case.
* score: Delete _Thread_BSP_contextSebastian Huber2014-02-191-1/+1
| | | | | | | | | | | | Do not return to BSP context in the exit() shutdown path. This makes it possible to re-use the initialization stack. It can be used for the interrupt stack for example. On targets with a small RAM this is a considerable benefit. This change eliminates also some special cases and simplifies the code. Delete _Thread_Set_global_exit_status(), _Thread_Get_global_exit_status() and _Thread_Stop_multitasking().
* smp: Add and use _Assert_Owner_of_giant()Sebastian Huber2013-08-301-1/+1
| | | | | | | | | | | | | | Add and use _ISR_Disable_without_giant() and _ISR_Enable_without_giant() if RTEMS_SMP is defined. On single processor systems the ISR disable/enable was the big hammer which ensured system-wide mutual exclusion. On SMP configurations this no longer works since other processors do not care about disabled interrupts on this processor and continue to execute freely. On SMP in addition to ISR disable/enable an SMP lock must be used. Currently we have only the Giant lock so we can check easily that ISR disable/enable is used only in the right context.
* smp: Fix warningsSebastian Huber2013-08-231-1/+0
|
* smp: Delete RTEMS_BSP_SMP_SIGNAL_TO_SELFSebastian Huber2013-08-211-7/+0
|
* smp: Use ISR lock in per-CPU controlSebastian Huber2013-08-091-6/+6
| | | | | | | Rename _Per_CPU_Lock_acquire() to _Per_CPU_ISR_disable_and_acquire(). Rename _Per_CPU_Lock_release() to _Per_CPU_Release_and_ISR_enable(). Add _Per_CPU_Acquire() and _Per_CPU_Release().
* smp: Generalize _Thread_Start_multitasking()Sebastian Huber2013-08-051-25/+2
| | | | | | | | | | Add context parameter to _Thread_Start_multitasking() and use this function in rtems_smp_secondary_cpu_initialize(). This avoids duplication of code. Fix missing floating point context initialization in rtems_smp_secondary_cpu_initialize(). Now performed via _Thread_Start_multitasking().
* smp: Delete _SMP_Request_other_cores_to_dispatch()Sebastian Huber2013-07-301-21/+0
| | | | | Use an event triggered unicast to inform remote processors about a necessary thread dispatch instead.
* smp: Delete _ISR_Disable_on_this_core(), etc.Sebastian Huber2013-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | Delete _ISR_Enable_on_this_core(), _ISR_Flash_on_this_core(), _ISR_SMP_Disable(), _ISR_SMP_Enable(), _ISR_SMP_Flash(). The ISR disable/enable interface has no parameter to pass a specific object. Thus it is only possible to implement a single global lock object with this interface. Using the ISR disable/enable as the giant lock on SMP configurations is not feasible. Potentially blocking resource obtain sequences protected by the thread dispatch disable level are subdivided into smaller ISR disabled critical sections. This works since on single processor configurations there is only one thread of execution that can block. On SMP this is different (image a mutex obtained concurrently by different threads on different processors). The thread dispatch disable level is currently used as the giant lock. There is not need to complicate things with this unused interface.
* smp: Add and use _Per_CPU_Get()Sebastian Huber2013-07-301-24/+27
| | | | | | Add and use _Per_CPU_Get_by_index() and _Per_CPU_Get_index(). Add _Per_CPU_Send_interrupt(). This avoids direct access of _Per_CPU_Information.
* score: Create thread implementation headerSebastian Huber2013-07-261-2/+2
| | | | | | | | Move implementation specific parts of thread.h and thread.inl into new header file threadimpl.h. The thread.h contains now only the application visible API. Remove superfluous header file includes from various files.
* smp: Add and use _CPU_SMP_Send_interrupt()Sebastian Huber2013-07-171-1/+1
| | | | Delete bsp_smp_interrupt_cpu().
* smp: Add and use _CPU_SMP_Get_current_processor()Sebastian Huber2013-07-171-15/+15
| | | | | | | | | | Add and use _SMP_Get_current_processor() and rtems_smp_get_current_processor(). Delete bsp_smp_interrupt_cpu(). Change type of current processor index from int to uint32_t to match _SMP_Processor_count type.
* smp: Delete RTEMS_BSP_SMP_CONTEXT_SWITCH_NECESSARYSebastian Huber2013-07-171-31/+29
| | | | | The thread dispatch is a side-effect of interrupt processing, thus there is no need to send an explicit message.
* scheduler: New simple SMP scheduler implementationSebastian Huber2013-06-141-0/+3
| | | | | | | | | | | | | | | | | The new Simple SMP Scheduler allocates a processor for the processor count highest priority ready threads. The thread priority and position in the ready chain are the only information to determine the scheduling decision. Threads with an allocated processor are in the scheduled chain. After initialization the scheduled chain has exactly processor count nodes. Each processor has exactly one allocated thread after initialization. All enqueue and extract operations may exchange threads with the scheduled chain. One thread will be added and another will be removed. The scheduled and ready chain is ordered according to the thread priority order. The chain insert operations are O(count of ready threads), thus this scheduler is unsuitable for most real-time applications. The thread preempt mode will be ignored.
* score: Rename rtems_smp_get_number_of_processors()Sebastian Huber2013-06-141-4/+4
| | | | | | | | | Rename in rtems_smp_get_processor_count(). Always provide <rtems/score/smp.h> and <rtems/rtems/smp.h>. Add _SMP_Get_processor_count(). This function will be a compile time constant defined to be one on uni-processor configurations. This allows iterations over all processors without overhead on uni-processor configurations.
* smp: Add and use _Per_CPU_Lock_acquire()Sebastian Huber2013-06-121-6/+6
| | | | Add and use _Per_CPU_Lock_release().
* smp: Set state PER_CPU_STATE_UP on main processorSebastian Huber2013-06-071-4/+6
|
* score: Move thread dispatch content to new fileSebastian Huber2013-06-071-0/+1
| | | | | | | Move thread dispatch declarations and inline functions to new header <rtems/score/threaddispatch.h> to make it independent of the Thread_Control structure. This avoids a cyclic dependency in case thread dispatch functions are used for the object implementation.
* smp: New SMP lock APISebastian Huber2013-05-311-6/+8
| | | | | | | | | | | | | | Move the SMP lock implementation to the CPU port. An optimal SMP lock implementation is highly architecture dependent. For example the memory models may be fundamentally different. The new SMP lock API has a flaw. It does not provide the ability to use a local context for acquire and release pairs. Such a context is necessary to implement for example the Mellor-Crummey and Scott (MCS) locks. The SMP lock is currently used in _Thread_Disable_dispatch() and _Thread_Enable_dispatch() and makes them to a giant lock acquire and release. Since these functions do not pass state information via a local context there is currently no use case for such a feature.
* smp: Use _CPU_Fatal_halt()Sebastian Huber2013-05-291-2/+2
|
* smp: Simplify SMP initialization sequenceSebastian Huber2013-05-291-156/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Delete bsp_smp_wait_for(). Other parts of the system work without timeout, e.g. the spinlocks. Using a timeout here does not make the system more robust. Delete bsp_smp_cpu_state and replace it with Per_CPU_State. The Per_CPU_State follows the Score naming conventions. Add _Per_CPU_Change_state() and _Per_CPU_Wait_for_state() functions to change and observe states. Use Per_CPU_State in Per_CPU_Control instead of the anonymous integer. Add _CPU_Processor_event_broadcast() and _CPU_Processor_event_receive() functions provided by the CPU port. Use these functions in _Per_CPU_Change_state() and _Per_CPU_Wait_for_state(). Add prototype for _SMP_Send_message(). Delete RTEMS_BSP_SMP_FIRST_TASK message. The first context switch is now performed in rtems_smp_secondary_cpu_initialize(). Issuing the first context switch in the context of the inter-processor interrupt is not possible on systems with a modern interrupt controller. Such an interrupt controler usually requires a handshake protocol with interrupt acknowledge and end of interrupt signals. A direct context switch in an interrupt handler circumvents the interrupt processing epilogue and may leave the system in an inconsistent state. Release lock in rtems_smp_process_interrupt() even if no message was delivered. This prevents deadlock of the system. Simplify and format _SMP_Send_message(), _SMP_Request_other_cores_to_perform_first_context_switch(), _SMP_Request_other_cores_to_dispatch() and _SMP_Request_other_cores_to_shutdown().
* smp: Delete bsp_smp_secondary_cpu_initialize()Sebastian Huber2013-05-291-3/+0
| | | | | | | Do not call bsp_smp_secondary_cpu_initialize() in rtems_smp_secondary_cpu_initialize(). This allows more flexibilty in the BSP low-level code. Specify context requirements for a call to rtems_smp_secondary_cpu_initialize().
* score misc: Score misc: Clean up Doxygen #5Alex Ivanov2012-11-291-20/+7
|