chore: rename softint to software_interrupt

main
Sean McBride 5 years ago
parent 21d9cd11fe
commit 7ba5a3acbe

@ -9,16 +9,16 @@
* Externs
***************************************/
extern __thread volatile sig_atomic_t softint__is_disabled;
extern __thread volatile sig_atomic_t software_interrupt__is_disabled;
/***************************************
* Public Static Inlines
***************************************/
static inline void
softint__disable(void)
software_interrupt__disable(void)
{
while (__sync_bool_compare_and_swap(&softint__is_disabled, 0, 1) == false)
while (__sync_bool_compare_and_swap(&software_interrupt__is_disabled, 0, 1) == false)
;
}
@ -27,18 +27,18 @@ softint__disable(void)
* Enables signals
*/
static inline void
softint__enable(void)
software_interrupt__enable(void)
{
if (__sync_bool_compare_and_swap(&softint__is_disabled, 1, 0) == false) assert(0);
if (__sync_bool_compare_and_swap(&software_interrupt__is_disabled, 1, 0) == false) assert(0);
}
/**
* @returns boolean if signals are enabled
*/
static inline int
softint__is_enabled(void)
software_interrupt__is_enabled(void)
{
return (softint__is_disabled == 0);
return (software_interrupt__is_disabled == 0);
}
/**
@ -47,7 +47,7 @@ softint__is_enabled(void)
* @return 0 on success. Exits program otherwise
**/
static inline int
softint__mask(int signal)
software_interrupt__mask(int signal)
{
sigset_t set;
int return_code;
@ -72,7 +72,7 @@ softint__mask(int signal)
* @return 0 on success. Exits program otherwise
**/
static inline int
softint__unmask(int signal)
software_interrupt__unmask(int signal)
{
sigset_t set;
int return_code;
@ -95,8 +95,8 @@ softint__unmask(int signal)
* Exports from module.c
***************************************/
void softint__initialize(void);
void softint__arm_timer(void);
void softint__disarm_timer(void);
void software_interrupt__initialize(void);
void software_interrupt__arm_timer(void);
void software_interrupt__disarm_timer(void);
#endif /* SFRT_SOFTINT_H */

@ -62,6 +62,8 @@ module__initialize_as_server(struct module *module)
* Module Mega Teardown Function
* Closes the socket and dynamic library, and then frees the module
* Returns harmlessly if there are outstanding references
*
* TODO: Untested Functionality. Unsure if this will work
* @param module - the module to teardown
**/
void

@ -44,8 +44,8 @@ runtime__initialize(void)
deque_init_sandbox(runtime__global_deque, SBOX_MAX_REQS);
// Mask Signals
softint__mask(SIGUSR1);
softint__mask(SIGALRM);
software_interrupt__mask(SIGUSR1);
software_interrupt__mask(SIGALRM);
// Initialize http_parser_settings global
http_parser_settings__initialize(&runtime__http_parser_settings);
@ -126,8 +126,8 @@ listener_thread__initialize(void)
ret = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cs);
assert(ret == 0);
softint__initialize();
softint__arm_timer();
software_interrupt__initialize();
software_interrupt__arm_timer();
}
/***************************
@ -168,7 +168,7 @@ static inline void
worker_thread__switch_to_sandbox(struct sandbox *next_sandbox)
{
arch_context_t *next_register_context = next_sandbox == NULL ? NULL : &next_sandbox->ctxt;
softint__disable();
software_interrupt__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);
@ -177,7 +177,7 @@ worker_thread__switch_to_sandbox(struct sandbox *next_sandbox)
worker_thread__completion_queue__add_sandbox(current_sandbox);
worker_thread__next_context = next_register_context;
arch_context_switch(current_register_context, next_register_context);
softint__enable();
software_interrupt__enable();
}
/**
@ -187,7 +187,7 @@ worker_thread__switch_to_sandbox(struct sandbox *next_sandbox)
void
worker_thread__wakeup_sandbox(sandbox_t *sandbox)
{
softint__disable();
software_interrupt__disable();
debuglog("[%p: %s]\n", sandbox, sandbox->module->name);
if (sandbox->state != BLOCKED) goto done;
assert(sandbox->state == BLOCKED);
@ -195,7 +195,7 @@ worker_thread__wakeup_sandbox(sandbox_t *sandbox)
sandbox->state = RUNNABLE;
ps_list_head_append_d(&worker_thread__run_queue, sandbox);
done:
softint__enable();
software_interrupt__enable();
}
@ -207,14 +207,14 @@ void
worker_thread__block_current_sandbox(void)
{
assert(worker_thread__is_in_callback == 0);
softint__disable();
software_interrupt__disable();
struct sandbox *current_sandbox = current_sandbox__get();
ps_list_rem_d(current_sandbox);
current_sandbox->state = BLOCKED;
struct sandbox *next_sandbox = worker_thread__get_next_sandbox(0);
debuglog("[%p: %next_sandbox, %p: %next_sandbox]\n", current_sandbox, current_sandbox->module->name,
next_sandbox, next_sandbox ? next_sandbox->module->name : "");
softint__enable();
software_interrupt__enable();
worker_thread__switch_to_sandbox(next_sandbox);
}
@ -395,9 +395,9 @@ worker_thread__single_loop(void)
if (!worker_thread__is_in_callback) worker_thread__execute_libuv_event_loop();
// Get and return the sandbox at the head of the thread local runqueue
softint__disable();
software_interrupt__disable();
struct sandbox *sandbox = worker_thread__get_next_sandbox(0);
softint__enable();
software_interrupt__enable();
assert(sandbox == NULL || sandbox->state == RUNNABLE);
return sandbox;
}
@ -414,11 +414,11 @@ worker_thread__main(void *return_code)
ps_list_head_init(&worker_thread__run_queue);
ps_list_head_init(&worker_thread__completion_queue);
softint__is_disabled = 0;
worker_thread__next_context = NULL;
software_interrupt__is_disabled = 0;
worker_thread__next_context = NULL;
#ifndef PREEMPT_DISABLE
softint__unmask(SIGALRM);
softint__unmask(SIGUSR1);
software_interrupt__unmask(SIGALRM);
software_interrupt__unmask(SIGUSR1);
#endif
uv_loop_init(&worker_thread__uvio_handle);
worker_thread__is_in_callback = 0;
@ -446,13 +446,13 @@ worker_thread__current_sandbox__exit(void)
{
struct sandbox *current_sandbox = current_sandbox__get();
assert(current_sandbox);
softint__disable();
software_interrupt__disable();
worker_thread__run_queue__remove_sandbox(current_sandbox);
current_sandbox->state = RETURNED;
struct sandbox *next_sandbox = worker_thread__get_next_sandbox(0);
assert(next_sandbox != current_sandbox);
softint__enable();
software_interrupt__enable();
// free resources from "main function execution", as stack still in use.
// unmap linear memory only!
munmap(current_sandbox->linear_memory_start, SBOX_MAX_MEM + PAGE_SIZE);

@ -178,10 +178,10 @@ current_sandbox__main(void)
// FIXME: is this right? this is the first time this sandbox is running.. so it wont
// return to worker_thread__switch_to_sandbox() api..
// we'd potentially do what we'd in worker_thread__switch_to_sandbox() api here for cleanup..
if (!softint__is_enabled()) {
if (!software_interrupt__is_enabled()) {
arch_context_init(&current_sandbox->ctxt, 0, 0);
worker_thread__next_context = NULL;
softint__enable();
software_interrupt__enable();
}
struct module *current_module = sandbox__get_module(current_sandbox);
int argument_count = module__get_argument_count(current_module);

@ -18,15 +18,15 @@
* Process Globals
***************************************/
static const int softint__supported_signals[] = { SIGALRM, SIGUSR1 };
static const int software_interrupt__supported_signals[] = { SIGALRM, SIGUSR1 };
/***************************************
* Thread Globals
***************************************/
__thread static volatile sig_atomic_t softint__SIGALRM_count = 0;
__thread static volatile sig_atomic_t softint__SIGUSR_count = 0;
__thread volatile sig_atomic_t softint__is_disabled = 0;
__thread static volatile sig_atomic_t software_interrupt__SIGALRM_count = 0;
__thread static volatile sig_atomic_t software_interrupt__SIGUSR_count = 0;
__thread volatile sig_atomic_t software_interrupt__is_disabled = 0;
/***************************************
* Externs
@ -38,8 +38,8 @@ extern pthread_t worker_threads[];
* Private Static Inlines
***************************************/
static inline void softint__handle_signals(int signal_type, siginfo_t *signal_info, void *user_context_raw);
static inline void softint__schedule_alarm(void *user_context_raw);
static inline void software_interrupt__handle_signals(int signal_type, siginfo_t *signal_info, void *user_context_raw);
static inline void software_interrupt__schedule_alarm(void *user_context_raw);
/**
* The handler function for Software Interrupts (signals)
@ -50,7 +50,7 @@ static inline void softint__schedule_alarm(void *user_context_raw);
* @param user_context_raw void* to a user_context struct
**/
static inline void
softint__handle_signals(int signal_type, siginfo_t *signal_info, void *user_context_raw)
software_interrupt__handle_signals(int signal_type, siginfo_t *signal_info, void *user_context_raw)
{
#ifdef PREEMPT_DISABLE
assert(0);
@ -75,33 +75,33 @@ softint__handle_signals(int signal_type, siginfo_t *signal_info, void *user_cont
} else {
assert(signal_info->si_code == SI_TKILL);
}
// debuglog("alrm:%d\n", softint__SIGALRM_count);
// debuglog("alrm:%d\n", software_interrupt__SIGALRM_count);
softint__SIGALRM_count++;
// softint__supported_signals per-core..
software_interrupt__SIGALRM_count++;
// software_interrupt__supported_signals per-core..
if (curr && curr->state == RETURNED) return;
if (worker_thread__next_context) return;
if (!softint__is_enabled()) return;
softint__schedule_alarm(user_context_raw);
if (!software_interrupt__is_enabled()) return;
software_interrupt__schedule_alarm(user_context_raw);
break;
}
case SIGUSR1: {
// make sure sigalrm doesn't mess this up if nested..
assert(!softint__is_enabled());
assert(!software_interrupt__is_enabled());
/* we set current before calling pthread_kill! */
assert(worker_thread__next_context && (&curr->ctxt == worker_thread__next_context));
assert(signal_info->si_code == SI_TKILL);
// debuglog("usr1:%d\n", softint__SIGUSR_count);
// debuglog("usr1:%d\n", software_interrupt__SIGUSR_count);
softint__SIGUSR_count++;
software_interrupt__SIGUSR_count++;
// do not save current sandbox.. it is in co-operative switch..
// pick the next from "worker_thread__next_context"..
// assert its "sp" to be zero in regs..
// memcpy from next context..
arch_mcontext_restore(&user_context->uc_mcontext, &curr->ctxt);
worker_thread__next_context = NULL;
softint__enable();
software_interrupt__enable();
break;
}
default:
@ -115,9 +115,9 @@ softint__handle_signals(int signal_type, siginfo_t *signal_info, void *user_cont
* @param user_context_raw void* to a user_context struct
**/
static inline void
softint__schedule_alarm(void *user_context_raw)
software_interrupt__schedule_alarm(void *user_context_raw)
{
softint__disable(); // no nesting!
software_interrupt__disable(); // no nesting!
struct sandbox *curr = current_sandbox__get();
ucontext_t * user_context = (ucontext_t *)user_context_raw;
@ -142,7 +142,7 @@ softint__schedule_alarm(void *user_context_raw)
// worker_thread__next_context = NULL;
done:
softint__enable();
software_interrupt__enable();
skip:
return;
}
@ -155,7 +155,7 @@ skip:
* Arms the Interval Timer to start in 10ms and then trigger a SIGALRM every 5ms
**/
void
softint__arm_timer(void)
software_interrupt__arm_timer(void)
{
#ifndef PREEMPT_DISABLE
struct itimerval interval_timer;
@ -176,7 +176,7 @@ softint__arm_timer(void)
* Disarm the Interval Timer
**/
void
softint__disarm_timer(void)
software_interrupt__disarm_timer(void)
{
struct itimerval interval_timer;
@ -197,15 +197,17 @@ softint__disarm_timer(void)
* Register sonftint_handler to execute on SIGALRM and SIGUSR1
**/
void
softint__initialize(void)
software_interrupt__initialize(void)
{
struct sigaction signal_action;
memset(&signal_action, 0, sizeof(struct sigaction));
signal_action.sa_sigaction = softint__handle_signals;
signal_action.sa_sigaction = software_interrupt__handle_signals;
signal_action.sa_flags = SA_SIGINFO | SA_RESTART;
for (int i = 0; i < (sizeof(softint__supported_signals) / sizeof(softint__supported_signals[0])); i++) {
int return_code = sigaction(softint__supported_signals[i], &signal_action, NULL);
for (int i = 0;
i < (sizeof(software_interrupt__supported_signals) / sizeof(software_interrupt__supported_signals[0]));
i++) {
int return_code = sigaction(software_interrupt__supported_signals[i], &signal_action, NULL);
if (return_code) {
perror("sigaction");
exit(1);

Loading…
Cancel
Save