<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for rtems (2011-05-26)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>jennifer</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2011-05-26 Jennifer Averett <Jennifer.Averett@OARcorp.com>
PR 1796/cpukit
* sapi/src/exshutdown.c, score/include/rtems/score/percpu.h,
score/include/rtems/score/smp.h, score/src/smp.c,
score/src/threaddispatch.c, score/src/threadhandler.c: Added SMP
interprocess communications.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2845&r2=text&tr2=1.2846&diff_format=h">M</a></td><td width='1%'>1.2846</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/sapi/src/exshutdown.c.diff?r1=text&tr1=1.4&r2=text&tr2=1.5&diff_format=h">M</a></td><td width='1%'>1.5</td><td width='100%'>cpukit/sapi/src/exshutdown.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/include/rtems/score/percpu.h.diff?r1=text&tr1=1.9&r2=text&tr2=1.10&diff_format=h">M</a></td><td width='1%'>1.10</td><td width='100%'>cpukit/score/include/rtems/score/percpu.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/include/rtems/score/smp.h.diff?r1=text&tr1=1.2&r2=text&tr2=1.3&diff_format=h">M</a></td><td width='1%'>1.3</td><td width='100%'>cpukit/score/include/rtems/score/smp.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/src/smp.c.diff?r1=text&tr1=1.5&r2=text&tr2=1.6&diff_format=h">M</a></td><td width='1%'>1.6</td><td width='100%'>cpukit/score/src/smp.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/src/threaddispatch.c.diff?r1=text&tr1=1.24&r2=text&tr2=1.25&diff_format=h">M</a></td><td width='1%'>1.25</td><td width='100%'>cpukit/score/src/threaddispatch.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/src/threadhandler.c.diff?r1=text&tr1=1.32&r2=text&tr2=1.33&diff_format=h">M</a></td><td width='1%'>1.33</td><td width='100%'>cpukit/score/src/threadhandler.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2845 rtems/cpukit/ChangeLog:1.2846
--- rtems/cpukit/ChangeLog:1.2845 Mon May 23 21:45:18 2011
+++ rtems/cpukit/ChangeLog Thu May 26 13:07:07 2011
</font><font color='#997700'>@@ -1,3 +1,11 @@
</font><font color='#000088'>+2011-05-26 Jennifer Averett <Jennifer.Averett@OARcorp.com>
+
+ PR 1796/cpukit
+ * sapi/src/exshutdown.c, score/include/rtems/score/percpu.h,
+ score/include/rtems/score/smp.h, score/src/smp.c,
+ score/src/threaddispatch.c, score/src/threadhandler.c: Added SMP
+ interprocess communications.
+
</font> 2011-05-24 Ralf Corsépius <ralf.corsepius@rtems.org>
* score/include/rtems/score/percpu.h,
<font color='#006600'>diff -u rtems/cpukit/sapi/src/exshutdown.c:1.4 rtems/cpukit/sapi/src/exshutdown.c:1.5
--- rtems/cpukit/sapi/src/exshutdown.c:1.4 Tue Aug 10 17:56:35 2010
+++ rtems/cpukit/sapi/src/exshutdown.c Thu May 26 13:07:07 2011
</font><font color='#997700'>@@ -1,7 +1,7 @@
</font> /*
* Initialization Manager
*
<font color='#880000'>- * COPYRIGHT (c) 1989-1999.
</font><font color='#000088'>+ * COPYRIGHT (c) 1989-2011.
</font> * On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
<font color='#997700'>@@ -20,6 +20,10 @@
</font> #include <rtems/score/thread.h>
#include <rtems/score/interr.h>
<font color='#000088'>+#if defined(RTEMS_SMP)
+ #include <rtems/score/smp.h>
+#endif
+
</font> /*
* rtems_shutdown_executive
*
<font color='#997700'>@@ -37,6 +41,9 @@
</font> )
{
if ( _System_state_Is_up( _System_state_Get() ) ) {
<font color='#000088'>+ #if defined(RTEMS_SMP)
+ _SMP_Request_other_cores_to_shutdown();
+ #endif
</font> _System_state_Set( SYSTEM_STATE_SHUTDOWN );
_Thread_Stop_multitasking();
}
<font color='#006600'>diff -u rtems/cpukit/score/include/rtems/score/percpu.h:1.9 rtems/cpukit/score/include/rtems/score/percpu.h:1.10
--- rtems/cpukit/score/include/rtems/score/percpu.h:1.9 Mon May 23 21:44:57 2011
+++ rtems/cpukit/score/include/rtems/score/percpu.h Thu May 26 13:07:07 2011
</font><font color='#997700'>@@ -79,9 +79,15 @@
</font>
/**
* This defines the constant used to indicate that the cpu code has
<font color='#000088'>+ * completed basic initialization and awaits further commands.
+ */
+ RTEMS_BSP_SMP_CPU_UP = 3,
+
+ /**
+ * This defines the constant used to indicate that the cpu code has
</font> * shut itself down.
*/
<font color='#880000'>- RTEMS_BSP_SMP_CPU_SHUTDOWN = 3
</font><font color='#000088'>+ RTEMS_BSP_SMP_CPU_SHUTDOWN = 4
</font> } bsp_smp_cpu_state;
/**
<font color='#006600'>diff -u rtems/cpukit/score/include/rtems/score/smp.h:1.2 rtems/cpukit/score/include/rtems/score/smp.h:1.3
--- rtems/cpukit/score/include/rtems/score/smp.h:1.2 Mon May 23 21:44:57 2011
+++ rtems/cpukit/score/include/rtems/score/smp.h Thu May 26 13:07:07 2011
</font><font color='#997700'>@@ -87,6 +87,14 @@
</font> );
/**
<font color='#000088'>+ * @brief Request Other Cores to Perform First Context Switch
+ *
+ * Send message to other cores requesting them to perform
+ * their first context switch operation.
+ */
+void _SMP_Request_other_cores_to_perform_first_context_switch(void);
+
+/**
</font> * @brief Request Dispatch on Other Cores
*
* Send message to other cores requesting them to perform
<font color='#006600'>diff -u rtems/cpukit/score/src/smp.c:1.5 rtems/cpukit/score/src/smp.c:1.6
--- rtems/cpukit/score/src/smp.c:1.5 Mon May 23 21:44:58 2011
+++ rtems/cpukit/score/src/smp.c Thu May 26 13:07:07 2011
</font><font color='#997700'>@@ -19,30 +19,35 @@
</font> #include <rtems/score/thread.h>
#if defined(RTEMS_SMP)
<font color='#880000'>-#define SMP_DEBUG
</font><font color='#000088'>+ #define RTEMS_DEBUG
+#endif
</font>
<font color='#880000'>-#if defined(SMP_DEBUG)
</font><font color='#000088'>+#if defined(RTEMS_DEBUG)
</font> #include <rtems/bspIo.h>
#endif
<font color='#000088'>+/*
+ * Process request to switch to the first task on a secondary core.
+ */
</font> void rtems_smp_run_first_task(int cpu)
{
Thread_Control *heir;
/*
<font color='#880000'>- * This CPU has an heir thread so we need to dispatch it.
</font><font color='#000088'>+ * The Scheduler will have selected the heir thread for each CPU core.
+ * Now we have been requested to perform the first context switch. So
+ * force a switch to the designated heir and make it executing on<span style="background-color: #FF0000"> </span>
+ * THIS core.
</font> */
<font color='#880000'>- heir = _Thread_Heir;
-
- /*
- * This is definitely a hack until we have SMP scheduling. Since there
- * is only one executing and heir right now, we have to fake this out.
- */
- _Thread_Dispatch_set_disable_level(1);
</font><font color='#000088'>+ heir = _Thread_Heir;
</font> _Thread_Executing = heir;
<font color='#000088'>+
</font> _CPU_Context_switch_to_first_task_smp( &heir->Registers );
}
<font color='#000088'>+/*
+ * Process request to initialize this secondary core.
+ */
</font> void rtems_smp_secondary_cpu_initialize(void)
{
int cpu;
<font color='#997700'>@@ -51,7 +56,7 @@
</font>
bsp_smp_secondary_cpu_initialize(cpu);
<font color='#880000'>- #if defined(SMP_DEBUG)
</font><font color='#000088'>+ #if defined(RTEMS_DEBUG)
</font> printk( "Made it to %d -- ", cpu );
#endif
<font color='#997700'>@@ -63,15 +68,26 @@
</font> _Per_CPU_Information[cpu].state = RTEMS_BSP_SMP_CPU_INITIALIZED;
/*
<font color='#880000'>- * HACK: Should not have to enable interrupts in real system here.
- * It should happen as part of switching to the first task.
</font><font color='#000088'>+ * With this secondary core out of reset, we can wait for the
+ * request to switch to the first task.
+ *
+ * XXX When SMP ISR code is complete, do we want interrupts on
+ * XXX or off at this point?
</font> */
<font color='#880000'>-
- _Per_CPU_Information[cpu].isr_nest_level = 1;
</font> _ISR_Set_level( 0 );
<font color='#880000'>- while(1) ;
</font><font color='#000088'>+ while(1) {
+ bsp_smp_wait_for(
+ (volatile unsigned int *)&_Per_CPU_Information[cpu].message,
+ RTEMS_BSP_SMP_FIRST_TASK,
+ 10000
+ );
+ }
</font> }
<font color='#000088'>+/*
+ * Process an interrupt processor interrupt which indicates a request
+ * from another core.
+ */
</font> void rtems_smp_process_interrupt(void)
{
int cpu;
<font color='#997700'>@@ -80,31 +96,53 @@
</font>
cpu = bsp_smp_processor_id();
<font color='#880000'>- level = _SMP_lock_spinlock_simple_Obtain( &_Per_CPU_Information[cpu].lock );
- message = _Per_CPU_Information[cpu].message;
- _Per_CPU_Information[cpu].message &= ~message;
- _SMP_lock_spinlock_simple_Release( &_Per_CPU_Information[cpu].lock, level );
</font><font color='#000088'>+ level = _SMP_lock_Simple_Spinlock_Obtain( &_Per_CPU_Information[cpu].lock );
+ message = _Per_CPU_Information[cpu].message;
</font>
<font color='#880000'>- #if defined(SMP_DEBUG)
</font><font color='#000088'>+ #if defined(RTEMS_DEBUG)
</font> {
void *sp = __builtin_frame_address(0);
<font color='#880000'>- if ( !(message & RTEMS_BSP_SMP_SHUTDOWN) )
- printk( "ISR on CPU %d -- (0x%02x) (0x%p)\n", cpu, message, sp );
- printk( "Dispatch level %d\n", _Thread_Dispatch_disable_level );
</font><font color='#000088'>+ if ( !(message & RTEMS_BSP_SMP_SHUTDOWN) ) {
+ printk( "ISR on CPU %d -- (0x%02x) (0x%p)\n", cpu, message, sp );
+ if ( message & RTEMS_BSP_SMP_CONTEXT_SWITCH_NECESSARY )
+ printk( "context switch necessary\n" );
+ if ( message & RTEMS_BSP_SMP_SIGNAL_TO_SELF )
+ printk( "signal to self\n" );
+ if ( message & RTEMS_BSP_SMP_SHUTDOWN )
+ printk( "shutdown\n" );
+ if ( message & RTEMS_BSP_SMP_FIRST_TASK )
+ printk( "switch to first task\n" );
+ }
+<span style="background-color: #FF0000"> </span>
+ printk( "Dispatch level %d\n", _Thread_Dispatch_get_disable_level() );
</font> }
#endif
if ( message & RTEMS_BSP_SMP_FIRST_TASK ) {
<font color='#000088'>+ /*
+ * XXX Thread dispatch disable level at this point will have to be
+ * XXX revisited when Interrupts on SMP is addressed.
+ */
+ _Thread_Dispatch_disable_level--; /* undo ISR code */
</font> _Per_CPU_Information[cpu].isr_nest_level = 0;
<font color='#880000'>- _Per_CPU_Information[cpu].message = 0;
- _Per_CPU_Information[cpu].state = RTEMS_BSP_SMP_CPU_INITIALIZED;
</font><font color='#000088'>+ _Per_CPU_Information[cpu].message &= ~message;
+ _Per_CPU_Information[cpu].state = RTEMS_BSP_SMP_CPU_UP;
+
+ _SMP_lock_Simple_Spinlock_Release( &_Per_CPU_Information[cpu].lock, level );
+ _Thread_Disable_dispatch();
</font> rtems_smp_run_first_task(cpu);
/* does not return */
}
if ( message & RTEMS_BSP_SMP_SHUTDOWN ) {
<font color='#880000'>- ISR_Level level;
- _Thread_Dispatch_set_disable_level(0);
</font><font color='#000088'>+ /*
+ * XXX Thread dispatch disable level at this point will have to be
+ * XXX revisited when Interrupts on SMP is addressed.
+ */
+ _Per_CPU_Information[cpu].message &= ~message;
+ _SMP_lock_Simple_Spinlock_Release( &_Per_CPU_Information[cpu].lock, level );
+
+ _Thread_Dispatch_disable_level--; /* undo ISR code */
</font> _Per_CPU_Information[cpu].isr_nest_level = 0;
_Per_CPU_Information[cpu].state = RTEMS_BSP_SMP_CPU_SHUTDOWN;
_ISR_Disable( level );
<font color='#997700'>@@ -114,12 +152,22 @@
</font> }
if ( message & RTEMS_BSP_SMP_CONTEXT_SWITCH_NECESSARY ) {
<font color='#880000'>- printk( "switch needed\n" );
- _Per_CPU_Information[cpu].dispatch_necessary = true;
</font><font color='#000088'>+ #if defined(RTEMS_DEBUG)
+ printk( "switch needed\n" );
+ #endif
+ /*
+ * XXX Thread dispatch disable level at this point will have to be
+ * XXX revisited when Interrupts on SMP is addressed.
+ */
+ _Per_CPU_Information[cpu].message &= ~message;
+ _SMP_lock_Simple_Spinlock_Release( &_Per_CPU_Information[cpu].lock, level );
</font> }
}
<font color='#880000'>-void rtems_smp_send_message(
</font><font color='#000088'>+/*
+ * Send an interrupt processor request to another cpu.
+ */
+void _SMP_Send_message(
</font> int cpu,
uint32_t message
)
<font color='#997700'>@@ -132,7 +180,10 @@
</font> bsp_smp_interrupt_cpu( cpu );
}
<font color='#880000'>-void rtems_smp_broadcast_message(
</font><font color='#000088'>+/*
+ * Send interrupt processor request to all other nodes
+ */
+void _SMP_Broadcast_message(
</font> uint32_t message
)
{
<font color='#997700'>@@ -151,4 +202,82 @@
</font> }
bsp_smp_broadcast_interrupt();
}
<font color='#880000'>-#endif
</font><font color='#000088'>+
+/*
+ * Send interrupt processor requests to perform first context switch<span style="background-color: #FF0000"> </span>
+ */
+void _SMP_Request_other_cores_to_perform_first_context_switch(void)
+{
+ int cpu;
+
+ for (cpu=1 ; cpu < _SMP_Processor_count ; cpu++ ) {
+ _SMP_Send_message( cpu, RTEMS_BSP_SMP_FIRST_TASK );
+ while (_Per_CPU_Information[cpu].state != RTEMS_BSP_SMP_CPU_UP ) {
+ bsp_smp_wait_for(
+ (volatile unsigned int *)&_Per_CPU_Information[cpu].state,
+ RTEMS_BSP_SMP_CPU_UP,
+ 10000
+ );
+ }
+ }
+}
+
+/*
+ * Send message to other cores requesting them to perform
+ * a thread dispatch operation.
+ */
+void _SMP_Request_other_cores_to_dispatch(void)
+{
+ int i;
+ int cpu;
+
+ cpu = bsp_smp_processor_id();
+
+ if ( !_System_state_Is_up (_System_state_Current) )
+ return;
+ for (i=1 ; i < _SMP_Processor_count ; i++ ) {
+ if ( cpu == i )
+ continue;
+ if ( _Per_CPU_Information[i].state != RTEMS_BSP_SMP_CPU_UP )
+ continue;
+ if ( !_Per_CPU_Information[i].dispatch_necessary )
+ continue;
+ _SMP_Send_message( i, RTEMS_BSP_SMP_CONTEXT_SWITCH_NECESSARY );
+ bsp_smp_wait_for(
+ (volatile unsigned int *)&_Per_CPU_Information[i].message,
+ 0,
+ 10000
+ );
+ }
+}
+
+/*
+ * Send message to other cores requesting them to shutdown.
+ */
+void _SMP_Request_other_cores_to_shutdown(void)
+{
+ bool allDown;
+ int ncpus;
+ int cpu;
+
+ ncpus = _SMP_Processor_count;
+
+ _SMP_Broadcast_message( RTEMS_BSP_SMP_SHUTDOWN );
+
+ allDown = true;
+ for (cpu=1 ; cpu<ncpus ; cpu++ ) {
+ bsp_smp_wait_for(
+ (unsigned int *)&_Per_CPU_Information[cpu].state,
+ RTEMS_BSP_SMP_CPU_SHUTDOWN,
+ 10000
+ );
+ if ( _Per_CPU_Information[cpu].state != RTEMS_BSP_SMP_CPU_SHUTDOWN )
+ allDown = false;
+ }
+ if ( !allDown )
+ printk( "All CPUs not successfully shutdown -- timed out\n" );
+ #if (RTEMS_DEBUG)
+ else<span style="background-color: #FF0000"> </span>
+ printk( "All CPUs shutdown successfully\n" );
+ #endif
+}
</font>
<font color='#006600'>diff -u rtems/cpukit/score/src/threaddispatch.c:1.24 rtems/cpukit/score/src/threaddispatch.c:1.25
--- rtems/cpukit/score/src/threaddispatch.c:1.24 Thu Apr 21 14:05:15 2011
+++ rtems/cpukit/score/src/threaddispatch.c Thu May 26 13:07:07 2011
</font><font color='#997700'>@@ -33,6 +33,10 @@
</font> #include <rtems/score/timestamp.h>
#endif
<font color='#000088'>+#if defined(RTEMS_SMP)
+ #include <rtems/score/smp.h>
+#endif
+
</font> /**
* _Thread_Dispatch
*
<font color='#997700'>@@ -47,18 +51,28 @@
</font> * dispatch thread
* no dispatch thread
*/
<font color='#880000'>-
</font> void _Thread_Dispatch( void )
{
Thread_Control *executing;
Thread_Control *heir;
ISR_Level level;
<font color='#000088'>+ _Thread_Disable_dispatch();
+ #if defined(RTEMS_SMP)
+ /*
+ * If necessary, send dispatch request to other cores.
+ */
+ _SMP_Request_other_cores_to_dispatch();
+ #endif
+
+ /*
+ * Now determine if we need to perform a dispatch on the current CPU.
+ */
</font> executing = _Thread_Executing;
_ISR_Disable( level );
while ( _Thread_Dispatch_necessary == true ) {
<font color='#000088'>+
</font> heir = _Thread_Heir;
<font color='#880000'>- _Thread_Dispatch_set_disable_level( 1 );
</font> _Thread_Dispatch_necessary = false;
_Thread_Executing = heir;
<font color='#997700'>@@ -96,7 +110,10 @@
</font> _Thread_Time_of_last_context_switch = uptime;
}
#else
<font color='#880000'>- heir->cpu_time_used++;
</font><font color='#000088'>+ {
+ TOD_Get_uptime( &_Thread_Time_of_last_context_switch );
+ heir->cpu_time_used++;
+ }
</font> #endif
/*
<font color='#006600'>diff -u rtems/cpukit/score/src/threadhandler.c:1.32 rtems/cpukit/score/src/threadhandler.c:1.33
--- rtems/cpukit/score/src/threadhandler.c:1.32 Fri Jan 28 14:24:53 2011
+++ rtems/cpukit/score/src/threadhandler.c Thu May 26 13:07:07 2011
</font><font color='#997700'>@@ -2,7 +2,7 @@
</font> * Thread Handler
*
*
<font color='#880000'>- * COPYRIGHT (c) 1989-2009.
</font><font color='#000088'>+ * COPYRIGHT (c) 1989-2011.
</font> * On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
<font color='#997700'>@@ -51,6 +51,11 @@
</font> #define EXECUTE_GLOBAL_CONSTRUCTORS
#endif
<font color='#000088'>+#if defined(RTEMS_SMP)
+ #include <rtems/score/smp.h>
+#endif
+
+
</font> /*PAGE
*
* _Thread_Handler
<font color='#997700'>@@ -138,8 +143,15 @@
</font> */
if (!doneCons) /* && (volatile void *)_init) */ {
INIT_NAME ();
<font color='#000088'>+<span style="background-color: #FF0000"> </span>
+ #if defined(RTEMS_SMP)
+ _Thread_Disable_dispatch();
+ _SMP_Request_other_cores_to_perform_first_context_switch();
+ _Thread_Enable_dispatch();
+ #endif
+
</font> }
<font color='#880000'>- #endif
</font><font color='#000088'>+ #endif
</font>
if ( executing->Start.prototype == THREAD_START_NUMERIC ) {
executing->Wait.return_argument =
</pre>
<p> </p>
<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>