Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions kern/arch/x86/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,17 +543,30 @@ void handle_nmi(struct hw_trapframe *hw_tf)
static void trap_dispatch(struct hw_trapframe *hw_tf)
{
struct per_cpu_info *pcpui;
struct preempt_data *vcpd;
struct proc *p;
bool handled = FALSE;
unsigned long aux = 0;
uintptr_t fixup_ip;

// Handle processor exceptions.
switch(hw_tf->tf_trapno) {
case T_DEBUG:
case T_BRKPT:
enable_irq();
monitor(hw_tf);
disable_irq();
handled = TRUE;
pcpui = &per_cpu_info[core_id()];
p = pcpui->cur_proc;
vcpd = &p->procdata->vcore_preempt_data[pcpui->owning_vcoreid];

if (in_kernel(hw_tf) || !proc_is_vcctx_ready(p) ||
vcpd->notif_disabled) {
/* Trap is in kernel, vcore, or early SCP context. */
enable_irq();
monitor(hw_tf);
disable_irq();
handled = TRUE;
} else {
handled = FALSE;
}
break;
case T_ILLOP:
{
Expand Down
17 changes: 9 additions & 8 deletions tests/block_test.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include <stdio.h>
#include <parlib/parlib.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <parlib/parlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <unistd.h>
#include "misc-compat.h"

pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
#define printf_safe(...) {}
Expand All @@ -20,16 +21,16 @@ void *my_retvals[NUM_TEST_THREADS];

__thread int my_id;
void *block_thread(void* arg)
{
{
assert(!in_vcore_context());
for (int i = 0; i < NUM_TEST_LOOPS; i++) {
printf_safe("[A] pthread %d on vcore %d\n", pthread_self()->id, vcore_id());
sys_block(5000 + pthread_self()->id);
printf_safe("[A] pthread %d on vcore %d\n", pthread_id(), vcore_id());
sys_block(5000 + pthread_id());
}
return (void*)(long)pthread_self()->id;
return (void*)(long)pthread_id();
}

int main(int argc, char** argv)
int main(int argc, char **argv)
{
struct timeval tv = {0};
if (gettimeofday(&tv, 0))
Expand Down
9 changes: 5 additions & 4 deletions tests/futex_timeout.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
#include <futex.h>
#include <parlib/parlib.h>
#include <parlib/vcore.h>
#include <futex.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include "misc-compat.h"

#define NUM_THREADS 10
pthread_t thandlers[NUM_THREADS];

void *handler(void *arg) {
int id = pthread_self()->id;
int id = pthread_id();
int var = 0;
struct timespec timeout = {
.tv_sec = id,
Expand Down
2 changes: 1 addition & 1 deletion tests/misc-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <parlib/timing.h>

#define pthread_id() (pthread_self()->id)
#define pthread_id() (pthread_self()->uthread.id)

#else

Expand Down
13 changes: 7 additions & 6 deletions tests/pthread_barrier_test.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include <stdio.h>
#include <parlib/parlib.h>
#include <pthread.h>
#include <stdlib.h>
#include <parlib/parlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include "misc-compat.h"

pthread_barrier_t barrier;

Expand All @@ -17,16 +18,16 @@ void **my_retvals;
bool run_barriertest = FALSE;

void *thread(void *arg)
{
{
while (!run_barriertest)
cpu_relax();
for(int i = 0; i < nr_loops; i++) {
pthread_barrier_wait(&barrier);
}
return (void*)(long)pthread_self()->id;
return (void*)(long)pthread_id();
}

int main(int argc, char** argv)
int main(int argc, char **argv)
{
struct timeval start_tv = {0};
struct timeval end_tv = {0};
Expand Down
Loading