/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*
* @APPLE_LICENSE_HEADER_END@
*/
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * HISTORY
- *
- * 15 October 2000 (debo)
- * Created.
- */
+#include <mach/mach_types.h>
+#include <mach/thread_act_server.h>
+
+#include <kern/kern_types.h>
#include <kern/processor.h>
#include <kern/thread.h>
kern_return_t
thread_policy_set(
- thread_act_t act,
+ thread_t thread,
thread_policy_flavor_t flavor,
thread_policy_t policy_info,
mach_msg_type_number_t count)
{
kern_return_t result = KERN_SUCCESS;
- thread_t thread;
spl_t s;
- if (act == THR_ACT_NULL)
+ if (thread == THREAD_NULL)
return (KERN_INVALID_ARGUMENT);
- thread = act_lock_thread(act);
- if (!act->active) {
- act_unlock_thread(act);
+ thread_mtx_lock(thread);
+ if (!thread->active) {
+ thread_mtx_unlock(thread);
return (KERN_TERMINATED);
}
- assert(thread != THREAD_NULL);
-
switch (flavor) {
case THREAD_EXTENDED_POLICY:
break;
}
- act_unlock_thread(act);
+ thread_mtx_unlock(thread);
return (result);
}
splx(s);
}
+void
+thread_policy_reset(
+ thread_t thread)
+{
+ if (!(thread->sched_mode & TH_MODE_FAILSAFE)) {
+ thread->sched_mode &= ~TH_MODE_REALTIME;
+
+ if (!(thread->sched_mode & TH_MODE_TIMESHARE)) {
+ thread->sched_mode |= TH_MODE_TIMESHARE;
+
+ if (thread->state & TH_RUN)
+ pset_share_incr(thread->processor_set);
+ }
+ }
+ else {
+ thread->safe_mode = 0;
+ thread->sched_mode &= ~TH_MODE_FAILSAFE;
+ }
+
+ thread->importance = 0;
+
+ thread_recompute_priority(thread);
+}
+
kern_return_t
thread_policy_get(
- thread_act_t act,
+ thread_t thread,
thread_policy_flavor_t flavor,
thread_policy_t policy_info,
mach_msg_type_number_t *count,
boolean_t *get_default)
{
kern_return_t result = KERN_SUCCESS;
- thread_t thread;
spl_t s;
- if (act == THR_ACT_NULL)
+ if (thread == THREAD_NULL)
return (KERN_INVALID_ARGUMENT);
- thread = act_lock_thread(act);
- if (!act->active) {
- act_unlock_thread(act);
+ thread_mtx_lock(thread);
+ if (!thread->active) {
+ thread_mtx_unlock(thread);
return (KERN_TERMINATED);
}
- assert(thread != THREAD_NULL);
-
switch (flavor) {
case THREAD_EXTENDED_POLICY:
break;
}
- act_unlock_thread(act);
+ thread_mtx_unlock(thread);
return (result);
}