diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-03-16 12:34:16 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-03-16 12:34:16 +0100 |
| commit | 2f39300ea1c19cf2a6996ab83b8c940c0b0060fe (patch) | |
| tree | c289a0c4990c6965462543cbd24c4928a3ff9c1c | |
| parent | aa97623eef5493e7c34acc6765727751920b062f (diff) | |
| download | pintos-master.tar.gz | |
| -rw-r--r-- | src/filesys/filesys.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/filesys/filesys.c b/src/filesys/filesys.c index ab6ddfe..5b38035 100644 --- a/src/filesys/filesys.c +++ b/src/filesys/filesys.c @@ -13,7 +13,7 @@ created twice with the same name. */ static struct lock create_lock; -static struct lock lookup_lock; // dir_lookup and dir_remove +static struct rwlock dir_lock; // dir_lookup and dir_remove /* The disk that contains the file system. */ struct disk *filesys_disk; @@ -30,7 +30,7 @@ filesys_init (bool format) PANIC ("hd0:1 (hdb) not present, file system initialization failed"); lock_init (&create_lock); - lock_init (&lookup_lock); + rwlock_init (&dir_lock); inode_init (); free_map_init (); @@ -83,9 +83,9 @@ filesys_open (const char *name) struct inode *inode = NULL; if (dir != NULL) { - lock_acquire (&lookup_lock); + rwlock_read_p (&dir_lock); dir_lookup (dir, name, &inode); - lock_release (&lookup_lock); + rwlock_read_v (&dir_lock); } dir_close (dir); @@ -100,9 +100,9 @@ bool filesys_remove (const char *name) { struct dir *dir = dir_open_root (); - lock_acquire (&lookup_lock); + rwlock_write_p (&dir_lock); bool success = dir != NULL && dir_remove (dir, name); - lock_release (&lookup_lock); + rwlock_write_v (&dir_lock); dir_close (dir); return success; |
