Unlock mutexes on process death
This commit is contained in:
@@ -85,6 +85,39 @@ static void proc_mutex_resume (struct proc* proc, struct proc_sq_entry* sq_entry
|
||||
cpu_request_sched (cpu);
|
||||
}
|
||||
|
||||
void proc_mutexes_cleanup (struct proc* proc) {
|
||||
spin_lock_ctx_t ctxpg, ctxrs;
|
||||
|
||||
spin_lock (&proc->procgroup->lock, &ctxpg);
|
||||
|
||||
struct rb_node_link* rnode;
|
||||
rbtree_first (&proc->procgroup->resource_tree, rnode);
|
||||
|
||||
while (rnode) {
|
||||
struct rb_node_link* next;
|
||||
rbtree_next (rnode, next);
|
||||
|
||||
struct proc_resource* resource = rbtree_entry (rnode, struct proc_resource, resource_tree_link);
|
||||
|
||||
rnode = next;
|
||||
|
||||
spin_lock (&resource->lock, &ctxrs);
|
||||
|
||||
if (resource->type != PR_MUTEX) {
|
||||
spin_unlock (&resource->lock, &ctxrs);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (resource->u.mutex.owner == proc && resource->u.mutex.locked) {
|
||||
spin_unlock (&resource->lock, &ctxrs);
|
||||
|
||||
proc_mutex_unlock (proc, &resource->u.mutex);
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock (&proc->procgroup->lock, &ctxpg);
|
||||
}
|
||||
|
||||
void proc_cleanup_resource_mutex (struct proc_resource* resource) {
|
||||
struct proc_mutex* mutex = &resource->u.mutex;
|
||||
spin_lock_ctx_t ctxmt, ctxsq;
|
||||
|
||||
Reference in New Issue
Block a user