Annotation of OSKit-Mach/ipc/ipc_target.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1994 The University of Utah and
                      3:  * the Computer Systems Laboratory (CSL).  All rights reserved.
                      4:  *
                      5:  * Permission to use, copy, modify and distribute this software and its
                      6:  * documentation is hereby granted, provided that both the copyright
                      7:  * notice and this permission notice appear in all copies of the
                      8:  * software, derivative works or modified versions, and any portions
                      9:  * thereof, and that both notices appear in supporting documentation.
                     10:  *
                     11:  * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
                     12:  * IS" CONDITION.  THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
                     13:  * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     14:  *
                     15:  * CSL requests users of this software to return to [email protected] any
                     16:  * improvements that they make and grant CSL redistribution rights.
                     17:  */
                     18: /*
                     19:  *     File:   ipc_target.c
                     20:  *
                     21:  *     Implementation for common part of IPC ports and port sets
                     22:  *     representing a target of messages and migrating RPCs.
                     23:  */
                     24: 
                     25: #include "sched_prim.h"
                     26: #include "ipc_target.h"
                     27: 
                     28: void
                     29: ipc_target_init(struct ipc_target *ipt, mach_port_t name)
                     30: {
                     31:        ipt->ipt_name = name;
                     32:        ipc_mqueue_init(&ipt->ipt_messages);
                     33: 
                     34: #ifdef MIGRATING_THREADS
                     35:        ipt->ipt_type = IPT_TYPE_MESSAGE_RPC;
                     36:        ipt->ipt_acts = 0;
                     37: 
                     38:        ipc_target_machine_init(ipt);
                     39: #endif
                     40: }
                     41: 
                     42: void
                     43: ipc_target_terminate(struct ipc_target *ipt)
                     44: {
                     45: }
                     46: 
                     47: #ifdef MIGRATING_THREADS
                     48: struct Act *
                     49: ipc_target_block(struct ipc_target *ipt)
                     50: {
                     51:        struct Act *act;
                     52: 
                     53:        ipt_lock(ipt);
                     54:        while ((act = ipt->ipt_acts) == 0) {
                     55:                /* XXX mp unsafe */
                     56:                ipt->ipt_waiting = 1;
                     57:                ipt_unlock(ipt);
                     58:                thread_wait((int)&ipt->ipt_acts, FALSE);
                     59:                ipt_lock(ipt);
                     60:        }
                     61:        ipt->ipt_acts = act->ipt_next;
                     62:        ipt_unlock(ipt);
                     63: 
                     64:        return act;
                     65: }
                     66: 
                     67: void
                     68: ipc_target_wakeup(struct ipc_target *ipt)
                     69: {
                     70:        ipt_lock(ipt);
                     71:        if (ipt->ipt_waiting) {
                     72:                thread_wakeup((int)&ipt->ipt_acts);
                     73:                ipt->ipt_waiting = 0;
                     74:        }
                     75:        ipt_unlock(ipt);
                     76: }
                     77: #endif /* MIGRATING_THREADS */
                     78: 

unix.superglobalmegacorp.com

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