static void test_isr_locks( void ) { ISR_Level normal_interrupt_level = _ISR_Get_level(); ISR_lock_Control initialized = ISR_LOCK_INITIALIZER; ISR_lock_Control lock; ISR_lock_Context lock_context; _ISR_lock_Initialize( &lock ); rtems_test_assert( memcmp( &lock, &initialized, sizeof( lock ) ) == 0 ); _ISR_lock_ISR_disable_and_acquire( &lock, &lock_context ); rtems_test_assert( normal_interrupt_level != _ISR_Get_level() ); _ISR_lock_Release_and_ISR_enable( &lock, &lock_context ); rtems_test_assert( normal_interrupt_level == _ISR_Get_level() ); _ISR_lock_Acquire( &lock, &lock_context ); rtems_test_assert( normal_interrupt_level == _ISR_Get_level() ); _ISR_lock_Release( &lock, &lock_context ); rtems_test_assert( normal_interrupt_level == _ISR_Get_level() ); _ISR_lock_Destroy( &lock ); _ISR_lock_Destroy( &initialized ); }
static bool _Thread_queue_Link_add( Thread_queue_Link *link, Thread_queue_Queue *source, Thread_queue_Queue *target ) { Thread_queue_Links *links; Thread_queue_Queue *recursive_target; ISR_lock_Context lock_context; link->source = source; link->target = target; links = &_Thread_queue_Links; recursive_target = target; _ISR_lock_Acquire( &links->Lock, &lock_context ); while ( true ) { Thread_queue_Link *recursive_link; recursive_link = _Thread_queue_Link_find( links, recursive_target ); if ( recursive_link == NULL ) { break; } recursive_target = recursive_link->target; if ( recursive_target == source ) { _ISR_lock_Release( &links->Lock, &lock_context ); return false; } } _RBTree_Insert_inline( &links->Links, &link->Registry_node, source, _Thread_queue_Link_less ); _ISR_lock_Release( &links->Lock, &lock_context ); return true; }
static void _Thread_queue_Link_remove( Thread_queue_Link *link ) { Thread_queue_Links *links; ISR_lock_Context lock_context; links = &_Thread_queue_Links; _ISR_lock_Acquire( &links->Lock, &lock_context ); _RBTree_Extract( &links->Links, &link->Registry_node ); _ISR_lock_Release( &links->Lock, &lock_context ); }