sched: enforce ref-counting on current task/thread pointers
This commit is contained in:
+5
-3
@@ -1261,9 +1261,11 @@ static kern_status_t request_missing_page(
|
||||
/* here:
|
||||
* `region` is locked.
|
||||
* `object` is unlocked.
|
||||
* `irq_flags` must be restored when `region` is unlocked.
|
||||
* the relevant page in `object` may or may not be committed.
|
||||
* if it isn't, it needs to be requested.
|
||||
* `irq_flags` must be restored when `region` is
|
||||
* unlocked.
|
||||
* the relevant page in `object` may or may
|
||||
* not be committed. if it isn't, it needs to be
|
||||
* requested.
|
||||
*/
|
||||
vm_object_lock(object);
|
||||
address_space_unlock(region);
|
||||
|
||||
+4
-2
@@ -159,6 +159,7 @@ kern_status_t vm_controller_recv(
|
||||
spin_unlock(&req->req_lock);
|
||||
|
||||
if (req->req_status == PAGE_REQUEST_ASYNC) {
|
||||
put_current_thread(req->req_sender);
|
||||
vm_cache_free(&page_request_cache, req);
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ kern_status_t vm_controller_detach_object(
|
||||
req->req_type = PAGE_REQUEST_DETACH;
|
||||
req->req_status = PAGE_REQUEST_ASYNC;
|
||||
req->req_object = vmo->vo_key;
|
||||
req->req_sender = current_thread();
|
||||
req->req_sender = get_current_thread();
|
||||
send_request_async(ctrl, req);
|
||||
|
||||
vmo->vo_ctrl = NULL;
|
||||
@@ -236,7 +237,7 @@ static void wait_for_reply(
|
||||
unsigned long *lock_flags)
|
||||
{
|
||||
struct wait_item waiter;
|
||||
struct thread *self = current_thread();
|
||||
struct thread *self = get_current_thread();
|
||||
|
||||
wait_item_init(&waiter, self);
|
||||
for (;;) {
|
||||
@@ -251,6 +252,7 @@ static void wait_for_reply(
|
||||
}
|
||||
|
||||
self->tr_state = THREAD_READY;
|
||||
put_current_thread(self);
|
||||
}
|
||||
|
||||
static void fulfill_requests(
|
||||
|
||||
+2
-1
@@ -376,7 +376,7 @@ static kern_status_t request_page(
|
||||
req.req_type = PAGE_REQUEST_READ;
|
||||
req.req_offset = offset;
|
||||
req.req_length = vm_page_order_to_bytes(VM_PAGE_4K);
|
||||
req.req_sender = current_thread();
|
||||
req.req_sender = get_current_thread();
|
||||
|
||||
object_ref(&vo->vo_base);
|
||||
req.req_object = vo->vo_key;
|
||||
@@ -388,6 +388,7 @@ static kern_status_t request_page(
|
||||
kern_status_t status
|
||||
= vm_controller_send_request(ctrl, &req, irq_flags);
|
||||
|
||||
put_current_thread(req.req_sender);
|
||||
spin_unlock(&req.req_lock);
|
||||
vm_controller_unlock_irqrestore(ctrl, *irq_flags);
|
||||
object_unref(&vo->vo_base);
|
||||
|
||||
Reference in New Issue
Block a user