rtems_task Task_1_through_3( rtems_task_argument argument ) { rtems_id tid; rtems_time_of_day time; rtems_status_code status; rtems_interval ticks; status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); directive_failed( status, "rtems_task_ident" ); /* * Use TOD_MILLISECONDS_TO_TICKS not RTEMS_MILLISECONDS_TO_TICKS to * test C implementation in SuperCore -- not macro version used * everywhere else. */ ticks = TOD_MILLISECONDS_TO_TICKS( task_number( tid ) * 5 * 1000 ); while( FOREVER ) { status = rtems_clock_get_tod( &time ); directive_failed( status, "rtems_clock_get_tod" ); if ( time.second >= 35 ) { puts( "*** END OF CBS SCHEDULER TEST 1 ***" ); rtems_test_exit( 0 ); } put_name( Task_name[ task_number( tid ) ], FALSE ); print_time( " - rtems_clock_get_tod - ", &time, "\n" ); status = rtems_task_wake_after( ticks ); directive_failed( status, "rtems_task_wake_after" ); } }
ER trcv_msg( T_MSG **ppk_msg, ID mbxid, TMO tmout ) { register ITRON_Mailbox_Control *the_mailbox; Watchdog_Interval interval; bool wait; Objects_Locations location; size_t size; if (!ppk_msg) return E_PAR; interval = 0; if ( tmout == TMO_POL ) { wait = false; } else { wait = true; if ( tmout != TMO_FEVR ) interval = TOD_MILLISECONDS_TO_TICKS(tmout); } if ( wait && _ITRON_Is_in_non_task_state() ) return E_CTX; the_mailbox = _ITRON_Mailbox_Get( mbxid, &location ); switch ( location ) { #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: #endif case OBJECTS_ERROR: return _ITRON_Mailbox_Clarify_get_id_error( mbxid ); case OBJECTS_LOCAL: _CORE_message_queue_Seize( &the_mailbox->message_queue, the_mailbox->Object.id, ppk_msg, &size, wait, interval ); break; } _ITRON_return_errorno( _ITRON_Mailbox_Translate_core_message_queue_return_code( _Thread_Executing->Wait.return_code ) ); }
ER dly_tsk( DLYTIME dlytim ) { Watchdog_Interval ticks; ticks = TOD_MILLISECONDS_TO_TICKS(dlytim); _Thread_Disable_dispatch(); if ( ticks == 0 ) { _Thread_Yield_processor(); } else { _Thread_Set_state( _Thread_Executing, STATES_DELAYING ); _Watchdog_Initialize( &_Thread_Executing->Timer, _Thread_Delay_ended, _Thread_Executing->Object.id, NULL ); _Watchdog_Insert_ticks( &_Thread_Executing->Timer, ticks ); } _Thread_Enable_dispatch(); return E_OK; }
ER tsnd_mbf( ID mbfid, VP msg, INT msgsz, TMO tmout ) { ITRON_Message_buffer_Control *the_message_buffer; Objects_Locations location; Watchdog_Interval interval; bool wait; CORE_message_queue_Status msg_status; if (msgsz <= 0 || !msg) return E_PAR; interval = 0; if ( tmout == TMO_POL ) { wait = false; } else { wait = true; if ( tmout != TMO_FEVR ) interval = TOD_MILLISECONDS_TO_TICKS(tmout); } if ( wait && _ITRON_Is_in_non_task_state() ) return E_CTX; the_message_buffer = _ITRON_Message_buffer_Get(mbfid, &location); switch (location) { #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: #endif case OBJECTS_ERROR: /* Multiprocessing not supported */ return _ITRON_Message_buffer_Clarify_get_id_error(mbfid); case OBJECTS_LOCAL: /* XXX Submit needs to take into account blocking */ msg_status = _CORE_message_queue_Submit( &the_message_buffer->message_queue, msg, msgsz, the_message_buffer->Object.id, NULL, CORE_MESSAGE_QUEUE_SEND_REQUEST, wait, /* sender may block */ interval /* timeout interval */ ); _Thread_Enable_dispatch(); return _ITRON_Message_buffer_Translate_core_message_buffer_return_code( msg_status ); } /* * If multiprocessing were supported, this is where we would announce * the existence of the semaphore to the rest of the system. */ #if defined(RTEMS_MULTIPROCESSING) #endif return E_OK; }