[rtems commit] posix: Use _POSIX_Threads_Sporadic_timer_insert()

Sebastian Huber sebh at rtems.org
Wed Jun 15 08:45:52 UTC 2016


Module:    rtems
Branch:    master
Commit:    5d65d0ddaf66cb621a5656c4dc6ccd1dfcc7afb4
Changeset: http://git.rtems.org/rtems/commit/?id=5d65d0ddaf66cb621a5656c4dc6ccd1dfcc7afb4

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Jun 15 08:50:29 2016 +0200

posix: Use _POSIX_Threads_Sporadic_timer_insert()

---

 cpukit/posix/include/rtems/posix/pthreadimpl.h | 15 ++++++++++++++-
 cpukit/posix/src/pthread.c                     |  8 +-------
 cpukit/posix/src/pthreadcreate.c               |  8 +-------
 3 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/pthreadimpl.h b/cpukit/posix/include/rtems/posix/pthreadimpl.h
index 68b6050..990a842 100644
--- a/cpukit/posix/include/rtems/posix/pthreadimpl.h
+++ b/cpukit/posix/include/rtems/posix/pthreadimpl.h
@@ -22,9 +22,11 @@
 #include <rtems/posix/pthread.h>
 #include <rtems/posix/config.h>
 #include <rtems/posix/threadsup.h>
+#include <rtems/score/assert.h>
 #include <rtems/score/objectimpl.h>
+#include <rtems/score/timespec.h>
 #include <rtems/score/threadimpl.h>
-#include <rtems/score/assert.h>
+#include <rtems/score/watchdogimpl.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -51,6 +53,17 @@ extern Thread_Information _POSIX_Threads_Information;
  */
 extern pthread_attr_t _POSIX_Threads_Default_attributes;
 
+RTEMS_INLINE_ROUTINE void _POSIX_Threads_Sporadic_timer_insert(
+  POSIX_API_Control *api
+)
+{
+  _Watchdog_Per_CPU_insert_relative(
+    &api->Sporadic_timer,
+    _Per_CPU_Get(),
+    _Timespec_To_ticks( &api->Attributes.schedparam.sched_ss_repl_period )
+  );
+}
+
 /**
  * @brief POSIX threads sporadic budget callout.
  *
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index 766ac01..622052c 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -31,14 +31,12 @@
 #include <rtems/score/threadimpl.h>
 #include <rtems/score/threadqimpl.h>
 #include <rtems/score/userextimpl.h>
-#include <rtems/score/watchdogimpl.h>
 #include <rtems/score/wkspace.h>
 #include <rtems/posix/pthreadimpl.h>
 #include <rtems/posix/priorityimpl.h>
 #include <rtems/posix/psignalimpl.h>
 #include <rtems/posix/config.h>
 #include <rtems/posix/keyimpl.h>
-#include <rtems/score/timespec.h>
 #include <rtems/score/cpusetimpl.h>
 #include <rtems/score/assert.h>
 
@@ -119,11 +117,7 @@ void _POSIX_Threads_Sporadic_budget_TSR( Watchdog_Control *watchdog )
     _Timespec_To_ticks( &api->schedparam.sched_ss_init_budget );
 
   _Watchdog_Per_CPU_remove_relative( &api->Sporadic_timer );
-  _Watchdog_Per_CPU_insert_relative(
-    &api->Sporadic_timer,
-    _Per_CPU_Get(),
-    _Timespec_To_ticks( &api->schedparam.sched_ss_repl_period )
-  );
+  _POSIX_Threads_Sporadic_timer_insert( api );
 
   new_priority = _POSIX_Priority_To_core( api->schedparam.sched_priority );
 
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index 7f95898..af19313 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -31,10 +31,8 @@
 #include <rtems/score/threadimpl.h>
 #include <rtems/score/apimutex.h>
 #include <rtems/score/stackimpl.h>
-#include <rtems/score/watchdogimpl.h>
 #include <rtems/score/schedulerimpl.h>
 
-
 static inline size_t _POSIX_Threads_Ensure_minimum_stack (
   size_t size
 )
@@ -253,11 +251,7 @@ int pthread_create(
 
   if ( schedpolicy == SCHED_SPORADIC ) {
     _ISR_lock_ISR_disable( &lock_context );
-    _Watchdog_Per_CPU_insert_relative(
-      &api->Sporadic_timer,
-      _Per_CPU_Get(),
-      _Timespec_To_ticks( &api->schedparam.sched_ss_repl_period )
-    );
+    _POSIX_Threads_Sporadic_timer_insert( api );
     _ISR_lock_ISR_enable( &lock_context );
   }
 




More information about the vc mailing list