Skip to content
Snippets Groups Projects
Commit ad2a717b authored by Videau Luc's avatar Videau Luc
Browse files

feat: add sys_acquire_mutex and sys_release_mutex

parent 044e4627
No related branches found
Tags tp1-act-4-5
No related merge requests found
......@@ -504,12 +504,32 @@ sys_create_mutex(void)
uint64
sys_acquire_mutex(void)
{
struct file *f;
int n;
uint64 p;
if(argfd(0,0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
return -1;
if (f->type != FD_MUTEX)
return -1;
acquiresleep(&f->mutex);
return 0;
}
uint64
sys_release_mutex(void)
{
struct file *f;
int n;
uint64 p;
if(argfd(0,0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
return -1;
if (f->type != FD_MUTEX)
return -1;
if (myproc()->pid != f->mutex.pid){
return -1;
}
releasesleep(&f->mutex);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment