source: rtems/cpukit/score/src/schedulersetaffinity.c @ 9db3cc21

5
Last change on this file since 9db3cc21 was 9db3cc21, checked in by Sebastian Huber <sebastian.huber@…>, on 10/29/17 at 06:38:37

score: Fix non-SMP build

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 * Copyright (c) 2014, 2017 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include <rtems/score/schedulerimpl.h>
20
21bool _Scheduler_Set_affinity(
22  Thread_Control       *the_thread,
23  size_t                cpusetsize,
24  const cpu_set_t      *cpuset
25)
26{
27  Processor_mask             affinity;
28  Processor_mask_Copy_status status;
29  const Scheduler_Control   *scheduler;
30  Scheduler_Node            *node;
31  ISR_lock_Context           lock_context;
32  bool                       ok;
33
34  status = _Processor_mask_From_cpu_set_t( &affinity, cpusetsize, cpuset );
35  if ( !_Processor_mask_Is_at_most_partial_loss( status ) ) {
36    return false;
37  }
38
39  /*
40   * Reduce affinity set to the online processors to be in line with
41   * _Thread_Initialize() which sets the default affinity to the set of online
42   * processors.
43   */
44  _Processor_mask_And( &affinity, _SMP_Get_online_processors(), &affinity );
45
46  scheduler = _Thread_Scheduler_get_home( the_thread );
47  _Scheduler_Acquire_critical( scheduler, &lock_context );
48
49  node = _Thread_Scheduler_get_home_node( the_thread );
50#if defined(RTEMS_SMP)
51  ok = ( *scheduler->Operations.set_affinity )(
52    scheduler,
53    the_thread,
54    node,
55    &affinity
56  );
57
58  if ( ok ) {
59    _Processor_mask_Assign( &the_thread->Scheduler.Affinity, &affinity );
60  }
61#else
62  ok = _Scheduler_default_Set_affinity_body(
63    scheduler,
64    the_thread,
65    node,
66    &affinity
67  );
68#endif
69
70  _Scheduler_Release_critical( scheduler, &lock_context );
71  return ok;
72}
Note: See TracBrowser for help on using the repository browser.