rtems_task High_task( rtems_task_argument argument ) { rtems_interrupt_level level; benchmark_timer_initialize(); rtems_interrupt_disable( level ); isr_disable_time = benchmark_timer_read(); benchmark_timer_initialize(); rtems_interrupt_flash( level ); isr_flash_time = benchmark_timer_read(); benchmark_timer_initialize(); rtems_interrupt_enable( level ); isr_enable_time = benchmark_timer_read(); benchmark_timer_initialize(); _Thread_Disable_dispatch(); thread_disable_dispatch_time = benchmark_timer_read(); benchmark_timer_initialize(); _Thread_Enable_dispatch(); thread_enable_dispatch_time = benchmark_timer_read(); benchmark_timer_initialize(); _Thread_Set_state( _Thread_Executing, STATES_SUSPENDED ); thread_set_state_time = benchmark_timer_read(); _Context_Switch_necessary = true; benchmark_timer_initialize(); _Thread_Dispatch(); /* dispatches Middle_task */ }
rtems_status_code rtems_task_restart( rtems_id id, uint32_t argument ) { register Thread_Control *the_thread; Objects_Locations location; the_thread = _Thread_Get( id, &location ); switch ( location ) { case OBJECTS_LOCAL: if ( _Thread_Restart( the_thread, NULL, argument ) ) { _Objects_Put( &the_thread->Object ); return RTEMS_SUCCESSFUL; } _Objects_Put( &the_thread->Object ); return RTEMS_INCORRECT_STATE; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: _Thread_Dispatch(); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif case OBJECTS_ERROR: break; } return RTEMS_INVALID_ID; }
static void _RTEMS_Tasks_Dispatch_if_necessary( Thread_Control *executing, bool needs_asr_dispatching ) { if ( _Thread_Dispatch_is_enabled() ) { bool dispatch_necessary = needs_asr_dispatching; /* * FIXME: This locking approach is brittle. It only works since the * current simple SMP scheduler has no support for the non-preempt mode. */ #if defined( RTEMS_SMP ) ISR_Level level; _ISR_Disable( level ); #endif if ( !_Thread_Is_heir( executing ) && executing->is_preemptible ) { dispatch_necessary = true; _Thread_Dispatch_necessary = dispatch_necessary; } #if defined( RTEMS_SMP ) _ISR_Enable( level ); #endif if ( dispatch_necessary ) { _Thread_Dispatch(); } } }
int sem_post( sem_t *sem ) { register POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; the_semaphore = _POSIX_Semaphore_Get( sem, &location ); switch ( location ) { case OBJECTS_ERROR: rtems_set_errno_and_return_minus_one( EINVAL ); case OBJECTS_REMOTE: _Thread_Dispatch(); return POSIX_MP_NOT_IMPLEMENTED(); rtems_set_errno_and_return_minus_one( EINVAL ); case OBJECTS_LOCAL: _CORE_semaphore_Surrender( &the_semaphore->Semaphore, the_semaphore->Object.id, #if defined(RTEMS_MULTIPROCESSING) NULL /* XXX need to define a routine to handle this case */ #else NULL #endif ); _Thread_Enable_dispatch(); return 0; } return POSIX_BOTTOM_REACHED(); }
rtems_status_code rtems_task_is_suspended( rtems_id id ) { register Thread_Control *the_thread; Objects_Locations location; the_thread = _Thread_Get( id, &location ); switch ( location ) { case OBJECTS_LOCAL: if ( !_States_Is_suspended( the_thread->current_state ) ) { _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; } _Thread_Enable_dispatch(); return RTEMS_ALREADY_SUSPENDED; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: _Thread_Dispatch(); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif case OBJECTS_ERROR: break; } return RTEMS_INVALID_ID; }
int timer_getoverrun( timer_t timerid ) { int overrun; POSIX_Timer_Control *ptimer; Objects_Locations location; ptimer = _POSIX_Timer_Get( timerid, &location ); switch ( location ) { case OBJECTS_REMOTE: #if defined(RTEMS_MULTIPROCESSING) _Thread_Dispatch(); rtems_set_errno_and_return_minus_one( EINVAL ); #endif case OBJECTS_ERROR: rtems_set_errno_and_return_minus_one( EINVAL ); case OBJECTS_LOCAL: overrun = ptimer->overrun; ptimer->overrun = 0; _Thread_Enable_dispatch(); return overrun; } return -1; /* unreached - only to remove warnings */ }
void __ISR_Handler(uint32_t vector, CPU_Interrupt_frame *ifr) { register uint32_t level; _exception_stack_frame = NULL; /* Interrupts are disabled upon entry to this Handler */ _Thread_Dispatch_disable_level++; #if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) if ( _ISR_Nest_level == 0 ) { /* Install irq stack */ _old_stack_ptr = stack_ptr; stack_ptr = _CPU_Interrupt_stack_high - 4; } #endif _ISR_Nest_level++; if ( _ISR_Vector_table[ vector] ) { (*_ISR_Vector_table[ vector ])(vector, ifr); }; /* Make sure that interrupts are disabled again */ _CPU_ISR_Disable( level ); _ISR_Nest_level--; #if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) if( _ISR_Nest_level == 0) stack_ptr = _old_stack_ptr; #endif _Thread_Dispatch_disable_level--; _CPU_ISR_Enable( level ); if ( _ISR_Nest_level ) return; if ( _Thread_Dispatch_disable_level ) { _ISR_Signals_to_thread_executing = FALSE; return; } if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { _ISR_Signals_to_thread_executing = FALSE; /* save off our stack frame so the context switcher can get to it */ _exception_stack_frame = ifr; _Thread_Dispatch(); /* and make sure its clear in case we didn't dispatch. if we did, its * already cleared */ _exception_stack_frame = NULL; } }
rtems_status_code rtems_task_delete( rtems_id id ) { register Thread_Control *the_thread; Objects_Locations location; Objects_Information *the_information; _RTEMS_Lock_allocator(); the_thread = _Thread_Get( id, &location ); switch ( location ) { case OBJECTS_LOCAL: the_information = _Objects_Get_information_id( the_thread->Object.id ); #if defined(RTEMS_DEBUG) if ( !the_information ) { _Thread_Enable_dispatch(); return RTEMS_INVALID_ID; /* This should never happen if _Thread_Get() works right */ } #endif #if defined(RTEMS_MULTIPROCESSING) if ( the_thread->is_global ) { _Objects_MP_Close( &_RTEMS_tasks_Information, the_thread->Object.id ); _RTEMS_tasks_MP_Send_process_packet( RTEMS_TASKS_MP_ANNOUNCE_DELETE, the_thread->Object.id, 0 /* Not used */ ); } #endif _Thread_Close( the_information, the_thread ); _RTEMS_tasks_Free( the_thread ); _RTEMS_Unlock_allocator(); _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: _RTEMS_Unlock_allocator(); _Thread_Dispatch(); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif case OBJECTS_ERROR: break; } _RTEMS_Unlock_allocator(); return RTEMS_INVALID_ID; }
rtems_status_code rtems_message_queue_delete( rtems_id id ) { register Message_queue_Control *the_message_queue; Objects_Locations location; the_message_queue = _Message_queue_Get( id, &location ); switch ( location ) { case OBJECTS_LOCAL: _Objects_Close( &_Message_queue_Information, &the_message_queue->Object ); _CORE_message_queue_Close( &the_message_queue->message_queue, #if defined(RTEMS_MULTIPROCESSING) _Message_queue_MP_Send_object_was_deleted, #else NULL, #endif CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED ); _Message_queue_Free( the_message_queue ); #if defined(RTEMS_MULTIPROCESSING) if ( _Attributes_Is_global( the_message_queue->attribute_set ) ) { _Objects_MP_Close( &_Message_queue_Information, the_message_queue->Object.id ); _Message_queue_MP_Send_process_packet( MESSAGE_QUEUE_MP_ANNOUNCE_DELETE, the_message_queue->Object.id, 0, /* Not used */ 0 ); } #endif _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: _Thread_Dispatch(); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif case OBJECTS_ERROR: break; } return RTEMS_INVALID_ID; }
void ppc_exc_wrapup(BSP_Exception_frame *frame) { /* dispatch_disable level is decremented from assembly code. */ if ( _Thread_Dispatch_necessary ) { /* FIXME: I believe it should be OK to re-enable * interrupts around the execution of _Thread_Dispatch(); */ _Thread_Dispatch(); } }
void __ISR_Handler( uint32_t vector) { ISR_Level level; _ISR_Disable( level ); _Thread_Dispatch_disable_level++; #if (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) if ( _ISR_Nest_level == 0 ) { /* Install irq stack */ _old_stack_ptr = stack_ptr; stack_ptr = _CPU_Interrupt_stack_high; } #endif _ISR_Nest_level++; _ISR_Enable( level ); /* call isp */ if ( _ISR_Vector_table[ vector]) (*_ISR_Vector_table[ vector ])( vector ); _ISR_Disable( level ); _Thread_Dispatch_disable_level--; _ISR_Nest_level--; #if(CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) if ( _ISR_Nest_level == 0 ) /* restore old stack pointer */ stack_ptr = _old_stack_ptr; #endif _ISR_Enable( level ); if ( _ISR_Nest_level ) return; if ( _Thread_Dispatch_disable_level ) { _ISR_Signals_to_thread_executing = FALSE; return; } if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { _ISR_Signals_to_thread_executing = FALSE; _Thread_Dispatch(); } }
rtems_task Task_2( rtems_task_argument argument ) { #if defined(RTEMS_SMP) rtems_interrupt_level level; #endif Chain_Control *ready_queues; #if (MUST_WAIT_FOR_INTERRUPT == 1) while ( Interrupt_occurred == 0 ); #endif end_time = benchmark_timer_read(); put_time( "rtems interrupt: entry overhead returns to preempting task", Interrupt_enter_time, 1, 0, timer_overhead ); put_time( "rtems interrupt: exit overhead returns to preempting task", end_time, 1, 0, 0 ); fflush( stdout ); /* * Switch back to the other task to exit the test. */ #if defined(RTEMS_SMP) rtems_interrupt_disable(level); #endif ready_queues = (Chain_Control *) _Scheduler.information; _Thread_Executing = (Thread_Control *) _Chain_First(&ready_queues[LOW_PRIORITY]); _Thread_Dispatch_necessary = 1; #if defined(RTEMS_SMP) rtems_interrupt_enable(level); #endif _Thread_Dispatch(); }
int timer_gettime( timer_t timerid, struct itimerspec *value ) { /* * IDEA: This function does not use functions of RTEMS to the handle * of timers. It uses some functions for managing the time. * * A possible form to do this is the following: * * - When a timer is initialized, the value of the time in * that moment is stored. * - When this function is called, it returns the difference * between the current time and the initialization time. */ POSIX_Timer_Control *ptimer; Objects_Locations location; struct timespec current_time; /* Reads the current time */ _TOD_Get( ¤t_time ); ptimer = _POSIX_Timer_Get( timerid, &location ); switch ( location ) { case OBJECTS_REMOTE: #if defined(RTEMS_MULTIPROCESSING) _Thread_Dispatch(); rtems_set_errno_and_return_minus_one( EINVAL ); #endif case OBJECTS_ERROR: rtems_set_errno_and_return_minus_one( EINVAL ); case OBJECTS_LOCAL: /* Calculates the time left before the timer finishes */ _Timespec_Subtract( &ptimer->timer_data.it_value, ¤t_time, &value->it_value ); value->it_interval = ptimer->timer_data.it_interval; _Thread_Enable_dispatch(); return 0; } return -1; /* unreached - only to remove warnings */ }
void __ISR_Handler( uint32_t vector) { ISR_Level level; _ISR_Disable( level ); _Thread_Dispatch_increment_disable_level(); #if (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) if ( _ISR_Nest_level == 0 ) { /* Install irq stack */ _old_stack_ptr = stack_ptr; stack_ptr = _CPU_Interrupt_stack_high; } #endif _ISR_Nest_level++; _ISR_Enable( level ); /* call isp */ if ( _ISR_Vector_table[ vector]) (*_ISR_Vector_table[ vector ])( vector ); _ISR_Disable( level ); _Thread_Dispatch_decrement_disable_level(); _ISR_Nest_level--; #if (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) if ( _ISR_Nest_level == 0 ) /* restore old stack pointer */ stack_ptr = _old_stack_ptr; #endif _ISR_Enable( level ); if ( _ISR_Nest_level ) return; if ( _Thread_Dispatch_in_critical_section() ) { return; } if ( _Thread_Dispatch_necessary ) { _Thread_Dispatch(); } }
rtems_status_code rtems_clock_tick( void ) { _TOD_Tickle_ticks(); _Watchdog_Tickle_ticks(); _Scheduler_Tick(); if ( _Thread_Is_context_switch_necessary() && _Thread_Dispatch_is_enabled() ) _Thread_Dispatch(); return RTEMS_SUCCESSFUL; }
rtems_status_code rtems_task_variable_get( rtems_id tid, void **ptr, void **result ) { Thread_Control *the_thread; Objects_Locations location; rtems_task_variable_t *tvp; if ( !ptr ) return RTEMS_INVALID_ADDRESS; if ( !result ) return RTEMS_INVALID_ADDRESS; the_thread = _Thread_Get (tid, &location); switch (location) { case OBJECTS_LOCAL: /* * Figure out if the variable is in this task's list. */ tvp = the_thread->task_variables; while (tvp) { if (tvp->ptr == ptr) { /* * Should this return the current (i.e not the * saved) value if `tid' is the current task? */ *result = tvp->tval; _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; } tvp = (rtems_task_variable_t *)tvp->next; } _Thread_Enable_dispatch(); return RTEMS_INVALID_ADDRESS; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: _Thread_Dispatch(); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif case OBJECTS_ERROR: break; } return RTEMS_INVALID_ID; }
rtems_status_code rtems_partition_delete( rtems_id id ) { register Partition_Control *the_partition; Objects_Locations location; the_partition = _Partition_Get( id, &location ); switch ( location ) { case OBJECTS_LOCAL: if ( the_partition->number_of_used_blocks == 0 ) { _Objects_Close( &_Partition_Information, &the_partition->Object ); _Partition_Free( the_partition ); #if defined(RTEMS_MULTIPROCESSING) if ( _Attributes_Is_global( the_partition->attribute_set ) ) { _Objects_MP_Close( &_Partition_Information, the_partition->Object.id ); _Partition_MP_Send_process_packet( PARTITION_MP_ANNOUNCE_DELETE, the_partition->Object.id, 0, /* Not used */ 0 /* Not used */ ); } #endif _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; } _Thread_Enable_dispatch(); return RTEMS_RESOURCE_IN_USE; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: _Thread_Dispatch(); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif case OBJECTS_ERROR: break; } return RTEMS_INVALID_ID; }
void _ISR_Thread_dispatch( void ) { if ( _Context_Switch_necessary ) { _Thread_Dispatch(); } else if ( _ISR_Signals_to_thread_executing ) { _ISR_Signals_to_thread_executing = false; if ( _Thread_Do_post_task_switch_extension || _Thread_Executing->do_post_task_switch_extension ) { _Thread_Executing->do_post_task_switch_extension = false; _API_extensions_Run_postswitch(); } } }
rtems_status_code rtems_task_delete( rtems_id id ) { Thread_Control *the_thread; Objects_Locations location; bool previous_life_protection; previous_life_protection = _Thread_Set_life_protection( true ); the_thread = _Thread_Get( id, &location ); switch ( location ) { case OBJECTS_LOCAL: #if defined(RTEMS_MULTIPROCESSING) if ( the_thread->is_global ) { _Objects_MP_Close( &_RTEMS_tasks_Information.Objects, the_thread->Object.id ); _RTEMS_tasks_MP_Send_process_packet( RTEMS_TASKS_MP_ANNOUNCE_DELETE, the_thread->Object.id, 0 /* Not used */ ); } #endif _Thread_Close( the_thread, _Thread_Executing ); _Objects_Put( &the_thread->Object ); _Thread_Set_life_protection( previous_life_protection ); return RTEMS_SUCCESSFUL; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: _Thread_Dispatch(); _Thread_Set_life_protection( previous_life_protection ); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif case OBJECTS_ERROR: break; } _Thread_Set_life_protection( previous_life_protection ); return RTEMS_INVALID_ID; }
rtems_task Task_2( rtems_task_argument argument ) { Thread_Control *executing = _Thread_Get_executing(); Scheduler_priority_Context *scheduler_context = _Scheduler_priority_Get_context( _Scheduler_Get( executing ) ); ISR_lock_Context lock_context; #if (MUST_WAIT_FOR_INTERRUPT == 1) while ( Interrupt_occurred == 0 ); #endif end_time = benchmark_timer_read(); put_time( "rtems interrupt: entry overhead returns to preempting task", Interrupt_enter_time, 1, 0, timer_overhead ); put_time( "rtems interrupt: exit overhead returns to preempting task", end_time, 1, 0, 0 ); fflush( stdout ); /* * Switch back to the other task to exit the test. */ _Scheduler_Acquire( executing, &lock_context ); _Thread_Executing = (Thread_Control *) _Chain_First(&scheduler_context->Ready[LOW_PRIORITY]); _Thread_Dispatch_necessary = 1; _Scheduler_Release( executing, &lock_context ); _Thread_Dispatch(); }
rtems_status_code rtems_task_start( rtems_id id, rtems_task_entry entry_point, rtems_task_argument argument ) { Thread_Control *the_thread; Objects_Locations location; bool successfully_started; if ( entry_point == NULL ) return RTEMS_INVALID_ADDRESS; the_thread = _Thread_Get( id, &location ); switch ( location ) { case OBJECTS_LOCAL: successfully_started = _Thread_Start( the_thread, THREAD_START_NUMERIC, entry_point, NULL, argument, NULL ); _Objects_Put( &the_thread->Object ); if ( successfully_started ) { return RTEMS_SUCCESSFUL; } else { return RTEMS_INCORRECT_STATE; } #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: _Thread_Dispatch(); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif case OBJECTS_ERROR: break; } return RTEMS_INVALID_ID; }
void __ISR_Handler(void) { register uint32_t level; /* Interrupts are disabled upon entry to this Handler */ #if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) if ( _ISR_Nest_level == 0 ) { /* Install irq stack */ _old_stack_ptr = stack_ptr; stack_ptr = _CPU_Interrupt_stack_high - 4; } #endif _ISR_Nest_level++; _Thread_Dispatch_increment_disable_level(); __IIC_Handler(); /* Make sure that interrupts are disabled again */ _CPU_ISR_Disable( level ); _Thread_Dispatch_decrement_disable_level(); _ISR_Nest_level--; if( _ISR_Nest_level == 0) { #if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) stack_ptr = _old_stack_ptr; #endif if( !_Thread_Dispatch_in_critical_section() ) { if ( _Thread_Dispatch_necessary ) { _CPU_ISR_Enable( level ); _Thread_Dispatch(); /* may have switched to another task and not return here immed. */ _CPU_ISR_Disable( level ); /* Keep _pairs_ of Enable/Disable */ } } } _CPU_ISR_Enable( level ); }
rtems_task High_task( rtems_task_argument argument ) { rtems_interrupt_level level; _Thread_Dispatch_disable(); benchmark_timer_initialize(); rtems_interrupt_local_disable( level ); isr_disable_time = benchmark_timer_read(); benchmark_timer_initialize(); #if defined(RTEMS_SMP) rtems_interrupt_local_enable( level ); rtems_interrupt_local_disable( level ); #else rtems_interrupt_flash( level ); #endif isr_flash_time = benchmark_timer_read(); benchmark_timer_initialize(); rtems_interrupt_local_enable( level ); isr_enable_time = benchmark_timer_read(); _Thread_Dispatch_enable( _Per_CPU_Get() ); benchmark_timer_initialize(); _Thread_Dispatch_disable(); thread_disable_dispatch_time = benchmark_timer_read(); benchmark_timer_initialize(); _Thread_Dispatch_enable( _Per_CPU_Get() ); thread_enable_dispatch_time = benchmark_timer_read(); benchmark_timer_initialize(); _Thread_Set_state( _Thread_Get_executing(), STATES_SUSPENDED ); thread_set_state_time = benchmark_timer_read(); set_thread_dispatch_necessary( true ); benchmark_timer_initialize(); _Thread_Dispatch(); /* dispatches Middle_task */ }
int pthread_sigmask( int how, const sigset_t *set, sigset_t *oset ) { POSIX_API_Control *api; if ( !set && !oset ) rtems_set_errno_and_return_minus_one( EINVAL ); api = _Thread_Get_executing()->API_Extensions[ THREAD_API_POSIX ]; if ( oset ) *oset = api->signals_blocked; if ( !set ) return 0; switch ( how ) { case SIG_BLOCK: api->signals_blocked |= *set; break; case SIG_UNBLOCK: api->signals_blocked &= ~*set; break; case SIG_SETMASK: api->signals_blocked = *set; break; default: rtems_set_errno_and_return_minus_one( EINVAL ); } /* XXX are there critical section problems here? */ /* XXX evaluate the new set */ if ( ~api->signals_blocked & (api->signals_pending | _POSIX_signals_Pending) ) { _Thread_Dispatch(); } return 0; }
rtems_task Task_2( rtems_task_argument argument ) { #if (MUST_WAIT_FOR_INTERRUPT == 1) while ( Interrupt_occurred == 0 ); #endif end_time = Timer_read(); put_time( "interrupt entry overhead: returns to preempting task", Interrupt_enter_time, 1, 0, timer_overhead ); put_time( "interrupt exit overhead: returns to preempting task", end_time, 1, 0, 0 ); fflush( stdout ); /* * Switch back to the other task to exit the test. */ _Thread_Dispatch_disable_level = 0; _Thread_Heir = (rtems_tcb *) _Thread_Ready_chain[254].first; _Context_Switch_necessary = 1; _Thread_Dispatch(); }
rtems_status_code rtems_semaphore_flush( rtems_id id ) { register Semaphore_Control *the_semaphore; Objects_Locations location; the_semaphore = _Semaphore_Get( id, &location ); switch ( location ) { case OBJECTS_LOCAL: if ( !_Attributes_Is_counting_semaphore(the_semaphore->attribute_set) ) { _CORE_mutex_Flush( &the_semaphore->Core_control.mutex, SEND_OBJECT_WAS_DELETED, CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT ); } else { _CORE_semaphore_Flush( &the_semaphore->Core_control.semaphore, SEND_OBJECT_WAS_DELETED, CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT ); } _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: _Thread_Dispatch(); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif case OBJECTS_ERROR: break; } return RTEMS_INVALID_ID; }
rtems_status_code rtems_event_system_send( rtems_id id, rtems_event_set event_in ) { rtems_status_code sc; Thread_Control *thread; Objects_Locations location; RTEMS_API_Control *api; ISR_lock_Context lock_context; thread = _Thread_Get_interrupt_disable( id, &location, &lock_context ); switch ( location ) { case OBJECTS_LOCAL: api = thread->API_Extensions[ THREAD_API_RTEMS ]; _Event_Surrender( thread, event_in, &api->System_event, THREAD_WAIT_CLASS_SYSTEM_EVENT, &lock_context ); _Objects_Put_for_get_isr_disable( &thread->Object ); sc = RTEMS_SUCCESSFUL; break; #ifdef RTEMS_MULTIPROCESSING case OBJECTS_REMOTE: _Thread_Dispatch(); sc = RTEMS_ILLEGAL_ON_REMOTE_OBJECT; break; #endif default: sc = RTEMS_INVALID_ID; break; } return sc; }
rtems_status_code rtems_event_system_send( rtems_id id, rtems_event_set event_in ) { rtems_status_code sc; Thread_Control *thread; Objects_Locations location; RTEMS_API_Control *api; thread = _Thread_Get( id, &location ); switch ( location ) { case OBJECTS_LOCAL: api = thread->API_Extensions[ THREAD_API_RTEMS ]; _Event_Surrender( thread, event_in, &api->System_event, &_System_event_Sync_state, STATES_WAITING_FOR_SYSTEM_EVENT ); _Objects_Put( &thread->Object ); sc = RTEMS_SUCCESSFUL; break; #ifdef RTEMS_MULTIPROCESSING case OBJECTS_REMOTE: _Thread_Dispatch(); sc = RTEMS_ILLEGAL_ON_REMOTE_OBJECT; break; #endif default: sc = RTEMS_INVALID_ID; break; } return sc; }
rtems_status_code rtems_task_start( rtems_id id, rtems_task_entry entry_point, rtems_task_argument argument ) { register Thread_Control *the_thread; Objects_Locations location; if ( entry_point == NULL ) return RTEMS_INVALID_ADDRESS; the_thread = _Thread_Get( id, &location ); switch ( location ) { case OBJECTS_LOCAL: if ( _Thread_Start( the_thread, THREAD_START_NUMERIC, entry_point, NULL, argument ) ) { _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; } _Thread_Enable_dispatch(); return RTEMS_INCORRECT_STATE; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: _Thread_Dispatch(); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif case OBJECTS_ERROR: break; } return RTEMS_INVALID_ID; }
int timer_delete( timer_t timerid ) { /* * IDEA: This function must probably stop the timer first and then delete it * * It will have to do a call to rtems_timer_cancel and then another * call to rtems_timer_delete. * The call to rtems_timer_delete will be probably unnecessary, * because rtems_timer_delete stops the timer before deleting it. */ POSIX_Timer_Control *ptimer; Objects_Locations location; ptimer = _POSIX_Timer_Get( timerid, &location ); switch ( location ) { case OBJECTS_REMOTE: #if defined(RTEMS_MULTIPROCESSING) _Thread_Dispatch(); rtems_set_errno_and_return_minus_one( EINVAL ); #endif case OBJECTS_ERROR: rtems_set_errno_and_return_minus_one( EINVAL ); case OBJECTS_LOCAL: _Objects_Close( &_POSIX_Timer_Information, &ptimer->Object ); ptimer->state = POSIX_TIMER_STATE_FREE; (void) _Watchdog_Remove( &ptimer->Timer ); _POSIX_Timer_Free( ptimer ); _Thread_Enable_dispatch(); return 0; } return -1; /* unreached - only to remove warnings */ }