summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-22 16:01:53 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-22 16:57:27 +0200
commita1ccc40f1e751414fccf8d1cd723f7b3b2d01db3 (patch)
tree6ea6f32cae23e945891dc21e9ae6061be8954388
parent2a3cff89af9dd781a7cb403cd4a8d6a218784144 (diff)
downloadrtems-a1ccc40f1e751414fccf8d1cd723f7b3b2d01db3.tar.bz2
rtems: Basic SMP support for timer server
-rw-r--r--cpukit/rtems/src/timerserver.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/cpukit/rtems/src/timerserver.c b/cpukit/rtems/src/timerserver.c
index ef32f00f70..0dc69c522c 100644
--- a/cpukit/rtems/src/timerserver.c
+++ b/cpukit/rtems/src/timerserver.c
@@ -345,6 +345,22 @@ static void _Timer_server_Get_watchdogs_that_fire_now(
}
}
+/* FIXME: This locking approach for SMP is improvable! */
+
+static void _Timer_server_SMP_lock_aquire( void )
+{
+#if defined( RTEMS_SMP )
+ _Thread_Disable_dispatch();
+#endif
+}
+
+static void _Timer_server_SMP_lock_release( void )
+{
+#if defined( RTEMS_SMP )
+ _Thread_Enable_dispatch();
+#endif
+}
+
/**
* @brief Timer server body.
*
@@ -365,6 +381,8 @@ static rtems_task _Timer_server_Body(
_Chain_Initialize_empty( &insert_chain );
_Chain_Initialize_empty( &fire_chain );
+ _Timer_server_SMP_lock_aquire();
+
while ( true ) {
_Timer_server_Get_watchdogs_that_fire_now( ts, &insert_chain, &fire_chain );
@@ -391,12 +409,16 @@ static rtems_task _Timer_server_Body(
break;
}
+ _Timer_server_SMP_lock_release();
+
/*
* The timer server may block here and wait for resources or time.
* The system watchdogs are inactive and will remain inactive since
* the active flag of the timer server is true.
*/
(*watchdog->routine)( watchdog->id, watchdog->user_data );
+
+ _Timer_server_SMP_lock_aquire();
}
} else {
ts->active = false;
@@ -404,11 +426,18 @@ static rtems_task _Timer_server_Body(
/*
* Block until there is something to do.
*/
+#if !defined( RTEMS_SMP )
_Thread_Disable_dispatch();
+#endif
_Thread_Set_state( ts->thread, STATES_DELAYING );
_Timer_server_Reset_interval_system_watchdog( ts );
_Timer_server_Reset_tod_system_watchdog( ts );
+#if !defined( RTEMS_SMP )
_Thread_Enable_dispatch();
+#endif
+
+ _Timer_server_SMP_lock_release();
+ _Timer_server_SMP_lock_aquire();
ts->active = true;