Changeset 95838f1 in mainline
- Timestamp:
- 2018-06-25T21:45:15Z (7 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)
- Location:
- uspace/lib/c/generic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async/client.c
r3679f51a r95838f1 243 243 assert(arg); 244 244 245 futex_ down(&async_futex);245 futex_lock(&async_futex); 246 246 247 247 amsg_t *msg = (amsg_t *) arg; … … 268 268 } 269 269 270 futex_u p(&async_futex);270 futex_unlock(&async_futex); 271 271 } 272 272 … … 357 357 amsg_t *msg = (amsg_t *) amsgid; 358 358 359 futex_ down(&async_futex);359 futex_lock(&async_futex); 360 360 361 361 assert(!msg->forget); … … 363 363 364 364 if (msg->done) { 365 futex_u p(&async_futex);365 futex_unlock(&async_futex); 366 366 goto done; 367 367 } … … 403 403 amsg_t *msg = (amsg_t *) amsgid; 404 404 405 futex_ down(&async_futex);405 futex_lock(&async_futex); 406 406 407 407 assert(!msg->forget); … … 409 409 410 410 if (msg->done) { 411 futex_u p(&async_futex);411 futex_unlock(&async_futex); 412 412 goto done; 413 413 } … … 477 477 assert(!msg->destroyed); 478 478 479 futex_ down(&async_futex);479 futex_lock(&async_futex); 480 480 481 481 if (msg->done) { … … 486 486 } 487 487 488 futex_u p(&async_futex);488 futex_unlock(&async_futex); 489 489 } 490 490 … … 506 506 tv_add_diff(&awaiter.to_event.expires, timeout); 507 507 508 futex_ down(&async_futex);508 futex_lock(&async_futex); 509 509 510 510 async_insert_timeout(&awaiter); -
uspace/lib/c/generic/async/server.c
r3679f51a r95838f1 432 432 * Remove myself from the connection hash table. 433 433 */ 434 futex_ down(&async_futex);434 futex_lock(&async_futex); 435 435 hash_table_remove(&conn_hash_table, &(conn_key_t){ 436 436 .task_id = fibril_connection->in_task_id, 437 437 .phone_hash = fibril_connection->in_phone_hash 438 438 }); 439 futex_u p(&async_futex);439 futex_unlock(&async_futex); 440 440 441 441 /* … … 520 520 /* Add connection to the connection hash table */ 521 521 522 futex_ down(&async_futex);522 futex_lock(&async_futex); 523 523 hash_table_insert(&conn_hash_table, &conn->link); 524 futex_u p(&async_futex);524 futex_unlock(&async_futex); 525 525 526 526 fibril_add_ready(conn->wdata.fid); … … 648 648 assert(call); 649 649 650 futex_ down(&async_futex);650 futex_lock(&async_futex); 651 651 652 652 ht_link_t *link = hash_table_find(&conn_hash_table, &(conn_key_t){ … … 655 655 }); 656 656 if (!link) { 657 futex_u p(&async_futex);657 futex_unlock(&async_futex); 658 658 return false; 659 659 } … … 663 663 msg_t *msg = malloc(sizeof(*msg)); 664 664 if (!msg) { 665 futex_u p(&async_futex);665 futex_unlock(&async_futex); 666 666 return false; 667 667 } … … 687 687 } 688 688 689 futex_u p(&async_futex);689 futex_unlock(&async_futex); 690 690 return true; 691 691 } … … 962 962 connection_t *conn = fibril_connection; 963 963 964 futex_ down(&async_futex);964 futex_lock(&async_futex); 965 965 966 966 if (usecs) { … … 982 982 memset(call, 0, sizeof(ipc_call_t)); 983 983 IPC_SET_IMETHOD(*call, IPC_M_PHONE_HUNGUP); 984 futex_u p(&async_futex);984 futex_unlock(&async_futex); 985 985 return conn->close_chandle; 986 986 } … … 1003 1003 * Get it again. 1004 1004 */ 1005 futex_ down(&async_futex);1005 futex_lock(&async_futex); 1006 1006 if ((usecs) && (conn->wdata.to_event.occurred) && 1007 1007 (list_empty(&conn->msg_queue))) { 1008 1008 /* If we timed out -> exit */ 1009 futex_u p(&async_futex);1009 futex_unlock(&async_futex); 1010 1010 return CAP_NIL; 1011 1011 } … … 1020 1020 free(msg); 1021 1021 1022 futex_u p(&async_futex);1022 futex_unlock(&async_futex); 1023 1023 return chandle; 1024 1024 } … … 1106 1106 getuptime(&tv); 1107 1107 1108 futex_ down(&async_futex);1108 futex_lock(&async_futex); 1109 1109 1110 1110 link_t *cur = list_first(&timeout_list); … … 1132 1132 } 1133 1133 1134 futex_u p(&async_futex);1134 futex_unlock(&async_futex); 1135 1135 } 1136 1136 … … 1144 1144 while (true) { 1145 1145 if (fibril_switch(FIBRIL_FROM_MANAGER)) { 1146 futex_u p(&async_futex);1146 futex_unlock(&async_futex); 1147 1147 /* 1148 1148 * async_futex is always held when entering a manager … … 1152 1152 } 1153 1153 1154 futex_ down(&async_futex);1154 futex_lock(&async_futex); 1155 1155 1156 1156 suseconds_t timeout; … … 1164 1164 1165 1165 if (tv_gteq(&tv, &waiter->to_event.expires)) { 1166 futex_u p(&async_futex);1166 futex_unlock(&async_futex); 1167 1167 handle_expired_timeouts(); 1168 1168 /* … … 1182 1182 timeout = tv_sub_diff(&waiter->to_event.expires, 1183 1183 &tv); 1184 futex_u p(&async_futex);1184 futex_unlock(&async_futex); 1185 1185 } 1186 1186 } else { 1187 futex_u p(&async_futex);1187 futex_unlock(&async_futex); 1188 1188 timeout = SYNCH_NO_TIMEOUT; 1189 1189 } … … 1226 1226 static errno_t async_manager_fibril(void *arg) 1227 1227 { 1228 futex_u p(&async_futex);1228 futex_unlock(&async_futex); 1229 1229 1230 1230 /* … … 1887 1887 _Noreturn void async_manager(void) 1888 1888 { 1889 futex_ down(&async_futex);1889 futex_lock(&async_futex); 1890 1890 fibril_switch(FIBRIL_FROM_DEAD); 1891 1891 __builtin_unreachable(); -
uspace/lib/c/generic/fibril.c
r3679f51a r95838f1 79 79 fibril->retval = fibril->func(fibril->arg); 80 80 81 futex_ down(&async_futex);81 futex_lock(&async_futex); 82 82 fibril_switch(FIBRIL_FROM_DEAD); 83 83 /* Not reached */ -
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.