diff options
Diffstat (limited to 'user/libthread/mutex.c')
| -rw-r--r-- | user/libthread/mutex.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/user/libthread/mutex.c b/user/libthread/mutex.c new file mode 100644 index 0000000..f78a6e8 --- /dev/null +++ b/user/libthread/mutex.c @@ -0,0 +1,35 @@ +/** + * @file mutex.c + * @author Hanjie Wu (hanjiew) + * @author Devang Acharya (devanga) + * @brief Mutex implementation + * @date 2023-02-22 + * + */ + +#include <stdint.h> + +#include <assert.h> +#include <mutex.h> + +/** + * @brief initialize the mutex pointed by mp + * + * @param mp mutex + * @return 0 + */ +int mutex_init(mutex_t* mp) { + mp->locked = 0; + mp->w_lock = 0; + mp->w_list = NULL; + return 0; +} + +/** + * @brief deactivate the mutex pointed by mp + * + * @param mp mutex + */ +void mutex_destroy(mutex_t* mp) { + affirm(mp->locked == 0); +} |
