proc.h

来自「基于组件方式开发操作系统的OSKIT源代码」· C头文件 代码 · 共 422 行 · 第 1/2 页

H
422
字号
/*- * Copyright (c) 1986, 1989, 1991, 1993 *	The Regents of the University of California.  All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * *	@(#)proc.h	8.15 (Berkeley) 5/19/95 * $Id: proc.h,v 1.66.2.4 1999/05/14 06:32:41 dg Exp $ */#ifndef _SYS_PROC_H_#define	_SYS_PROC_H_#include <machine/proc.h>		/* Machine-dependent proc substruct. */#include <sys/callout.h>		/* For struct callout_handle. */#include <sys/rtprio.h>			/* For struct rtprio. */#include <sys/select.h>			/* For struct selinfo. */#include <sys/signal.h>#include <sys/signalvar.h>#ifndef KERNEL#include <sys/time.h>			/* For structs itimerval, timeval. */#endif#include <sys/ucred.h>#include <sys/queue.h>#include <sys/filedesc.h>#ifdef OSKIT#include <oskit/dev/dev.h>#endif/* * One structure allocated per session. */struct	session {	int	s_count;		/* Ref cnt; pgrps in session. */	struct	proc *s_leader;		/* Session leader. */	struct	vnode *s_ttyvp;		/* Vnode of controlling terminal. */	struct	tty *s_ttyp;		/* Controlling terminal. */	pid_t	s_sid;			/* Session ID */	char	s_login[roundup(MAXLOGNAME, sizeof(long))];	/* Setlogin() name. */};/* * One structure allocated per process group. */struct	pgrp {	LIST_ENTRY(pgrp) pg_hash;	/* Hash chain. */	LIST_HEAD(, proc) pg_members;	/* Pointer to pgrp members. */	struct	session *pg_session;	/* Pointer to session. */	struct  sigiolst pg_sigiolst;	/* List of sigio sources. */	pid_t	pg_id;			/* Pgrp id. */	int	pg_jobc;	/* # procs qualifying pgrp for job control */};struct	procsig {#define ps_begincopy ps_sigignore	sigset_t ps_sigignore;	/* Signals being ignored. */	sigset_t ps_sigcatch;	/* Signals being caught by user. */	int      ps_flag;	struct	 sigacts *ps_sigacts;#define ps_endcopy ps_refcnt	int	 ps_refcnt;};/* * pasleep structure, used by asleep() syscall to hold requested priority * and timeout values for await(). */struct  pasleep {	int	as_priority;	/* Async priority. */	int	as_timo;	/* Async timeout. */};/* * Description of a process. * * This structure contains the information needed to manage a thread of * control, known in UN*X as a process; it has references to substructures * containing descriptions of things that the process uses, but may share * with related processes.  The process structure and the substructures * are always addressable except for those marked "(PROC ONLY)" below, * which might be addressable only on a processor on which the process * is running. */#ifdef OSKIT/*   * For the OSKit we use our own stripped down proc structure. */struct	proc {	TAILQ_ENTRY(proc) p_procq;	/* run/sleep queue. */	struct	pcred *p_cred;	       /* Process owner's identity. */	struct	pstats *p_stats;	/* Accounting/statistics (PROC ONLY). */#define	p_ucred		p_cred->pc_ucred	int	p_flag;			/* P_* flags. */	char	p_stat;			/* S* process status. */	char	p_pad1[3];	pid_t	p_pid;			/* Process identifier. */	void	*p_wchan;	 /* Sleep address. */	const char *p_wmesg;	 /* Reason for sleep. */	u_short	p_acflag;	/* Accounting flags. */	osenv_sleeprec_t		       p_sr;	/*	 * When selrecord is invoked, this points to an object used to	 * manage a set of listeners.	 */	struct	listener_mgr	*p_sel;};#else /* !OSKIT */struct	proc {	TAILQ_ENTRY(proc) p_procq;	/* run/sleep queue. */	LIST_ENTRY(proc) p_list;	/* List of all processes. */	/* substructures: */	struct	pcred *p_cred;		/* Process owner's identity. */	struct	filedesc *p_fd;		/* Ptr to open files structure. */	struct	pstats *p_stats;	/* Accounting/statistics (PROC ONLY). */	struct	plimit *p_limit;	/* Process limits. */	struct	vm_object *p_upages_obj;/* Upages object */	struct	procsig *p_procsig;#define p_sigacts	p_procsig->ps_sigacts#define p_sigignore	p_procsig->ps_sigignore#define p_sigcatch	p_procsig->ps_sigcatch#define	p_ucred		p_cred->pc_ucred#define	p_rlimit	p_limit->pl_rlimit	int	p_flag;			/* P_* flags. */	char	p_stat;			/* S* process status. */	char	p_pad1[3];	pid_t	p_pid;			/* Process identifier. */	LIST_ENTRY(proc) p_hash;	/* Hash chain. */	LIST_ENTRY(proc) p_pglist;	/* List of processes in pgrp. */	struct	proc *p_pptr;	 	/* Pointer to parent process. */	LIST_ENTRY(proc) p_sibling;	/* List of sibling processes. */	LIST_HEAD(, proc) p_children;	/* Pointer to list of children. */	struct callout_handle p_ithandle; /*					      * Callout handle for scheduling					      * p_realtimer.					      *//* The following fields are all zeroed upon creation in fork. */#define	p_startzero	p_oppid	pid_t	p_oppid;	 /* Save parent pid during ptrace. XXX */	int	p_dupfd;	 /* Sideways return value from fdopen. XXX */	struct	vmspace *p_vmspace;	/* Address space. */	/* scheduling */	u_int	p_estcpu;	 /* Time averaged value of p_cpticks. */	int	p_cpticks;	 /* Ticks of cpu time. */	fixpt_t	p_pctcpu;	 /* %cpu for this process during p_swtime */	void	*p_wchan;	 /* Sleep address. */	const char *p_wmesg;	 /* Reason for sleep. */	u_int	p_swtime;	 /* Time swapped in or out. */	u_int	p_slptime;	 /* Time since last blocked. */	struct	itimerval p_realtimer;	/* Alarm timer. */	u_int64_t	p_runtime;	/* Real time in microsec. */	struct	timeval p_switchtime;	/* When last scheduled */	u_quad_t p_uticks;		/* Statclock hits in user mode. */	u_quad_t p_sticks;		/* Statclock hits in system mode. */	u_quad_t p_iticks;		/* Statclock hits processing intr. */	int	p_traceflag;		/* Kernel trace points. */	struct	vnode *p_tracep;	/* Trace to vnode. */	int	p_siglist;		/* Signals arrived but not delivered. */	struct	vnode *p_textvp;	/* Vnode of executable. */	char	p_lock;			/* Process lock (prevent swap) count. */	char	p_oncpu;		/* Which cpu we are on */	char	p_lastcpu;		/* Last cpu we were on */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?