Changeset 82d56184 in mainline for uspace/lib/c/generic/adt/prodcons.c
- Timestamp:
- 2011-06-01T21:05:19Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5cac9cd
- Parents:
- 682cfceb (diff), 5d1b3aa (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/prodcons.c
r682cfceb r82d56184 1 1 /* 2 * Copyright (c) 20 09Martin Decky2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #include <test.h> 29 /** @addtogroup libc 30 * @{ 31 */ 32 /** @file 33 */ 30 34 31 const char *test_fpu1(void) 35 #include <adt/prodcons.h> 36 #include <adt/list.h> 37 #include <fibril_synch.h> 38 39 void prodcons_initialize(prodcons_t *pc) 32 40 { 33 return NULL; 41 list_initialize(&pc->list); 42 fibril_mutex_initialize(&pc->mtx); 43 fibril_condvar_initialize(&pc->cv); 34 44 } 45 46 void prodcons_produce(prodcons_t *pc, link_t *item) 47 { 48 fibril_mutex_lock(&pc->mtx); 49 50 list_append(item, &pc->list); 51 fibril_condvar_signal(&pc->cv); 52 53 fibril_mutex_unlock(&pc->mtx); 54 } 55 56 link_t *prodcons_consume(prodcons_t *pc) 57 { 58 fibril_mutex_lock(&pc->mtx); 59 60 while (list_empty(&pc->list)) 61 fibril_condvar_wait(&pc->cv, &pc->mtx); 62 63 link_t *head = pc->list.next; 64 list_remove(head); 65 66 fibril_mutex_unlock(&pc->mtx); 67 68 return head; 69 } 70 71 /** @} 72 */
Note:
See TracChangeset
for help on using the changeset viewer.