• Home
  • Raw
  • Download

Lines Matching refs:cond

45 STATIC INLINE INT32 CondInitCheck(const pthread_cond_t *cond)  in CondInitCheck()  argument
47 if ((cond->event.stEventList.pstPrev == NULL) && in CondInitCheck()
48 (cond->event.stEventList.pstNext == NULL)) { in CondInitCheck()
97 int pthread_cond_destroy(pthread_cond_t *cond) in pthread_cond_destroy() argument
99 if (cond == NULL) { in pthread_cond_destroy()
103 if (CondInitCheck(cond)) { in pthread_cond_destroy()
107 if (LOS_EventDestroy(&cond->event) != LOS_OK) { in pthread_cond_destroy()
110 if (pthread_mutex_destroy(cond->mutex) != ENOERR) { in pthread_cond_destroy()
114 free(cond->mutex); in pthread_cond_destroy()
115 cond->mutex = NULL; in pthread_cond_destroy()
119 int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) in pthread_cond_init() argument
123 if (cond == NULL) { in pthread_cond_init()
127 (VOID)LOS_EventInit(&(cond->event)); in pthread_cond_init()
129 cond->mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); in pthread_cond_init()
130 if (cond->mutex == NULL) { in pthread_cond_init()
134 (VOID)pthread_mutex_init(cond->mutex, NULL); in pthread_cond_init()
136 cond->value = 0; in pthread_cond_init()
137 (VOID)pthread_mutex_lock(cond->mutex); in pthread_cond_init()
138 cond->count = 0; in pthread_cond_init()
139 (VOID)pthread_mutex_unlock(cond->mutex); in pthread_cond_init()
144 STATIC VOID PthreadCondValueModify(pthread_cond_t *cond) in PthreadCondValueModify() argument
146 UINT32 flags = ((UINT32)cond->value & COND_FLAGS_MASK); in PthreadCondValueModify()
150 oldVal = cond->value; in PthreadCondValueModify()
152 if (LOS_AtomicCmpXchg32bits(&cond->value, newVal, oldVal) == 0) { in PthreadCondValueModify()
158 int pthread_cond_broadcast(pthread_cond_t *cond) in pthread_cond_broadcast() argument
162 if (cond == NULL) { in pthread_cond_broadcast()
166 (VOID)pthread_mutex_lock(cond->mutex); in pthread_cond_broadcast()
167 if (cond->count > 0) { in pthread_cond_broadcast()
168 cond->count = 0; in pthread_cond_broadcast()
169 (VOID)pthread_mutex_unlock(cond->mutex); in pthread_cond_broadcast()
171 PthreadCondValueModify(cond); in pthread_cond_broadcast()
173 (VOID)LOS_EventWrite(&(cond->event), BROADCAST_EVENT); in pthread_cond_broadcast()
176 (VOID)pthread_mutex_unlock(cond->mutex); in pthread_cond_broadcast()
181 int pthread_cond_signal(pthread_cond_t *cond) in pthread_cond_signal() argument
185 if (cond == NULL) { in pthread_cond_signal()
189 (VOID)pthread_mutex_lock(cond->mutex); in pthread_cond_signal()
190 if (cond->count > 0) { in pthread_cond_signal()
191 cond->count--; in pthread_cond_signal()
192 (VOID)pthread_mutex_unlock(cond->mutex); in pthread_cond_signal()
193 PthreadCondValueModify(cond); in pthread_cond_signal()
194 (VOID)OsEventWriteOnce(&(cond->event), 0x01); in pthread_cond_signal()
198 (VOID)pthread_mutex_unlock(cond->mutex); in pthread_cond_signal()
203 STATIC INT32 PthreadCondWaitSub(pthread_cond_t *cond, INT32 value, UINT32 ticks) in PthreadCondWaitSub() argument
205 EventCond eventCond = { &cond->value, value, ~0x01U }; in PthreadCondWaitSub()
216 return (int)OsEventReadWithCond(&eventCond, &(cond->event), 0x0fU, in PthreadCondWaitSub()
219 STATIC VOID PthreadCountSub(pthread_cond_t *cond) in PthreadCountSub() argument
221 (VOID)pthread_mutex_lock(cond->mutex); in PthreadCountSub()
222 if (cond->count > 0) { in PthreadCountSub()
223 cond->count--; in PthreadCountSub()
225 (VOID)pthread_mutex_unlock(cond->mutex); in PthreadCountSub()
228 STATIC INT32 ProcessReturnVal(pthread_cond_t *cond, INT32 val) in ProcessReturnVal() argument
238 PthreadCountSub(cond); in ProcessReturnVal()
242 PthreadCountSub(cond); in ProcessReturnVal()
249 int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, in pthread_cond_timedwait() argument
257 if ((cond == NULL) || (mutex == NULL) || (absTime == NULL)) { in pthread_cond_timedwait()
261 if (CondInitCheck(cond)) { in pthread_cond_timedwait()
262 ret = pthread_cond_init(cond, NULL); in pthread_cond_timedwait()
267 oldValue = cond->value; in pthread_cond_timedwait()
269 (VOID)pthread_mutex_lock(cond->mutex); in pthread_cond_timedwait()
270 cond->count++; in pthread_cond_timedwait()
271 (VOID)pthread_mutex_unlock(cond->mutex); in pthread_cond_timedwait()
287 ret = PthreadCondWaitSub(cond, oldValue, absTicks); in pthread_cond_timedwait()
289 ret = (INT32)LOS_EventRead(&(cond->event), 0x0f, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, absTicks); in pthread_cond_timedwait()
295 ret = ProcessReturnVal(cond, ret); in pthread_cond_timedwait()
300 int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) in pthread_cond_wait() argument
305 if ((cond == NULL) || (mutex == NULL)) { in pthread_cond_wait()
309 if (CondInitCheck(cond)) { in pthread_cond_wait()
310 ret = pthread_cond_init(cond, NULL); in pthread_cond_wait()
315 oldValue = cond->value; in pthread_cond_wait()
317 (VOID)pthread_mutex_lock(cond->mutex); in pthread_cond_wait()
318 cond->count++; in pthread_cond_wait()
319 (VOID)pthread_mutex_unlock(cond->mutex); in pthread_cond_wait()
326 ret = PthreadCondWaitSub(cond, oldValue, LOS_WAIT_FOREVER); in pthread_cond_wait()
328 …ret = (INT32)LOS_EventRead(&(cond->event), 0x0f, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FORE… in pthread_cond_wait()
341 PthreadCountSub(cond); in pthread_cond_wait()