fix context switch in lpm_sleep

This commit is contained in:
Oliver Hahm 2013-06-12 16:18:32 +02:00
parent d31bad6c9e
commit b8f674f5b6

View File

@ -46,11 +46,19 @@ void _native_lpm_sleep()
retval = select(1, &_native_uart_rfds, NULL, NULL, NULL);
DEBUG("_native_lpm_sleep: retval: %i\n", retval);
if (retval != -1) {
DEBUG("\n\n\t\treturn from syscall, calling _native_handle_uart0_input\n\n");
/* uart ready, swap to ISR context and handle input */
makecontext(_native_isr_ctx, _native_handle_uart0_input, 0);
swapcontext((ucontext_t*)(active_thread->sp), _native_isr_ctx);
}
else if ((retval == -1) && (errno == EINTR)) {
/* TODO: reevaluate and merge with above branch
* IF any thread except the idle thread uses lpm_set this could make sense... */
/* select interrupted by signal swap to ISR context and handle input */
DEBUG("\n\n\t\treturn from interrupted syscall, swapping context and calling _native_handle_uart0_input\n\n");
makecontext(_native_isr_ctx, _native_handle_uart0_input, 0);
swapcontext(_native_cur_ctx, _native_isr_ctx);
}
else if (errno != EINTR) {
else {
err(1, "lpm_set(): select()");
}
#else