IP_FASTTEXT IP_PUBLIC void ipcom_spinlock_lock(Ipcom_spinlock sl_handle) { #ifdef IPCOM_USE_SMP Ipcom_vxworks_spinlock_t *sl = (Ipcom_vxworks_spinlock_t*) sl_handle; #ifdef IPCOM_SPINLOCK_BUSY_PERSIST int i; atomicVal_t count; try_again: if (vxCas(&sl->count, 1, 0)) goto got_it; for (i = IPCOM_SPINLOCK_BUSY_PERSIST; i > 0; --i) { count = vxAtomicGet(&sl->count); if (count < 0) break; if (count == 1) goto try_again; } #endif /* IPCOM_SPINLOCK_BUSY_PERSIST */ if (vxAtomicDec(&sl->count) <= 0) /* Contention for this lock, let's sleep until the lock gets available */ semTake(sl->sem, WAIT_FOREVER); else { #ifdef IPCOM_SPINLOCK_BUSY_PERSIST got_it: #endif /* prevent load/store re-ordering beyond this point */ VX_MEM_BARRIER_RW(); } #else IPCOM_UNUSED_ARG(sl_handle); ip_assert(sl_handle == IPCOM_SPINLOCK_TAG); taskLock(); #endif }
void os_osExit ( void) { os_uint32 initCount; #ifndef NDEBUG OS_REPORT(OS_INFO, "os__reallocdoublecopycount", 0, "count=%d", vxAtomicGet(&os__reallocdoublecopycount)); #endif initCount = pa_dec32_nv(&_ospl_osInitCount); if (initCount == 0) { os_sharedMemoryExit(); os_reportExit(); os_threadModuleExit(); } else if ((initCount + 1) < initCount){ /* The 0 boundary is passed, so os_osExit is called more often than * os_osInit. Therefore undo decrement as nothing happened and warn. */ initCount = pa_inc32_nv(&_ospl_osInitCount); OS_REPORT(OS_WARNING, "os_osExit", 1, "OS-layer not initialized"); /* Fail in case of DEV, as it is incorrect API usage */ assert(0); } return; }