Properly implement liballoc_free ()

This commit is contained in:
2026-01-16 22:09:16 +01:00
parent ab8093cc6c
commit 9a7dbf0594
12 changed files with 142 additions and 24 deletions

View File

@@ -10,16 +10,16 @@ void proc_mutex_lock (struct proc* proc, struct proc_mutex* mutex) {
spin_lock_ctx_t ctxmt;
try:
spin_lock (&mutex->lock, &ctxmt);
spin_lock (&mutex->resource->lock, &ctxmt);
if (!mutex->locked || mutex->owner == proc) {
mutex->locked = true;
mutex->owner = proc;
spin_unlock (&mutex->lock, &ctxmt);
spin_unlock (&mutex->resource->lock, &ctxmt);
return;
}
spin_unlock (&mutex->lock, &ctxmt);
spin_unlock (&mutex->resource->lock, &ctxmt);
proc_suspend (proc, &mutex->suspension_q);
@@ -29,10 +29,10 @@ try:
bool proc_mutex_unlock (struct proc* proc, struct proc_mutex* mutex) {
spin_lock_ctx_t ctxmt, ctxsq;
spin_lock (&mutex->lock, &ctxmt);
spin_lock (&mutex->resource->lock, &ctxmt);
if (mutex->owner != proc) {
spin_unlock (&mutex->lock, &ctxmt);
spin_unlock (&mutex->resource->lock, &ctxmt);
return false;
}
@@ -47,7 +47,7 @@ bool proc_mutex_unlock (struct proc* proc, struct proc_mutex* mutex) {
mutex->owner = resumed_proc;
spin_unlock (&mutex->suspension_q.lock, &ctxsq);
spin_unlock (&mutex->lock, &ctxmt);
spin_unlock (&mutex->resource->lock, &ctxmt);
proc_resume (resumed_proc);
return true;
@@ -58,7 +58,7 @@ bool proc_mutex_unlock (struct proc* proc, struct proc_mutex* mutex) {
mutex->locked = false;
mutex->owner = NULL;
spin_unlock (&mutex->lock, &ctxmt);
spin_unlock (&mutex->resource->lock, &ctxmt);
return true;
}