chore: Assorted cleanup

main
Sean McBride 5 years ago
parent b896f6f1b1
commit 75a34360b8

@ -334,24 +334,4 @@ current_sandbox__get_libuv_handle(int handle_index)
return sandbox__get_libuv_handle(sandbox, 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 : &current_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 */ #endif /* SFRT_SANDBOX_H */

@ -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 int worker_threads_argument[SBOX_NCORES] = { 0 }; // The worker sets its argument to -1 on error
pthread_t worker_threads[SBOX_NCORES]; 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 * Returns instructions on use of CLI if used incorrectly

@ -163,6 +163,26 @@ static __thread unsigned int in_callback;
static inline void add_sandbox_to_local_run_queue(struct sandbox *sandbox); 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 : &current_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 * 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 * @param sandbox the sandbox to check and update if blocked

@ -1,5 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include "get_time.h" // #include "get_time.h"
unsigned long int unsigned long int
fib(unsigned long int n) fib(unsigned long int n)
{ {

Loading…
Cancel
Save