summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-05-28 18:11:51 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-06-02 08:28:42 +0200
commit25f5730fe515911e42591f66294baff0369d9883 (patch)
treea6ab2d7c98499ec959d4272a2ec9bd6069589e09 /cpukit
parentscore: _Scheduler_Get_affinity() (diff)
downloadrtems-25f5730fe515911e42591f66294baff0369d9883.tar.bz2
score: _Scheduler_Set_affinity()
Do not change the scheduler with this function. Documentation. Coding style.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/rtems/include/rtems/rtems/tasks.h11
-rw-r--r--cpukit/score/include/rtems/score/schedulerimpl.h10
-rw-r--r--cpukit/score/src/schedulersetaffinity.c52
3 files changed, 29 insertions, 44 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h
index 76653fd7c4..e0fa27e16f 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -521,6 +521,17 @@ rtems_status_code rtems_task_get_affinity(
/**
* @brief Sets the processor affinity set of a task.
*
+ * This function will not change the scheduler of the task. The intersection
+ * of the processor affinity set and the set of processors owned by the
+ * scheduler of the task must be non-empty. It is not an error if the
+ * processor affinity set contains processors that are not part of the set of
+ * processors owned by the scheduler instance of the task. A task will simply
+ * not run under normal circumstances on these processors since the scheduler
+ * ignores them. Some locking protocols may temporarily use processors that
+ * are not included in the processor affinity set of the task. It is also not
+ * an error if the processor affinity set contains processors that are not part
+ * of the system.
+ *
* @param[in] id Identifier of the task. Use @ref RTEMS_SELF to select the
* executing task.
* @param[in] cpusetsize Size of the specified affinity set buffer in
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index a434c8ca8c..f1acf32d35 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -418,7 +418,6 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_default_Set_affinity_body(
const cpu_set_t *cpuset
)
{
- size_t cpu_max = _CPU_set_Maximum_CPU_count( cpusetsize );
uint32_t cpu_count = _SMP_Get_processor_count();
uint32_t cpu_index;
bool ok = true;
@@ -429,8 +428,7 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_default_Set_affinity_body(
_Scheduler_Get_by_CPU_index( cpu_index );
ok = ok
- && ( ( CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset )
- && scheduler == scheduler_of_cpu )
+ && ( CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset )
|| ( !CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset )
&& scheduler != scheduler_of_cpu ) );
#else
@@ -440,12 +438,6 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_default_Set_affinity_body(
#endif
}
- for ( ; cpu_index < cpu_max ; ++cpu_index ) {
- ok = ok && !CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset );
- }
-
- _Scheduler_Set( scheduler, the_thread );
-
return ok;
}
diff --git a/cpukit/score/src/schedulersetaffinity.c b/cpukit/score/src/schedulersetaffinity.c
index a20888b617..f7c9336df1 100644
--- a/cpukit/score/src/schedulersetaffinity.c
+++ b/cpukit/score/src/schedulersetaffinity.c
@@ -26,45 +26,27 @@ bool _Scheduler_Set_affinity(
const cpu_set_t *cpuset
)
{
- bool ok;
+ const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
- if ( _CPU_set_Is_large_enough( cpusetsize ) ) {
-#if defined(RTEMS_SMP)
- uint32_t cpu_count = _SMP_Get_processor_count();
- uint32_t cpu_index;
-
- ok = false;
-
- for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
- if ( CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset ) ) {
- const Scheduler_Control *scheduler_of_cpu =
- _Scheduler_Get_by_CPU_index( cpu_index );
-
- if ( scheduler_of_cpu != NULL ) {
- ok = ( *scheduler_of_cpu->Operations.set_affinity )(
- scheduler_of_cpu,
- the_thread,
- cpusetsize,
- cpuset
- );
- }
+ if ( !_CPU_set_Is_large_enough( cpusetsize ) ) {
+ return false;
+ }
- break;
- }
- }
+#if defined(RTEMS_SMP)
+ return ( *scheduler->Operations.set_affinity )(
+ scheduler,
+ the_thread,
+ cpusetsize,
+ cpuset
+ );
#else
- ok = _Scheduler_default_Set_affinity_body(
- _Scheduler_Get( the_thread ),
- the_thread,
- cpusetsize,
- cpuset
- );
+ return _Scheduler_default_Set_affinity_body(
+ scheduler,
+ the_thread,
+ cpusetsize,
+ cpuset
+ );
#endif
- } else {
- ok = false;
- }
-
- return ok;
}
#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */