source: rtems/cpukit/score/src/schedulerpriorityaffinitysmp.c @ beab7329

4.115
Last change on this file since beab7329 was beab7329, checked in by Sebastian Huber <sebastian.huber@…>, on 05/13/14 at 14:03:05

score: Introduce scheduler nodes

Rename scheduler per-thread information into scheduler nodes using
Scheduler_Node as the base type. Use inheritance for specialized
schedulers.

Move the scheduler specific states from the thread control block into
the scheduler node structure.

Validate the SMP scheduler node state transitions in case RTEMS_DEBUG is
defined.

  • 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
35bool _Scheduler_priority_affinity_SMP_Allocate(
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  return true;
49}
50
51bool _Scheduler_priority_affinity_SMP_Get_affinity(
52  const Scheduler_Control *scheduler,
53  Thread_Control          *thread,
54  size_t                   cpusetsize,
55  cpu_set_t               *cpuset
56)
57{
58  Scheduler_priority_affinity_SMP_Node *node =
59    _Scheduler_priority_affinity_Node_get(thread);
60
61  (void) scheduler;
62
63  if ( node->Affinity.setsize != cpusetsize ) {
64    return false;
65  }
66
67  CPU_COPY( cpuset, node->Affinity.set );
68  return true;
69}
70
71bool _Scheduler_priority_affinity_SMP_Set_affinity(
72  const Scheduler_Control *scheduler,
73  Thread_Control          *thread,
74  size_t                   cpusetsize,
75  cpu_set_t               *cpuset
76)
77{
78  Scheduler_priority_affinity_SMP_Node *node =
79    _Scheduler_priority_affinity_Node_get(thread);
80
81  (void) scheduler;
82 
83  if ( ! _CPU_set_Is_valid( cpuset, cpusetsize ) ) {
84    return false;
85  }
86
87  CPU_COPY( node->Affinity.set, cpuset );
88 
89  return true;
90}
Note: See TracBrowser for help on using the repository browser.