source: rtems/cpukit/posix/src/pthreadsetaffinitynp.c @ 0e16fa45

5
Last change on this file since 0e16fa45 was b2dbb634, checked in by Sebastian Huber <sebastian.huber@…>, on 10/10/17 at 09:36:23

score: Remove CPU_set_Control

Use Processor_mask instead.

Update #2514.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Pthread Set 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#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#if HAVE_DECL_PTHREAD_SETAFFINITY_NP
22
23#define  _GNU_SOURCE
24#include <pthread.h>
25#include <errno.h>
26
27#include <rtems/score/threadimpl.h>
28#include <rtems/score/schedulerimpl.h>
29
30int pthread_setaffinity_np(
31  pthread_t        thread,
32  size_t           cpusetsize,
33  const cpu_set_t *cpuset
34)
35{
36  Thread_Control   *the_thread;
37  ISR_lock_Context  lock_context;
38  Per_CPU_Control  *cpu_self;
39  bool              ok;
40
41  if ( cpuset == NULL ) {
42    return EFAULT;
43  }
44
45  the_thread = _Thread_Get( thread, &lock_context );
46
47  if ( the_thread == NULL ) {
48    return ESRCH;
49  }
50
51  cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
52  _Thread_State_acquire_critical( the_thread, &lock_context );
53
54  ok = _Scheduler_Set_affinity(
55    the_thread,
56    cpusetsize,
57    cpuset
58  );
59
60  _Thread_State_release( the_thread, &lock_context );
61  _Thread_Dispatch_enable( cpu_self );
62  return ok ? 0 : EINVAL;
63}
64#endif
Note: See TracBrowser for help on using the repository browser.