diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-03-16 12:30:14 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-03-16 12:30:14 +0100 |
| commit | aa97623eef5493e7c34acc6765727751920b062f (patch) | |
| tree | 28e135007bc8c242c6a949de6d9e48bff5041414 | |
| parent | 08b04f0cc9f44d78043c6d464c50731242481734 (diff) | |
| download | pintos-aa97623eef5493e7c34acc6765727751920b062f.tar.gz | |
lock lookup via fs_open and fs_remove
| -rw-r--r-- | src/filesys/filesys.c | 10 | ||||
| -rwxr-xr-x | src/userprog/start_recursor.sh | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/filesys/filesys.c b/src/filesys/filesys.c index d30f728..ab6ddfe 100644 --- a/src/filesys/filesys.c +++ b/src/filesys/filesys.c @@ -13,6 +13,8 @@ created twice with the same name. */ static struct lock create_lock; +static struct lock lookup_lock; // dir_lookup and dir_remove + /* The disk that contains the file system. */ struct disk *filesys_disk; @@ -28,6 +30,7 @@ filesys_init (bool format) PANIC ("hd0:1 (hdb) not present, file system initialization failed"); lock_init (&create_lock); + lock_init (&lookup_lock); inode_init (); free_map_init (); @@ -79,8 +82,11 @@ filesys_open (const char *name) struct dir *dir = dir_open_root (); struct inode *inode = NULL; - if (dir != NULL) + if (dir != NULL) { + lock_acquire (&lookup_lock); dir_lookup (dir, name, &inode); + lock_release (&lookup_lock); + } dir_close (dir); return file_open (inode); @@ -94,7 +100,9 @@ bool filesys_remove (const char *name) { struct dir *dir = dir_open_root (); + lock_acquire (&lookup_lock); bool success = dir != NULL && dir_remove (dir, name); + lock_release (&lookup_lock); dir_close (dir); return success; diff --git a/src/userprog/start_recursor.sh b/src/userprog/start_recursor.sh index 6f5e99b..46db573 100755 --- a/src/userprog/start_recursor.sh +++ b/src/userprog/start_recursor.sh @@ -3,4 +3,4 @@ cd build pintos-mkdisk fs.dsk 400 pintos -v --qemu -- -f -q pintos -v --qemu -p ../../examples/recursor_ng -a recursor_ng -- -q -pintos -v --qemu -m 128 -- run "recursor_ng pintosmaster 6 1" +pintos -v --qemu -m 128 -- -q run "recursor_ng pintosmaster 6 1" |
