Changeset f5d4570f in rtems


Ignore:
Timestamp:
07/11/15 19:14:46 (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
083e6d6
Parents:
9341773
git-author:
Sebastian Huber <sebastian.huber@…> (07/11/15 19:14:46)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/13/15 06:56:57)
Message:

score: Simplify _Thread_Lock_set()

Exploit the fact that the current thread lock must be the default thread
lock and interrupts are disabled if we call _Thread_Lock_set().

File:
1 edited

Legend:

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

    r9341773 rf5d4570f  
    10101010
    10111011/**
    1012  * @brief Release the default thread lock.
     1012 * @brief Releases the thread lock inside a critical section (interrupts
     1013 * disabled).
     1014 *
     1015 * The previous interrupt status is not restored.
     1016 *
     1017 * @param[in] lock The lock.
     1018 * @param[in] lock_context The lock context used for the corresponding lock
     1019 * acquire.
     1020 */
     1021RTEMS_INLINE_ROUTINE void _Thread_Lock_release_critical(
     1022  ISR_lock_Control *lock,
     1023  ISR_lock_Context *lock_context
     1024)
     1025{
     1026  _ISR_lock_Release( lock, lock_context );
     1027}
     1028
     1029/**
     1030 * @brief Releases the thread lock.
     1031 *
     1032 * @param[in] lock The lock returned by _Thread_Lock_acquire().
     1033 * @param[in] lock_context The lock context used for _Thread_Lock_acquire().
     1034 */
     1035RTEMS_INLINE_ROUTINE void _Thread_Lock_release(
     1036  ISR_lock_Control *lock,
     1037  ISR_lock_Context *lock_context
     1038)
     1039{
     1040  _Thread_Lock_release_critical( lock, lock_context );
     1041  _ISR_lock_ISR_enable( lock_context );
     1042}
     1043
     1044/**
     1045 * @brief Releases the default thread lock inside a critical section
     1046 * (interrupts disabled).
     1047 *
     1048 * The previous interrupt status is not restored.
     1049 *
     1050 * @param[in] the_thread The thread.
     1051 * @param[in] lock_context The lock context used for the corresponding lock
     1052 * acquire.
     1053 */
     1054RTEMS_INLINE_ROUTINE void _Thread_Lock_release_default_critical(
     1055  Thread_Control   *the_thread,
     1056  ISR_lock_Context *lock_context
     1057)
     1058{
     1059  _Thread_Lock_release_critical(
     1060#if defined(RTEMS_SMP)
     1061    &the_thread->Lock.Default,
     1062#else
     1063    NULL,
     1064#endif
     1065    lock_context
     1066  );
     1067}
     1068
     1069/**
     1070 * @brief Releases the default thread lock.
    10131071 *
    10141072 * @param[in] the_thread The thread.
     
    10211079)
    10221080{
    1023   _ISR_lock_Release_and_ISR_enable( &the_thread->Lock.Default, lock_context );
    1024 }
    1025 
    1026 /**
    1027  * @brief Release the thread lock.
    1028  *
    1029  * @param[in] lock The lock returned by _Thread_Lock_acquire().
    1030  * @param[in] lock_context The lock context used for _Thread_Lock_acquire().
    1031  */
    1032 RTEMS_INLINE_ROUTINE void _Thread_Lock_release(
    1033   ISR_lock_Control *lock,
    1034   ISR_lock_Context *lock_context
    1035 )
    1036 {
    1037   _ISR_lock_Release_and_ISR_enable( lock, lock_context );
     1081  _Thread_Lock_release_default_critical( the_thread, lock_context );
     1082  _ISR_lock_ISR_enable( lock_context );
    10381083}
    10391084
     
    11361181)
    11371182{
    1138   ISR_lock_Control *lock;
    1139   ISR_lock_Context  lock_context;
    1140 
    1141   lock = _Thread_Lock_acquire( the_thread, &lock_context );
     1183  ISR_lock_Context lock_context;
     1184
     1185  _Thread_Lock_acquire_default_critical( the_thread, &lock_context );
     1186  _Assert( the_thread->Lock.current == &the_thread->Lock.Default );
    11421187  _Thread_Lock_set_unprotected( the_thread, new_lock );
    1143   _Thread_Lock_release( lock, &lock_context );
     1188  _Thread_Lock_release_default_critical( the_thread, &lock_context );
    11441189}
    11451190#else
Note: See TracChangeset for help on using the changeset viewer.