Changeset 9bde0d5 in mainline for uspace/lib/c/generic/async
- Timestamp:
- 2018-07-18T19:56:43Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 42f5860
- Parents:
- 40abf56a
- git-author:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-18 19:47:28)
- git-committer:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-18 19:56:43)
- Location:
- uspace/lib/c/generic/async
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async/ports.c
r40abf56a r9bde0d5 99 99 100 100 /** Futex guarding the interface hash table. */ 101 static futex_t interface_futex = FUTEX_INITIALIZER;101 static FIBRIL_RMUTEX_INITIALIZE(interface_mutex); 102 102 static hash_table_t interface_hash_table; 103 103 … … 205 205 interface_t *interface; 206 206 207 f utex_lock(&interface_futex);207 fibril_rmutex_lock(&interface_mutex); 208 208 209 209 ht_link_t *link = hash_table_find(&interface_hash_table, &iface); … … 214 214 215 215 if (!interface) { 216 f utex_unlock(&interface_futex);216 fibril_rmutex_unlock(&interface_mutex); 217 217 return ENOMEM; 218 218 } … … 220 220 port_t *port = async_new_port(interface, handler, data); 221 221 if (!port) { 222 f utex_unlock(&interface_futex);222 fibril_rmutex_unlock(&interface_mutex); 223 223 return ENOMEM; 224 224 } … … 226 226 *port_id = port->id; 227 227 228 f utex_unlock(&interface_futex);228 fibril_rmutex_unlock(&interface_mutex); 229 229 230 230 return EOK; … … 252 252 port_t *port = NULL; 253 253 254 f utex_lock(&interface_futex);254 fibril_rmutex_lock(&interface_mutex); 255 255 256 256 ht_link_t *link = hash_table_find(&interface_hash_table, &iface); … … 264 264 } 265 265 266 f utex_unlock(&interface_futex);266 fibril_rmutex_unlock(&interface_mutex); 267 267 268 268 return port; -
uspace/lib/c/generic/async/server.c
r40abf56a r9bde0d5 234 234 } 235 235 236 static futex_t client_futex = FUTEX_INITIALIZER;236 static FIBRIL_RMUTEX_INITIALIZE(client_mutex); 237 237 static hash_table_t client_hash_table; 238 238 239 239 // TODO: lockfree notification_queue? 240 static futex_t notification_futex = FUTEX_INITIALIZER;240 static FIBRIL_RMUTEX_INITIALIZE(notification_mutex); 241 241 static hash_table_t notification_hash_table; 242 242 static LIST_INITIALIZE(notification_queue); … … 339 339 client_t *client = NULL; 340 340 341 f utex_lock(&client_futex);341 fibril_rmutex_lock(&client_mutex); 342 342 ht_link_t *link = hash_table_find(&client_hash_table, &client_id); 343 343 if (link) { … … 346 346 } else if (create) { 347 347 // TODO: move the malloc out of critical section 348 /* malloc() is rmutex safe. */ 348 349 client = malloc(sizeof(client_t)); 349 350 if (client) { … … 356 357 } 357 358 358 f utex_unlock(&client_futex);359 fibril_rmutex_unlock(&client_mutex); 359 360 return client; 360 361 } … … 364 365 bool destroy; 365 366 366 f utex_lock(&client_futex);367 fibril_rmutex_lock(&client_mutex); 367 368 368 369 if (atomic_predec(&client->refcnt) == 0) { … … 372 373 destroy = false; 373 374 374 f utex_unlock(&client_futex);375 fibril_rmutex_unlock(&client_mutex); 375 376 376 377 if (destroy) { … … 693 694 fibril_semaphore_down(¬ification_semaphore); 694 695 695 f utex_lock(¬ification_futex);696 fibril_rmutex_lock(¬ification_mutex); 696 697 697 698 /* … … 727 728 list_remove(¬ification->qlink); 728 729 729 f utex_unlock(¬ification_futex);730 fibril_rmutex_unlock(¬ification_mutex); 730 731 731 732 if (handler) … … 766 767 assert(call); 767 768 768 f utex_lock(¬ification_futex);769 fibril_rmutex_lock(¬ification_mutex); 769 770 770 771 notification_msg_t *m = list_pop(¬ification_freelist, … … 772 773 773 774 if (!m) { 774 f utex_unlock(¬ification_futex);775 fibril_rmutex_unlock(¬ification_mutex); 775 776 m = malloc(sizeof(notification_msg_t)); 776 777 if (!m) { … … 779 780 } 780 781 781 f utex_lock(¬ification_futex);782 fibril_rmutex_lock(¬ification_mutex); 782 783 notification_freelist_total++; 783 784 } … … 789 790 // TODO: Make sure this can't happen and turn it into assert. 790 791 notification_freelist_total--; 791 f utex_unlock(¬ification_futex);792 fibril_rmutex_unlock(¬ification_mutex); 792 793 free(m); 793 794 return; … … 804 805 list_append(¬ification->qlink, ¬ification_queue); 805 806 806 f utex_unlock(¬ification_futex);807 fibril_rmutex_unlock(¬ification_mutex); 807 808 808 809 fibril_semaphore_up(¬ification_semaphore); … … 829 830 fid_t fib = 0; 830 831 831 f utex_lock(¬ification_futex);832 fibril_rmutex_lock(¬ification_mutex); 832 833 833 834 if (notification_avail == 0) { … … 835 836 fib = fibril_create(notification_fibril_func, NULL); 836 837 if (fib == 0) { 837 f utex_unlock(¬ification_futex);838 fibril_rmutex_unlock(¬ification_mutex); 838 839 free(notification); 839 840 return NULL; … … 847 848 hash_table_insert(¬ification_hash_table, ¬ification->htlink); 848 849 849 f utex_unlock(¬ification_futex);850 fibril_rmutex_unlock(¬ification_mutex); 850 851 851 852 if (imethod == 0) {
Note:
See TracChangeset
for help on using the changeset viewer.