From 2f39300ea1c19cf2a6996ab83b8c940c0b0060fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 16 Mar 2021 12:34:16 +0100 Subject: rwlock root_dir --- src/filesys/filesys.c | 12 ++++++------ 1 file 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; -- cgit v1.2.1