source: rtems/cpukit/score/src/schedulersetaffinity.c @ 0daa8ab

5
Last change on this file since 0daa8ab was 197a614, checked in by Sebastian Huber <sebastian.huber@…>, on 07/05/17 at 13:14:26

score: Add scheduler node to set affinity op

Update #3059.

  • Property mode set to 100644
File size: 1.5 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  scheduler = _Thread_Scheduler_get_home( the_thread );
40  _Scheduler_Acquire_critical( scheduler, &lock_context );
41
42  node = _Thread_Scheduler_get_home_node( the_thread );
43#if defined(RTEMS_SMP)
44  ok = ( *scheduler->Operations.set_affinity )(
45    scheduler,
46    the_thread,
47    node,
48    &affinity
49  );
50
51  if ( ok ) {
52    _Processor_mask_Assign( &the_thread->Scheduler.Affinity, &affinity );
53  }
54#else
55  ok = _Scheduler_default_Set_affinity_body(
56    scheduler,
57    the_thread,
58    node,
59    &affinity
60  );
61#endif
62
63  _Scheduler_Release_critical( scheduler, &lock_context );
64  return ok;
65}
Note: See TracBrowser for help on using the repository browser.