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;
|
||||
}
|
||||
|
||||
@@ -105,6 +105,8 @@ struct proc* proc_spawn_rd (char* name) {
|
||||
|
||||
bool ok = proc_check_elf (rd_file->content);
|
||||
|
||||
DEBUG ("Spawning %s, elf header %s\n", name, ok ? "ok" : "bad");
|
||||
|
||||
if (!ok)
|
||||
return NULL;
|
||||
|
||||
@@ -112,24 +114,21 @@ struct proc* proc_spawn_rd (char* name) {
|
||||
}
|
||||
|
||||
struct proc* proc_find_pid (int pid) {
|
||||
spin_lock_ctx_t ctxprtr;
|
||||
struct proc* proc = NULL;
|
||||
|
||||
spin_lock (&proc_tree_lock, &ctxprtr);
|
||||
spin_lock (&proc_tree_lock);
|
||||
rbtree_find (struct proc, &proc_tree, pid, proc, proc_tree_link, pid);
|
||||
spin_unlock (&proc_tree_lock, &ctxprtr);
|
||||
spin_unlock (&proc_tree_lock);
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
||||
bool proc_register (struct proc* proc, struct cpu** reschedule_cpu) {
|
||||
spin_lock_ctx_t ctxcpu, ctxprtr, ctxpr;
|
||||
|
||||
struct cpu* cpu = *reschedule_cpu != NULL ? *reschedule_cpu : cpu_find_lightest ();
|
||||
|
||||
spin_lock (&proc_tree_lock, &ctxprtr);
|
||||
spin_lock (&cpu->lock, &ctxcpu);
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
spin_lock (&proc_tree_lock);
|
||||
spin_lock (&cpu->lock);
|
||||
spin_lock (&proc->lock);
|
||||
|
||||
proc->cpu = cpu;
|
||||
|
||||
@@ -140,9 +139,9 @@ bool proc_register (struct proc* proc, struct cpu** reschedule_cpu) {
|
||||
if (cpu->proc_current == NULL)
|
||||
cpu->proc_current = proc;
|
||||
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
spin_unlock (&cpu->lock, &ctxcpu);
|
||||
spin_unlock (&proc_tree_lock, &ctxprtr);
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&cpu->lock);
|
||||
spin_unlock (&proc_tree_lock);
|
||||
|
||||
*reschedule_cpu = cpu;
|
||||
|
||||
@@ -181,10 +180,8 @@ static struct proc* proc_find_sched (struct cpu* cpu) {
|
||||
static void proc_reap (void) {
|
||||
struct proc* proc = NULL;
|
||||
struct list_node_link* reap_list = NULL;
|
||||
spin_lock_ctx_t ctxprtr;
|
||||
spin_lock_ctx_t ctxpr;
|
||||
|
||||
spin_lock (&proc_tree_lock, &ctxprtr);
|
||||
spin_lock (&proc_tree_lock);
|
||||
|
||||
struct rb_node_link* node;
|
||||
rbtree_first (&proc_tree, node);
|
||||
@@ -195,16 +192,16 @@ static void proc_reap (void) {
|
||||
proc = rbtree_entry (node, struct proc, proc_tree_link);
|
||||
|
||||
if (atomic_load (&proc->state) == PROC_DEAD) {
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
spin_lock (&proc->lock);
|
||||
rbtree_delete (&proc_tree, &proc->proc_tree_link);
|
||||
list_append (reap_list, &proc->reap_link);
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
spin_unlock (&proc->lock);
|
||||
}
|
||||
|
||||
node = next;
|
||||
}
|
||||
|
||||
spin_unlock (&proc_tree_lock, &ctxprtr);
|
||||
spin_unlock (&proc_tree_lock);
|
||||
|
||||
struct list_node_link *reap_link, *reap_link_tmp;
|
||||
list_foreach (reap_list, reap_link, reap_link_tmp) {
|
||||
@@ -217,8 +214,6 @@ static void proc_reap (void) {
|
||||
}
|
||||
|
||||
void proc_sched (void) {
|
||||
spin_lock_ctx_t ctxcpu;
|
||||
|
||||
int s_cycles = atomic_fetch_add (&sched_cycles, 1);
|
||||
|
||||
if (s_cycles % SCHED_REAP_FREQ == 0)
|
||||
@@ -227,31 +222,29 @@ void proc_sched (void) {
|
||||
struct proc* next = NULL;
|
||||
struct cpu* cpu = thiscpu;
|
||||
|
||||
spin_lock (&cpu->lock, &ctxcpu);
|
||||
spin_lock (&cpu->lock);
|
||||
|
||||
next = proc_find_sched (cpu);
|
||||
|
||||
if (next) {
|
||||
cpu->proc_current = next;
|
||||
|
||||
do_sched (next, &cpu->lock, &ctxcpu);
|
||||
do_sched (next, &cpu->lock);
|
||||
} else {
|
||||
cpu->proc_current = NULL;
|
||||
spin_unlock (&cpu->lock, &ctxcpu);
|
||||
spin_unlock (&cpu->lock);
|
||||
|
||||
spin ();
|
||||
}
|
||||
}
|
||||
|
||||
bool proc_kill (struct proc* proc, struct cpu** reschedule_cpu) {
|
||||
spin_lock_ctx_t ctxpr, ctxcpu;
|
||||
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
spin_lock (&proc->lock);
|
||||
struct cpu* cpu = proc->cpu;
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
spin_unlock (&proc->lock);
|
||||
|
||||
spin_lock (&cpu->lock, &ctxcpu);
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
spin_lock (&cpu->lock);
|
||||
spin_lock (&proc->lock);
|
||||
|
||||
atomic_store (&proc->state, PROC_DEAD);
|
||||
proc->cpu = NULL;
|
||||
@@ -261,8 +254,8 @@ bool proc_kill (struct proc* proc, struct cpu** reschedule_cpu) {
|
||||
if (cpu->proc_current == proc)
|
||||
cpu->proc_current = NULL;
|
||||
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
spin_unlock (&cpu->lock, &ctxcpu);
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&cpu->lock);
|
||||
|
||||
DEBUG ("killed PID %d\n", proc->pid);
|
||||
|
||||
@@ -290,7 +283,6 @@ void proc_init (void) {
|
||||
struct cpu* init_cpu = thiscpu;
|
||||
proc_register (init, &init_cpu);
|
||||
|
||||
spin_lock_ctx_t ctxcpu;
|
||||
spin_lock (&spin_proc->cpu->lock, &ctxcpu);
|
||||
do_sched (spin_proc, &spin_proc->cpu->lock, &ctxcpu);
|
||||
spin_lock (&spin_proc->cpu->lock);
|
||||
do_sched (spin_proc, &spin_proc->cpu->lock);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <libk/rbtree.h>
|
||||
#include <libk/std.h>
|
||||
#include <libk/string.h>
|
||||
#include <mm/liballoc.h>
|
||||
#include <mm/pmm.h>
|
||||
#include <proc/proc.h>
|
||||
@@ -14,16 +15,14 @@ static atomic_int pgids = 0;
|
||||
|
||||
uintptr_t procgroup_map (struct procgroup* procgroup, uintptr_t vaddr, size_t pages, uint32_t flags,
|
||||
uintptr_t* out_paddr) {
|
||||
spin_lock_ctx_t ctxpg;
|
||||
|
||||
spin_lock (&procgroup->lock, &ctxpg);
|
||||
spin_lock (&procgroup->lock);
|
||||
|
||||
vaddr = (vaddr == 0) ? procgroup->map_base : vaddr;
|
||||
|
||||
struct proc_mapping* mapping = malloc (sizeof (*mapping));
|
||||
|
||||
if (mapping == NULL) {
|
||||
spin_unlock (&procgroup->lock, &ctxpg);
|
||||
spin_unlock (&procgroup->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,7 +30,7 @@ uintptr_t procgroup_map (struct procgroup* procgroup, uintptr_t vaddr, size_t pa
|
||||
|
||||
if (paddr == PMM_ALLOC_ERR) {
|
||||
free (mapping);
|
||||
spin_unlock (&procgroup->lock, &ctxpg);
|
||||
spin_unlock (&procgroup->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -51,7 +50,7 @@ uintptr_t procgroup_map (struct procgroup* procgroup, uintptr_t vaddr, size_t pa
|
||||
mm_map_page (&procgroup->pd, ppage, vpage, flags);
|
||||
}
|
||||
|
||||
spin_unlock (&procgroup->lock, &ctxpg);
|
||||
spin_unlock (&procgroup->lock);
|
||||
|
||||
return vaddr;
|
||||
}
|
||||
@@ -63,13 +62,12 @@ bool procgroup_unmap (struct procgroup* procgroup, uintptr_t start_vaddr, size_t
|
||||
struct list_node_link *mapping_link, *mapping_link_tmp;
|
||||
|
||||
bool used_tail_mapping = false;
|
||||
spin_lock_ctx_t ctxpg;
|
||||
|
||||
struct proc_mapping* tail_mapping = malloc (sizeof (*tail_mapping));
|
||||
if (tail_mapping == NULL)
|
||||
return false;
|
||||
|
||||
spin_lock (&procgroup->lock, &ctxpg);
|
||||
spin_lock (&procgroup->lock);
|
||||
|
||||
list_foreach (procgroup->mappings, mapping_link, mapping_link_tmp) {
|
||||
struct proc_mapping* mapping =
|
||||
@@ -122,19 +120,19 @@ bool procgroup_unmap (struct procgroup* procgroup, uintptr_t start_vaddr, size_t
|
||||
mm_unmap_page (&procgroup->pd, vpage);
|
||||
}
|
||||
|
||||
spin_unlock (&procgroup->lock, &ctxpg);
|
||||
spin_unlock (&procgroup->lock);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct procgroup* procgroup_create (void) {
|
||||
spin_lock_ctx_t ctxpgtr;
|
||||
|
||||
struct procgroup* procgroup = malloc (sizeof (*procgroup));
|
||||
if (procgroup == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset (procgroup, 0, sizeof (*procgroup));
|
||||
|
||||
procgroup->refs = 0;
|
||||
procgroup->memb_proc_tree = NULL;
|
||||
procgroup->lock = SPIN_LOCK_INIT;
|
||||
@@ -142,48 +140,44 @@ struct procgroup* procgroup_create (void) {
|
||||
procgroup->pd.cr3_paddr = mm_alloc_user_pd_phys ();
|
||||
procgroup->map_base = PROC_MAP_BASE;
|
||||
|
||||
spin_lock (&procgroup_tree_lock, &ctxpgtr);
|
||||
spin_lock (&procgroup_tree_lock);
|
||||
rbtree_insert (struct procgroup, &procgroup_tree, &procgroup->procgroup_tree_link,
|
||||
procgroup_tree_link, pgid);
|
||||
spin_unlock (&procgroup_tree_lock, &ctxpgtr);
|
||||
spin_unlock (&procgroup_tree_lock);
|
||||
|
||||
return procgroup;
|
||||
}
|
||||
|
||||
void procgroup_attach (struct procgroup* procgroup, struct proc* proc) {
|
||||
spin_lock_ctx_t ctxpg, ctxpr;
|
||||
|
||||
spin_lock (&procgroup->lock, &ctxpg);
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
spin_lock (&procgroup->lock);
|
||||
spin_lock (&proc->lock);
|
||||
|
||||
rbtree_insert (struct proc, &procgroup->memb_proc_tree, &proc->procgroup_memb_tree_link,
|
||||
procgroup_memb_tree_link, pid);
|
||||
atomic_fetch_add (&procgroup->refs, 1);
|
||||
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
spin_unlock (&procgroup->lock, &ctxpg);
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&procgroup->lock);
|
||||
}
|
||||
|
||||
void procgroup_detach (struct procgroup* procgroup, struct proc* proc) {
|
||||
spin_lock_ctx_t ctxpg, ctxpr, ctxpgtr;
|
||||
|
||||
spin_lock (&procgroup->lock, &ctxpg);
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
spin_lock (&procgroup->lock);
|
||||
spin_lock (&proc->lock);
|
||||
|
||||
rbtree_delete (&procgroup->memb_proc_tree, &proc->procgroup_memb_tree_link);
|
||||
int refs = atomic_fetch_sub (&procgroup->refs, 1);
|
||||
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
spin_unlock (&procgroup->lock, &ctxpg);
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&procgroup->lock);
|
||||
|
||||
if (refs == 1) {
|
||||
spin_lock (&procgroup_tree_lock, &ctxpgtr);
|
||||
spin_lock (&procgroup->lock, &ctxpg);
|
||||
spin_lock (&procgroup_tree_lock);
|
||||
spin_lock (&procgroup->lock);
|
||||
|
||||
rbtree_delete (&procgroup_tree, &procgroup->procgroup_tree_link);
|
||||
|
||||
spin_unlock (&procgroup->lock, &ctxpg);
|
||||
spin_unlock (&procgroup_tree_lock, &ctxpgtr);
|
||||
spin_unlock (&procgroup->lock);
|
||||
spin_unlock (&procgroup_tree_lock);
|
||||
|
||||
/* delete resources */
|
||||
struct rb_node_link* rnode;
|
||||
|
||||
@@ -13,19 +13,17 @@
|
||||
#include <sys/debug.h>
|
||||
|
||||
struct proc_resource* proc_find_resource (struct procgroup* procgroup, int rid) {
|
||||
spin_lock_ctx_t ctxpg;
|
||||
struct proc_resource* resource = NULL;
|
||||
|
||||
spin_lock (&procgroup->lock, &ctxpg);
|
||||
spin_lock (&procgroup->lock);
|
||||
rbtree_find (struct proc_resource, &procgroup->resource_tree, rid, resource, resource_tree_link,
|
||||
rid);
|
||||
spin_unlock (&procgroup->lock, &ctxpg);
|
||||
spin_unlock (&procgroup->lock);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
struct proc_resource* proc_create_resource_mutex (struct procgroup* procgroup, int rid) {
|
||||
spin_lock_ctx_t ctxpg;
|
||||
struct proc_resource* resource;
|
||||
|
||||
resource = proc_find_resource (procgroup, rid);
|
||||
@@ -43,10 +41,10 @@ struct proc_resource* proc_create_resource_mutex (struct procgroup* procgroup, i
|
||||
resource->rid = rid;
|
||||
resource->type = PR_MUTEX;
|
||||
|
||||
spin_lock (&procgroup->lock, &ctxpg);
|
||||
spin_lock (&procgroup->lock);
|
||||
rbtree_insert (struct proc_resource, &procgroup->resource_tree, &resource->resource_tree_link,
|
||||
resource_tree_link, rid);
|
||||
spin_unlock (&procgroup->lock, &ctxpg);
|
||||
spin_unlock (&procgroup->lock);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
@@ -9,24 +9,23 @@
|
||||
#include <sys/spin_lock.h>
|
||||
|
||||
bool proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock_t* resource_lock,
|
||||
spin_lock_ctx_t* ctxrl, struct cpu** reschedule_cpu) {
|
||||
spin_lock_ctx_t ctxpr, ctxcpu, ctxsq;
|
||||
struct cpu** reschedule_cpu) {
|
||||
struct cpu* cpu = proc->cpu;
|
||||
|
||||
struct proc_sq_entry* sq_entry = malloc (sizeof (*sq_entry));
|
||||
if (!sq_entry) {
|
||||
spin_unlock (resource_lock, ctxrl);
|
||||
spin_unlock (resource_lock);
|
||||
return PROC_NO_RESCHEDULE;
|
||||
}
|
||||
|
||||
sq_entry->proc = proc;
|
||||
sq_entry->sq = sq;
|
||||
|
||||
spin_lock (&cpu->lock, &ctxcpu);
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
spin_lock (&sq->lock, &ctxsq);
|
||||
spin_lock (&cpu->lock);
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&sq->lock);
|
||||
|
||||
spin_unlock (resource_lock, ctxrl);
|
||||
spin_unlock (resource_lock);
|
||||
|
||||
atomic_store (&proc->state, PROC_SUSPENDED);
|
||||
|
||||
@@ -44,9 +43,9 @@ bool proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock
|
||||
|
||||
proc->cpu = NULL;
|
||||
|
||||
spin_unlock (&sq->lock, &ctxsq);
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
spin_unlock (&cpu->lock, &ctxcpu);
|
||||
spin_unlock (&sq->lock);
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&cpu->lock);
|
||||
|
||||
*reschedule_cpu = cpu;
|
||||
|
||||
@@ -55,13 +54,12 @@ bool proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock
|
||||
|
||||
bool proc_sq_resume (struct proc* proc, struct proc_sq_entry* sq_entry,
|
||||
struct cpu** reschedule_cpu) {
|
||||
spin_lock_ctx_t ctxsq, ctxpr, ctxcpu;
|
||||
struct cpu* cpu = cpu_find_lightest ();
|
||||
struct proc_suspension_q* sq = sq_entry->sq;
|
||||
|
||||
spin_lock (&cpu->lock, &ctxcpu);
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
spin_lock (&sq->lock, &ctxsq);
|
||||
spin_lock (&cpu->lock);
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&sq->lock);
|
||||
|
||||
/* remove from sq's list */
|
||||
list_remove (sq->proc_list, &sq_entry->sq_link);
|
||||
@@ -77,9 +75,9 @@ bool proc_sq_resume (struct proc* proc, struct proc_sq_entry* sq_entry,
|
||||
list_append (cpu->proc_run_q, &proc->cpu_run_q_link);
|
||||
atomic_fetch_add (&cpu->proc_run_q_count, 1);
|
||||
|
||||
spin_unlock (&sq->lock, &ctxsq);
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
spin_unlock (&cpu->lock, &ctxcpu);
|
||||
spin_unlock (&sq->lock);
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&cpu->lock);
|
||||
|
||||
free (sq_entry);
|
||||
|
||||
@@ -89,9 +87,7 @@ bool proc_sq_resume (struct proc* proc, struct proc_sq_entry* sq_entry,
|
||||
}
|
||||
|
||||
void proc_sqs_cleanup (struct proc* proc) {
|
||||
spin_lock_ctx_t ctxsq, ctxpr;
|
||||
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
spin_lock (&proc->lock);
|
||||
|
||||
/* clean suspension queue entries */
|
||||
struct list_node_link *sq_link, *sq_link_tmp;
|
||||
@@ -99,7 +95,7 @@ void proc_sqs_cleanup (struct proc* proc) {
|
||||
struct proc_sq_entry* sq_entry = list_entry (sq_link, struct proc_sq_entry, proc_link);
|
||||
struct proc_suspension_q* sq = sq_entry->sq;
|
||||
|
||||
spin_lock (&sq->lock, &ctxsq);
|
||||
spin_lock (&sq->lock);
|
||||
|
||||
/* remove from sq's list */
|
||||
list_remove (sq->proc_list, &sq_entry->sq_link);
|
||||
@@ -107,10 +103,10 @@ void proc_sqs_cleanup (struct proc* proc) {
|
||||
/* remove from proc's list */
|
||||
list_remove (proc->sq_entries, &sq_entry->proc_link);
|
||||
|
||||
spin_unlock (&sq->lock, &ctxsq);
|
||||
spin_unlock (&sq->lock);
|
||||
|
||||
free (sq_entry);
|
||||
}
|
||||
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
spin_unlock (&proc->lock);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ struct proc_sq_entry {
|
||||
|
||||
void proc_sqs_cleanup (struct proc* proc);
|
||||
bool proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock_t* resource_lock,
|
||||
spin_lock_ctx_t* ctxrl, struct cpu** reschedule_cpu);
|
||||
struct cpu** reschedule_cpu);
|
||||
bool proc_sq_resume (struct proc* proc, struct proc_sq_entry* sq_entry,
|
||||
struct cpu** reschedule_cpu);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user