From c4a2d251637a4cb20ece92710717adb55b6a865e Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Sun, 14 Nov 2021 21:51:18 +0100 Subject: [PATCH] TD2 question I.4 Create userthread.cc content and call it from exception.cc --- code/Makefile.common | 2 +- code/userprog/exception.cc | 7 +++++++ code/userprog/userthread.cc | 13 +++++++++++++ code/userprog/userthread.h | 7 +++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/code/Makefile.common b/code/Makefile.common index 51711e6..23fb09a 100644 --- a/code/Makefile.common +++ b/code/Makefile.common @@ -31,7 +31,7 @@ THREAD_O := main.o list.o scheduler.o synch.o synchlist.o \ stats.o sysdep.o timer.o USERPROG_O := addrspace.o bitmap.o exception.o progtest.o console.o \ - consoledriver.o machine.o mipssim.o translate.o + consoledriver.o machine.o mipssim.o translate.o userthread.o VM_O := diff --git a/code/userprog/exception.cc b/code/userprog/exception.cc index c4d751e..687f9e2 100644 --- a/code/userprog/exception.cc +++ b/code/userprog/exception.cc @@ -25,6 +25,10 @@ #include "system.h" #include "syscall.h" +#ifdef CHANGED +#include "userthread.h" +#endif + //---------------------------------------------------------------------- // UpdatePC : Increments the Program Counter register in order to resume // the user program immediately after the "syscall" instruction. @@ -210,6 +214,9 @@ ExceptionHandler (ExceptionType which) } case SC_ThreadCreate: { + int f = machine->ReadRegister(4); + int args = machine->ReadRegister(5); + do_ThreadCreate(f, args); break; } case SC_ThreadExit: diff --git a/code/userprog/userthread.cc b/code/userprog/userthread.cc index e69de29..6c65d2e 100644 --- a/code/userprog/userthread.cc +++ b/code/userprog/userthread.cc @@ -0,0 +1,13 @@ +#ifdef CHANGED +#include "copyright.h" +#include "system.h" +#include "userthread.h" +#include "syscall.h" + +int do_ThreadCreate(int f, int arg){ + DEBUG('x',"Enter do_ThreadCreate function\n"); +} + +void do_ThreadExit(){ +} +#endif diff --git a/code/userprog/userthread.h b/code/userprog/userthread.h index e69de29..7051d3c 100644 --- a/code/userprog/userthread.h +++ b/code/userprog/userthread.h @@ -0,0 +1,7 @@ +#ifdef CHANGED +#include "copyright.h" +#include "utility.h" + +extern int do_ThreadCreate(int f, int arg); +extern void do_ThreadExit(); +#endif