/trunk/uspace/lib/libc/include/async.h |
---|
45,7 → 45,7 |
static inline void async_manager(void) |
{ |
fibril_schedule_next_adv(FIBRIL_TO_MANAGER); |
fibril_switch(FIBRIL_TO_MANAGER); |
} |
ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs); |
/trunk/uspace/lib/libc/include/fibril.h |
---|
77,7 → 77,7 |
extern fid_t fibril_create(int (*func)(void *), void *arg); |
extern fibril_t *fibril_setup(void); |
extern void fibril_teardown(fibril_t *f); |
extern int fibril_schedule_next_adv(fibril_switch_type_t stype); |
extern int fibril_switch(fibril_switch_type_t stype); |
extern void fibril_add_ready(fid_t fid); |
extern void fibril_add_manager(fid_t fid); |
extern void fibril_remove_manager(void); |
85,8 → 85,8 |
extern void fibril_inc_sercount(void); |
extern void fibril_dec_sercount(void); |
static inline int fibril_schedule_next(void) { |
return fibril_schedule_next_adv(FIBRIL_PREEMPT); |
static inline int fibril_yield(void) { |
return fibril_switch(FIBRIL_PREEMPT); |
} |
#endif |
/trunk/uspace/lib/libc/generic/fibril.c |
---|
75,7 → 75,7 |
if (!tcb) |
return NULL; |
f = malloc(sizeof(*f)); |
f = malloc(sizeof(fibril_t)); |
if (!f) { |
__free_tls(tcb); |
return NULL; |
84,6 → 84,13 |
tcb->fibril_data = f; |
f->tcb = tcb; |
f->func = NULL; |
f->arg = NULL; |
f->stack = NULL; |
f->clean_after_me = NULL; |
f->retval = 0; |
f->flags = 0; |
return f; |
} |
106,11 → 113,11 |
/* Call the implementing function. */ |
f->retval = f->func(f->arg); |
fibril_schedule_next_adv(FIBRIL_FROM_DEAD); |
fibril_switch(FIBRIL_FROM_DEAD); |
/* not reached */ |
} |
/** Schedule next fibril. |
/** Switch from the current fibril. |
* |
* If calling with FIBRIL_TO_MANAGER parameter, the async_futex should be |
* held. |
121,7 → 128,7 |
* @return Return 0 if there is no ready fibril, |
* return 1 otherwise. |
*/ |
int fibril_schedule_next_adv(fibril_switch_type_t stype) |
int fibril_switch(fibril_switch_type_t stype) |
{ |
fibril_t *srcf, *dstf; |
int retval = 0; |
138,8 → 145,8 |
* Do not preempt if there is not sufficient count of fibril |
* managers. |
*/ |
if (list_empty(&serialized_list) && fibrils_in_manager <= |
serialized_fibrils) { |
if (list_empty(&serialized_list) && |
fibrils_in_manager <= serialized_fibrils) { |
goto ret_0; |
} |
} |
163,7 → 170,18 |
* Cleanup after the dead fibril from which we |
* restored context here. |
*/ |
free(srcf->clean_after_me->stack); |
void *stack = srcf->clean_after_me->stack; |
if (stack) { |
/* |
* This check is necessary because a |
* thread could have exited like a |
* normal fibril using the |
* FIBRIL_FROM_DEAD switch type. In that |
* case, its fibril will not have the |
* stack member filled. |
*/ |
free(stack); |
} |
fibril_teardown(srcf->clean_after_me); |
srcf->clean_after_me = NULL; |
} |
233,17 → 251,13 |
return 0; |
f->stack = (char *) malloc(FIBRIL_INITIAL_STACK_PAGES_NO * |
getpagesize()); |
if (!f->stack) { |
fibril_teardown(f); |
return 0; |
} |
f->func = func; |
f->arg = arg; |
f->func = func; |
f->clean_after_me = NULL; |
f->retval = 0; |
f->flags = 0; |
context_save(&f->ctx); |
context_set(&f->ctx, FADDR(fibril_main), f->stack, |
/trunk/uspace/lib/libc/generic/ipc.c |
---|
219,7 → 219,7 |
if (can_preempt) { |
call->fid = fibril_get_id(); |
fibril_schedule_next_adv(FIBRIL_TO_MANAGER); |
fibril_switch(FIBRIL_TO_MANAGER); |
/* Async futex unlocked by previous call */ |
} else { |
call->fid = 0; |
/trunk/uspace/lib/libc/generic/async.c |
---|
362,7 → 362,7 |
* former case, handle_expired_timeouts() and, in the latter |
* case, route_call() will perform the wakeup. |
*/ |
fibril_schedule_next_adv(FIBRIL_TO_MANAGER); |
fibril_switch(FIBRIL_TO_MANAGER); |
/* |
* Futex is up after getting back from async_manager get it |
* again. |
584,7 → 584,7 |
struct timeval tv; |
while (1) { |
if (fibril_schedule_next_adv(FIBRIL_FROM_MANAGER)) { |
if (fibril_switch(FIBRIL_FROM_MANAGER)) { |
futex_up(&async_futex); |
/* |
* async_futex is always held when entering a manager |
803,8 → 803,8 |
msg->wdata.active = 0; |
msg->wdata.inlist = 0; |
/* Leave the async_futex locked when entering this function */ |
fibril_schedule_next_adv(FIBRIL_TO_MANAGER); |
/* futex is up automatically after fibril_schedule_next...*/ |
fibril_switch(FIBRIL_TO_MANAGER); |
/* futex is up automatically after fibril_switch...*/ |
done: |
if (retval) |
*retval = msg->retval; |
842,8 → 842,8 |
insert_timeout(&msg->wdata); |
/* Leave the async_futex locked when entering this function */ |
fibril_schedule_next_adv(FIBRIL_TO_MANAGER); |
/* futex is up automatically after fibril_schedule_next...*/ |
fibril_switch(FIBRIL_TO_MANAGER); |
/* futex is up automatically after fibril_switch...*/ |
if (!msg->done) |
return ETIMEOUT; |
884,8 → 884,8 |
futex_down(&async_futex); |
insert_timeout(&msg->wdata); |
/* Leave the async_futex locked when entering this function */ |
fibril_schedule_next_adv(FIBRIL_TO_MANAGER); |
/* futex is up automatically after fibril_schedule_next_adv()...*/ |
fibril_switch(FIBRIL_TO_MANAGER); |
/* futex is up automatically after fibril_switch()...*/ |
free(msg); |
} |