source: rtems/cpukit/score/src/thread.c @ 9bfad8c

5
Last change on this file since 9bfad8c was 9bfad8c, checked in by Sebastian Huber <sebastian.huber@…>, on 06/08/16 at 20:22:46

score: Add thread priority to scheduler nodes

The thread priority is manifest in two independent areas. One area is
the user visible thread priority along with a potential thread queue.
The other is the scheduler. Currently, a thread priority update via
_Thread_Change_priority() first updates the user visble thread priority
and the thread queue, then the scheduler is notified if necessary. The
priority is passed to the scheduler via a local variable. A generation
counter ensures that the scheduler discards out-of-date priorities.

This use of a local variable ties the update in these two areas close
together. For later enhancements and the OMIP locking protocol
implementation we need more flexibility. Add a thread priority
information block to Scheduler_Node and synchronize priority value
updates via a sequence lock on SMP configurations.

Update #2556.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Initialize Thread Handler
5 *  @ingroup ScoreThread
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2011.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/threadimpl.h>
22#include <rtems/score/interr.h>
23#include <rtems/score/scheduler.h>
24#include <rtems/score/wkspace.h>
25
26#define THREAD_OFFSET_ASSERT( field ) \
27  RTEMS_STATIC_ASSERT( \
28    offsetof( Thread_Control, field ) == offsetof( Thread_Proxy_control, field ), \
29    field \
30  )
31
32THREAD_OFFSET_ASSERT( Object );
33THREAD_OFFSET_ASSERT( Join_queue );
34THREAD_OFFSET_ASSERT( current_state );
35THREAD_OFFSET_ASSERT( current_priority );
36THREAD_OFFSET_ASSERT( real_priority );
37THREAD_OFFSET_ASSERT( priority_restore_hint );
38THREAD_OFFSET_ASSERT( resource_count );
39THREAD_OFFSET_ASSERT( Wait );
40THREAD_OFFSET_ASSERT( Timer );
41#if defined(RTEMS_MULTIPROCESSING)
42THREAD_OFFSET_ASSERT( receive_packet );
43#endif
44
45Thread_Information _Thread_Internal_information;
46
47void _Thread_Initialize_information(
48  Thread_Information  *information,
49  Objects_APIs         the_api,
50  uint16_t             the_class,
51  uint32_t             maximum,
52  bool                 is_string,
53  uint32_t             maximum_name_length
54)
55{
56  _Objects_Initialize_information(
57    &information->Objects,
58    the_api,
59    the_class,
60    maximum,
61    _Thread_Control_size,
62    is_string,
63    maximum_name_length,
64    NULL
65  );
66
67  _Freechain_Initialize(
68    &information->Free_thread_queue_heads,
69    _Workspace_Allocate_or_fatal_error,
70    _Objects_Maximum_per_allocation( maximum ),
71    THREAD_QUEUE_HEADS_SIZE( _Scheduler_Count )
72  );
73}
74
75void _Thread_Handler_initialization(void)
76{
77  rtems_stack_allocate_init_hook stack_allocate_init_hook =
78    rtems_configuration_get_stack_allocate_init_hook();
79  #if defined(RTEMS_MULTIPROCESSING)
80    uint32_t maximum_proxies =
81      _Configuration_MP_table->maximum_proxies;
82  #endif
83
84  if ( rtems_configuration_get_stack_allocate_hook() == NULL ||
85       rtems_configuration_get_stack_free_hook() == NULL)
86    _Terminate(
87      INTERNAL_ERROR_CORE,
88      true,
89      INTERNAL_ERROR_BAD_STACK_HOOK
90    );
91
92  if ( stack_allocate_init_hook != NULL )
93    (*stack_allocate_init_hook)( rtems_configuration_get_stack_space_size() );
94
95  #if defined(RTEMS_MULTIPROCESSING)
96    _Thread_MP_Handler_initialization( maximum_proxies );
97  #endif
98
99  /*
100   *  Initialize the internal class of threads.  We need an IDLE thread
101   *  per CPU in an SMP system.  In addition, if this is a loosely
102   *  coupled multiprocessing system, account for the MPCI Server Thread.
103   */
104  _Thread_Initialize_information(
105    &_Thread_Internal_information,
106    OBJECTS_INTERNAL_API,
107    OBJECTS_INTERNAL_THREADS,
108    _Thread_Get_maximum_internal_threads(),
109    false,                      /* true if names for this object are strings */
110    8                           /* maximum length of each object's name */
111  );
112
113}
Note: See TracBrowser for help on using the repository browser.