Remove spinlock contexts
All checks were successful
Build documentation / build-and-deploy (push) Successful in 28s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 28s
This commit is contained in:
@@ -12,9 +12,7 @@
|
||||
#include <sys/spin_lock.h>
|
||||
|
||||
void proc_mutexes_cleanup (struct proc* proc) {
|
||||
spin_lock_ctx_t ctxpg, ctxrs;
|
||||
|
||||
spin_lock (&proc->procgroup->lock, &ctxpg);
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
|
||||
struct rb_node_link* rnode;
|
||||
rbtree_first (&proc->procgroup->resource_tree, rnode);
|
||||
@@ -27,30 +25,29 @@ void proc_mutexes_cleanup (struct proc* proc) {
|
||||
|
||||
rnode = next;
|
||||
|
||||
spin_lock (&resource->lock, &ctxrs);
|
||||
spin_lock (&resource->lock);
|
||||
|
||||
if (resource->type != PR_MUTEX) {
|
||||
spin_unlock (&resource->lock, &ctxrs);
|
||||
spin_unlock (&resource->lock);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (resource->u.mutex.owner == proc && resource->u.mutex.locked) {
|
||||
spin_unlock (&resource->lock, &ctxrs);
|
||||
spin_unlock (&resource->lock);
|
||||
|
||||
struct cpu* reschedule_cpu;
|
||||
proc_mutex_unlock (proc, &resource->u.mutex, &reschedule_cpu);
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock (&proc->procgroup->lock, &ctxpg);
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
}
|
||||
|
||||
bool proc_cleanup_resource_mutex (struct proc_resource* resource, struct cpu** reschedule_cpu) {
|
||||
struct proc_mutex* mutex = &resource->u.mutex;
|
||||
spin_lock_ctx_t ctxmt, ctxsq;
|
||||
|
||||
spin_lock (&mutex->resource->lock, &ctxmt);
|
||||
spin_lock (&mutex->suspension_q.lock, &ctxsq);
|
||||
spin_lock (&mutex->resource->lock);
|
||||
spin_lock (&mutex->suspension_q.lock);
|
||||
|
||||
bool reschedule = PROC_NO_RESCHEDULE;
|
||||
|
||||
@@ -60,52 +57,47 @@ bool proc_cleanup_resource_mutex (struct proc_resource* resource, struct cpu** r
|
||||
struct proc* suspended_proc = sq_entry->proc;
|
||||
|
||||
/* we will relock during resume */
|
||||
spin_unlock (&mutex->suspension_q.lock, &ctxsq);
|
||||
spin_unlock (&mutex->resource->lock, &ctxmt);
|
||||
spin_unlock (&mutex->suspension_q.lock);
|
||||
spin_unlock (&mutex->resource->lock);
|
||||
|
||||
reschedule = reschedule || proc_sq_resume (suspended_proc, sq_entry, reschedule_cpu);
|
||||
|
||||
/* reacquire */
|
||||
spin_lock (&mutex->resource->lock, &ctxmt);
|
||||
spin_lock (&mutex->suspension_q.lock, &ctxsq);
|
||||
spin_lock (&mutex->resource->lock);
|
||||
spin_lock (&mutex->suspension_q.lock);
|
||||
}
|
||||
|
||||
mutex->locked = false;
|
||||
mutex->owner = NULL;
|
||||
|
||||
spin_unlock (&mutex->suspension_q.lock, &ctxsq);
|
||||
spin_unlock (&mutex->resource->lock, &ctxmt);
|
||||
spin_unlock (&mutex->suspension_q.lock);
|
||||
spin_unlock (&mutex->resource->lock);
|
||||
|
||||
return reschedule;
|
||||
}
|
||||
|
||||
bool proc_mutex_lock (struct proc* proc, struct proc_mutex* mutex, struct cpu** reschedule_cpu) {
|
||||
spin_lock_ctx_t ctxmt;
|
||||
|
||||
spin_lock (&mutex->resource->lock, &ctxmt);
|
||||
spin_lock (&mutex->resource->lock);
|
||||
|
||||
if (!mutex->locked || mutex->owner == proc) {
|
||||
mutex->locked = true;
|
||||
mutex->owner = proc;
|
||||
spin_unlock (&mutex->resource->lock, &ctxmt);
|
||||
spin_unlock (&mutex->resource->lock);
|
||||
return PROC_NO_RESCHEDULE;
|
||||
}
|
||||
|
||||
return proc_sq_suspend (proc, &mutex->suspension_q, &mutex->resource->lock, &ctxmt,
|
||||
reschedule_cpu);
|
||||
return proc_sq_suspend (proc, &mutex->suspension_q, &mutex->resource->lock, reschedule_cpu);
|
||||
}
|
||||
|
||||
bool proc_mutex_unlock (struct proc* proc, struct proc_mutex* mutex, struct cpu** reschedule_cpu) {
|
||||
spin_lock_ctx_t ctxmt, ctxsq;
|
||||
|
||||
spin_lock (&mutex->resource->lock, &ctxmt);
|
||||
spin_lock (&mutex->resource->lock);
|
||||
|
||||
if (mutex->owner != proc) {
|
||||
spin_unlock (&mutex->resource->lock, &ctxmt);
|
||||
spin_unlock (&mutex->resource->lock);
|
||||
return PROC_NO_RESCHEDULE;
|
||||
}
|
||||
|
||||
spin_lock (&mutex->suspension_q.lock, &ctxsq);
|
||||
spin_lock (&mutex->suspension_q.lock);
|
||||
|
||||
struct list_node_link* node = mutex->suspension_q.proc_list;
|
||||
|
||||
@@ -116,8 +108,8 @@ bool proc_mutex_unlock (struct proc* proc, struct proc_mutex* mutex, struct cpu*
|
||||
mutex->owner = resumed_proc;
|
||||
mutex->locked = true;
|
||||
|
||||
spin_unlock (&mutex->suspension_q.lock, &ctxsq);
|
||||
spin_unlock (&mutex->resource->lock, &ctxmt);
|
||||
spin_unlock (&mutex->suspension_q.lock);
|
||||
spin_unlock (&mutex->resource->lock);
|
||||
|
||||
return proc_sq_resume (resumed_proc, sq_entry, reschedule_cpu);
|
||||
}
|
||||
@@ -125,8 +117,8 @@ bool proc_mutex_unlock (struct proc* proc, struct proc_mutex* mutex, struct cpu*
|
||||
mutex->locked = false;
|
||||
mutex->owner = NULL;
|
||||
|
||||
spin_unlock (&mutex->suspension_q.lock, &ctxsq);
|
||||
spin_unlock (&mutex->resource->lock, &ctxmt);
|
||||
spin_unlock (&mutex->suspension_q.lock);
|
||||
spin_unlock (&mutex->resource->lock);
|
||||
|
||||
return PROC_NO_RESCHEDULE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user