Changeset 6a941e3 in rtems


Ignore:
Timestamp:
Mar 17, 2015, 3:24:44 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
7b35a36
Parents:
e0a25fb
git-author:
Sebastian Huber <sebastian.huber@…> (03/17/15 15:24:44)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/20/15 07:49:33)
Message:

score: Fix _Thread_Change_priority()

Atomically update the current priority of a thread and the wait queue.
Serialize the scheduler update in a separate critical section with a
generation number.

New test sptests/spintrcritical23.

Close #2310.

Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/thread.h

    re0a25fb r6a941e3  
    583583  /** This field is the base priority of this thread. */
    584584  Priority_Control         real_priority;
     585
     586  /**
     587   * @brief Generation of the current priority value.
     588   *
     589   * It is used in _Thread_Change_priority() to serialize the update of
     590   * priority related data structures.
     591   */
     592  uint32_t                 priority_generation;
     593
    585594  /** This field is the number of mutexes currently held by this thread. */
    586595  uint32_t                 resource_count;
  • cpukit/score/src/threadchangepriority.c

    re0a25fb r6a941e3  
    3030)
    3131{
     32  ISR_Level level;
     33
     34  _ISR_Disable( level );
     35
    3236  /*
    3337   *  Do not bother recomputing all the priority related information if
     
    3539   */
    3640  if ( the_thread->current_priority != new_priority ) {
    37     ISR_Level level;
    38 
    39     _ISR_Disable( level );
     41    uint32_t my_generation = the_thread->priority_generation + 1;
    4042
    4143    the_thread->current_priority = new_priority;
    42 
    43     if ( _States_Is_ready( the_thread->current_state ) ) {
    44       _Scheduler_Change_priority(
    45         the_thread,
    46         new_priority,
    47         prepend_it
    48       );
    49     } else {
    50       _Scheduler_Update_priority( the_thread, new_priority );
    51     }
    52 
    53     _ISR_Enable( level );
     44    the_thread->priority_generation = my_generation;
    5445
    5546    _Thread_queue_Requeue( the_thread->Wait.queue, the_thread );
     47
     48    _ISR_Flash( level );
     49
     50    if ( the_thread->priority_generation == my_generation ) {
     51      if ( _States_Is_ready( the_thread->current_state ) ) {
     52        _Scheduler_Change_priority(
     53          the_thread,
     54          new_priority,
     55          prepend_it
     56        );
     57      } else {
     58        _Scheduler_Update_priority( the_thread, new_priority );
     59      }
     60    }
    5661  }
     62
     63  _ISR_Enable( level );
    5764}
  • cpukit/score/src/threadinitialize.c

    re0a25fb r6a941e3  
    199199  the_thread->resource_count          = 0;
    200200  the_thread->real_priority           = priority;
     201  the_thread->priority_generation     = 0;
    201202  the_thread->Start.initial_priority  = priority;
    202203
  • testsuites/sptests/Makefile.am

    re0a25fb r6a941e3  
    3838_SUBDIRS += sp29
    3939endif
     40_SUBDIRS += spintrcritical23
    4041_SUBDIRS += spatomic01
    4142_SUBDIRS += spintrcritical22
  • testsuites/sptests/configure.ac

    re0a25fb r6a941e3  
    4141# Explicitly list all Makefiles here
    4242AC_CONFIG_FILES([Makefile
     43spintrcritical23/Makefile
    4344spatomic01/Makefile
    4445spglobalcon01/Makefile
Note: See TracChangeset for help on using the changeset viewer.