Changeset 95838f1 in mainline for uspace/lib/c/generic/fibril_synch.c
- Timestamp:
- 2018-06-25T21:45:15Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 38e3427
- Parents:
- 3679f51a
- git-author:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-25 20:58:01)
- git-committer:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-25 21:45:15)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/fibril_synch.c
r3679f51a r95838f1 106 106 fibril_t *f = (fibril_t *) fibril_get_id(); 107 107 108 futex_ down(&async_futex);108 futex_lock(&async_futex); 109 109 if (fm->counter-- <= 0) { 110 110 awaiter_t wdata; … … 119 119 } else { 120 120 fm->oi.owned_by = f; 121 futex_u p(&async_futex);121 futex_unlock(&async_futex); 122 122 } 123 123 } … … 127 127 bool locked = false; 128 128 129 futex_ down(&async_futex);129 futex_lock(&async_futex); 130 130 if (fm->counter > 0) { 131 131 fm->counter--; … … 133 133 locked = true; 134 134 } 135 futex_u p(&async_futex);135 futex_unlock(&async_futex); 136 136 137 137 return locked; … … 166 166 { 167 167 assert(fibril_mutex_is_locked(fm)); 168 futex_ down(&async_futex);168 futex_lock(&async_futex); 169 169 _fibril_mutex_unlock_unsafe(fm); 170 futex_u p(&async_futex);170 futex_unlock(&async_futex); 171 171 } 172 172 … … 175 175 bool locked = false; 176 176 177 futex_ down(&async_futex);177 futex_lock(&async_futex); 178 178 if (fm->counter <= 0) 179 179 locked = true; 180 futex_u p(&async_futex);180 futex_unlock(&async_futex); 181 181 182 182 return locked; … … 195 195 fibril_t *f = (fibril_t *) fibril_get_id(); 196 196 197 futex_ down(&async_futex);197 futex_lock(&async_futex); 198 198 if (frw->writers) { 199 199 awaiter_t wdata; … … 211 211 if (frw->readers++ == 0) 212 212 frw->oi.owned_by = f; 213 futex_u p(&async_futex);213 futex_unlock(&async_futex); 214 214 } 215 215 } … … 219 219 fibril_t *f = (fibril_t *) fibril_get_id(); 220 220 221 futex_ down(&async_futex);221 futex_lock(&async_futex); 222 222 if (frw->writers || frw->readers) { 223 223 awaiter_t wdata; … … 234 234 frw->oi.owned_by = f; 235 235 frw->writers++; 236 futex_u p(&async_futex);236 futex_unlock(&async_futex); 237 237 } 238 238 } … … 240 240 static void _fibril_rwlock_common_unlock(fibril_rwlock_t *frw) 241 241 { 242 futex_ down(&async_futex);242 futex_lock(&async_futex); 243 243 if (frw->readers) { 244 244 if (--frw->readers) { … … 301 301 } 302 302 out: 303 futex_u p(&async_futex);303 futex_unlock(&async_futex); 304 304 } 305 305 … … 320 320 bool locked = false; 321 321 322 futex_ down(&async_futex);322 futex_lock(&async_futex); 323 323 if (frw->readers) 324 324 locked = true; 325 futex_u p(&async_futex);325 futex_unlock(&async_futex); 326 326 327 327 return locked; … … 332 332 bool locked = false; 333 333 334 futex_ down(&async_futex);334 futex_lock(&async_futex); 335 335 if (frw->writers) { 336 336 assert(frw->writers == 1); 337 337 locked = true; 338 338 } 339 futex_u p(&async_futex);339 futex_unlock(&async_futex); 340 340 341 341 return locked; … … 369 369 wdata.wu_event.inlist = true; 370 370 371 futex_ down(&async_futex);371 futex_lock(&async_futex); 372 372 if (timeout) { 373 373 getuptime(&wdata.to_event.expires); … … 381 381 382 382 /* async_futex not held after fibril_switch() */ 383 futex_ down(&async_futex);383 futex_lock(&async_futex); 384 384 if (wdata.to_event.inlist) 385 385 list_remove(&wdata.to_event.link); 386 386 if (wdata.wu_event.inlist) 387 387 list_remove(&wdata.wu_event.link); 388 futex_u p(&async_futex);388 futex_unlock(&async_futex); 389 389 390 390 return wdata.to_event.occurred ? ETIMEOUT : EOK; … … 404 404 awaiter_t *wdp; 405 405 406 futex_ down(&async_futex);406 futex_lock(&async_futex); 407 407 while (!list_empty(&fcv->waiters)) { 408 408 tmp = list_first(&fcv->waiters); … … 418 418 } 419 419 } 420 futex_u p(&async_futex);420 futex_unlock(&async_futex); 421 421 } 422 422 … … 657 657 void fibril_semaphore_up(fibril_semaphore_t *sem) 658 658 { 659 futex_ down(&async_futex);659 futex_lock(&async_futex); 660 660 sem->count++; 661 661 662 662 if (sem->count > 0) { 663 futex_u p(&async_futex);663 futex_unlock(&async_futex); 664 664 return; 665 665 } … … 669 669 list_remove(tmp); 670 670 671 futex_u p(&async_futex);671 futex_unlock(&async_futex); 672 672 673 673 awaiter_t *wdp = list_get_instance(tmp, awaiter_t, wu_event.link); … … 685 685 void fibril_semaphore_down(fibril_semaphore_t *sem) 686 686 { 687 futex_ down(&async_futex);687 futex_lock(&async_futex); 688 688 sem->count--; 689 689 690 690 if (sem->count >= 0) { 691 futex_u p(&async_futex);691 futex_unlock(&async_futex); 692 692 return; 693 693 }
Note:
See TracChangeset
for help on using the changeset viewer.