summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-08 11:14:27 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-04-15 08:37:12 +0200
commit0712d172d0bce40f3a9190af511249256ddac5f1 (patch)
treeedfe262b0e46134e3704641cac50ff9d147e9e2a
parentscore: Simplify thread control initialization (diff)
downloadrtems-0712d172d0bce40f3a9190af511249256ddac5f1.tar.bz2
score: Task get/set affinity
Make rtems_task_get_affinity() and rtems_task_set_affinity() available on non-SMP configurations. Allow larger CPU sets.
-rw-r--r--cpukit/rtems/Makefile.am9
-rw-r--r--cpukit/rtems/include/rtems/rtems/tasks.h50
-rw-r--r--cpukit/score/Makefile.am2
-rw-r--r--cpukit/score/include/rtems/score/cpusetimpl.h18
-rw-r--r--cpukit/score/include/rtems/score/schedulerimpl.h113
-rw-r--r--cpukit/score/src/schedulerdefaultgetaffinity.c20
-rw-r--r--cpukit/score/src/schedulerdefaultsetaffinity.c11
-rw-r--r--cpukit/score/src/schedulergetaffinity.c55
-rw-r--r--cpukit/score/src/schedulersetaffinity.c55
-rw-r--r--testsuites/sptests/Makefile.am3
-rw-r--r--testsuites/sptests/configure.ac1
-rw-r--r--testsuites/sptests/spscheduler01/Makefile.am19
-rw-r--r--testsuites/sptests/spscheduler01/init.c130
-rw-r--r--testsuites/sptests/spscheduler01/spscheduler01.doc13
-rw-r--r--testsuites/sptests/spscheduler01/spscheduler01.scn2
15 files changed, 410 insertions, 91 deletions
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index a279ed7ac2..b6a19c4f14 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -92,6 +92,7 @@ librtems_a_SOURCES += src/rtemsobjectgetclassicname.c
librtems_a_SOURCES += src/tasks.c
librtems_a_SOURCES += src/taskcreate.c
librtems_a_SOURCES += src/taskdelete.c
+librtems_a_SOURCES += src/taskgetaffinity.c
librtems_a_SOURCES += src/taskgetnote.c
librtems_a_SOURCES += src/taskident.c
librtems_a_SOURCES += src/taskinitusers.c
@@ -100,6 +101,7 @@ librtems_a_SOURCES += src/taskmode.c
librtems_a_SOURCES += src/taskrestart.c
librtems_a_SOURCES += src/taskresume.c
librtems_a_SOURCES += src/taskself.c
+librtems_a_SOURCES += src/tasksetaffinity.c
librtems_a_SOURCES += src/tasksetnote.c
librtems_a_SOURCES += src/tasksetpriority.c
librtems_a_SOURCES += src/taskstart.c
@@ -274,12 +276,5 @@ librtems_a_SOURCES += src/signalmp.c
librtems_a_SOURCES += src/taskmp.c
endif
-## SMP Files
-if HAS_SMP
-librtems_a_SOURCES += src/tasksetaffinity.c
-librtems_a_SOURCES += src/taskgetaffinity.c
-endif
-
-
include $(srcdir)/preinstall.am
include $(top_srcdir)/automake/local.am
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h
index 56dd12d7f0..87128be5f5 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -494,22 +494,23 @@ rtems_status_code rtems_task_variable_delete(
);
#endif
-#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP)
+#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
/**
- * @brief RTEMS Get Task Affinity
+ * @brief Gets the processor affinity set of a task.
*
- * This directive returns the cpuset for the
- * given task. The cpuset size must be the
- * same size as the task affinity set size.
+ * @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
+ * bytes. This value must be positive.
+ * @param[out] cpuset The current processor affinity set of the task. A set
+ * bit in the affinity set means that the task can execute on this processor
+ * and a cleared bit means the opposite.
*
- * @param[in] id is the thread to extract
- * @param[in] cpusetsize is the size of the cpuset
- * @param[out] cpuset is the tasks affinity cpuset
- *
- * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful
- * @retval RTEMS_INVALID_ADDRESS if cpuset is NULL
- * @retval RTEMS_INVALID_NUMBER if cpusetsize is incorrect
- * @retval RTEMS_INVALID_ID if id not valid
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL.
+ * @retval RTEMS_INVALID_ID Invalid task identifier.
+ * @retval RTEMS_INVALID_NUMBER The affinity set buffer is too small for the
+ * current processor affinity set of the task.
*/
rtems_status_code rtems_task_get_affinity(
rtems_id id,
@@ -518,19 +519,20 @@ rtems_status_code rtems_task_get_affinity(
);
/**
- * @brief RTEMS Set Task Affinity
+ * @brief Sets the processor affinity set of a task.
*
- * This directive sets the given tasks
- * affinity cpuset.
+ * @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
+ * bytes. This value must be positive.
+ * @param[in] cpuset The new processor affinity set for the task. A set bit in
+ * the affinity set means that the task can execute on this processor and a
+ * cleared bit means the opposite.
*
- * @param[in] id is the thread to extract
- * @param[in] cpusetsize is the size of the cpuset
- * @param[in] cpuset is affinity set to assign to the task
- *
- * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful
- * @retval RTEMS_INVALID_ADDRESS if cpuset is NULL
- * @retval RTEMS_INVALID_NUMBER if cpuset or cpusetsize is incorrect
- * @retval RTEMS_INVALID_ID if id not valid
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL.
+ * @retval RTEMS_INVALID_ID Invalid task identifier.
+ * @retval RTEMS_INVALID_NUMBER Invalid processor affinity set.
*/
rtems_status_code rtems_task_set_affinity(
rtems_id id,
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 4cd89d792a..ae925507d1 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -195,6 +195,8 @@ libscore_a_SOURCES += src/objectallocate.c src/objectclose.c \
## SCHEDULER_C_FILES
libscore_a_SOURCES += src/log2table.c
libscore_a_SOURCES += src/scheduler.c
+libscore_a_SOURCES += src/schedulergetaffinity.c
+libscore_a_SOURCES += src/schedulersetaffinity.c
libscore_a_SOURCES += src/schedulerdefaultallocatefree.c
libscore_a_SOURCES += src/schedulerdefaultreleasejob.c
libscore_a_SOURCES += src/schedulerdefaultstartidle.c
diff --git a/cpukit/score/include/rtems/score/cpusetimpl.h b/cpukit/score/include/rtems/score/cpusetimpl.h
index 06fe3f5a8e..8ae240847b 100644
--- a/cpukit/score/include/rtems/score/cpusetimpl.h
+++ b/cpukit/score/include/rtems/score/cpusetimpl.h
@@ -20,6 +20,9 @@
#define _RTEMS_SCORE_CPUSETIMPL_H
#include <rtems/score/cpuset.h>
+#include <rtems/score/smp.h>
+
+#include <limits.h>
#ifdef __cplusplus
extern "C" {
@@ -58,6 +61,21 @@ void _CPU_set_Show_default( const char *description );
*/
const CPU_set_Control *_CPU_set_Default(void);
+RTEMS_INLINE_ROUTINE size_t _CPU_set_Maximum_CPU_count(
+ size_t cpusetsize
+)
+{
+ return cpusetsize * CHAR_BIT;
+}
+
+RTEMS_INLINE_ROUTINE bool _CPU_set_Is_large_enough(
+ size_t cpusetsize
+)
+{
+ return _CPU_set_Maximum_CPU_count( cpusetsize )
+ >= _SMP_Get_processor_count();
+}
+
#endif
/**
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index 5c787239d0..e088d26b88 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -20,6 +20,7 @@
#define _RTEMS_SCORE_SCHEDULERIMPL_H
#include <rtems/score/scheduler.h>
+#include <rtems/score/cpusetimpl.h>
#include <rtems/score/threadimpl.h>
#ifdef __cplusplus
@@ -257,49 +258,81 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle(
( *scheduler->Operations.start_idle )( scheduler, the_thread, cpu );
}
-#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP)
- /**
- * @brief Obtain the processor affinity for a thread.
- *
- * @param[in,out] thread The thread.
- * @parma[out] cpuset The processor affinity for this thread
- */
- RTEMS_INLINE_ROUTINE int _Scheduler_Get_affinity(
- const Scheduler_Control *scheduler,
- Thread_Control *the_thread,
- size_t cpusetsize,
- cpu_set_t *cpuset
- )
- {
- return ( *scheduler->Operations.get_affinity )(
- scheduler,
- the_thread,
- cpusetsize,
- cpuset
- );
+#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
+
+RTEMS_INLINE_ROUTINE void _Scheduler_Get_processor_set(
+ const Scheduler_Control *scheduler,
+ size_t cpusetsize,
+ cpu_set_t *cpuset
+)
+{
+ uint32_t cpu_count = _SMP_Get_processor_count();
+ uint32_t cpu_index;
+
+ (void) scheduler;
+
+ CPU_ZERO_S( cpusetsize, cpuset );
+
+ for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
+ CPU_SET_S( (int) cpu_index, cpusetsize, cpuset );
+ }
+}
+
+RTEMS_INLINE_ROUTINE bool _Scheduler_default_Get_affinity_body(
+ const Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ size_t cpusetsize,
+ cpu_set_t *cpuset
+)
+{
+ (void) the_thread;
+
+ _Scheduler_Get_processor_set( scheduler, cpusetsize, cpuset );
+
+ return true;
+}
+
+bool _Scheduler_Get_affinity(
+ const Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ size_t cpusetsize,
+ cpu_set_t *cpuset
+);
+
+RTEMS_INLINE_ROUTINE bool _Scheduler_default_Set_affinity_body(
+ const Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ size_t cpusetsize,
+ 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;
+
+ (void) scheduler;
+ (void) the_thread;
+
+ for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
+ ok = ok && CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset );
}
- /**
- * @brief Set the processor affinity for a thread.
- *
- * @param[in,out] thread The thread.
- * @parma[in] cpuset The processor affinity for this thread
- */
- RTEMS_INLINE_ROUTINE int _Scheduler_Set_affinity(
- const Scheduler_Control *scheduler,
- Thread_Control *the_thread,
- size_t cpusetsize,
- const cpu_set_t *cpuset
- )
- {
- return ( *scheduler->Operations.set_affinity )(
- scheduler,
- the_thread,
- cpusetsize,
- cpuset
- );
+ for ( ; cpu_index < cpu_max ; ++cpu_index ) {
+ ok = ok && !CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset );
}
-#endif
+
+ return ok;
+}
+
+bool _Scheduler_Set_affinity(
+ const Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ size_t cpusetsize,
+ const cpu_set_t *cpuset
+);
+
+#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir(
Thread_Control *heir,
diff --git a/cpukit/score/src/schedulerdefaultgetaffinity.c b/cpukit/score/src/schedulerdefaultgetaffinity.c
index 367fc25293..56a4ee4fad 100644
--- a/cpukit/score/src/schedulerdefaultgetaffinity.c
+++ b/cpukit/score/src/schedulerdefaultgetaffinity.c
@@ -20,7 +20,6 @@
#endif
#include <rtems/score/schedulerimpl.h>
-#include <rtems/score/cpusetimpl.h>
bool _Scheduler_default_Get_affinity(
const Scheduler_Control *scheduler,
@@ -29,17 +28,10 @@ bool _Scheduler_default_Get_affinity(
cpu_set_t *cpuset
)
{
- const CPU_set_Control *ctl;
-
- (void) scheduler;
- (void) thread;
-
- ctl = _CPU_set_Default();
- if ( cpusetsize != ctl->setsize ) {
- return false;
- }
-
- CPU_COPY( cpuset, ctl->set );
-
- return true;
+ return _Scheduler_default_Get_affinity_body(
+ scheduler,
+ thread,
+ cpusetsize,
+ cpuset
+ );
}
diff --git a/cpukit/score/src/schedulerdefaultsetaffinity.c b/cpukit/score/src/schedulerdefaultsetaffinity.c
index 33be12b286..e53f8b8349 100644
--- a/cpukit/score/src/schedulerdefaultsetaffinity.c
+++ b/cpukit/score/src/schedulerdefaultsetaffinity.c
@@ -20,7 +20,6 @@
#endif
#include <rtems/score/schedulerimpl.h>
-#include <rtems/score/cpusetimpl.h>
bool _Scheduler_default_Set_affinity(
const Scheduler_Control *scheduler,
@@ -29,8 +28,10 @@ bool _Scheduler_default_Set_affinity(
const cpu_set_t *cpuset
)
{
- (void) scheduler;
- (void) thread;
-
- return _CPU_set_Is_valid( cpuset, cpusetsize );
+ return _Scheduler_default_Set_affinity_body(
+ scheduler,
+ thread,
+ cpusetsize,
+ cpuset
+ );
}
diff --git a/cpukit/score/src/schedulergetaffinity.c b/cpukit/score/src/schedulergetaffinity.c
new file mode 100644
index 0000000000..d9e62b5650
--- /dev/null
+++ b/cpukit/score/src/schedulergetaffinity.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/score/schedulerimpl.h>
+
+#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
+
+bool _Scheduler_Get_affinity(
+ const Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ size_t cpusetsize,
+ cpu_set_t *cpuset
+)
+{
+ bool ok;
+
+ if ( _CPU_set_Is_large_enough( cpusetsize ) ) {
+#if defined(RTEMS_SMP)
+ ok = ( *scheduler->Operations.get_affinity )(
+ scheduler,
+ the_thread,
+ cpusetsize,
+ cpuset
+ );
+#else
+ ok = _Scheduler_default_Get_affinity_body(
+ scheduler,
+ the_thread,
+ cpusetsize,
+ cpuset
+ );
+#endif
+ } else {
+ ok = false;
+ }
+
+ return ok;
+}
+
+#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
diff --git a/cpukit/score/src/schedulersetaffinity.c b/cpukit/score/src/schedulersetaffinity.c
new file mode 100644
index 0000000000..2416a195c5
--- /dev/null
+++ b/cpukit/score/src/schedulersetaffinity.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/score/schedulerimpl.h>
+
+#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
+
+bool _Scheduler_Set_affinity(
+ const Scheduler_Control *scheduler,
+ Thread_Control *the_thread,
+ size_t cpusetsize,
+ const cpu_set_t *cpuset
+)
+{
+ bool ok;
+
+ if ( _CPU_set_Is_large_enough( cpusetsize ) ) {
+#if defined(RTEMS_SMP)
+ ok = ( *scheduler->Operations.set_affinity )(
+ scheduler,
+ the_thread,
+ cpusetsize,
+ cpuset
+ );
+#else
+ ok = _Scheduler_default_Set_affinity_body(
+ scheduler,
+ the_thread,
+ cpusetsize,
+ cpuset
+ );
+#endif
+ } else {
+ ok = false;
+ }
+
+ return ok;
+}
+
+#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 1d530e2654..0477e26aa9 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -37,7 +37,8 @@ if HAS_SMP
else
SUBDIRS += sp29
endif
- SUBDIRS += spprofiling01
+SUBDIRS += spscheduler01
+SUBDIRS += spprofiling01
SUBDIRS += spfatal28
SUBDIRS += spthreadlife01
SUBDIRS += spprofiling01
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 30d2787bc7..6be14e4626 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -40,6 +40,7 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes")
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile
+spscheduler01/Makefile
spfatal28/Makefile
spthreadlife01/Makefile
spprofiling01/Makefile
diff --git a/testsuites/sptests/spscheduler01/Makefile.am b/testsuites/sptests/spscheduler01/Makefile.am
new file mode 100644
index 0000000000..f108426b0c
--- /dev/null
+++ b/testsuites/sptests/spscheduler01/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = spscheduler01
+spscheduler01_SOURCES = init.c
+
+dist_rtems_tests_DATA = spscheduler01.scn spscheduler01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spscheduler01_OBJECTS)
+LINK_LIBS = $(spscheduler01_LDLIBS)
+
+spscheduler01$(EXEEXT): $(spscheduler01_OBJECTS) $(spscheduler01_DEPENDENCIES)
+ @rm -f spscheduler01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spscheduler01/init.c b/testsuites/sptests/spscheduler01/init.c
new file mode 100644
index 0000000000..f8c4bb2717
--- /dev/null
+++ b/testsuites/sptests/spscheduler01/init.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/libcsupport.h>
+
+#include <limits.h>
+
+#include "tmacros.h"
+
+const char rtems_test_name[] = "SPSCHEDULER 1";
+
+static rtems_id invalid_id = 1;
+
+static void test_task_get_set_affinity(void)
+{
+#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
+ rtems_id self_id = rtems_task_self();
+ rtems_status_code sc;
+ cpu_set_t cpusetone;
+ cpu_set_t cpuset;
+ size_t big = 2 * CHAR_BIT * sizeof(cpu_set_t);
+ size_t cpusetbigsize = CPU_ALLOC_SIZE(big);
+ cpu_set_t *cpusetbigone;
+ cpu_set_t *cpusetbig;
+
+ CPU_ZERO(&cpusetone);
+ CPU_SET(0, &cpusetone);
+
+ sc = rtems_task_get_affinity(RTEMS_SELF, sizeof(cpuset), NULL);
+ rtems_test_assert(sc == RTEMS_INVALID_ADDRESS);
+
+ sc = rtems_task_set_affinity(RTEMS_SELF, sizeof(cpuset), NULL);
+ rtems_test_assert(sc == RTEMS_INVALID_ADDRESS);
+
+ sc = rtems_task_get_affinity(RTEMS_SELF, 0, &cpuset);
+ rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
+
+ sc = rtems_task_set_affinity(RTEMS_SELF, 0, &cpuset);
+ rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
+
+ sc = rtems_task_get_affinity(invalid_id, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_INVALID_ID);
+
+ sc = rtems_task_set_affinity(invalid_id, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_INVALID_ID);
+
+ sc = rtems_task_get_affinity(RTEMS_SELF, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ rtems_test_assert(CPU_EQUAL(&cpuset, &cpusetone));
+
+ sc = rtems_task_set_affinity(RTEMS_SELF, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_get_affinity(self_id, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ rtems_test_assert(CPU_EQUAL(&cpuset, &cpusetone));
+
+ sc = rtems_task_set_affinity(self_id, sizeof(cpuset), &cpuset);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ cpusetbigone = CPU_ALLOC(big);
+ rtems_test_assert(cpusetbigone != NULL);
+
+ cpusetbig = CPU_ALLOC(big);
+ rtems_test_assert(cpusetbig != NULL);
+
+ CPU_ZERO_S(cpusetbigsize, cpusetbigone);
+ CPU_SET_S(0, cpusetbigsize, cpusetbigone);
+
+ sc = rtems_task_get_affinity(RTEMS_SELF, cpusetbigsize, cpusetbig);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ rtems_test_assert(CPU_EQUAL_S(cpusetbigsize, cpusetbig, cpusetbigone));
+
+ sc = rtems_task_set_affinity(RTEMS_SELF, cpusetbigsize, cpusetbig);
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+ CPU_FREE(cpusetbig);
+ CPU_FREE(cpusetbigone);
+#endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
+}
+
+static void Init(rtems_task_argument arg)
+{
+ rtems_resource_snapshot snapshot;
+
+ TEST_BEGIN();
+
+ rtems_resource_snapshot_take(&snapshot);
+
+ test_task_get_set_affinity();
+
+ rtems_test_assert(rtems_resource_snapshot_check(&snapshot));
+
+ TEST_END();
+ rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/sptests/spscheduler01/spscheduler01.doc b/testsuites/sptests/spscheduler01/spscheduler01.doc
new file mode 100644
index 0000000000..00ac13e8c1
--- /dev/null
+++ b/testsuites/sptests/spscheduler01/spscheduler01.doc
@@ -0,0 +1,13 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: spscheduler01
+
+directives:
+
+ - rtems_task_get_affinity()
+ - rtems_task_set_affinity()
+
+concepts:
+
+ - Ensure that the task set/get affinity functions work on non-SMP
+ configurations.
diff --git a/testsuites/sptests/spscheduler01/spscheduler01.scn b/testsuites/sptests/spscheduler01/spscheduler01.scn
new file mode 100644
index 0000000000..8c73372c49
--- /dev/null
+++ b/testsuites/sptests/spscheduler01/spscheduler01.scn
@@ -0,0 +1,2 @@
+*** BEGIN OF TEST SPSCHEDULER 1 ***
+*** END OF TEST SPSCHEDULER 1 ***