Lines Matching refs:mbox
160 struct sys_mbox *mbox; in sys_mbox_new() local
163 mbox = (struct sys_mbox *)malloc(sizeof(struct sys_mbox)); in sys_mbox_new()
164 if (mbox == NULL) { in sys_mbox_new()
167 memset(mbox, 0, sizeof(struct sys_mbox)); in sys_mbox_new()
169 mbox->first = mbox->last = 0; in sys_mbox_new()
170 sys_sem_new(&mbox->not_empty, 0); in sys_mbox_new()
171 sys_sem_new(&mbox->not_full, 0); in sys_mbox_new()
172 sys_sem_new(&mbox->mutex, 1); in sys_mbox_new()
173 mbox->wait_send = 0; in sys_mbox_new()
175 *mb = mbox; in sys_mbox_new()
188 struct sys_mbox *mbox = *mb; in sys_mbox_free() local
190 sys_arch_sem_wait(&mbox->mutex, 0); in sys_mbox_free()
192 sys_sem_free(&mbox->not_empty); in sys_mbox_free()
193 sys_sem_free(&mbox->not_full); in sys_mbox_free()
194 sys_sem_free(&mbox->mutex); in sys_mbox_free()
196 free(mbox); in sys_mbox_free()
209 struct sys_mbox *mbox; in sys_mbox_post() local
211 mbox = *mb; in sys_mbox_post()
213 sys_arch_sem_wait(&mbox->mutex, 0); in sys_mbox_post()
215 LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_post: mbox %p msg %p\n", (void *)mbox, (void *)msg)); in sys_mbox_post()
217 while ((mbox->last + 1) >= (mbox->first + SYS_MBOX_SIZE)) { in sys_mbox_post()
218 mbox->wait_send++; in sys_mbox_post()
219 sys_sem_signal(&mbox->mutex); in sys_mbox_post()
220 sys_arch_sem_wait(&mbox->not_full, 0); in sys_mbox_post()
221 sys_arch_sem_wait(&mbox->mutex, 0); in sys_mbox_post()
222 mbox->wait_send--; in sys_mbox_post()
225 mbox->msgs[mbox->last % SYS_MBOX_SIZE] = msg; in sys_mbox_post()
227 if (mbox->last == mbox->first) { in sys_mbox_post()
233 mbox->last++; in sys_mbox_post()
236 sys_sem_signal(&mbox->not_empty); in sys_mbox_post()
239 sys_sem_signal(&mbox->mutex); in sys_mbox_post()
250 struct sys_mbox *mbox; in sys_mbox_trypost() local
252 mbox = *mb; in sys_mbox_trypost()
254 sys_arch_sem_wait(&mbox->mutex, 0); in sys_mbox_trypost()
257 (void *)mbox, (void *)msg)); in sys_mbox_trypost()
259 if ((mbox->last + 1) >= (mbox->first + SYS_MBOX_SIZE)) { in sys_mbox_trypost()
260 sys_sem_signal(&mbox->mutex); in sys_mbox_trypost()
264 mbox->msgs[mbox->last % SYS_MBOX_SIZE] = msg; in sys_mbox_trypost()
266 if (mbox->last == mbox->first) { in sys_mbox_trypost()
272 mbox->last++; in sys_mbox_trypost()
275 sys_sem_signal(&mbox->not_empty); in sys_mbox_trypost()
278 sys_sem_signal(&mbox->mutex); in sys_mbox_trypost()
301 struct sys_mbox *mbox; in sys_arch_mbox_fetch() local
303 mbox = *mb; in sys_arch_mbox_fetch()
307 sys_arch_sem_wait(&mbox->mutex, 0); in sys_arch_mbox_fetch()
309 while (mbox->first == mbox->last) { in sys_arch_mbox_fetch()
310 sys_sem_signal(&mbox->mutex); in sys_arch_mbox_fetch()
315 time_needed = sys_arch_sem_wait(&mbox->not_empty, timeout); in sys_arch_mbox_fetch()
321 sys_arch_sem_wait(&mbox->not_empty, 0); in sys_arch_mbox_fetch()
324 sys_arch_sem_wait(&mbox->mutex, 0); in sys_arch_mbox_fetch()
328 LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p msg %p\n", (void *)mbox, *msg)); in sys_arch_mbox_fetch()
329 *msg = mbox->msgs[mbox->first % SYS_MBOX_SIZE]; in sys_arch_mbox_fetch()
331 LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p, null msg\n", (void *)mbox)); in sys_arch_mbox_fetch()
334 mbox->first++; in sys_arch_mbox_fetch()
336 if (mbox->wait_send) { in sys_arch_mbox_fetch()
337 sys_sem_signal(&mbox->not_full); in sys_arch_mbox_fetch()
340 sys_sem_signal(&mbox->mutex); in sys_arch_mbox_fetch()
353 struct sys_mbox *mbox; in sys_arch_mbox_tryfetch() local
355 mbox = *mb; in sys_arch_mbox_tryfetch()
357 sys_arch_sem_wait(&mbox->mutex, 0); in sys_arch_mbox_tryfetch()
359 if (mbox->first == mbox->last) { in sys_arch_mbox_tryfetch()
360 sys_sem_signal(&mbox->mutex); in sys_arch_mbox_tryfetch()
365 LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_tryfetch: mbox %p msg %p\n", (void *)mbox, *msg)); in sys_arch_mbox_tryfetch()
366 *msg = mbox->msgs[mbox->first % SYS_MBOX_SIZE]; in sys_arch_mbox_tryfetch()
368 LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_tryfetch: mbox %p, null msg\n", (void *)mbox)); in sys_arch_mbox_tryfetch()
371 mbox->first++; in sys_arch_mbox_tryfetch()
373 if (mbox->wait_send) { in sys_arch_mbox_tryfetch()
374 sys_sem_signal(&mbox->not_full); in sys_arch_mbox_tryfetch()
377 sys_sem_signal(&mbox->mutex); in sys_arch_mbox_tryfetch()