41,7 → 41,6 |
#include <proc/uarg.h> |
#include <mm/as.h> |
#include <mm/slab.h> |
#include <atomic.h> |
#include <synch/spinlock.h> |
#include <synch/waitq.h> |
#include <arch.h> |
141,8 → 140,11 |
|
/* |
* Increment address space reference count. |
* TODO: Reconsider the locking scheme. |
*/ |
atomic_inc(&as->refcount); |
mutex_lock(&as->lock); |
as->refcount++; |
mutex_unlock(&as->lock); |
|
spinlock_lock(&tasks_lock); |
|
164,8 → 166,15 |
task_destroy_arch(t); |
btree_destroy(&t->futexes); |
|
if (atomic_predec(&t->as->refcount) == 0) |
mutex_lock_active(&t->as->lock); |
if (--t->as->refcount == 0) { |
mutex_unlock(&t->as->lock); |
as_destroy(t->as); |
/* |
* t->as is destroyed. |
*/ |
} else |
mutex_unlock(&t->as->lock); |
|
free(t); |
TASK = NULL; |