summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-11 10:58:59 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-12 13:24:41 +0200
commite135271b933c896068a343b161773ce3b685be43 (patch)
tree83faf308498a9695ba551f8e5b3f7473daa37d68 /cpukit/score
parentscore: Use thread state lock for current state (diff)
downloadrtems-e135271b933c896068a343b161773ce3b685be43.tar.bz2
score: Avoid Giant lock _Scheduler_Set_affinity()
Update #2555.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/include/rtems/score/schedulerimpl.h6
-rw-r--r--cpukit/score/include/rtems/score/statesimpl.h2
-rw-r--r--cpukit/score/include/rtems/score/thread.h1
-rw-r--r--cpukit/score/src/schedulerpriorityaffinitysmp.c25
-rw-r--r--cpukit/score/src/schedulersetaffinity.c20
5 files changed, 36 insertions, 18 deletions
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index c888237376..640f871b05 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -698,9 +698,9 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_default_Set_affinity_body(
}
bool _Scheduler_Set_affinity(
- Thread_Control *the_thread,
- size_t cpusetsize,
- const cpu_set_t *cpuset
+ Thread_Control *the_thread,
+ size_t cpusetsize,
+ const cpu_set_t *cpuset
);
#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
diff --git a/cpukit/score/include/rtems/score/statesimpl.h b/cpukit/score/include/rtems/score/statesimpl.h
index 97cadb2888..f3c2293b96 100644
--- a/cpukit/score/include/rtems/score/statesimpl.h
+++ b/cpukit/score/include/rtems/score/statesimpl.h
@@ -80,8 +80,6 @@ extern "C" {
#define STATES_WAITING_FOR_TERMINATION 0x100000
/** This macro corresponds to a task being a zombie. */
#define STATES_ZOMBIE 0x200000
-/** This macro corresponds to a task migrating to another scheduler. */
-#define STATES_MIGRATING 0x400000
/** This macro corresponds to a task restarting. */
#define STATES_RESTARTING 0x800000
/** This macro corresponds to a task waiting for a join. */
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 15b068d92b..18e0f5429b 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -718,6 +718,7 @@ struct _Thread_Control {
* The lock of this thread queue is used for various purposes. It protects
* the following fields
*
+ * - POSIX_API_Control::Attributes,
* - RTEMS_API_Control::Signal,
* - Thread_Control::current_state,
* - Thread_Control::Post_switch_actions,
diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c
index 98487ec43f..fa56e2b1b5 100644
--- a/cpukit/score/src/schedulerpriorityaffinitysmp.c
+++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c
@@ -616,10 +616,8 @@ bool _Scheduler_priority_affinity_SMP_Set_affinity(
const cpu_set_t *cpuset
)
{
- Scheduler_priority_affinity_SMP_Node *node =
- _Scheduler_priority_affinity_SMP_Thread_get_node(thread);
-
- (void) scheduler;
+ Scheduler_priority_affinity_SMP_Node *node;
+ States_Control current_state;
/*
* Validate that the cpset meets basic requirements.
@@ -628,6 +626,8 @@ bool _Scheduler_priority_affinity_SMP_Set_affinity(
return false;
}
+ node = _Scheduler_priority_affinity_SMP_Thread_get_node( thread );
+
/*
* The old and new set are the same, there is no point in
* doing anything.
@@ -635,9 +635,20 @@ bool _Scheduler_priority_affinity_SMP_Set_affinity(
if ( CPU_EQUAL_S( cpusetsize, cpuset, node->Affinity.set ) )
return true;
- _Thread_Set_state( thread, STATES_MIGRATING );
- CPU_COPY( node->Affinity.set, cpuset );
- _Thread_Clear_state( thread, STATES_MIGRATING );
+ current_state = thread->current_state;
+
+ if ( _States_Is_ready( current_state ) ) {
+ _Scheduler_priority_affinity_SMP_Block( scheduler, thread );
+ }
+
+ CPU_COPY( node->Affinity.set, cpuset );
+
+ if ( _States_Is_ready( current_state ) ) {
+ /*
+ * FIXME: Do not ignore threads in need for help.
+ */
+ (void) _Scheduler_priority_affinity_SMP_Unblock( scheduler, thread );
+ }
return true;
}
diff --git a/cpukit/score/src/schedulersetaffinity.c b/cpukit/score/src/schedulersetaffinity.c
index f7c9336df1..b59d8eb68e 100644
--- a/cpukit/score/src/schedulersetaffinity.c
+++ b/cpukit/score/src/schedulersetaffinity.c
@@ -21,32 +21,40 @@
#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
bool _Scheduler_Set_affinity(
- Thread_Control *the_thread,
- size_t cpusetsize,
- const cpu_set_t *cpuset
+ Thread_Control *the_thread,
+ size_t cpusetsize,
+ const cpu_set_t *cpuset
)
{
- const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
+ const Scheduler_Control *scheduler;
+ ISR_lock_Context lock_context;
+ bool ok;
if ( !_CPU_set_Is_large_enough( cpusetsize ) ) {
return false;
}
+ scheduler = _Scheduler_Get( the_thread );
+ _Scheduler_Acquire_critical( scheduler, &lock_context );
+
#if defined(RTEMS_SMP)
- return ( *scheduler->Operations.set_affinity )(
+ ok = ( *scheduler->Operations.set_affinity )(
scheduler,
the_thread,
cpusetsize,
cpuset
);
#else
- return _Scheduler_default_Set_affinity_body(
+ ok = _Scheduler_default_Set_affinity_body(
scheduler,
the_thread,
cpusetsize,
cpuset
);
#endif
+
+ _Scheduler_Release_critical( scheduler, &lock_context );
+ return ok;
}
#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */