From 987a71ec4019307e791897de98e807caafd35ce3 Mon Sep 17 00:00:00 2001 From: EDiasAlberto Date: Tue, 12 Nov 2024 16:00:19 +0000 Subject: [PATCH] Fix rox checking and make filesys_lock global --- src/userprog/process.c | 5 +++-- src/userprog/syscall.c | 3 --- src/userprog/syscall.h | 3 +++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/userprog/process.c b/src/userprog/process.c index 3d12bd1..e02500f 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -8,6 +8,7 @@ #include #include "userprog/gdt.h" #include "userprog/pagedir.h" +#include "userprog/syscall.h" #include "userprog/tss.h" #include "filesys/directory.h" #include "filesys/file.h" @@ -81,8 +82,8 @@ process_execute (const char *cmd) of the process. */ char *file_name = strtok_r (cmd_copy, " ", &data->cmd_saveptr); -/* Validates that the current file to be executed is a valid file */ -if (filesys_open (file_name) == NULL) + /* Validates that the current file to be executed is a valid file */ + if (filesys_open (file_name) == NULL) return TID_ERROR; /* Create a new thread to execute the command, by initializing diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index ccb02f3..b1ce4cc 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -13,7 +13,6 @@ #include #include -static struct lock filesys_lock; static unsigned fd_counter = MIN_USER_FD; struct open_file @@ -143,9 +142,7 @@ syscall_exec (const char *cmd_line) { validate_user_pointer (cmd_line, 1); - lock_acquire (&filesys_lock); pid_t pid = process_execute(cmd_line); - lock_release (&filesys_lock); return pid; } diff --git a/src/userprog/syscall.h b/src/userprog/syscall.h index 0f9288b..16af00c 100644 --- a/src/userprog/syscall.h +++ b/src/userprog/syscall.h @@ -2,11 +2,14 @@ #define USERPROG_SYSCALL_H #include +#include "threads/synch.h" #define MIN_USER_FD 2 typedef int pid_t; +struct lock filesys_lock; + void syscall_init (void); unsigned fd_hash (const struct hash_elem *element, void *aux);