Changeset 116d3f6f in mainline
- Timestamp:
- 2007-10-03T06:55:56Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 18525c5
- Parents:
- 5b5d25f
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/async.c
r5b5d25f r116d3f6f 363 363 * case, route_call() will perform the wakeup. 364 364 */ 365 fibril_s chedule_next_adv(FIBRIL_TO_MANAGER);365 fibril_switch(FIBRIL_TO_MANAGER); 366 366 /* 367 367 * Futex is up after getting back from async_manager get it … … 585 585 586 586 while (1) { 587 if (fibril_s chedule_next_adv(FIBRIL_FROM_MANAGER)) {587 if (fibril_switch(FIBRIL_FROM_MANAGER)) { 588 588 futex_up(&async_futex); 589 589 /* … … 804 804 msg->wdata.inlist = 0; 805 805 /* Leave the async_futex locked when entering this function */ 806 fibril_s chedule_next_adv(FIBRIL_TO_MANAGER);807 /* futex is up automatically after fibril_s chedule_next...*/806 fibril_switch(FIBRIL_TO_MANAGER); 807 /* futex is up automatically after fibril_switch...*/ 808 808 done: 809 809 if (retval) … … 843 843 844 844 /* Leave the async_futex locked when entering this function */ 845 fibril_s chedule_next_adv(FIBRIL_TO_MANAGER);846 /* futex is up automatically after fibril_s chedule_next...*/845 fibril_switch(FIBRIL_TO_MANAGER); 846 /* futex is up automatically after fibril_switch...*/ 847 847 848 848 if (!msg->done) … … 885 885 insert_timeout(&msg->wdata); 886 886 /* Leave the async_futex locked when entering this function */ 887 fibril_s chedule_next_adv(FIBRIL_TO_MANAGER);888 /* futex is up automatically after fibril_s chedule_next_adv()...*/887 fibril_switch(FIBRIL_TO_MANAGER); 888 /* futex is up automatically after fibril_switch()...*/ 889 889 free(msg); 890 890 } -
uspace/lib/libc/generic/fibril.c
r5b5d25f r116d3f6f 76 76 return NULL; 77 77 78 f = malloc(sizeof( *f));78 f = malloc(sizeof(fibril_t)); 79 79 if (!f) { 80 80 __free_tls(tcb); … … 85 85 f->tcb = tcb; 86 86 87 f->func = NULL; 88 f->arg = NULL; 89 f->stack = NULL; 90 f->clean_after_me = NULL; 91 f->retval = 0; 92 f->flags = 0; 93 87 94 return f; 88 95 } … … 107 114 f->retval = f->func(f->arg); 108 115 109 fibril_s chedule_next_adv(FIBRIL_FROM_DEAD);116 fibril_switch(FIBRIL_FROM_DEAD); 110 117 /* not reached */ 111 118 } 112 119 113 /** S chedule next fibril.120 /** Switch from the current fibril. 114 121 * 115 122 * If calling with FIBRIL_TO_MANAGER parameter, the async_futex should be … … 122 129 * return 1 otherwise. 123 130 */ 124 int fibril_s chedule_next_adv(fibril_switch_type_t stype)131 int fibril_switch(fibril_switch_type_t stype) 125 132 { 126 133 fibril_t *srcf, *dstf; … … 139 146 * managers. 140 147 */ 141 if (list_empty(&serialized_list) && fibrils_in_manager <=142 serialized_fibrils) {148 if (list_empty(&serialized_list) && 149 fibrils_in_manager <= serialized_fibrils) { 143 150 goto ret_0; 144 151 } … … 164 171 * restored context here. 165 172 */ 166 free(srcf->clean_after_me->stack); 173 void *stack = srcf->clean_after_me->stack; 174 if (stack) { 175 /* 176 * This check is necessary because a 177 * thread could have exited like a 178 * normal fibril using the 179 * FIBRIL_FROM_DEAD switch type. In that 180 * case, its fibril will not have the 181 * stack member filled. 182 */ 183 free(stack); 184 } 167 185 fibril_teardown(srcf->clean_after_me); 168 186 srcf->clean_after_me = NULL; … … 185 203 } 186 204 } 187 205 188 206 /* Choose a new fibril to run */ 189 207 if (stype == FIBRIL_TO_MANAGER || stype == FIBRIL_FROM_DEAD) { … … 195 213 fibrils_in_manager++; 196 214 197 if (stype == FIBRIL_FROM_DEAD) 215 if (stype == FIBRIL_FROM_DEAD) 198 216 dstf->clean_after_me = srcf; 199 217 } else { … … 234 252 f->stack = (char *) malloc(FIBRIL_INITIAL_STACK_PAGES_NO * 235 253 getpagesize()); 236 237 254 if (!f->stack) { 238 255 fibril_teardown(f); 239 256 return 0; 240 257 } 241 258 259 f->func = func; 242 260 f->arg = arg; 243 f->func = func;244 f->clean_after_me = NULL;245 f->retval = 0;246 f->flags = 0;247 261 248 262 context_save(&f->ctx); -
uspace/lib/libc/generic/ipc.c
r5b5d25f r116d3f6f 220 220 if (can_preempt) { 221 221 call->fid = fibril_get_id(); 222 fibril_s chedule_next_adv(FIBRIL_TO_MANAGER);222 fibril_switch(FIBRIL_TO_MANAGER); 223 223 /* Async futex unlocked by previous call */ 224 224 } else { -
uspace/lib/libc/generic/thread.c
r5b5d25f r116d3f6f 105 105 f = fibril_setup(); 106 106 __tcb_set(f->tcb); 107 107 108 108 uarg->uspace_thread_function(uarg->uspace_thread_arg); 109 109 /* XXX: we cannot free the userspace stack while running on it */ -
uspace/lib/libc/include/async.h
r5b5d25f r116d3f6f 46 46 static inline void async_manager(void) 47 47 { 48 fibril_s chedule_next_adv(FIBRIL_TO_MANAGER);48 fibril_switch(FIBRIL_TO_MANAGER); 49 49 } 50 50 -
uspace/lib/libc/include/fibril.h
r5b5d25f r116d3f6f 78 78 extern fibril_t *fibril_setup(void); 79 79 extern void fibril_teardown(fibril_t *f); 80 extern int fibril_s chedule_next_adv(fibril_switch_type_t stype);80 extern int fibril_switch(fibril_switch_type_t stype); 81 81 extern void fibril_add_ready(fid_t fid); 82 82 extern void fibril_add_manager(fid_t fid); … … 86 86 extern void fibril_dec_sercount(void); 87 87 88 static inline int fibril_ schedule_next(void) {89 return fibril_s chedule_next_adv(FIBRIL_PREEMPT);88 static inline int fibril_yield(void) { 89 return fibril_switch(FIBRIL_PREEMPT); 90 90 } 91 91 -
uspace/srv/fs/fat/fat.c
r5b5d25f r116d3f6f 183 183 async_set_client_connection(fat_connection); 184 184 185 async_create_manager(); 186 187 /* 188 * TODO: Interestingly, if we merely return, the only thread dies. 189 * If the only thread dies, the whole task is destroyed. 190 * Prevent the thread from exiting when there are active fibrils. 191 */ 192 fibril_schedule_next_adv(FIBRIL_FROM_DEAD); 185 async_manager(); 193 186 /* not reached */ 194 195 187 return 0; 196 188 }
Note:
See TracChangeset
for help on using the changeset viewer.