Skip to content

Commit

Permalink
Rename start_thread and remove cpu parameter to handle_interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Dec 24, 2017
1 parent 5b60581 commit 2b5374c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion emu/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ flatten void cpu_run(struct cpu_state *cpu) {
int interrupt = cpu_step32(cpu);
if (interrupt != INT_NONE) {
cpu->trapno = interrupt;
handle_interrupt(cpu, interrupt);
handle_interrupt(interrupt);
}
if (i++ >= 100000) {
i = 0;
Expand Down
5 changes: 2 additions & 3 deletions kernel/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ syscall_t syscall_table[] = {
[324] = (syscall_t) sys_fallocate,
};

void handle_interrupt(struct cpu_state *cpu, int interrupt) {
void handle_interrupt(int interrupt) {
TRACELN_(instr, "\n");
TRACE("int %d ", interrupt);
struct cpu_state *cpu = &current->cpu;
if (interrupt == INT_SYSCALL) {
int syscall_num = cpu->eax;
if (syscall_num >= NUM_SYSCALLS || syscall_table[syscall_num] == NULL) {
Expand All @@ -119,8 +120,6 @@ void handle_interrupt(struct cpu_state *cpu, int interrupt) {
cpu->eax = result;
}
} else if (interrupt == INT_GPF) {
// page fault handling is a thing
// TODO SIGSEGV
println("page fault at %x", cpu->segfault_addr);
deliver_signal(current, SIGSEGV_);
} else if (interrupt == INT_UNDEFINED) {
Expand Down
2 changes: 1 addition & 1 deletion kernel/calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "kernel/signal.h"
#include "kernel/sock.h"

void handle_interrupt(struct cpu_state *cpu, int interrupt);
void handle_interrupt(int interrupt);

int must_check user_read(addr_t addr, void *buf, size_t count);
int must_check user_write(addr_t addr, const void *buf, size_t count);
Expand Down
2 changes: 1 addition & 1 deletion kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static int init_process(struct process *proc, dword_t flags, addr_t ctid_addr) {
err = _EFAULT;
goto fail_free_proc;
}
start_thread(proc);
process_start(proc);

if (flags & CLONE_VFORK_) {
// jeez why does every wait need a lock
Expand Down
4 changes: 2 additions & 2 deletions kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ static void *process_run(void *proc) {
process_run_hook();
else
cpu_run(&current->cpu);
assert(false);
abort(); // above function call should never return
}

void start_thread(struct process *proc) {
void process_start(struct process *proc) {
if (pthread_create(&proc->thread, NULL, process_run, proc) < 0)
abort();
pthread_detach(proc->thread);
Expand Down
2 changes: 1 addition & 1 deletion kernel/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ extern lock_t pids_lock;
// When a thread is created to run a new process, this function is used.
extern void (*process_run_hook)(void);
// TODO document
void start_thread(struct process *proc);
void process_start(struct process *proc);

extern void (*exit_hook)(int code);

Expand Down
2 changes: 1 addition & 1 deletion tools/ptraceomatic.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static void step_tracing(struct cpu_state *cpu, int pid, int sender, int receive
exit(1);
}
}
handle_interrupt(cpu, interrupt);
handle_interrupt(interrupt);
}

// step real cpu
Expand Down

0 comments on commit 2b5374c

Please sign in to comment.