/*
- * Copyright (c) 1993-1995, 1999-2000 Apple Computer, Inc.
+ * Copyright (c) 1993-1995, 1999-2005 Apple Computer, Inc.
* All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
- *
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
*
* @APPLE_LICENSE_HEADER_END@
*/
-/*
- * Thread-based callout module.
- *
- * HISTORY
- *
- * 10 July 1999 (debo)
- * Pulled into Mac OS X (microkernel).
- *
- * 3 July 1993 (debo)
- * Created.
- */
#include <mach/mach_types.h>
+#include <mach/thread_act.h>
+#include <kern/kern_types.h>
+#include <kern/kalloc.h>
#include <kern/sched_prim.h>
#include <kern/clock.h>
#include <kern/task.h>
#include <kern/thread.h>
+#include <kern/wait_queue.h>
+
+#include <vm/vm_pageout.h>
#include <kern/thread_call.h>
#include <kern/call_entry.h>
thread_call_t call
);
-static void __inline__
+static __inline__ void
_set_delayed_call_timer(
thread_call_t call
);
void
thread_call_initialize(void)
{
- thread_call_t call;
- spl_t s;
+ kern_return_t result;
+ thread_t thread;
+ thread_call_t call;
+ spl_t s;
- simple_lock_init(&thread_call_lock, ETAP_MISC_TIMER);
+ simple_lock_init(&thread_call_lock, 0);
s = splsched();
simple_lock(&thread_call_lock);
simple_unlock(&thread_call_lock);
splx(s);
- kernel_thread_with_priority(_activate_thread, MAXPRI_KERNEL - 2);
+ result = kernel_thread_start_priority((thread_continue_t)_activate_thread, NULL, MAXPRI_KERNEL - 2, &thread);
+ if (result != KERN_SUCCESS)
+ panic("thread_call_initialize");
+
+ thread_deallocate(thread);
}
void
simple_unlock(&thread_call_lock);
splx(s);
- kfree((vm_offset_t)call, sizeof (thread_call_data_t));
+ kfree(call, sizeof (thread_call_data_t));
return (TRUE);
}
void
_call_thread_wake(void)
{
- if (wait_queue_wakeup_one(
- &call_thread_waitqueue, &call_thread_waitqueue,
- THREAD_AWAKENED) == KERN_SUCCESS) {
+ if (wait_queue_wakeup_one(&call_thread_waitqueue, NULL, THREAD_AWAKENED) == KERN_SUCCESS) {
thread_call_vars.idle_thread_num--;
if (++thread_call_vars.active_num > thread_call_vars.active_hiwat)
(void) splsched();
simple_lock(&thread_call_lock);
- self->active_callout = TRUE;
+ self->options |= TH_OPT_CALLOUT;
while (thread_call_vars.pending_num > 0) {
thread_call_t call;
simple_lock(&thread_call_lock);
}
- self->active_callout = FALSE;
+ self->options &= ~TH_OPT_CALLOUT;
if (--thread_call_vars.active_num < thread_call_vars.active_lowat)
thread_call_vars.active_lowat = thread_call_vars.active_num;
if (thread_call_vars.idle_thread_num < thread_call_vars.thread_lowat) {
thread_call_vars.idle_thread_num++;
- wait_queue_assert_wait(
- &call_thread_waitqueue, &call_thread_waitqueue,
- THREAD_INTERRUPTIBLE);
+ wait_queue_assert_wait(&call_thread_waitqueue, NULL, THREAD_UNINT, 0);
simple_unlock(&thread_call_lock);
(void) spllo();
- thread_block(_call_thread_continue);
+ thread_block((thread_continue_t)_call_thread_continue);
/* NOTREACHED */
}
simple_unlock(&thread_call_lock);
(void) spllo();
- (void) thread_terminate(self->top_act);
+ thread_terminate(self);
/* NOTREACHED */
}
void
_activate_thread_continue(void)
{
+ kern_return_t result;
+ thread_t thread;
+
(void) splsched();
simple_lock(&thread_call_lock);
simple_unlock(&thread_call_lock);
(void) spllo();
- kernel_thread_with_priority(_call_thread, MAXPRI_KERNEL - 1);
+ result = kernel_thread_start_priority((thread_continue_t)_call_thread, NULL, MAXPRI_KERNEL - 1, &thread);
+ if (result != KERN_SUCCESS)
+ panic("activate_thread");
+
+ thread_deallocate(thread);
(void) splsched();
simple_lock(&thread_call_lock);
simple_unlock(&thread_call_lock);
(void) spllo();
- thread_block(_activate_thread_continue);
+ thread_block((thread_continue_t)_activate_thread_continue);
/* NOTREACHED */
}
{
thread_t self = current_thread();
- self->vm_privilege = TRUE;
+ self->options |= TH_OPT_VMPRIV;
vm_page_free_reserve(2); /* XXX */
_activate_thread_continue();
static
void
_delayed_call_timer(
- timer_call_param_t p0,
- timer_call_param_t p1
+ __unused timer_call_param_t p0,
+ __unused timer_call_param_t p1
)
{
uint64_t timestamp;