Changeset c170438 in mainline
- Timestamp:
- 2016-05-24T21:00:37Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2a7ba5e
- Parents:
- f570cdf
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/i8042/main.c
rf570cdf rc170438 43 43 #include <ddf/log.h> 44 44 #include <stdio.h> 45 #include <async.h>46 45 #include "i8042.h" 47 46 … … 152 151 ddf_log_init(NAME); 153 152 154 /*155 * Alleviate the virtual memory / page table pressure caused by156 * interrupt storms when the default large stacks are used.157 */158 async_set_notification_handler_stack_size(PAGE_SIZE);159 160 153 return ddf_driver_main(&i8042_driver); 161 154 } -
uspace/lib/c/generic/async.c
rf570cdf rc170438 493 493 } 494 494 495 static size_t notification_handler_stksz = FIBRIL_DFLT_STK_SIZE;496 497 /** Set the stack size for the notification handler notification fibrils.498 *499 * @param size Stack size in bytes.500 */501 void async_set_notification_handler_stack_size(size_t size)502 {503 notification_handler_stksz = size;504 }505 506 495 /** Mutex protecting inactive_exch_list and avail_phone_cv. 507 496 * … … 998 987 } 999 988 1000 /** Notification fibril. 1001 * 1002 * When a notification arrives, a fibril with this implementing function is 1003 * created. It calls the corresponding notification handler and does the final 1004 * cleanup. 1005 * 1006 * @param arg Message structure pointer. 1007 * 1008 * @return Always zero. 1009 * 1010 */ 1011 static int notification_fibril(void *arg) 1012 { 1013 assert(arg); 1014 1015 msg_t *msg = (msg_t *) arg; 989 /** Process notification. 990 * 991 * @param callid Hash of the incoming call. 992 * @param call Data of the incoming call. 993 */ 994 static void process_notification(ipc_callid_t callid, ipc_call_t *call) 995 { 1016 996 async_notification_handler_t handler = NULL; 1017 997 void *data = NULL; 998 999 assert(call); 1018 1000 1019 1001 futex_down(&async_futex); 1020 1002 1021 1003 ht_link_t *link = hash_table_find(¬ification_hash_table, 1022 &IPC_GET_IMETHOD( msg->call));1004 &IPC_GET_IMETHOD(*call)); 1023 1005 if (link) { 1024 1006 notification_t *notification = … … 1031 1013 1032 1014 if (handler) 1033 handler(msg->callid, &msg->call, data); 1034 1035 free(msg); 1036 return 0; 1037 } 1038 1039 /** Process notification. 1040 * 1041 * A new fibril is created which would process the notification. 1042 * 1043 * @param callid Hash of the incoming call. 1044 * @param call Data of the incoming call. 1045 * 1046 * @return False if an error occured. 1047 * True if the call was passed to the notification fibril. 1048 * 1049 */ 1050 static bool process_notification(ipc_callid_t callid, ipc_call_t *call) 1051 { 1052 assert(call); 1053 1054 futex_down(&async_futex); 1055 1056 msg_t *msg = malloc(sizeof(*msg)); 1057 if (!msg) { 1058 futex_up(&async_futex); 1059 return false; 1060 } 1061 1062 msg->callid = callid; 1063 msg->call = *call; 1064 1065 fid_t fid = fibril_create_generic(notification_fibril, msg, 1066 notification_handler_stksz); 1067 if (fid == 0) { 1068 free(msg); 1069 futex_up(&async_futex); 1070 return false; 1071 } 1072 1073 fibril_add_ready(fid); 1074 1075 futex_up(&async_futex); 1076 return true; 1015 handler(callid, call, data); 1077 1016 } 1078 1017 … … 1375 1314 /* Kernel notification */ 1376 1315 if ((callid & IPC_CALLID_NOTIFICATION)) { 1316 fibril_t *fibril = (fibril_t *) __tcb_get()->fibril_data; 1317 unsigned oldsw = fibril->switches; 1318 1377 1319 process_notification(callid, call); 1320 1321 if (oldsw != fibril->switches) { 1322 /* 1323 * The notification handler did not execute atomically 1324 * and so the current manager fibril assumed the role of 1325 * a notification fibril. While waiting for its 1326 * resources, it switched to another manager fibril that 1327 * had already existed or it created a new one. We 1328 * therefore know there is at least yet another 1329 * manager fibril that can take over. We now kill the 1330 * current 'notification' fibril to prevent fibril 1331 * population explosion. 1332 */ 1333 futex_down(&async_futex); 1334 fibril_switch(FIBRIL_FROM_DEAD); 1335 } 1378 1336 return; 1379 1337 } … … 1550 1508 void async_create_manager(void) 1551 1509 { 1552 fid_t fid = fibril_create (async_manager_fibril, NULL);1510 fid_t fid = fibril_create_generic(async_manager_fibril, NULL, PAGE_SIZE); 1553 1511 if (fid != 0) 1554 1512 fibril_add_manager(fid); -
uspace/lib/c/generic/fibril.c
rf570cdf rc170438 113 113 114 114 fibril->waits_for = NULL; 115 116 fibril->switches = 0; 115 117 116 118 /* … … 216 218 assert(stype == FIBRIL_TO_MANAGER); 217 219 220 srcf->switches++; 221 218 222 /* 219 223 * Don't put the current fibril into any list, it should -
uspace/lib/c/generic/ipc.c
rf570cdf rc170438 96 96 } 97 97 98 /** Prolog for ipc_call_async_*() functions.98 /** Prologue for ipc_call_async_*() functions. 99 99 * 100 100 * @param private Argument for the answer/error callback. … … 122 122 } 123 123 124 /** Epilog for ipc_call_async_*() functions.124 /** Epilogue for ipc_call_async_*() functions. 125 125 * 126 126 * @param callid Value returned by the SYS_IPC_CALL_ASYNC_* syscall. -
uspace/lib/c/include/async.h
rf570cdf rc170438 165 165 extern int async_create_callback_port(async_exch_t *, iface_t, sysarg_t, 166 166 sysarg_t, async_port_handler_t, void *, port_id_t *); 167 168 extern void async_set_notification_handler_stack_size(size_t);169 167 170 168 extern int async_irq_subscribe(int, int, async_notification_handler_t, void *, -
uspace/lib/c/include/fibril.h
rf570cdf rc170438 78 78 79 79 fibril_owner_info_t *waits_for; 80 81 unsigned switches; 80 82 } fibril_t; 81 83 -
uspace/srv/hw/bus/cuda_adb/cuda_adb.c
rf570cdf rc170438 47 47 #include <errno.h> 48 48 #include <ipc/adb.h> 49 #include <async.h>50 49 #include <assert.h> 51 50 #include "cuda_adb.h" … … 158 157 printf(NAME ": VIA-CUDA Apple Desktop Bus driver\n"); 159 158 160 /*161 * Alleviate the virtual memory / page table pressure caused by162 * interrupt storms when the default large stacks are used.163 */164 async_set_notification_handler_stack_size(PAGE_SIZE);165 166 159 for (i = 0; i < ADB_MAX_ADDR; ++i) { 167 160 adb_dev[i].client_sess = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.