Spinlock save cpu flags
This commit is contained in:
@@ -11,25 +11,27 @@
|
||||
#include <sys/spin_lock.h>
|
||||
|
||||
int proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock_t* resource_lock,
|
||||
struct reschedule_ctx* rctx) {
|
||||
uint64_t lockflags, struct reschedule_ctx* rctx) {
|
||||
uint64_t fc, fp, fsq;
|
||||
|
||||
struct cpu* cpu = proc->cpu;
|
||||
|
||||
struct proc_sq_entry* sq_entry = malloc (sizeof (*sq_entry));
|
||||
if (!sq_entry) {
|
||||
if (resource_lock != NULL)
|
||||
spin_unlock (resource_lock);
|
||||
spin_unlock (resource_lock, lockflags);
|
||||
return -ST_OOM_ERROR;
|
||||
}
|
||||
|
||||
sq_entry->proc = proc;
|
||||
sq_entry->sq = sq;
|
||||
|
||||
spin_lock (&cpu->lock);
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&sq->lock);
|
||||
spin_lock (&cpu->lock, &fc);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
spin_lock (&sq->lock, &fsq);
|
||||
|
||||
if (resource_lock != NULL)
|
||||
spin_unlock (resource_lock);
|
||||
spin_unlock (resource_lock, lockflags);
|
||||
|
||||
proc->state = PROC_SUSPENDED;
|
||||
|
||||
@@ -48,9 +50,9 @@ int proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock_
|
||||
proc->cpu = NULL;
|
||||
int state = proc->state;
|
||||
|
||||
spin_unlock (&sq->lock);
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&cpu->lock);
|
||||
spin_unlock (&sq->lock, fsq);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
spin_unlock (&cpu->lock, fc);
|
||||
|
||||
rctx_insert_cpu (rctx, cpu);
|
||||
|
||||
@@ -59,12 +61,14 @@ int proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock_
|
||||
|
||||
int proc_sq_resume (struct proc* proc, struct proc_sq_entry* sq_entry,
|
||||
struct reschedule_ctx* rctx) {
|
||||
uint64_t fc, fp, fsq;
|
||||
|
||||
struct cpu* cpu = cpu_find_lightest ();
|
||||
struct proc_suspension_q* sq = sq_entry->sq;
|
||||
|
||||
spin_lock (&cpu->lock);
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&sq->lock);
|
||||
spin_lock (&cpu->lock, &fc);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
spin_lock (&sq->lock, &fsq);
|
||||
|
||||
/* remove from sq's list */
|
||||
list_remove (sq->proc_list, &sq_entry->sq_link);
|
||||
@@ -82,9 +86,9 @@ int proc_sq_resume (struct proc* proc, struct proc_sq_entry* sq_entry,
|
||||
|
||||
int state = proc->state;
|
||||
|
||||
spin_unlock (&sq->lock);
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&cpu->lock);
|
||||
spin_unlock (&sq->lock, fsq);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
spin_unlock (&cpu->lock, fc);
|
||||
|
||||
free (sq_entry);
|
||||
|
||||
@@ -94,7 +98,9 @@ int proc_sq_resume (struct proc* proc, struct proc_sq_entry* sq_entry,
|
||||
}
|
||||
|
||||
void proc_sqs_cleanup (struct proc* proc) {
|
||||
spin_lock (&proc->lock);
|
||||
uint64_t fsq, fp;
|
||||
|
||||
spin_lock (&proc->lock, &fp);
|
||||
|
||||
/* clean suspension queue entries */
|
||||
struct list_node_link *sq_link, *sq_link_tmp;
|
||||
@@ -102,7 +108,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);
|
||||
spin_lock (&sq->lock, &fsq);
|
||||
|
||||
/* remove from sq's list */
|
||||
list_remove (sq->proc_list, &sq_entry->sq_link);
|
||||
@@ -110,10 +116,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);
|
||||
spin_unlock (&sq->lock, fsq);
|
||||
|
||||
free (sq_entry);
|
||||
}
|
||||
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user