source: rtems/cpukit/score/src/schedulerpriorityaffinitysmp.c @ 5b1ff71a

4.115
Last change on this file since 5b1ff71a was 69aa3349, checked in by Sebastian Huber <sebastian.huber@…>, on 04/08/14 at 07:42:29

score: Simplify thread control initialization

The thread control block contains fields that point to application
configuration dependent memory areas, like the scheduler information,
the API control blocks, the user extension context table, the RTEMS
notepads and the Newlib re-entrancy support. Account for these areas in
the configuration and avoid extra workspace allocations for these areas.

This helps also to avoid heap fragementation and reduces the per thread
memory due to a reduced heap allocation overhead.

  • 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
28RTEMS_INLINE_ROUTINE Scheduler_priority_affinity_SMP_Per_thread *
29_Scheduler_priority_affinity_Get_scheduler_info( Thread_Control *thread )
30{
31  return ( Scheduler_priority_affinity_SMP_Per_thread * ) thread->scheduler_info;
32}
33
34bool _Scheduler_priority_affinity_SMP_Allocate(
35  const Scheduler_Control *scheduler,
36  Thread_Control          *the_thread
37)
38{
39  Scheduler_priority_affinity_SMP_Per_thread *info =
40    the_thread->scheduler_info;
41
42  info->Affinity = *_CPU_set_Default();
43  info->Affinity.set = &info->Affinity.preallocated;
44
45  return true;
46}
47
48bool _Scheduler_priority_affinity_SMP_Get_affinity(
49  const Scheduler_Control *scheduler,
50  Thread_Control          *thread,
51  size_t                   cpusetsize,
52  cpu_set_t               *cpuset
53)
54{
55  Scheduler_priority_affinity_SMP_Per_thread *info =
56    _Scheduler_priority_affinity_Get_scheduler_info(thread);
57
58  (void) scheduler;
59
60  if ( info->Affinity.setsize != cpusetsize ) {
61    return false;
62  }
63
64  CPU_COPY( cpuset, info->Affinity.set );
65  return true;
66}
67
68bool _Scheduler_priority_affinity_SMP_Set_affinity(
69  const Scheduler_Control *scheduler,
70  Thread_Control          *thread,
71  size_t                   cpusetsize,
72  cpu_set_t               *cpuset
73)
74{
75  Scheduler_priority_affinity_SMP_Per_thread *info =
76    _Scheduler_priority_affinity_Get_scheduler_info(thread);
77
78  (void) scheduler;
79 
80  if ( ! _CPU_set_Is_valid( cpuset, cpusetsize ) ) {
81    return false;
82  }
83
84  CPU_COPY( info->Affinity.set, cpuset );
85 
86  return true;
87}
Note: See TracBrowser for help on using the repository browser.