add a flag to exit while loop for each worker thread

worker_generates_requests_to_global_queue
Xiaosu Lyu 3 years ago
parent c205066070
commit 8164b5274f

@ -24,6 +24,7 @@
#include "sandbox_set_as_running_user.h" #include "sandbox_set_as_running_user.h"
#include "scheduler_options.h" #include "scheduler_options.h"
extern thread_local bool pthread_stop;
/** /**
* This scheduler provides for cooperative and preemptive multitasking in a OS process's userspace. * This scheduler provides for cooperative and preemptive multitasking in a OS process's userspace.
@ -392,7 +393,7 @@ scheduler_switch_to_base_context(struct arch_context *current_context)
static inline void static inline void
scheduler_idle_loop() scheduler_idle_loop()
{ {
while (true) { while (!pthread_stop) {
/* Assumption: only called by the "base context" */ /* Assumption: only called by the "base context" */
assert(current_sandbox_get() == NULL); assert(current_sandbox_get() == NULL);

@ -28,6 +28,7 @@
extern uint64_t total_held[1024]; extern uint64_t total_held[1024];
extern uint64_t longest_held[1024]; extern uint64_t longest_held[1024];
extern thread_local bool pthread_stop;
thread_local _Atomic volatile sig_atomic_t handler_depth = 0; thread_local _Atomic volatile sig_atomic_t handler_depth = 0;
thread_local _Atomic volatile sig_atomic_t deferred_sigalrm = 0; thread_local _Atomic volatile sig_atomic_t deferred_sigalrm = 0;
@ -232,19 +233,19 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
uint32_t total_sandboxes_error = atomic_load(&sandbox_state_totals[SANDBOX_ERROR]); uint32_t total_sandboxes_error = atomic_load(&sandbox_state_totals[SANDBOX_ERROR]);
printf("throughput is %f error request is %u global total request %d worker %d total requests is %u worker total_held %"PRIu64" longest_held %"PRIu64" listener total_held %"PRIu64" longest_held %"PRIu64"\n", throughput, total_sandboxes_error, atomic_load(&sandbox_state_totals[SANDBOX_COMPLETE]), worker_thread_idx, total_local_requests, total_held[worker_thread_idx], longest_held[worker_thread_idx], total_held[200], longest_held[200]); printf("throughput is %f error request is %u global total request %d worker %d total requests is %u worker total_held %"PRIu64" longest_held %"PRIu64" listener total_held %"PRIu64" longest_held %"PRIu64"\n", throughput, total_sandboxes_error, atomic_load(&sandbox_state_totals[SANDBOX_COMPLETE]), worker_thread_idx, total_local_requests, total_held[worker_thread_idx], longest_held[worker_thread_idx], total_held[200], longest_held[200]);
fflush(stdout); fflush(stdout);
pthread_exit(0); pthread_stop = true;
} }
default: { default: {
const char *signal_name = strsignal(signal_type); const char *signal_name = strsignal(signal_type);
switch (signal_info->si_code) { switch (signal_info->si_code) {
case SI_TKILL: case SI_TKILL:
panic("software_interrupt_handle_signals unexpectedly received signal %s from a thread kill\n", printf("software_interrupt_handle_signals unexpectedly received signal %s from a thread kill\n",
signal_name); signal_name);
case SI_KERNEL: case SI_KERNEL:
panic("software_interrupt_handle_signals unexpectedly received signal %s from the kernel\n", printf("software_interrupt_handle_signals unexpectedly received signal %s from the kernel\n",
signal_name); signal_name);
default: default:
panic("software_interrupt_handle_signals unexpectedly received signal %s with si_code %d\n", printf("software_interrupt_handle_signals unexpectedly received signal %s with si_code %d\n",
signal_name, signal_info->si_code); signal_name, signal_info->si_code);
} }
} }

@ -29,6 +29,8 @@ thread_local struct arch_context worker_thread_base_context;
/* Used to index into global arguments and deadlines arrays */ /* Used to index into global arguments and deadlines arrays */
thread_local int worker_thread_idx; thread_local int worker_thread_idx;
thread_local bool pthread_stop = false;
/* Used to track tenants' timeouts */ /* Used to track tenants' timeouts */
thread_local struct priority_queue *worker_thread_timeout_queue; thread_local struct priority_queue *worker_thread_timeout_queue;
/*********************** /***********************

Loading…
Cancel
Save