|
|
1.1 ! root 1: /* ! 2: * Mach Operating System ! 3: * Copyright (c) 1992,1991,1990,1989,1988,1987 Carnegie Mellon University ! 4: * All Rights Reserved. ! 5: * ! 6: * Permission to use, copy, modify and distribute this software and its ! 7: * documentation is hereby granted, provided that both the copyright ! 8: * notice and this permission notice appear in all copies of the ! 9: * software, derivative works or modified versions, and any portions ! 10: * thereof, and that both notices appear in supporting documentation. ! 11: * ! 12: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" ! 13: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR ! 14: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ! 15: * ! 16: * Carnegie Mellon requests users of this software to return to ! 17: * ! 18: * Software Distribution Coordinator or [email protected] ! 19: * School of Computer Science ! 20: * Carnegie Mellon University ! 21: * Pittsburgh PA 15213-3890 ! 22: * ! 23: * any improvements or extensions that they make and grant Carnegie Mellon ! 24: * the rights to redistribute these changes. ! 25: */ ! 26: /* ! 27: * File: sched_prim.h ! 28: * Author: David Golub ! 29: * ! 30: * Scheduling primitive definitions file ! 31: * ! 32: */ ! 33: ! 34: #ifndef _KERN_SCHED_PRIM_H_ ! 35: #define _KERN_SCHED_PRIM_H_ ! 36: ! 37: #include <mach/boolean.h> ! 38: #include <mach/message.h> /* for mach_msg_timeout_t */ ! 39: #include <kern/lock.h> ! 40: #include <kern/kern_types.h> /* for thread_t */ ! 41: ! 42: /* ! 43: * Possible results of assert_wait - returned in ! 44: * current_thread()->wait_result. ! 45: */ ! 46: #define THREAD_AWAKENED 0 /* normal wakeup */ ! 47: #define THREAD_TIMED_OUT 1 /* timeout expired */ ! 48: #define THREAD_INTERRUPTED 2 /* interrupted by clear_wait */ ! 49: #define THREAD_RESTART 3 /* restart operation entirely */ ! 50: ! 51: typedef void *event_t; /* wait event */ ! 52: ! 53: typedef void (*continuation_t)(void); /* continuation */ ! 54: ! 55: /* ! 56: * Exported interface to sched_prim.c. ! 57: */ ! 58: ! 59: extern void sched_init(void); ! 60: ! 61: extern void assert_wait( ! 62: event_t event, ! 63: boolean_t interruptible); ! 64: extern void clear_wait( ! 65: thread_t thread, ! 66: int result, ! 67: boolean_t interrupt_only); ! 68: extern void thread_sleep( ! 69: event_t event, ! 70: simple_lock_t lock, ! 71: boolean_t interruptible); ! 72: extern void thread_wakeup(); /* for function pointers */ ! 73: extern void thread_wakeup_prim( ! 74: event_t event, ! 75: boolean_t one_thread, ! 76: int result); ! 77: extern boolean_t thread_invoke( ! 78: thread_t old_thread, ! 79: continuation_t continuation, ! 80: thread_t new_thread); ! 81: extern void thread_block( ! 82: continuation_t continuation); ! 83: extern void thread_run( ! 84: continuation_t continuation, ! 85: thread_t new_thread); ! 86: extern void thread_set_timeout( ! 87: int t); ! 88: extern void thread_setrun( ! 89: thread_t thread, ! 90: boolean_t may_preempt); ! 91: extern void thread_dispatch( ! 92: thread_t thread); ! 93: extern void thread_continue( ! 94: thread_t old_thread); ! 95: extern void thread_go( ! 96: thread_t thread); ! 97: extern void thread_will_wait( ! 98: thread_t thread); ! 99: extern void thread_will_wait_with_timeout( ! 100: thread_t thread, ! 101: mach_msg_timeout_t msecs); ! 102: extern boolean_t thread_handoff( ! 103: thread_t old_thread, ! 104: continuation_t continuation, ! 105: thread_t new_thread); ! 106: extern void recompute_priorities(); ! 107: ! 108: /* ! 109: * Routines defined as macros ! 110: */ ! 111: ! 112: #define thread_wakeup(x) \ ! 113: thread_wakeup_prim((x), FALSE, THREAD_AWAKENED) ! 114: #define thread_wakeup_with_result(x, z) \ ! 115: thread_wakeup_prim((x), FALSE, (z)) ! 116: #define thread_wakeup_one(x) \ ! 117: thread_wakeup_prim((x), TRUE, THREAD_AWAKENED) ! 118: ! 119: /* ! 120: * Machine-dependent code must define these functions. ! 121: */ ! 122: ! 123: extern void thread_bootstrap_return(void); ! 124: extern void thread_exception_return(void); ! 125: #ifdef __GNUC__ ! 126: extern void __volatile__ thread_syscall_return(kern_return_t); ! 127: #else ! 128: extern void thread_syscall_return(kern_return_t); ! 129: #endif ! 130: extern thread_t switch_context( ! 131: thread_t old_thread, ! 132: continuation_t continuation, ! 133: thread_t new_thread); ! 134: extern void stack_handoff( ! 135: thread_t old_thread, ! 136: thread_t new_thread); ! 137: ! 138: /* ! 139: * These functions are either defined in kern/thread.c ! 140: * via machine-dependent stack_attach and stack_detach functions, ! 141: * or are defined directly by machine-dependent code. ! 142: */ ! 143: ! 144: extern void stack_alloc( ! 145: thread_t thread, ! 146: void (*resume)(thread_t)); ! 147: extern boolean_t stack_alloc_try( ! 148: thread_t thread, ! 149: void (*resume)(thread_t)); ! 150: extern void stack_free( ! 151: thread_t thread); ! 152: ! 153: /* ! 154: * Convert a timeout in milliseconds (mach_msg_timeout_t) ! 155: * to a timeout in ticks (for use by set_timeout). ! 156: * This conversion rounds UP so that small timeouts ! 157: * at least wait for one tick instead of not waiting at all. ! 158: */ ! 159: ! 160: #define convert_ipc_timeout_to_ticks(millis) \ ! 161: (((millis) * hz + 999) / 1000) ! 162: ! 163: #endif /* _KERN_SCHED_PRIM_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.