Annotation of Gnu-Mach/kern/sched_prim.h, revision 1.1.1.2

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();
1.1.1.2 ! root      107: extern void    update_priority(
        !           108:        thread_t        thread);
        !           109: extern void    compute_my_priority(
        !           110:        thread_t        thread);
        !           111: extern void thread_bind(
        !           112:     thread_t   thread,
        !           113:     processor_t     processor);
        !           114: extern void compute_priority(
        !           115:     thread_t   thread,
        !           116:     boolean_t       resched);
        !           117: extern void thread_timeout_setup(
        !           118:     register thread_t   thread);
1.1       root      119: 
                    120: /*
                    121:  *     Routines defined as macros
                    122:  */
                    123: 
                    124: #define thread_wakeup(x)                                               \
                    125:                thread_wakeup_prim((x), FALSE, THREAD_AWAKENED)
                    126: #define thread_wakeup_with_result(x, z)                                        \
                    127:                thread_wakeup_prim((x), FALSE, (z))
                    128: #define thread_wakeup_one(x)                                           \
                    129:                thread_wakeup_prim((x), TRUE, THREAD_AWAKENED)
                    130: 
                    131: /*
                    132:  *     Machine-dependent code must define these functions.
                    133:  */
                    134: 
                    135: extern void    thread_bootstrap_return(void);
                    136: extern void    thread_exception_return(void);
                    137: #ifdef __GNUC__
1.1.1.2 ! root      138: extern void    __attribute__((__noreturn__)) thread_syscall_return(kern_return_t);
1.1       root      139: #else
                    140: extern void    thread_syscall_return(kern_return_t);
                    141: #endif
                    142: extern thread_t        switch_context(
                    143:        thread_t        old_thread,
                    144:        continuation_t  continuation,
                    145:        thread_t        new_thread);
                    146: extern void    stack_handoff(
                    147:        thread_t        old_thread,
                    148:        thread_t        new_thread);
                    149: 
                    150: /*
                    151:  *     These functions are either defined in kern/thread.c
                    152:  *     via machine-dependent stack_attach and stack_detach functions,
                    153:  *     or are defined directly by machine-dependent code.
                    154:  */
                    155: 
                    156: extern void    stack_alloc(
                    157:        thread_t        thread,
                    158:        void            (*resume)(thread_t));
                    159: extern boolean_t stack_alloc_try(
                    160:        thread_t        thread,
                    161:        void            (*resume)(thread_t));
                    162: extern void    stack_free(
                    163:        thread_t        thread);
                    164: 
                    165: /*
                    166:  *     Convert a timeout in milliseconds (mach_msg_timeout_t)
                    167:  *     to a timeout in ticks (for use by set_timeout).
                    168:  *     This conversion rounds UP so that small timeouts
                    169:  *     at least wait for one tick instead of not waiting at all.
                    170:  */
                    171: 
                    172: #define convert_ipc_timeout_to_ticks(millis)   \
                    173:                (((millis) * hz + 999) / 1000)
                    174: 
                    175: #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.