Changeset fb27af76 in rtems
- Timestamp:
- 11/15/99 16:39:01 (24 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 9da0994
- Parents:
- afb11f8
- Files:
-
- 14 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/itron/src/Makefile.in
rafb11f8 rfb27af76 20 20 can_wup 21 21 22 SEMAPHORE_C_PIECES = itronsem 22 SEMAPHORE_C_PIECES = itronsem cre_sem del_sem preq_sem ref_sem sig_sem \ 23 twai_sem wai_sem 23 24 24 25 EVENTFLAGS_C_PIECES = eventflags -
c/src/exec/itron/src/itronsem.c
rafb11f8 rfb27af76 52 52 } 53 53 54 /*55 * cre_sem - Create Semaphore56 *57 * This function implements the ITRON 3.0 cre_sem() service.58 */59 60 ER cre_sem(61 ID semid,62 T_CSEM *pk_csem63 )64 {65 CORE_semaphore_Attributes the_semaphore_attributes;66 ITRON_Semaphore_Control *the_semaphore;67 68 /*69 * Bad pointer to the attributes structure70 */71 72 if ( !pk_csem )73 return E_PAR;74 75 /*76 * Bits were set that were note defined.77 */78 79 if ( pk_csem->sematr & _ITRON_SEMAPHORE_UNUSED_ATTRIBUTES )80 return E_RSATR;81 82 /*83 * Initial semaphore count exceeds the maximum.84 */85 86 if ( pk_csem->isemcnt > pk_csem->maxsem )87 return E_PAR;88 89 /*90 * This error is not in the specification but this condition91 * does not make sense.92 */93 94 if ( pk_csem->maxsem == 0 )95 return E_PAR;96 97 _Thread_Disable_dispatch(); /* prevents deletion */98 99 the_semaphore = _ITRON_Semaphore_Allocate( semid );100 if ( !the_semaphore ) {101 _Thread_Enable_dispatch();102 return _ITRON_Semaphore_Clarify_allocation_id_error( semid );103 }104 105 if ( pk_csem->sematr & TA_TPRI )106 the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY;107 else108 the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;109 110 the_semaphore_attributes.maximum_count = pk_csem->maxsem;111 112 _CORE_semaphore_Initialize(113 &the_semaphore->semaphore,114 OBJECTS_ITRON_SEMAPHORES,115 &the_semaphore_attributes,116 pk_csem->isemcnt,117 NULL /* Multiprocessing not supported */118 );119 120 _ITRON_Objects_Open( &_ITRON_Semaphore_Information, &the_semaphore->Object );121 122 /*123 * If multiprocessing were supported, this is where we would announce124 * the existence of the semaphore to the rest of the system.125 */126 127 #if defined(RTEMS_MULTIPROCESSING)128 #endif129 130 _Thread_Enable_dispatch();131 return E_OK;132 }133 134 /*135 * del_sem - Delete Semaphore136 *137 * This function implements the ITRON 3.0 del_sem() service.138 */139 140 ER del_sem(141 ID semid142 )143 {144 ITRON_Semaphore_Control *the_semaphore;145 Objects_Locations location;146 147 the_semaphore = _ITRON_Semaphore_Get( semid, &location );148 switch ( location ) {149 case OBJECTS_REMOTE: /* Multiprocessing not supported */150 case OBJECTS_ERROR:151 return _ITRON_Semaphore_Clarify_get_id_error( semid );152 153 case OBJECTS_LOCAL:154 _CORE_semaphore_Flush(155 &the_semaphore->semaphore,156 NULL, /* Multiprocessing not supported */157 CORE_SEMAPHORE_WAS_DELETED158 );159 160 _ITRON_Objects_Close(161 &_ITRON_Semaphore_Information,162 &the_semaphore->Object163 );164 165 _ITRON_Semaphore_Free( the_semaphore );166 167 /*168 * If multiprocessing were supported, this is where we would announce169 * the destruction of the semaphore to the rest of the system.170 */171 172 #if defined(RTEMS_MULTIPROCESSING)173 #endif174 175 _Thread_Enable_dispatch();176 return E_OK;177 178 }179 return E_OK;180 }181 182 /*183 * sig_sem - Signal Semaphore184 *185 * This function implements the ITRON 3.0 sig_sem() service.186 */187 188 ER sig_sem(189 ID semid190 )191 {192 ITRON_Semaphore_Control *the_semaphore;193 Objects_Locations location;194 CORE_semaphore_Status status;195 196 the_semaphore = _ITRON_Semaphore_Get( semid, &location );197 switch ( location ) {198 case OBJECTS_REMOTE: /* Multiprocessing not supported */199 case OBJECTS_ERROR:200 return _ITRON_Semaphore_Clarify_get_id_error( semid );201 202 case OBJECTS_LOCAL:203 /*204 * XXX maxsemcnt205 */206 207 status = _CORE_semaphore_Surrender(208 &the_semaphore->semaphore,209 the_semaphore->Object.id,210 NULL /* Multiprocessing not supported */211 );212 _Thread_Enable_dispatch();213 return _ITRON_Semaphore_Translate_core_semaphore_return_code( status );214 }215 return E_OK;216 }217 218 /*219 * wai_sem - Wait on Semaphore220 *221 * This function implements the ITRON 3.0 wai_sem() service.222 */223 224 ER wai_sem(225 ID semid226 )227 {228 return twai_sem( semid, TMO_FEVR );229 }230 231 /*232 * preq_sem - Poll and Request Semaphore233 *234 * This function implements the ITRON 3.0 preq_sem() service.235 */236 237 ER preq_sem(238 ID semid239 )240 {241 return twai_sem( semid, TMO_POL );242 }243 244 /*245 * twai_sem - Wait on Semaphore with Timeout246 *247 * This function implements the ITRON 3.0 twai_sem() service.248 */249 250 ER twai_sem(251 ID semid,252 TMO tmout253 )254 {255 ITRON_Semaphore_Control *the_semaphore;256 Objects_Locations location;257 Watchdog_Interval interval;258 boolean wait;259 CORE_semaphore_Status status;260 261 interval = 0;262 if ( tmout == TMO_POL ) {263 wait = FALSE;264 } else {265 wait = TRUE;266 if ( tmout != TMO_FEVR )267 interval = TOD_MILLISECONDS_TO_TICKS(tmout);268 }269 270 if ( wait && _ITRON_Is_in_non_task_state() )271 return E_CTX;272 273 the_semaphore = _ITRON_Semaphore_Get( semid, &location );274 switch ( location ) {275 case OBJECTS_REMOTE: /* Multiprocessing not supported */276 case OBJECTS_ERROR:277 return _ITRON_Semaphore_Clarify_get_id_error( semid );278 279 case OBJECTS_LOCAL:280 _CORE_semaphore_Seize(281 &the_semaphore->semaphore,282 the_semaphore->Object.id,283 wait, /* wait for a timeout */284 interval /* timeout value */285 );286 _Thread_Enable_dispatch();287 status = (CORE_semaphore_Status) _Thread_Executing->Wait.return_code;288 return _ITRON_Semaphore_Translate_core_semaphore_return_code( status );289 }290 return E_OK;291 }292 293 /*294 * ref_sem - Reference Semaphore Status295 *296 * This function implements the ITRON 3.0 ref_sem() service.297 */298 299 ER ref_sem(300 ID semid,301 T_RSEM *pk_rsem302 )303 {304 ITRON_Semaphore_Control *the_semaphore;305 Objects_Locations location;306 307 if ( !pk_rsem )308 return E_PAR; /* XXX check this error code */309 310 the_semaphore = _ITRON_Semaphore_Get( semid, &location );311 switch ( location ) {312 case OBJECTS_REMOTE: /* Multiprocessing not supported */313 case OBJECTS_ERROR:314 return _ITRON_Semaphore_Clarify_get_id_error( semid );315 316 case OBJECTS_LOCAL:317 /*318 * Fill in the current semaphore count319 */320 321 pk_rsem->semcnt = _CORE_semaphore_Get_count( &the_semaphore->semaphore );322 323 /*324 * Fill in whether or not there is a waiting task325 */326 327 if ( !_Thread_queue_First( &the_semaphore->semaphore.Wait_queue ) )328 pk_rsem->wtsk = FALSE;329 else330 pk_rsem->wtsk = TRUE;331 332 _Thread_Enable_dispatch();333 return E_OK;334 }335 return E_OK;336 }337 -
cpukit/itron/src/itronsem.c
rafb11f8 rfb27af76 52 52 } 53 53 54 /*55 * cre_sem - Create Semaphore56 *57 * This function implements the ITRON 3.0 cre_sem() service.58 */59 60 ER cre_sem(61 ID semid,62 T_CSEM *pk_csem63 )64 {65 CORE_semaphore_Attributes the_semaphore_attributes;66 ITRON_Semaphore_Control *the_semaphore;67 68 /*69 * Bad pointer to the attributes structure70 */71 72 if ( !pk_csem )73 return E_PAR;74 75 /*76 * Bits were set that were note defined.77 */78 79 if ( pk_csem->sematr & _ITRON_SEMAPHORE_UNUSED_ATTRIBUTES )80 return E_RSATR;81 82 /*83 * Initial semaphore count exceeds the maximum.84 */85 86 if ( pk_csem->isemcnt > pk_csem->maxsem )87 return E_PAR;88 89 /*90 * This error is not in the specification but this condition91 * does not make sense.92 */93 94 if ( pk_csem->maxsem == 0 )95 return E_PAR;96 97 _Thread_Disable_dispatch(); /* prevents deletion */98 99 the_semaphore = _ITRON_Semaphore_Allocate( semid );100 if ( !the_semaphore ) {101 _Thread_Enable_dispatch();102 return _ITRON_Semaphore_Clarify_allocation_id_error( semid );103 }104 105 if ( pk_csem->sematr & TA_TPRI )106 the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY;107 else108 the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;109 110 the_semaphore_attributes.maximum_count = pk_csem->maxsem;111 112 _CORE_semaphore_Initialize(113 &the_semaphore->semaphore,114 OBJECTS_ITRON_SEMAPHORES,115 &the_semaphore_attributes,116 pk_csem->isemcnt,117 NULL /* Multiprocessing not supported */118 );119 120 _ITRON_Objects_Open( &_ITRON_Semaphore_Information, &the_semaphore->Object );121 122 /*123 * If multiprocessing were supported, this is where we would announce124 * the existence of the semaphore to the rest of the system.125 */126 127 #if defined(RTEMS_MULTIPROCESSING)128 #endif129 130 _Thread_Enable_dispatch();131 return E_OK;132 }133 134 /*135 * del_sem - Delete Semaphore136 *137 * This function implements the ITRON 3.0 del_sem() service.138 */139 140 ER del_sem(141 ID semid142 )143 {144 ITRON_Semaphore_Control *the_semaphore;145 Objects_Locations location;146 147 the_semaphore = _ITRON_Semaphore_Get( semid, &location );148 switch ( location ) {149 case OBJECTS_REMOTE: /* Multiprocessing not supported */150 case OBJECTS_ERROR:151 return _ITRON_Semaphore_Clarify_get_id_error( semid );152 153 case OBJECTS_LOCAL:154 _CORE_semaphore_Flush(155 &the_semaphore->semaphore,156 NULL, /* Multiprocessing not supported */157 CORE_SEMAPHORE_WAS_DELETED158 );159 160 _ITRON_Objects_Close(161 &_ITRON_Semaphore_Information,162 &the_semaphore->Object163 );164 165 _ITRON_Semaphore_Free( the_semaphore );166 167 /*168 * If multiprocessing were supported, this is where we would announce169 * the destruction of the semaphore to the rest of the system.170 */171 172 #if defined(RTEMS_MULTIPROCESSING)173 #endif174 175 _Thread_Enable_dispatch();176 return E_OK;177 178 }179 return E_OK;180 }181 182 /*183 * sig_sem - Signal Semaphore184 *185 * This function implements the ITRON 3.0 sig_sem() service.186 */187 188 ER sig_sem(189 ID semid190 )191 {192 ITRON_Semaphore_Control *the_semaphore;193 Objects_Locations location;194 CORE_semaphore_Status status;195 196 the_semaphore = _ITRON_Semaphore_Get( semid, &location );197 switch ( location ) {198 case OBJECTS_REMOTE: /* Multiprocessing not supported */199 case OBJECTS_ERROR:200 return _ITRON_Semaphore_Clarify_get_id_error( semid );201 202 case OBJECTS_LOCAL:203 /*204 * XXX maxsemcnt205 */206 207 status = _CORE_semaphore_Surrender(208 &the_semaphore->semaphore,209 the_semaphore->Object.id,210 NULL /* Multiprocessing not supported */211 );212 _Thread_Enable_dispatch();213 return _ITRON_Semaphore_Translate_core_semaphore_return_code( status );214 }215 return E_OK;216 }217 218 /*219 * wai_sem - Wait on Semaphore220 *221 * This function implements the ITRON 3.0 wai_sem() service.222 */223 224 ER wai_sem(225 ID semid226 )227 {228 return twai_sem( semid, TMO_FEVR );229 }230 231 /*232 * preq_sem - Poll and Request Semaphore233 *234 * This function implements the ITRON 3.0 preq_sem() service.235 */236 237 ER preq_sem(238 ID semid239 )240 {241 return twai_sem( semid, TMO_POL );242 }243 244 /*245 * twai_sem - Wait on Semaphore with Timeout246 *247 * This function implements the ITRON 3.0 twai_sem() service.248 */249 250 ER twai_sem(251 ID semid,252 TMO tmout253 )254 {255 ITRON_Semaphore_Control *the_semaphore;256 Objects_Locations location;257 Watchdog_Interval interval;258 boolean wait;259 CORE_semaphore_Status status;260 261 interval = 0;262 if ( tmout == TMO_POL ) {263 wait = FALSE;264 } else {265 wait = TRUE;266 if ( tmout != TMO_FEVR )267 interval = TOD_MILLISECONDS_TO_TICKS(tmout);268 }269 270 if ( wait && _ITRON_Is_in_non_task_state() )271 return E_CTX;272 273 the_semaphore = _ITRON_Semaphore_Get( semid, &location );274 switch ( location ) {275 case OBJECTS_REMOTE: /* Multiprocessing not supported */276 case OBJECTS_ERROR:277 return _ITRON_Semaphore_Clarify_get_id_error( semid );278 279 case OBJECTS_LOCAL:280 _CORE_semaphore_Seize(281 &the_semaphore->semaphore,282 the_semaphore->Object.id,283 wait, /* wait for a timeout */284 interval /* timeout value */285 );286 _Thread_Enable_dispatch();287 status = (CORE_semaphore_Status) _Thread_Executing->Wait.return_code;288 return _ITRON_Semaphore_Translate_core_semaphore_return_code( status );289 }290 return E_OK;291 }292 293 /*294 * ref_sem - Reference Semaphore Status295 *296 * This function implements the ITRON 3.0 ref_sem() service.297 */298 299 ER ref_sem(300 ID semid,301 T_RSEM *pk_rsem302 )303 {304 ITRON_Semaphore_Control *the_semaphore;305 Objects_Locations location;306 307 if ( !pk_rsem )308 return E_PAR; /* XXX check this error code */309 310 the_semaphore = _ITRON_Semaphore_Get( semid, &location );311 switch ( location ) {312 case OBJECTS_REMOTE: /* Multiprocessing not supported */313 case OBJECTS_ERROR:314 return _ITRON_Semaphore_Clarify_get_id_error( semid );315 316 case OBJECTS_LOCAL:317 /*318 * Fill in the current semaphore count319 */320 321 pk_rsem->semcnt = _CORE_semaphore_Get_count( &the_semaphore->semaphore );322 323 /*324 * Fill in whether or not there is a waiting task325 */326 327 if ( !_Thread_queue_First( &the_semaphore->semaphore.Wait_queue ) )328 pk_rsem->wtsk = FALSE;329 else330 pk_rsem->wtsk = TRUE;331 332 _Thread_Enable_dispatch();333 return E_OK;334 }335 return E_OK;336 }337
Note: See TracChangeset
for help on using the changeset viewer.