diff --git a/runtime/include/sandbox.h b/runtime/include/sandbox.h index 2711ea3..662d5ff 100644 --- a/runtime/include/sandbox.h +++ b/runtime/include/sandbox.h @@ -334,24 +334,4 @@ current_sandbox__get_libuv_handle(int handle_index) return sandbox__get_libuv_handle(sandbox, handle_index); } -/** - * @brief Switches to the next sandbox, placing the current sandbox of the completion queue if in RETURNED state - * @param next The Sandbox Context to switch to or NULL - * @return void - */ -static inline void -switch_to_sandbox(struct sandbox *next_sandbox) -{ - arch_context_t *next_register_context = next_sandbox == NULL ? NULL : &next_sandbox->ctxt; - softint__disable(); - struct sandbox *current_sandbox = current_sandbox__get(); - arch_context_t *current_register_context = current_sandbox == NULL ? NULL : ¤t_sandbox->ctxt; - current_sandbox__set(next_sandbox); - // If the current sandbox we're switching from is in a RETURNED state, add to completion queue - if (current_sandbox && current_sandbox->state == RETURNED) add_sandbox_to_completion_queue(current_sandbox); - next_context = next_register_context; - arch_context_switch(current_register_context, next_register_context); - softint__enable(); -} - #endif /* SFRT_SANDBOX_H */ diff --git a/runtime/src/main.c b/runtime/src/main.c index f4f3a5e..0340429 100644 --- a/runtime/src/main.c +++ b/runtime/src/main.c @@ -19,18 +19,6 @@ u32 first_worker_processor = 0; int worker_threads_argument[SBOX_NCORES] = { 0 }; // The worker sets its argument to -1 on error pthread_t worker_threads[SBOX_NCORES]; -/** - * @return timestamp in usec - **/ -static u64 -get_time() -{ - struct timeval Tp; - int stat; - stat = gettimeofday(&Tp, NULL); - if (stat != 0) printf("Error return from gettimeofday: %d", stat); - return (Tp.tv_sec * 1000000 + Tp.tv_usec); -} /** * Returns instructions on use of CLI if used incorrectly diff --git a/runtime/src/runtime.c b/runtime/src/runtime.c index 3261943..9a98bfe 100644 --- a/runtime/src/runtime.c +++ b/runtime/src/runtime.c @@ -163,6 +163,26 @@ static __thread unsigned int in_callback; static inline void add_sandbox_to_local_run_queue(struct sandbox *sandbox); +/** + * @brief Switches to the next sandbox, placing the current sandbox of the completion queue if in RETURNED state + * @param next The Sandbox Context to switch to or NULL + * @return void + */ +static inline void +switch_to_sandbox(struct sandbox *next_sandbox) +{ + arch_context_t *next_register_context = next_sandbox == NULL ? NULL : &next_sandbox->ctxt; + softint__disable(); + struct sandbox *current_sandbox = current_sandbox__get(); + arch_context_t *current_register_context = current_sandbox == NULL ? NULL : ¤t_sandbox->ctxt; + current_sandbox__set(next_sandbox); + // If the current sandbox we're switching from is in a RETURNED state, add to completion queue + if (current_sandbox && current_sandbox->state == RETURNED) add_sandbox_to_completion_queue(current_sandbox); + next_context = next_register_context; + arch_context_switch(current_register_context, next_register_context); + softint__enable(); +} + /** * If this sandbox is blocked, mark it as runnable and add to the head of the thread-local runqueue * @param sandbox the sandbox to check and update if blocked diff --git a/runtime/tests/fibonacci/main.c b/runtime/tests/fibonacci/main.c index d35c0b7..1e2ca3d 100644 --- a/runtime/tests/fibonacci/main.c +++ b/runtime/tests/fibonacci/main.c @@ -1,5 +1,5 @@ #include -#include "get_time.h" +// #include "get_time.h" unsigned long int fib(unsigned long int n) {