Move suspension q's cleanup to proc/suspension_q.c
This commit is contained in:
@@ -94,31 +94,7 @@ struct proc* proc_clone (struct proc* proto, uintptr_t vstack_top, uintptr_t ent
|
|||||||
}
|
}
|
||||||
|
|
||||||
void proc_cleanup (struct proc* proc) {
|
void proc_cleanup (struct proc* proc) {
|
||||||
spin_lock_ctx_t ctxsq, ctxpr;
|
proc_sqs_cleanup (proc);
|
||||||
|
|
||||||
spin_lock (&proc->lock, &ctxpr);
|
|
||||||
|
|
||||||
/* clean suspension queue entries */
|
|
||||||
struct list_node_link *sq_link, *sq_link_tmp;
|
|
||||||
list_foreach (proc->sq_entries, sq_link, sq_link_tmp) {
|
|
||||||
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);
|
|
||||||
|
|
||||||
/* remove from sq's list */
|
|
||||||
list_remove (sq->proc_list, &sq_entry->sq_link);
|
|
||||||
|
|
||||||
/* remove from proc's list */
|
|
||||||
list_remove (proc->sq_entries, &sq_entry->proc_link);
|
|
||||||
|
|
||||||
spin_unlock (&sq->lock, &ctxsq);
|
|
||||||
|
|
||||||
free (sq_entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_unlock (&proc->lock, &ctxpr);
|
|
||||||
|
|
||||||
proc_mutexes_cleanup (proc);
|
proc_mutexes_cleanup (proc);
|
||||||
|
|
||||||
pmm_free (proc->pdata.kernel_stack, KSTACK_SIZE / PAGE_SIZE);
|
pmm_free (proc->pdata.kernel_stack, KSTACK_SIZE / PAGE_SIZE);
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
c += proc/proc.c \
|
c += proc/proc.c \
|
||||||
proc/resource.c \
|
proc/resource.c \
|
||||||
proc/mutex.c \
|
proc/mutex.c \
|
||||||
proc/procgroup.c
|
proc/procgroup.c \
|
||||||
|
proc/suspension_q.c
|
||||||
|
|
||||||
o += proc/proc.o \
|
o += proc/proc.o \
|
||||||
proc/resource.o \
|
proc/resource.o \
|
||||||
proc/mutex.o \
|
proc/mutex.o \
|
||||||
proc/procgroup.o
|
proc/procgroup.o \
|
||||||
|
proc/suspension_q.o
|
||||||
|
|||||||
32
kernel/proc/suspension_q.c
Normal file
32
kernel/proc/suspension_q.c
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#include <libk/list.h>
|
||||||
|
#include <mm/liballoc.h>
|
||||||
|
#include <proc/proc.h>
|
||||||
|
#include <proc/suspension_q.h>
|
||||||
|
#include <sync/spin_lock.h>
|
||||||
|
|
||||||
|
void proc_sqs_cleanup (struct proc* proc) {
|
||||||
|
spin_lock_ctx_t ctxsq, ctxpr;
|
||||||
|
|
||||||
|
spin_lock (&proc->lock, &ctxpr);
|
||||||
|
|
||||||
|
/* clean suspension queue entries */
|
||||||
|
struct list_node_link *sq_link, *sq_link_tmp;
|
||||||
|
list_foreach (proc->sq_entries, sq_link, sq_link_tmp) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* remove from sq's list */
|
||||||
|
list_remove (sq->proc_list, &sq_entry->sq_link);
|
||||||
|
|
||||||
|
/* remove from proc's list */
|
||||||
|
list_remove (proc->sq_entries, &sq_entry->proc_link);
|
||||||
|
|
||||||
|
spin_unlock (&sq->lock, &ctxsq);
|
||||||
|
|
||||||
|
free (sq_entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
spin_unlock (&proc->lock, &ctxpr);
|
||||||
|
}
|
||||||
@@ -4,9 +4,13 @@
|
|||||||
#include <libk/list.h>
|
#include <libk/list.h>
|
||||||
#include <sync/spin_lock.h>
|
#include <sync/spin_lock.h>
|
||||||
|
|
||||||
|
struct proc;
|
||||||
|
|
||||||
struct proc_suspension_q {
|
struct proc_suspension_q {
|
||||||
struct list_node_link* proc_list;
|
struct list_node_link* proc_list;
|
||||||
spin_lock_t lock;
|
spin_lock_t lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void proc_sqs_cleanup (struct proc* proc);
|
||||||
|
|
||||||
#endif // _KERNEL_PROC_SUSPENTION_Q_H
|
#endif // _KERNEL_PROC_SUSPENTION_Q_H
|
||||||
|
|||||||
Reference in New Issue
Block a user