source: rtems/cpukit/score/src/schedulerpriorityaffinitysmp.c @ 8e467384

4.115
Last change on this file since 8e467384 was 8e467384, checked in by Sebastian Huber <sebastian.huber@…>, on Jun 3, 2014 at 8:29:30 AM

score: Replace _Scheduler_Allocate/Free()

Replace _Scheduler_Allocate() with _Scheduler_Node_initialize(). Remove
the return status and thus the node initialization must be always
successful.

Rename _Scheduler_Free() to _Scheduler_Node_destroy().

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief Deterministic Priority Affinity SMP Scheduler Implementation
5 *
6 * @ingroup ScoreSchedulerPriorityAffinitySMP
7 */
8
9/*
10 *  COPYRIGHT (c) 2014.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19  #include "config.h"
20#endif
21
22#include <rtems/score/schedulerpriorityaffinitysmp.h>
23#include <rtems/score/schedulerpriorityimpl.h>
24#include <rtems/score/schedulersmpimpl.h>
25#include <rtems/score/wkspace.h>
26#include <rtems/score/cpusetimpl.h>
27
28static Scheduler_priority_affinity_SMP_Node *
29_Scheduler_priority_affinity_Node_get( Thread_Control *thread )
30{
31  return ( Scheduler_priority_affinity_SMP_Node * )
32    _Scheduler_Node_get( thread );
33}
34
35void _Scheduler_priority_affinity_SMP_Node_initialize(
36  const Scheduler_Control *scheduler,
37  Thread_Control          *the_thread
38)
39{
40  Scheduler_priority_affinity_SMP_Node *node =
41    _Scheduler_priority_affinity_Node_get( the_thread );
42
43  _Scheduler_SMP_Node_initialize( &node->Base.Base );
44
45  node->Affinity = *_CPU_set_Default();
46  node->Affinity.set = &node->Affinity.preallocated;
47}
48
49bool _Scheduler_priority_affinity_SMP_Get_affinity(
50  const Scheduler_Control *scheduler,
51  Thread_Control          *thread,
52  size_t                   cpusetsize,
53  cpu_set_t               *cpuset
54)
55{
56  Scheduler_priority_affinity_SMP_Node *node =
57    _Scheduler_priority_affinity_Node_get(thread);
58
59  (void) scheduler;
60
61  if ( node->Affinity.setsize != cpusetsize ) {
62    return false;
63  }
64
65  CPU_COPY( cpuset, node->Affinity.set );
66  return true; 
67}
68
69bool _Scheduler_priority_affinity_SMP_Set_affinity(
70  const Scheduler_Control *scheduler,
71  Thread_Control          *thread,
72  size_t                   cpusetsize,
73  cpu_set_t               *cpuset
74)
75{
76  Scheduler_priority_affinity_SMP_Node *node =
77    _Scheduler_priority_affinity_Node_get(thread);
78
79  (void) scheduler;
80 
81  if ( ! _CPU_set_Is_valid( cpuset, cpusetsize ) ) {
82    return false;
83  }
84
85  CPU_COPY( node->Affinity.set, cpuset );
86 
87  return true;
88}
Note: See TracBrowser for help on using the repository browser.