source: rtems/cpukit/score/src/threadsetpriority.c @ 900d337f

4.115
Last change on this file since 900d337f was 900d337f, checked in by Sebastian Huber <sebastian.huber@…>, on 05/05/15 at 11:05:54

score: Rework _Thread_Change_priority()

Move the writes to Thread_Control::current_priority and
Thread_Control::real_priority into _Thread_Change_priority() under the
protection of the thread lock. Add a filter function to
_Thread_Change_priority() to enable specialized variants.

Avoid race conditions during a thread priority restore with the new
Thread_Control::priority_restore_hint for an important average case
optimizations used by priority inheritance mutexes.

Update #2273.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Set Thread Priority
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
23static bool _Thread_Set_priority_filter(
24  Thread_Control   *the_thread,
25  Priority_Control *new_priority_ptr,
26  void             *arg
27)
28{
29  Priority_Control  current_priority;
30  Priority_Control  new_priority;
31  Priority_Control *old_priority_ptr;
32
33  current_priority = the_thread->current_priority;
34  new_priority = *new_priority_ptr;
35
36  old_priority_ptr = arg;
37  *old_priority_ptr = current_priority;
38
39  the_thread->real_priority = new_priority;
40
41  return _Thread_Priority_less_than( current_priority, new_priority )
42    || !_Thread_Owns_resources( the_thread );
43}
44
45void _Thread_Set_priority(
46  Thread_Control   *the_thread,
47  Priority_Control  new_priority,
48  Priority_Control *old_priority,
49  bool              prepend_it
50)
51{
52  _Thread_Change_priority(
53    the_thread,
54    new_priority,
55    old_priority,
56    _Thread_Set_priority_filter,
57    prepend_it
58  );
59}
Note: See TracBrowser for help on using the repository browser.