summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pthreadgetattrnp.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-06 10:07:38 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-09 14:52:58 +0200
commitaf9115f35cfb3d0adeb3e105fd608883596f2637 (patch)
treed6638dc66e87ad1736f7675f79e7e6d116e5c463 /cpukit/posix/src/pthreadgetattrnp.c
parentscore: Change Timestamp_Control to sbintime_t (diff)
downloadrtems-af9115f35cfb3d0adeb3e105fd608883596f2637.tar.bz2
posix: Simplify POSIX_API_Control
Return stack area via pthread_getattr_np(). Simplify * pthread_attr_setaffinity_np(), and * pthread_attr_getaffinity_np() and let the scheduler do the more sophisticated error checks. Make * pthread_setaffinity_np(), * pthread_getaffinity_np(), * pthread_attr_setaffinity_np(), and * pthread_attr_getaffinity_np() available in all configurations. Update #2514. Close #3145. Close #3168.
Diffstat (limited to 'cpukit/posix/src/pthreadgetattrnp.c')
-rw-r--r--cpukit/posix/src/pthreadgetattrnp.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/cpukit/posix/src/pthreadgetattrnp.c b/cpukit/posix/src/pthreadgetattrnp.c
index 63de97be4b..d815fc8c53 100644
--- a/cpukit/posix/src/pthreadgetattrnp.c
+++ b/cpukit/posix/src/pthreadgetattrnp.c
@@ -21,8 +21,10 @@
#define _GNU_SOURCE
#include <pthread.h>
#include <errno.h>
+#include <string.h>
#include <rtems/posix/pthreadimpl.h>
+#include <rtems/score/schedulerimpl.h>
#include <rtems/score/threadimpl.h>
int pthread_getattr_np(
@@ -33,11 +35,14 @@ int pthread_getattr_np(
Thread_Control *the_thread;
ISR_lock_Context lock_context;
POSIX_API_Control *api;
+ bool ok;
if ( attr == NULL ) {
return EINVAL;
}
+ attr = memset( attr, 0, sizeof( *attr ) );
+
the_thread = _Thread_Get( thread, &lock_context );
if ( the_thread == NULL ) {
@@ -47,7 +52,21 @@ int pthread_getattr_np(
_Thread_State_acquire_critical( the_thread, &lock_context );
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
- _POSIX_Threads_Copy_attributes( attr, &api->Attributes);
+
+ attr->is_initialized = true;
+ attr->stackaddr = the_thread->Start.Initial_stack.area;
+ attr->stacksize = the_thread->Start.Initial_stack.size;
+ attr->contentionscope = PTHREAD_SCOPE_PROCESS;
+
+ if ( api->created_with_explicit_scheduler ) {
+ attr->inheritsched = PTHREAD_EXPLICIT_SCHED;
+ } else {
+ attr->inheritsched = PTHREAD_INHERIT_SCHED;
+ }
+
+ attr->schedpolicy = api->schedpolicy;
+ attr->schedparam = api->schedparam;
+ attr->cputime_clock_allowed = 1;
if ( _Thread_Is_joinable( the_thread ) ) {
attr->detachstate = PTHREAD_CREATE_JOINABLE;
@@ -55,6 +74,14 @@ int pthread_getattr_np(
attr->detachstate = PTHREAD_CREATE_DETACHED;
}
+ attr->affinityset = &attr->affinitysetpreallocated;
+ attr->affinitysetsize = sizeof( attr->affinitysetpreallocated );
+ ok = _Scheduler_Get_affinity(
+ the_thread,
+ attr->affinitysetsize,
+ attr->affinityset
+ );
+
_Thread_State_release( the_thread, &lock_context );
- return 0;
+ return ok ? 0 : EINVAL;
}