Annotation of Gnu-Mach/ipc/ipc_thread.h, revision 1.1.1.3

1.1       root        1: /* 
                      2:  * Mach Operating System
                      3:  * Copyright (c) 1991,1990,1989 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:  */
                     28: /*
                     29:  *     File:   ipc/ipc_thread.h
                     30:  *     Author: Rich Draves
                     31:  *     Date:   1989
                     32:  *
                     33:  *     Definitions for the IPC component of threads.
                     34:  */
                     35: 
                     36: #ifndef        _IPC_IPC_THREAD_H_
                     37: #define _IPC_IPC_THREAD_H_
                     38: 
                     39: #include <kern/thread.h>
                     40: 
                     41: typedef thread_t ipc_thread_t;
                     42: 
                     43: #define        ITH_NULL                THREAD_NULL
                     44: 
                     45: #define        ith_lock_init(thread)   simple_lock_init(&(thread)->ith_lock_data)
                     46: #define        ith_lock(thread)        simple_lock(&(thread)->ith_lock_data)
                     47: #define        ith_unlock(thread)      simple_unlock(&(thread)->ith_lock_data)
                     48: 
1.1.1.2   root       49: /*
                     50:  *     Note that this isn't a queue, but rather a stack. This causes
                     51:  *     threads that were recently running to be reused earlier, which
                     52:  *     helps improve locality of reference.
                     53:  */
1.1       root       54: typedef struct ipc_thread_queue {
                     55:        ipc_thread_t ithq_base;
                     56: } *ipc_thread_queue_t;
                     57: 
                     58: #define        ITHQ_NULL               ((ipc_thread_queue_t) 0)
                     59: 
                     60: 
                     61: #define        ipc_thread_links_init(thread)           \
                     62: MACRO_BEGIN                                    \
                     63:        (thread)->ith_next = (thread);          \
                     64:        (thread)->ith_prev = (thread);          \
                     65: MACRO_END
                     66: 
                     67: #define        ipc_thread_queue_init(queue)            \
                     68: MACRO_BEGIN                                    \
                     69:        (queue)->ithq_base = ITH_NULL;          \
                     70: MACRO_END
                     71: 
                     72: #define        ipc_thread_queue_empty(queue)   ((queue)->ithq_base == ITH_NULL)
                     73: 
                     74: #define        ipc_thread_queue_first(queue)   ((queue)->ithq_base)
                     75: 
                     76: #define        ipc_thread_rmqueue_first_macro(queue, thread)                   \
                     77: MACRO_BEGIN                                                            \
1.1.1.3 ! root       78:        ipc_thread_t _next;                                             \
1.1       root       79:                                                                        \
                     80:        assert((queue)->ithq_base == (thread));                         \
                     81:                                                                        \
                     82:        _next = (thread)->ith_next;                                     \
                     83:        if (_next == (thread)) {                                        \
                     84:                assert((thread)->ith_prev == (thread));                 \
                     85:                (queue)->ithq_base = ITH_NULL;                          \
                     86:        } else {                                                        \
1.1.1.3 ! root       87:                ipc_thread_t _prev = (thread)->ith_prev;                \
1.1       root       88:                                                                        \
                     89:                (queue)->ithq_base = _next;                             \
                     90:                _next->ith_prev = _prev;                                \
                     91:                _prev->ith_next = _next;                                \
                     92:                ipc_thread_links_init(thread);                          \
                     93:        }                                                               \
                     94: MACRO_END
                     95: 
                     96: #define        ipc_thread_enqueue_macro(queue, thread)                         \
                     97: MACRO_BEGIN                                                            \
1.1.1.3 ! root       98:        ipc_thread_t _first = (queue)->ithq_base;                       \
1.1       root       99:                                                                        \
                    100:        if (_first == ITH_NULL) {                                       \
                    101:                (queue)->ithq_base = (thread);                          \
                    102:                assert((thread)->ith_next == (thread));                 \
                    103:                assert((thread)->ith_prev == (thread));                 \
                    104:        } else {                                                        \
1.1.1.3 ! root      105:                ipc_thread_t _last = _first->ith_prev;                  \
1.1       root      106:                                                                        \
                    107:                (thread)->ith_next = _first;                            \
                    108:                (thread)->ith_prev = _last;                             \
                    109:                _first->ith_prev = (thread);                            \
                    110:                _last->ith_next = (thread);                             \
1.1.1.2   root      111:                (queue)->ithq_base = (thread);                          \
1.1       root      112:        }                                                               \
                    113: MACRO_END
                    114: 
                    115: /* Enqueue a thread on a message queue */
                    116: extern void ipc_thread_enqueue(
                    117:        ipc_thread_queue_t      queue,
                    118:        ipc_thread_t            thread);
                    119: 
                    120: /* Dequeue a thread from a message queue */
                    121: extern ipc_thread_t ipc_thread_dequeue(
                    122:        ipc_thread_queue_t      queue);
                    123: 
                    124: /* Remove a thread from a message queue */
                    125: extern void ipc_thread_rmqueue(
                    126:        ipc_thread_queue_t      queue,
                    127:        ipc_thread_t            thread);
                    128: 
                    129: #endif /* _IPC_IPC_THREAD_H_ */

unix.superglobalmegacorp.com

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