Redesign reschedule points, allow one operation to reschedule many cpus at once
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m12s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m12s
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include <sys/smp.h>
|
||||
#include <sys/spin_lock.h>
|
||||
|
||||
void proc_mutexes_cleanup (struct proc* proc) {
|
||||
void proc_mutexes_cleanup (struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
|
||||
struct rb_node_link* rnode;
|
||||
@@ -35,22 +35,19 @@ void proc_mutexes_cleanup (struct proc* proc) {
|
||||
if (resource->u.mutex.owner == proc && resource->u.mutex.locked) {
|
||||
spin_unlock (&resource->lock);
|
||||
|
||||
struct cpu* reschedule_cpu;
|
||||
proc_mutex_unlock (proc, &resource->u.mutex, &reschedule_cpu);
|
||||
proc_mutex_unlock (proc, &resource->u.mutex, rctx);
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
}
|
||||
|
||||
bool proc_cleanup_resource_mutex (struct proc_resource* resource, struct cpu** reschedule_cpu) {
|
||||
void proc_cleanup_resource_mutex (struct proc_resource* resource, struct reschedule_ctx* rctx) {
|
||||
struct proc_mutex* mutex = &resource->u.mutex;
|
||||
|
||||
spin_lock (&mutex->resource->lock);
|
||||
spin_lock (&mutex->suspension_q.lock);
|
||||
|
||||
bool reschedule = PROC_NO_RESCHEDULE;
|
||||
|
||||
while (mutex->suspension_q.proc_list != NULL) {
|
||||
struct list_node_link* node = mutex->suspension_q.proc_list;
|
||||
struct proc_sq_entry* sq_entry = list_entry (node, struct proc_sq_entry, sq_link);
|
||||
@@ -60,7 +57,7 @@ bool proc_cleanup_resource_mutex (struct proc_resource* resource, struct cpu** r
|
||||
spin_unlock (&mutex->suspension_q.lock);
|
||||
spin_unlock (&mutex->resource->lock);
|
||||
|
||||
reschedule = reschedule || proc_sq_resume (suspended_proc, sq_entry, reschedule_cpu);
|
||||
proc_sq_resume (suspended_proc, sq_entry, rctx);
|
||||
|
||||
/* reacquire */
|
||||
spin_lock (&mutex->resource->lock);
|
||||
@@ -72,29 +69,27 @@ bool proc_cleanup_resource_mutex (struct proc_resource* resource, struct cpu** r
|
||||
|
||||
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) {
|
||||
void proc_mutex_lock (struct proc* proc, struct proc_mutex* mutex, struct reschedule_ctx* rctx) {
|
||||
spin_lock (&mutex->resource->lock);
|
||||
|
||||
if (!mutex->locked || mutex->owner == proc) {
|
||||
mutex->locked = true;
|
||||
mutex->owner = proc;
|
||||
spin_unlock (&mutex->resource->lock);
|
||||
return PROC_NO_RESCHEDULE;
|
||||
return;
|
||||
}
|
||||
|
||||
return proc_sq_suspend (proc, &mutex->suspension_q, &mutex->resource->lock, reschedule_cpu);
|
||||
proc_sq_suspend (proc, &mutex->suspension_q, &mutex->resource->lock, rctx);
|
||||
}
|
||||
|
||||
bool proc_mutex_unlock (struct proc* proc, struct proc_mutex* mutex, struct cpu** reschedule_cpu) {
|
||||
void proc_mutex_unlock (struct proc* proc, struct proc_mutex* mutex, struct reschedule_ctx* rctx) {
|
||||
spin_lock (&mutex->resource->lock);
|
||||
|
||||
if (mutex->owner != proc) {
|
||||
spin_unlock (&mutex->resource->lock);
|
||||
return PROC_NO_RESCHEDULE;
|
||||
return;
|
||||
}
|
||||
|
||||
spin_lock (&mutex->suspension_q.lock);
|
||||
@@ -111,7 +106,8 @@ bool proc_mutex_unlock (struct proc* proc, struct proc_mutex* mutex, struct cpu*
|
||||
spin_unlock (&mutex->suspension_q.lock);
|
||||
spin_unlock (&mutex->resource->lock);
|
||||
|
||||
return proc_sq_resume (resumed_proc, sq_entry, reschedule_cpu);
|
||||
proc_sq_resume (resumed_proc, sq_entry, rctx);
|
||||
return;
|
||||
}
|
||||
|
||||
mutex->locked = false;
|
||||
@@ -119,6 +115,4 @@ bool proc_mutex_unlock (struct proc* proc, struct proc_mutex* mutex, struct cpu*
|
||||
|
||||
spin_unlock (&mutex->suspension_q.lock);
|
||||
spin_unlock (&mutex->resource->lock);
|
||||
|
||||
return PROC_NO_RESCHEDULE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user