Changeset 3ede440 in mainline
- Timestamp:
- 2019-02-01T22:30:53Z (6 years ago)
- Parents:
- 1a37496
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-01 22:12:04)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-01 22:30:53)
- Location:
- uspace/lib/c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/thread/fibril_synch.c
r1a37496 r3ede440 165 165 { 166 166 fm->oi.owned_by = NULL; 167 fm->counter = 1;167 fm->counter = 0; 168 168 list_initialize(&fm->waiters); 169 169 } … … 175 175 futex_lock(&fibril_synch_futex); 176 176 177 if (fm->counter-- > 0) { 177 fm->counter++; 178 179 if (fm->counter == 1) { 180 /* I am the only one here. */ 178 181 fm->oi.owned_by = f; 179 182 futex_unlock(&fibril_synch_futex); … … 196 199 197 200 futex_lock(&fibril_synch_futex); 198 if (fm->counter >0) {199 fm->counter --;201 if (fm->counter == 0) { 202 fm->counter++; 200 203 fm->oi.owned_by = (fibril_t *) fibril_get_id(); 201 204 locked = true; … … 209 212 { 210 213 assert(fm->oi.owned_by == (fibril_t *) fibril_get_id()); 211 212 if (fm->counter++ < 0) { 214 assert(fm->counter > 0); 215 216 fm->counter--; 217 218 if (fm->counter > 0) { 213 219 awaiter_t *wdp = list_pop(&fm->waiters, awaiter_t, link); 214 220 assert(wdp); -
uspace/lib/c/include/fibril_synch.h
r1a37496 r3ede440 44 44 typedef struct { 45 45 fibril_owner_info_t oi; /**< Keep this the first thing. */ 46 int counter; 46 int counter; /**< # of fibrils currently waiting for or running in the critical section. */ 47 47 list_t waiters; 48 48 } fibril_mutex_t; … … 53 53 .owned_by = NULL \ 54 54 }, \ 55 .counter = 1, \55 .counter = 0, \ 56 56 .waiters = LIST_INITIALIZER((name).waiters), \ 57 57 }
Note:
See TracChangeset
for help on using the changeset viewer.