Annotation of XNU/bsd/kern/parallel.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /* 
        !            23:  * Mach Operating System
        !            24:  * Copyright (c) 1989 Carnegie-Mellon University
        !            25:  * Copyright (c) 1988 Carnegie-Mellon University
        !            26:  * Copyright (c) 1987 Carnegie-Mellon University
        !            27:  * All rights reserved.  The CMU software License Agreement specifies
        !            28:  * the terms and conditions for use and redistribution.
        !            29:  */
        !            30: /*
        !            31:  * HISTORY
        !            32:  * 
        !            33:  * Revision 1.1.1.1  1998/09/22 21:06:13  wsanchez
        !            34:  * Import of Mac OS X kernel (~semeria)
        !            35:  *
        !            36:  * Revision 1.1.1.1  1997/09/30 02:44:39  wsanchez
        !            37:  * Import of kernel from umeshv/kernel
        !            38:  *
        !            39:  * Revision 2.4  89/12/22  15:52:48  rpd
        !            40:  *     MACH_HOST support: when releasing master, context switch away
        !            41:  *     immediately if thread is not assigned to default processor set.
        !            42:  *     [89/11/16            dlb]
        !            43:  * 
        !            44:  * Revision 2.3  89/10/11  14:19:20  dlb
        !            45:  *     Processor logic - explicitly record bound processor in thread
        !            46:  *     instead of changing whichq pointer.
        !            47:  *     [88/09/30            dlb]
        !            48:  * 
        !            49:  * Revision 2.2  89/02/25  18:07:24  gm0w
        !            50:  *     Changes for cleanup.
        !            51:  * 
        !            52:  * 15-Oct-87  David Golub (dbg) at Carnegie-Mellon University
        !            53:  *     Use thread_bind (inline version) to bind thread to master cpu
        !            54:  *     while holding unix-lock.
        !            55:  *
        !            56:  *  9-Oct-87  Robert Baron (rvb) at Carnegie-Mellon University
        !            57:  *     Define unix_reset for longjmp/setjmp reset.
        !            58:  *
        !            59:  * 25-Sep-87  Robert Baron (rvb) at Carnegie-Mellon University
        !            60:  *     Clean out some debugging code.
        !            61:  *
        !            62:  * 21-Sep-87  Robert Baron (rvb) at Carnegie-Mellon University
        !            63:  *     Created.
        !            64:  *
        !            65:  */
        !            66: 
        !            67: 
        !            68: #include <cpus.h>
        !            69: #include <mach_host.h>
        !            70: 
        !            71: #if    NCPUS > 1
        !            72: 
        !            73: #include <kern/processor.h>
        !            74: #include <kern/thread.h>
        !            75: #include <kern/sched_prim.h>
        !            76: #include <kern/parallel.h>
        !            77: 
        !            78: void unix_master()
        !            79: {
        !            80:        register thread_t t = current_thread();
        !            81:        
        !            82:        if (! (++( t->unix_lock )))     {
        !            83: 
        !            84:                /* thread_bind(t, master_processor); */
        !            85:                t->bound_processor = master_processor;
        !            86: 
        !            87:                if (cpu_number() != master_cpu) {
        !            88:                        t->interruptible = FALSE;
        !            89:                        thread_block(0);
        !            90:                }
        !            91:        }
        !            92: }
        !            93: 
        !            94: void unix_release()
        !            95: {
        !            96:        register thread_t t = current_thread();
        !            97: 
        !            98:        t->unix_lock--;
        !            99:        if (t->unix_lock < 0) {
        !           100:                /* thread_bind(t, PROCESSOR_NULL); */
        !           101:                t->bound_processor = PROCESSOR_NULL;
        !           102: #if    MACH_HOST
        !           103:                if (t->processor_set != &default_pset)
        !           104:                        thread_block(0);
        !           105: #endif MACH_HOST
        !           106:        }
        !           107: }
        !           108: 
        !           109: void unix_reset()
        !           110: {
        !           111:        register thread_t       t = current_thread();
        !           112: 
        !           113:        if (t->unix_lock != -1)
        !           114:                t->unix_lock = 0;
        !           115: }
        !           116: 
        !           117: #endif NCPUS > 1

unix.superglobalmegacorp.com

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