Annotation of OSKit-Mach/kern/act.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1993,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:  *      Author: Bryan Ford, University of Utah CSL
                     19:  */
                     20: /*
                     21:  *     File:   act.h
                     22:  *
                     23:  *     This defines the Act structure,
                     24:  *     which is the kernel representation of a user-space activation.
                     25:  *
                     26:  */
                     27: 
                     28: #ifndef        _KERN_ACT_H_
                     29: #define _KERN_ACT_H_
                     30: 
                     31: #ifdef MIGRATING_THREADS
                     32: 
                     33: #ifndef __dead /* XXX */
                     34: #define __dead
                     35: #endif
                     36: 
                     37: #include <mach_ipc_compat.h>
                     38: #include <mach/vm_param.h>
                     39: #include <mach/port.h>
                     40: #include <kern/lock.h>
                     41: #include <kern/refcount.h>
                     42: #include <kern/queue.h>
                     43: 
                     44: #include "act.h"/*XXX*/
                     45: 
                     46: struct task;
                     47: struct thread;
                     48: struct Act;
                     49: 
                     50: 
                     51: struct ReturnHandler {
                     52:        struct ReturnHandler *next;
                     53:        void (*handler)(struct ReturnHandler *rh, struct Act *act);
                     54: };
                     55: typedef struct ReturnHandler ReturnHandler;
                     56: 
                     57: 
                     58: 
                     59: struct Act {
                     60: 
                     61:        /*** Task linkage ***/
                     62: 
                     63:        /* Links for task's circular list of activations.
                     64:           The activation is only on the task's activation list while active.
                     65:           Must be first.  */
                     66:        queue_chain_t   task_links;
                     67: 
                     68:        /* Reference to the task this activation is in.
                     69:           This is constant as long as the activation is allocated.  */
                     70:        struct task     *task;
                     71: 
                     72: 
                     73: 
                     74:        /*** Machine-dependent state ***/
                     75:        /* XXX should be first to allow maximum flexibility to MD code */
                     76:        MachineAct      mact;
                     77: 
                     78: 
                     79: 
                     80:        /*** Consistency ***/
                     81:        RefCount        ref_count;
                     82:        decl_simple_lock_data(,lock)
                     83: 
                     84: 
                     85: 
                     86:        /*** ipc_target-related stuff ***/
                     87: 
                     88:        /* ActPool this activation normally lives on, zero if none.
                     89:           The activation and actpool hold references to each other as long as this is nonzero
                     90:           (even when the activation isn't actually on the actpool's list).  */
                     91:        struct ipc_target       *ipt;
                     92: 
                     93:        /* Link on the ipt's list of activations.
                     94:           The activation is only actually on the ipt's list (and hence this is valid)
                     95:           when we're not in use (thread == 0) and not suspended (suspend_count == 0).  */
                     96:        struct Act      *ipt_next;
                     97: 
                     98: 
                     99: 
                    100:        /*** Thread linkage ***/
                    101: 
                    102:        /* Thread this activation is in, zero if not in use.
                    103:           The thread holds a reference on the activation while this is nonzero. */
                    104:        struct thread   *thread;
                    105: 
                    106:        /* The rest in this section is only valid when thread is nonzero.  */
                    107: 
                    108:        /* Next higher and next lower activation on the thread's activation stack.
                    109:           For a topmost activation or the null_act, higher is undefined.
                    110:           The bottommost activation is always the null_act.  */
                    111:        struct Act      *higher, *lower;
                    112: 
                    113:        /* Alert bits pending at this activation;
                    114:           some of them may have propagated from lower activations.  */
                    115:        unsigned        alerts;
                    116: 
                    117:        /* Mask of alert bits to be allowed to pass through from lower levels.  */
                    118:        unsigned        alert_mask;
                    119: 
                    120: 
                    121: 
                    122:        /*** Control information ***/
                    123: 
                    124:        /* Number of outstanding suspensions on this activation.  */
                    125:        int             suspend_count;
                    126: 
                    127:        /* This is normally true, but is set to false when the activation is terminated.  */
                    128:        int             active;
                    129: 
                    130:        /* Chain of return handlers to be called
                    131:           before the thread is allowed to return to this invocation */
                    132:        ReturnHandler   *handlers;
                    133: 
                    134:        /* A special ReturnHandler attached to the above chain to handle suspension and such */
                    135:        ReturnHandler   special_handler;
                    136: 
                    137: 
                    138: 
                    139:        /* Special ports attached to this activation */
                    140:        struct ipc_port *self;                  /* not a right, doesn't hold ref */
                    141:        struct ipc_port *self_port;             /* a send right */
                    142:        struct ipc_port *exception_port;        /* a send right */
                    143:        struct ipc_port *syscall_port;          /* a send right */
                    144: #if    MACH_IPC_COMPAT
                    145:        struct ipc_port *reply_port;            /* a send right */
                    146:        struct task     *reply_task;
                    147: #endif MACH_IPC_COMPAT
                    148: };
                    149: typedef struct Act Act;
                    150: typedef struct Act *act_t;
                    151: typedef mach_port_t *act_array_t;
                    152: 
                    153: #define ACT_NULL ((Act*)0)
                    154: 
                    155: 
                    156: /* Exported to world */
                    157: kern_return_t  act_create(struct task *task, vm_offset_t user_stack, vm_offset_t user_rbuf, vm_size_t user_rbuf_size, struct Act **new_act);
                    158: kern_return_t  act_alert_mask(struct Act *act, unsigned alert_mask);
                    159: kern_return_t  act_alert(struct Act *act, unsigned alerts);
                    160: kern_return_t  act_abort(struct Act *act);
                    161: kern_return_t  act_abort_safely(struct Act *act);
                    162: kern_return_t  act_terminate(struct Act *act);
                    163: kern_return_t  act_suspend(struct Act *act);
                    164: kern_return_t  act_resume(struct Act *act);
                    165: kern_return_t  act_get_state(struct Act *act, int flavor,
                    166:                        natural_t *state, natural_t *pcount);
                    167: kern_return_t  act_set_state(struct Act *act, int flavor,
                    168:                        natural_t *state, natural_t count);
                    169: 
                    170: #define                act_lock(act)           simple_lock(&(act)->lock)
                    171: #define                act_unlock(act)         simple_unlock(&(act)->lock)
                    172: 
                    173: #define                act_reference(act)      refcount_take(&(act)->ref_count)
                    174: void           act_deallocate(struct Act *act);
                    175: 
                    176: /* Exported to startup.c */
                    177: void           act_init(void);
                    178: 
                    179: /* Exported to task.c */
                    180: kern_return_t  act_terminate_task_locked(struct Act *act);
                    181: 
                    182: /* Exported to thread.c */
                    183: extern Act     null_act;
                    184: kern_return_t  act_create_kernel(Act **out_act);
                    185: 
                    186: /* Exported to machine-dependent activation code */
                    187: void           act_execute_returnhandlers(void);
                    188: 
                    189: 
                    190: 
                    191: /* System-dependent functions */
                    192: kern_return_t  act_machine_create(struct task *task, Act *inc, vm_offset_t user_stack, vm_offset_t user_rbuf, vm_size_t user_rbuf_size);
                    193: void           act_machine_destroy(Act *inc);
                    194: kern_return_t  act_machine_set_state(Act *inc, int flavor, int *tstate, unsigned count);
                    195: kern_return_t  act_machine_get_state(Act *inc, int flavor, int *tstate, unsigned *count);
                    196: 
                    197: 
                    198: 
                    199: #endif /* MIGRATING_THREADS */
                    200: #endif _KERN_ACT_H_

unix.superglobalmegacorp.com

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