Annotation of kernel/kern/sched_prim.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /* 
                     26:  * Mach Operating System
                     27:  * Copyright (c) 1992,1991,1990,1989,1988,1987 Carnegie Mellon University
                     28:  * All Rights Reserved.
                     29:  * 
                     30:  * Permission to use, copy, modify and distribute this software and its
                     31:  * documentation is hereby granted, provided that both the copyright
                     32:  * notice and this permission notice appear in all copies of the
                     33:  * software, derivative works or modified versions, and any portions
                     34:  * thereof, and that both notices appear in supporting documentation.
                     35:  * 
                     36:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     37:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     38:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     39:  * 
                     40:  * Carnegie Mellon requests users of this software to return to
                     41:  * 
                     42:  *  Software Distribution Coordinator  or  [email protected]
                     43:  *  School of Computer Science
                     44:  *  Carnegie Mellon University
                     45:  *  Pittsburgh PA 15213-3890
                     46:  * 
                     47:  * any improvements or extensions that they make and grant Carnegie Mellon
                     48:  * the rights to redistribute these changes.
                     49:  */
                     50: /*
                     51:  *     File:   sched_prim.h
                     52:  *     Author: David Golub
                     53:  *
                     54:  *     Scheduling primitive definitions file
                     55:  *
                     56:  */
                     57: 
                     58: #ifndef        _KERN_SCHED_PRIM_H_
                     59: #define _KERN_SCHED_PRIM_H_
                     60: 
                     61: #include <mach/boolean.h>
                     62: #include <mach/message.h>      /* for mach_msg_timeout_t */
                     63: #include <kern/lock.h>
                     64: #include <kern/kern_types.h>   /* for thread_t */
                     65: 
                     66: /*
                     67:  *     Possible results of assert_wait - returned in
                     68:  *     current_thread()->wait_result.
                     69:  */
                     70: #define THREAD_AWAKENED                0               /* normal wakeup */
                     71: #define THREAD_TIMED_OUT       1               /* timeout expired */
                     72: #define THREAD_INTERRUPTED     2               /* interrupted by clear_wait */
                     73: #define THREAD_SHOULD_TERMINATE        3               /* thread should terminate */
                     74: #define THREAD_RESTART         4               /* restart operation entirely */
                     75: 
                     76: typedef        void    *event_t;                       /* wait event */
                     77: 
                     78: typedef        void    (*continuation_t)(void);        /* continuation */
                     79: 
                     80: /*
                     81:  *     Exported interface to sched_prim.c.
                     82:  */
                     83: 
                     84: extern void    sched_init(void);
                     85: 
                     86: extern void    assert_wait(
                     87:        event_t         event,
                     88:        boolean_t       interruptible);
                     89: extern void    clear_wait(
                     90:        thread_t        thread,
                     91:        int             result,
                     92:        boolean_t       interrupt_only);
                     93: extern void    thread_sleep(
                     94:        event_t         event,
                     95:        simple_lock_t   lock,
                     96:        boolean_t       interruptible);
                     97: extern void    thread_wakeup();                /* for function pointers */
                     98: extern void    thread_wakeup_prim(
                     99:        event_t         event,
                    100:        boolean_t       one_thread,
                    101:        int             result);
                    102: extern boolean_t thread_invoke(
                    103:        thread_t        old_thread,
                    104:        continuation_t  continuation,
                    105:        thread_t        new_thread);
                    106: extern void    thread_block(void);
                    107: extern void    thread_block_with_continuation(
                    108:        continuation_t  continuation);
                    109: extern void    thread_run(
                    110:        continuation_t  continuation,
                    111:        thread_t        new_thread);
                    112: extern void    thread_set_timeout(
                    113:        int             t);
                    114: extern void    thread_setrun(
                    115:        thread_t        thread,
                    116:        boolean_t       may_preempt);
                    117: extern void    thread_dispatch(
                    118:        thread_t        thread);
                    119: extern void    thread_continue(
                    120:        thread_t        old_thread);
                    121: extern void    thread_go(
                    122:        thread_t        thread);
                    123: extern void    thread_go_and_switch(
                    124:        continuation_t  continuation,
                    125:        thread_t        thread);
                    126: extern void    thread_will_wait(
                    127:        thread_t        thread);
                    128: extern void    thread_will_wait_with_timeout(
                    129:        thread_t        thread,
                    130:        mach_msg_timeout_t msecs);
                    131: extern boolean_t thread_handoff(
                    132:        thread_t        old_thread,
                    133:        continuation_t  continuation,
                    134:        thread_t        new_thread);
                    135: extern void    recompute_priorities();
                    136: 
                    137: /*
                    138:  *     Routines defined as macros
                    139:  */
                    140: 
                    141: #define thread_wakeup(x)                                               \
                    142:                thread_wakeup_prim((x), FALSE, THREAD_AWAKENED)
                    143: #define thread_wakeup_with_result(x, z)                                        \
                    144:                thread_wakeup_prim((x), FALSE, (z))
                    145: #define thread_wakeup_one(x)                                           \
                    146:                thread_wakeup_prim((x), TRUE, THREAD_AWAKENED)
                    147: 
                    148: /*
                    149:  *     Machine-dependent code must define these functions.
                    150:  */
                    151: 
                    152: extern void    thread_bootstrap_return(void);
                    153: extern void    thread_exception_return(void);
                    154: #ifdef __GNUC__
                    155: extern void    __volatile__ thread_syscall_return(kern_return_t);
                    156: #else
                    157: extern void    thread_syscall_return(kern_return_t);
                    158: #endif
                    159: extern thread_t        switch_context(
                    160:        thread_t        old_thread,
                    161:        continuation_t  continuation,
                    162:        thread_t        new_thread);
                    163: extern void    stack_handoff(
                    164:        thread_t        old_thread,
                    165:        thread_t        new_thread);
                    166: 
                    167: /*
                    168:  *     These functions are either defined in kern/thread.c
                    169:  *     via machine-dependent stack_attach and stack_detach functions,
                    170:  *     or are defined directly by machine-dependent code.
                    171:  */
                    172: 
                    173: extern void    stack_alloc(
                    174:        thread_t        thread,
                    175:        void            (*resume)(thread_t));
                    176: extern boolean_t stack_alloc_try(
                    177:        thread_t        thread,
                    178:        void            (*resume)(thread_t));
                    179: extern void    stack_free(
                    180:        thread_t        thread);
                    181: 
                    182: /*
                    183:  *     Convert a timeout in milliseconds (mach_msg_timeout_t)
                    184:  *     to a timeout in ticks (for use by set_timeout).
                    185:  *     This conversion rounds UP so that small timeouts
                    186:  *     at least wait for one tick instead of not waiting at all.
                    187:  */
                    188: 
                    189: #define convert_ipc_timeout_to_ticks(millis)   \
                    190:                (((millis) * hz + 999) / 1000)
                    191: 
                    192: #endif /* _KERN_SCHED_PRIM_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.