From eb02f47b126b56091ffaeaad470a48e2ac6d57b5 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 10 Nov 1999 13:48:27 +0000 Subject: Committed modifications from ITRON Task and Task Dependendent Synchronization Working Group. Included are tests. --- c/src/exec/itron/include/itronsys/types.h | 2 - c/src/exec/itron/include/rtems/itron/object.h | 2 +- c/src/exec/itron/include/rtems/itron/task.h | 11 ++++ c/src/exec/itron/inline/rtems/itron/task.inl | 28 ++++++++-- c/src/exec/itron/src/can_wup.c | 21 ++++++- c/src/exec/itron/src/chg_pri.c | 40 +++++++++++++- c/src/exec/itron/src/cre_tsk.c | 79 ++++++++++++--------------- c/src/exec/itron/src/del_tsk.c | 15 +++-- c/src/exec/itron/src/exd_tsk.c | 4 +- c/src/exec/itron/src/ext_tsk.c | 5 ++ c/src/exec/itron/src/frsm_tsk.c | 27 ++++++++- c/src/exec/itron/src/get_tid.c | 6 ++ c/src/exec/itron/src/ref_tsk.c | 55 ++++++++++++++++++- c/src/exec/itron/src/rel_wai.c | 25 ++++++++- c/src/exec/itron/src/rot_rdq.c | 20 +++++++ c/src/exec/itron/src/rsm_tsk.c | 27 ++++++++- c/src/exec/itron/src/slp_tsk.c | 2 +- c/src/exec/itron/src/sta_tsk.c | 36 +++--------- c/src/exec/itron/src/sus_tsk.c | 29 +++++++++- c/src/exec/itron/src/task.c | 4 +- c/src/exec/itron/src/ter_tsk.c | 26 ++++++++- 21 files changed, 365 insertions(+), 99 deletions(-) (limited to 'c/src/exec/itron') diff --git a/c/src/exec/itron/include/itronsys/types.h b/c/src/exec/itron/include/itronsys/types.h index c9dc8db40e..80cb31f3b8 100644 --- a/c/src/exec/itron/include/itronsys/types.h +++ b/c/src/exec/itron/include/itronsys/types.h @@ -19,14 +19,12 @@ extern "C" { * off the shell programs including paranoia. */ -#if 0 typedef signed8 B; /* signed 8-bit integer */ typedef signed16 H; /* signed 16-bit integer */ typedef signed32 W; /* signed 32-bit integer */ typedef unsigned8 UB; /* unsigned 8-bit integer */ typedef unsigned16 UH; /* unsigned 16-bit integer */ typedef unsigned32 UW; /* unsigned 32-bit integer */ -#endif typedef unsigned32 VW; /* unpredictable data type (32-bit size) */ typedef unsigned16 VH; /* unpredictable data type (16-bit size) */ diff --git a/c/src/exec/itron/include/rtems/itron/object.h b/c/src/exec/itron/include/rtems/itron/object.h index 71bc9ed6d1..919baffd9e 100644 --- a/c/src/exec/itron/include/rtems/itron/object.h +++ b/c/src/exec/itron/include/rtems/itron/object.h @@ -80,7 +80,7 @@ typedef Objects_Control ITRON_Objects_Control; #define _ITRON_Objects_Clarify_get_id_error( _the_information, _id ) \ (((_id) < -4) ? E_OACV : /* attempt to access a "system object" */ \ ((_id) <= 0) ? E_ID : /* bogus index of 0 - -3 */ \ - ((_id) <= (_the_information)->maximum) ? E_OBJ : /* object is in use */ \ + ((_id) <= (_the_information)->maximum) ? E_NOEXS : /* does not exist */ \ E_ID) /* simply a bad id */ diff --git a/c/src/exec/itron/include/rtems/itron/task.h b/c/src/exec/itron/include/rtems/itron/task.h index fffcc16d82..5d52d632f5 100644 --- a/c/src/exec/itron/include/rtems/itron/task.h +++ b/c/src/exec/itron/include/rtems/itron/task.h @@ -77,7 +77,18 @@ ER _ITRON_Delete_task( Thread_Control *the_thread ); +/* XXX remove the need for this. Enable dispatch should not be hidden */ + +#define _ITRON_return_errorno( _errno ) \ +do { \ + _Thread_Enable_dispatch(); \ + return _errno; \ +} while (0); + + +#ifndef __RTEMS_APPLICATION__ #include +#endif #ifdef __cplusplus } diff --git a/c/src/exec/itron/inline/rtems/itron/task.inl b/c/src/exec/itron/inline/rtems/itron/task.inl index 1833fee84a..834e47b0c9 100644 --- a/c/src/exec/itron/inline/rtems/itron/task.inl +++ b/c/src/exec/itron/inline/rtems/itron/task.inl @@ -109,7 +109,13 @@ RTEMS_INLINE_ROUTINE Thread_Control *_ITRON_Task_Get ( ID id, Objects_Locations *location ) -{ +{ + if ( id == 0 ) { + _Thread_Disable_dispatch(); + *location = OBJECTS_LOCAL; + return _Thread_Executing; + } + return (Thread_Control *) _ITRON_Objects_Get( &_ITRON_Task_Information, id, location ); } @@ -144,17 +150,29 @@ RTEMS_INLINE_ROUTINE boolean _ITRON_Task_Is_null ( * _ITRON_tasks_Priority_to_Core */ -RTEMS_INLINE_ROUTINE Priority_Control _ITRON_Task_Priority_to_Core( - PRI _priority +RTEMS_INLINE_ROUTINE _ITRON_Task_Priority_to_Core( + PRI ITRON_priority +) +{ + return (Priority_Control) ITRON_priority; +} + +/*PAGE + * + * _ITRON_tasks_Core_to_Priority + */ + +RTEMS_INLINE_ROUTINE _ITRON_Task_Core_to_Priority( + Priority_Control core_priority ) { - return ((Priority_Control) (_priority)); + return (PRI) core_priority; } + #ifdef __cplusplus } #endif #endif /* end of include file */ - diff --git a/c/src/exec/itron/src/can_wup.c b/c/src/exec/itron/src/can_wup.c index d75d379de9..b7442d1392 100644 --- a/c/src/exec/itron/src/can_wup.c +++ b/c/src/exec/itron/src/can_wup.c @@ -25,6 +25,25 @@ ER can_wup( ID tskid ) { - return E_OK; + register Thread_Control *the_thread; + Objects_Locations location; + + the_thread = _ITRON_Task_Get( tskid, &location ); + if (!the_thread) + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + switch ( location ) { + case OBJECTS_REMOTE: + case OBJECTS_ERROR: + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + case OBJECTS_LOCAL: + /* + * XXX - FILL ME IN. + */ + return E_OK; + } + + return E_OBJ; /* XXX - Should never get here */ } diff --git a/c/src/exec/itron/src/chg_pri.c b/c/src/exec/itron/src/chg_pri.c index b2d42905e5..412bab054e 100644 --- a/c/src/exec/itron/src/chg_pri.c +++ b/c/src/exec/itron/src/chg_pri.c @@ -25,6 +25,44 @@ ER chg_pri( PRI tskpri ) { - return E_OK; + register Thread_Control *the_thread; + Objects_Locations location; + Priority_Control new_priority; + + the_thread = _ITRON_Task_Get( tskid, &location ); + if (!the_thread) + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + if (_States_Is_dormant( the_thread->current_state )) + return -1; + + if (( tskpri <= 0 ) || ( tskpri >= 256 )) + _ITRON_return_errorno( E_PAR ); + + switch ( location ) { + case OBJECTS_REMOTE: + case OBJECTS_ERROR: + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid )); + + case OBJECTS_LOCAL: + new_priority = _ITRON_Task_Priority_to_Core( tskpri ); + the_thread->real_priority = new_priority; + + /* + * XXX This is from the rtems side and I'm not sure what this is for. + * XXX Is this check right or should change priority be called + * regardless? + */ + + if ( the_thread->resource_count == 0 || + the_thread->current_priority > new_priority ) + _Thread_Change_priority( the_thread, new_priority, FALSE ); + + _Thread_Enable_dispatch(); + return E_OK; + } + + return E_OBJ; /* XXX - Should never get here */ } + diff --git a/c/src/exec/itron/src/cre_tsk.c b/c/src/exec/itron/src/cre_tsk.c index 76bcd75eda..f4e8e605fc 100644 --- a/c/src/exec/itron/src/cre_tsk.c +++ b/c/src/exec/itron/src/cre_tsk.c @@ -21,28 +21,6 @@ * cre_tsk - Create Task */ -/* - * XXX - How do I return these errors ??? Do I have to validate the ID - prior to calling the ID routine ?? - E_NOMEM Insufficient memory (Memory for control block and/or user stack - cannot be allocated) - E_ID Invalid ID Number (tskid was invalid or could not be used) - E_RSATR Reserved attribute (tskatr was invalid or could not be used) - E_OBJ Invalid object state (a task of the same ID already exists) - E_OACV Object access violation (A tskid less than -4 was specified from - a user task. This is implementation dependent.) - E_PAR Parameter error (pk_ctsk, task, itskpri and/or stksz is invalid) - EN_OBJNO An object number which could not be accessed on the target node - is specified. - EN_CTXID Specified an object on another node when the system call was - issued from a task in dispatch disabled state or from a task- - independent portion - EN_PAR A value outside the range supported by the target node and/or - transmission packet format was specified as a parameter (a value - outside supported range was specified for exinf, tskatr, task, - itskpri and/or stksz) - */ - ER cre_tsk( ID tskid, T_CTSK *pk_ctsk @@ -59,19 +37,40 @@ ER cre_tsk( _Thread_Disable_dispatch(); + /* + * Validate Parameters. + */ + + if ( pk_ctsk == NULL ) + _ITRON_return_errorno( E_PAR ); + + if ((pk_ctsk->tskatr != TA_ASM ) && + (pk_ctsk->tskatr != TA_HLNG) && + (pk_ctsk->tskatr != TA_COP0) && + (pk_ctsk->tskatr != TA_COP1) && + (pk_ctsk->tskatr != TA_COP2) && + (pk_ctsk->tskatr != TA_COP3) && + (pk_ctsk->tskatr != TA_COP4) && + (pk_ctsk->tskatr != TA_COP5) && + (pk_ctsk->tskatr != TA_COP6) && + (pk_ctsk->tskatr != TA_COP7)) + _ITRON_return_errorno( E_RSATR ); + + if (( pk_ctsk->itskpri <= 0 ) || ( pk_ctsk->itskpri >= 256 )) + if ( pk_ctsk->itskpri <= 0 ) + _ITRON_return_errorno( E_PAR ); + if ( pk_ctsk->task == NULL ) + _ITRON_return_errorno( E_PAR ); + if ( pk_ctsk->stksz < 0 ) + _ITRON_return_errorno( E_PAR ); + /* * allocate the thread. */ the_thread = _ITRON_Task_Allocate( tskid ); - if ( !the_thread ) { - ena_dsp(); - return _ITRON_Task_Clarify_allocation_id_error( tskid ); - } - - /* - * XXX - FIX THE VARIABLES TO THE CORRECT VALUES!!! - */ + if ( !the_thread ) + _ITRON_return_errorno( _ITRON_Task_Clarify_allocation_id_error( tskid ) ); /* * Initialize the core thread for this task. @@ -83,7 +82,7 @@ ER cre_tsk( the_thread, NULL, pk_ctsk->stksz, - TRUE, /* XXX - All tasks FP ??? */ + TRUE, /* XXX - All tasks FP for now */ core_priority, TRUE, THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE, @@ -94,22 +93,9 @@ ER cre_tsk( if ( !status ) { _ITRON_Task_Free( the_thread ); - _Thread_Enable_dispatch(); - return -1; -#if (0) -/* XXX */ -#endif + _ITRON_return_errorno( E_NOMEM ); } -#if (0) /* XXX We have any thing else to set per API structure? */ - api = the_thread->API_Extensions[ THREAD_API_ITRON ]; - asr = &api->Signal; - - asr->is_enabled = FALSE; - - *id = the_thread->Object.id; -#endif - /* * This insures we evaluate the process-wide signals pending when we * first run. @@ -125,3 +111,6 @@ ER cre_tsk( return E_OK; } + + + diff --git a/c/src/exec/itron/src/del_tsk.c b/c/src/exec/itron/src/del_tsk.c index 5230acddca..4514eb6348 100644 --- a/c/src/exec/itron/src/del_tsk.c +++ b/c/src/exec/itron/src/del_tsk.c @@ -29,16 +29,21 @@ ER del_tsk( Objects_Locations location; ER result; - /* XXX - Fix Documentation and error checking for this error on self */ - the_thread = _ITRON_Task_Get( tskid, &location ); - _Thread_Disable_dispatch(); + + if (!the_thread) + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + if ( the_thread == _Thread_Executing ) + _ITRON_return_errorno( E_OBJ ); + + if ( !_States_Is_dormant( the_thread->current_state ) ) + _ITRON_return_errorno( E_OBJ ); switch ( location ) { case OBJECTS_REMOTE: case OBJECTS_ERROR: - _Thread_Enable_dispatch(); - return _ITRON_Task_Clarify_get_id_error( tskid ); + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); case OBJECTS_LOCAL: result = _ITRON_Delete_task( the_thread ); diff --git a/c/src/exec/itron/src/exd_tsk.c b/c/src/exec/itron/src/exd_tsk.c index c2b86f3126..51c0eb04c5 100644 --- a/c/src/exec/itron/src/exd_tsk.c +++ b/c/src/exec/itron/src/exd_tsk.c @@ -25,13 +25,13 @@ void exd_tsk( void ) { Objects_Information *the_information; + _Thread_Disable_dispatch(); + the_information = _Objects_Get_information( _Thread_Executing->Object.id ); /* This should never happen if _Thread_Get() works right */ assert( the_information ); - _Thread_Disable_dispatch(); - _Thread_Set_state( _Thread_Executing, STATES_DORMANT ); _ITRON_Delete_task( _Thread_Executing ); diff --git a/c/src/exec/itron/src/ext_tsk.c b/c/src/exec/itron/src/ext_tsk.c index a8a3b0ec23..d3f13939f1 100644 --- a/c/src/exec/itron/src/ext_tsk.c +++ b/c/src/exec/itron/src/ext_tsk.c @@ -23,5 +23,10 @@ void ext_tsk( void ) { + _Thread_Disable_dispatch(); + + _Thread_Restart( _Thread_Executing, NULL, 0 ); _Thread_Set_state( _Thread_Executing, STATES_DORMANT ); + + _Thread_Enable_dispatch(); } diff --git a/c/src/exec/itron/src/frsm_tsk.c b/c/src/exec/itron/src/frsm_tsk.c index 8fe5e9e6fc..2840061dd6 100644 --- a/c/src/exec/itron/src/frsm_tsk.c +++ b/c/src/exec/itron/src/frsm_tsk.c @@ -25,7 +25,32 @@ ER frsm_tsk( ID tskid ) { - return E_OK; + register Thread_Control *the_thread; + Objects_Locations location; + + the_thread = _ITRON_Task_Get( tskid, &location ); + if (!the_thread) + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + if ( the_thread == _Thread_Executing ) + _ITRON_return_errorno( E_OBJ ); + + if (_States_Is_dormant( the_thread->current_state )) + _ITRON_return_errorno( E_OBJ ); + + switch ( location ) { + case OBJECTS_REMOTE: + case OBJECTS_ERROR: + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + case OBJECTS_LOCAL: + _Thread_Resume( the_thread, TRUE ); + _Thread_Enable_dispatch(); + return E_OK; + } + + return E_OBJ; /* XXX - Should never get here */ + } diff --git a/c/src/exec/itron/src/get_tid.c b/c/src/exec/itron/src/get_tid.c index 1c5175052a..7904e3e167 100644 --- a/c/src/exec/itron/src/get_tid.c +++ b/c/src/exec/itron/src/get_tid.c @@ -24,6 +24,12 @@ ER get_tid( ID *p_tskid ) { + /* + * This does not support multiprocessing. The id handling will have + * to be enhanced to support multiprocessing. + */ + + *p_tskid = _Objects_Get_index( _Thread_Executing->Object.id ); return E_OK; } diff --git a/c/src/exec/itron/src/ref_tsk.c b/c/src/exec/itron/src/ref_tsk.c index 50ce76e8ed..2c6ad11709 100644 --- a/c/src/exec/itron/src/ref_tsk.c +++ b/c/src/exec/itron/src/ref_tsk.c @@ -26,6 +26,59 @@ ER ref_tsk( ID tskid ) { - return E_OK; + register Thread_Control *the_thread; + Objects_Locations location; + Priority_Control core_priority; + + the_thread = _ITRON_Task_Get( tskid, &location ); + if (!the_thread) + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + if (!pk_rtsk) + _ITRON_return_errorno( E_PAR ); + + /* + * The following are extended functions [level X ]. + * XXX - tskwait, wid, wupcnt, and tskatr are presently not implemented. + */ + + pk_rtsk->tskwait = 0; + pk_rtsk->wid = 0; + pk_rtsk->wupcnt = 0; + pk_rtsk->suscnt = the_thread->suspend_count; + pk_rtsk->tskatr = 0; + pk_rtsk->task = the_thread->Start.entry_point; + core_priority = the_thread->Start.initial_priority; + pk_rtsk->itskpri = _ITRON_Task_Core_to_Priority( core_priority ); + pk_rtsk->stksz = the_thread->Start.Initial_stack.size; + + /* + * The following are required. + */ + + pk_rtsk->exinf = NULL; /* extended information */ + pk_rtsk->tskpri = _ITRON_Task_Core_to_Priority(the_thread->current_priority); + pk_rtsk->tskstat = 0; + + /* + * Mask in the tskstat information + * Convert the task state XXX double check this + */ + + if ( the_thread == _Thread_Executing ) + pk_rtsk->tskstat |= TTS_RUN; + if ((the_thread->current_state & STATES_READY) != 0) + pk_rtsk->tskstat = TTS_RDY; + if (_States_Is_dormant( the_thread->current_state )) + pk_rtsk->tskstat = TTS_DMT; + if ((the_thread->current_state & STATES_SUSPENDED) != 0) + pk_rtsk->tskstat = TTS_SUS; + if ((the_thread->current_state & STATES_BLOCKED) != 0) + pk_rtsk->tskstat = TTS_WAI; + + return E_OK; /* XXX - Should never get here */ } + + + diff --git a/c/src/exec/itron/src/rel_wai.c b/c/src/exec/itron/src/rel_wai.c index 390433ec0c..81d7e6dc94 100644 --- a/c/src/exec/itron/src/rel_wai.c +++ b/c/src/exec/itron/src/rel_wai.c @@ -24,7 +24,30 @@ ER rel_wai( ID tskid ) { - return E_OK; + register Thread_Control *the_thread; + Objects_Locations location; + + the_thread = _ITRON_Task_Get( tskid, &location ); + if (!the_thread) + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + _Thread_Disable_dispatch(); + + switch ( location ) { + case OBJECTS_REMOTE: + case OBJECTS_ERROR: + _Thread_Enable_dispatch(); + return _ITRON_Task_Clarify_get_id_error( tskid ); + + case OBJECTS_LOCAL: + /* + * XXX - FILL ME IN. + */ + return E_OK; + } + + return E_OBJ; /* XXX - Should never get here */ } + diff --git a/c/src/exec/itron/src/rot_rdq.c b/c/src/exec/itron/src/rot_rdq.c index b329313946..ac6d89d55f 100644 --- a/c/src/exec/itron/src/rot_rdq.c +++ b/c/src/exec/itron/src/rot_rdq.c @@ -24,6 +24,26 @@ ER rot_rdq( PRI tskpri ) { + PRI priority; + + + _Thread_Disable_dispatch(); + + /* + * Yield of processor will rotate the queue for this processor. + */ + + if (( tskpri <= 0 ) || ( tskpri >= 256 )) + _ITRON_return_errorno( E_PAR ); + + priority = _ITRON_Task_Core_to_Priority(_Thread_Executing->current_priority); + if ( priority == tskpri ) + _Thread_Yield_processor(); + else { + _Thread_Rotate_Ready_Queue( _ITRON_Task_Core_to_Priority( tskpri ) ); + } + _Thread_Enable_dispatch(); + return E_OK; } diff --git a/c/src/exec/itron/src/rsm_tsk.c b/c/src/exec/itron/src/rsm_tsk.c index a19842f8da..81be3446eb 100644 --- a/c/src/exec/itron/src/rsm_tsk.c +++ b/c/src/exec/itron/src/rsm_tsk.c @@ -25,6 +25,31 @@ ER rsm_tsk( ID tskid ) { - return E_OK; + register Thread_Control *the_thread; + Objects_Locations location; + + the_thread = _ITRON_Task_Get( tskid, &location ); + + if (!the_thread) + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + if ( the_thread == _Thread_Executing ) + _ITRON_return_errorno( E_OBJ ); + + if (_States_Is_dormant( the_thread->current_state )) + _ITRON_return_errorno( E_OBJ ); + + switch ( location ) { + case OBJECTS_REMOTE: + case OBJECTS_ERROR: + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + case OBJECTS_LOCAL: + _Thread_Resume( the_thread, FALSE ); + _Thread_Enable_dispatch(); + return E_OK; + } + + return E_OBJ; /* XXX - Should never get here */ } diff --git a/c/src/exec/itron/src/slp_tsk.c b/c/src/exec/itron/src/slp_tsk.c index 00562dda92..b8c84c9808 100644 --- a/c/src/exec/itron/src/slp_tsk.c +++ b/c/src/exec/itron/src/slp_tsk.c @@ -19,7 +19,7 @@ /* - * slp_tsk - Sleep Task Sleep Task with Timeout + * slp_tsk - Sleep Task */ ER slp_tsk( void ) diff --git a/c/src/exec/itron/src/sta_tsk.c b/c/src/exec/itron/src/sta_tsk.c index 91a6586c0e..73cc49e36b 100644 --- a/c/src/exec/itron/src/sta_tsk.c +++ b/c/src/exec/itron/src/sta_tsk.c @@ -21,24 +21,6 @@ * sta_tsk - Start Task */ -/* - * XXX - How Do I know when these happen ??? - E_NOEXS Object does not exist (the task specified by tskid does not exist) - E_OACV Object access violation (A tskid less than -4 was specified from - a user task. This is implementation dependent.) - E_OBJ Invalid object state (the target task is not in DORMANT state) - EN_OBJNO An object number which could not be accessed on the target node - is specified. XXX Should never get on a single processor?? - EN_CTXID Specified an object on another node when the system call was - issued from a task in dispatch disabled state or from a task- - independent portionXXX Should never get on a single processor?? - EN_PAR A value outside the range supported by the target node and/or - transmission packet format was specified as a parameter (a value - outside supported range was specified for stacd) -XXX- What does _ITRON_Task_Get return on an invalid id and how do you know - if it is E_ID, E_NOEXS, E_OACV -*/ - ER sta_tsk( ID tskid, INT stacd @@ -49,10 +31,16 @@ ER sta_tsk( boolean status; the_thread = _ITRON_Task_Get( tskid, &location ); + if (!the_thread) + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + if ( !_States_Is_dormant( the_thread->current_state ) ) + _ITRON_return_errorno( E_OBJ ); + switch ( location ) { case OBJECTS_REMOTE: case OBJECTS_ERROR: - return E_ID; /* XXX */ + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); case OBJECTS_LOCAL: status = _Thread_Start( @@ -63,14 +51,8 @@ ER sta_tsk( 0 /* unused */ ); - /* - * Wrong state XXX - */ - - if ( !status ) { - _Thread_Enable_dispatch(); - return E_OBJ; - } + if ( !status ) + _ITRON_return_errorno( E_OBJ ); _Thread_Enable_dispatch(); return E_OK; diff --git a/c/src/exec/itron/src/sus_tsk.c b/c/src/exec/itron/src/sus_tsk.c index f4a5d5b851..12ef07ff7b 100644 --- a/c/src/exec/itron/src/sus_tsk.c +++ b/c/src/exec/itron/src/sus_tsk.c @@ -29,6 +29,33 @@ ER sus_tsk( ID tskid ) { - return E_OK; + register Thread_Control *the_thread; + Objects_Locations location; + + the_thread = _ITRON_Task_Get( tskid, &location ); + if (!the_thread) + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + if ( the_thread == _Thread_Executing ) + _ITRON_return_errorno( E_OBJ ); + + switch ( location ) { + case OBJECTS_REMOTE: + case OBJECTS_ERROR: + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + case OBJECTS_LOCAL: + _Thread_Suspend( the_thread ); + _Thread_Enable_dispatch(); + return E_OK; + } + + return E_OBJ; /* XXX - Should never get here */ } + + + + + + diff --git a/c/src/exec/itron/src/task.c b/c/src/exec/itron/src/task.c index f646b29d49..c4e785a4bb 100644 --- a/c/src/exec/itron/src/task.c +++ b/c/src/exec/itron/src/task.c @@ -117,10 +117,8 @@ ER _ITRON_Delete_task( Objects_Information *the_information; the_information = _Objects_Get_information( the_thread->Object.id ); - if ( !the_information ) { - return -1; /* XXX */ - /* This should never happen if _Thread_Get() works right */ + return E_OBJ; /* XXX - should never happen */ } _Thread_Close( the_information, the_thread ); diff --git a/c/src/exec/itron/src/ter_tsk.c b/c/src/exec/itron/src/ter_tsk.c index c0d05c1fec..070cfcee25 100644 --- a/c/src/exec/itron/src/ter_tsk.c +++ b/c/src/exec/itron/src/ter_tsk.c @@ -18,13 +18,37 @@ /* - * ter_tsk - Terminate Other Task + * ter_tsk - Terminate Other Task - Set State to DORMANT */ ER ter_tsk( ID tskid ) { + register Thread_Control *the_thread; + Objects_Locations location; + + the_thread = _ITRON_Task_Get( tskid, &location ); + + if ( !the_thread ) + _ITRON_return_errorno( _ITRON_Task_Clarify_get_id_error( tskid ) ); + + if ( the_thread == _Thread_Executing ) + _ITRON_return_errorno( E_OBJ ); + + if ( _States_Is_dormant( the_thread->current_state ) ) + _ITRON_return_errorno( E_OBJ ); + + _Thread_Restart( the_thread, NULL, 0 ); + _Thread_Set_state( the_thread, STATES_DORMANT ); + + _Thread_Enable_dispatch(); return E_OK; } + + + + + + -- cgit v1.2.3