#include "userprog/syscall.h" #include #include #include "threads/interrupt.h" #include "threads/thread.h" static void syscall_handler (struct intr_frame *); void syscall_init (void) { intr_register_int (0x30, 3, INTR_ON, syscall_handler, "syscall"); } static void syscall_handler (struct intr_frame *f UNUSED) { int syscall_number = *((int *)f->esp); switch (syscall_number) { case 9: // printf printf ("printf: %s", *((char **)(f->esp+8))); break; default: printf ("kernel: unknown syscall '%d'\n", syscall_number); break; } thread_exit (); }