source: rtems/cpukit/posix/src/pthreadgetaffinitynp.c @ dbb30e26

5
Last change on this file since dbb30e26 was af9115f3, checked in by Sebastian Huber <sebastian.huber@…>, on 10/06/17 at 08:07:38

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.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Pthread Get Affinity
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#if HAVE_DECL_PTHREAD_GETAFFINITY_NP
23
24#define  _GNU_SOURCE
25#include <pthread.h>
26#include <errno.h>
27
28#include <rtems/score/threadimpl.h>
29#include <rtems/score/schedulerimpl.h>
30
31int pthread_getaffinity_np(
32  pthread_t  thread,
33  size_t     cpusetsize,
34  cpu_set_t *cpuset
35)
36{
37  Thread_Control   *the_thread;
38  ISR_lock_Context  lock_context;
39  Per_CPU_Control  *cpu_self;
40  bool              ok;
41
42  if ( cpuset == NULL ) {
43    return EFAULT;
44  }
45
46  the_thread = _Thread_Get( thread, &lock_context );
47
48  if ( the_thread == NULL ) {
49    return ESRCH;
50  }
51
52  cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
53  _Thread_State_acquire_critical( the_thread, &lock_context );
54
55  ok = _Scheduler_Get_affinity(
56    the_thread,
57    cpusetsize,
58    cpuset
59  );
60
61  _Thread_State_release( the_thread, &lock_context );
62  _Thread_Dispatch_enable( cpu_self );
63  return ok ? 0 : EINVAL;
64}
65
66#endif
Note: See TracBrowser for help on using the repository browser.