proc.h revision ab9a77c71b58e388d02c6199c8bfbcb998aae845
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#ifndef _SYS_PROC_H
#define _SYS_PROC_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/watchpoint.h>
#if defined(__x86)
#include <sys/segments.h>
#endif
#include <sys/door_impl.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Profile arguments.
*/
struct prof {
void *pr_base; /* buffer base */
long pr_samples; /* sample count */
};
/* hash function for the lwpid hash table, p->p_tidhash[] */
/*
* An lwp directory entry.
* If le_thread != NULL, this is an active lwp.
* If le_thread == NULL, this is an unreaped zombie lwp.
*/
typedef struct lwpent {
} lwpent_t;
typedef struct pctxop {
void (*save_op)(void *); /* function to invoke to save ctx */
void (*restore_op)(void *); /* function to invoke to restore ctx */
void (*fork_op)(void *, void *); /* invoke to fork context */
void (*exit_op)(void *); /* invoked during process exit */
void (*free_op)(void *, int); /* function which frees the context */
void *arg; /* argument to above functions */
} pctxop_t;
/*
* Elements of the lwp directory, p->p_lwpdir[].
*
* We allocate lwp directory entries separately from lwp directory
* elements because the lwp directory must be allocated as an array.
* The number of lwps can grow quite large and we want to keep the
* size of the kmem_alloc()d directory as small as possible.
*
* If ld_entry == NULL, the entry is free and is on the free list,
* p->p_lwpfree, linked through ld_next. If ld_entry != NULL, the
* entry is used and ld_next is the thread-id hash link pointer.
*/
typedef struct lwpdir {
} lwpdir_t;
struct pool;
struct task;
struct zone;
struct corectl_path;
struct corectl_content;
/*
* One structure allocated per active process. It contains all
* data needed about the process while the process may be swapped
* out. Other per-process data (user.h) is also inside the proc structure.
* Lightweight-process data (lwp.h) and the kernel stack may be swapped out.
*/
typedef struct proc {
/*
* Fields requiring no explicit locking
*/
/*
* Fields protected by pidlock
*/
int p_swapcnt; /* number of swapped out lwps */
char p_stat; /* status of process */
char p_wcode; /* current wait code */
int p_wdata; /* current wait return value */
struct proc *p_nextorph;
/*
* Fields protected by p_lock
*/
/* to to be held. */
/* flags defined below */
/*
* Per process signal stuff.
*/
/*
* Special per-process flag when set will fix misaligned memory
* references.
*/
char p_fixalignment;
/*
* Per process lwp and kernel thread stuff
*/
int p_lwpcnt; /* number of lwps in this process */
int p_lwprcnt; /* number of not stopped lwps */
int p_lwpdaemon; /* number of TP_DAEMON lwps */
int p_lwpwait; /* number of lwps in lwp_wait() */
int p_lwpdwait; /* number of daemons in lwp_wait() */
int p_zombcnt; /* number of zombie lwps */
/* on which process has threads */
/*
* /proc (process filesystem) debugger interface stuff.
*/
int p_mapcnt; /* number of active pr_mappage()s */
/*
* Microstate accounting, resource usage, and real-time profiling
*/
/*
* profiling. A lock is used in the event of multiple lwp's
*/
/*
* The user structure
*/
/*
* Doors.
*/
struct door_node *p_unref_list;
char p_unref_thread; /* unref thread created */
/*
* Kernel probes
*/
/*
* C2 Security (C2_AUDIT)
*/
#if defined(__x86)
/*
* LDT support.
*/
#endif
int p_dtrace_probes; /* are there probes for this proc? */
/* (protected by P_PR_LOCK) */
void *p_dtrace_helpers; /* DTrace helpers, if any */
} proc_t;
#define PROC_T /* headers relying on proc_t are OK */
#ifdef _KERNEL
/* active process chain */
/* Well known processes */
#endif /* _KERNEL */
/*
* Stuff to keep track of the number of processes each uid has.
* It is tracked on a per-zone basis; that is, if users in different
* zones have the same uid, they are tracked separately.
*
* A structure is allocated when a new <uid,zoneid> pair shows up
* There is a hash to find each structure.
*/
struct upcount {
};
/* process ID info */
struct pid {
unsigned int pid_prinactive :1;
unsigned int pid_pgorphaned :1;
unsigned int pid_prslot :24;
struct proc *pid_pglink;
struct proc *pid_pgtail;
};
/*
* Structure containing persistent process lock. The structure and
* macro allow "mutex_enter(&p->p_lock)" to continue working.
*/
struct plock {
};
#ifdef _KERNEL
#endif /* _KERNEL */
/* stat codes */
/* p_pidflag codes */
/* p_proc_flag codes -- these flags are mostly private to /proc */
/*
* p_flag codes
*
* note that two of these flags, SMSACCT and SSYS, are exported to /proc's
* psinfo_t.p_flag field. Historically, all were, but since they are
* implementation dependant, we only export the ones people have come to
* rely upon. Hence, the bit positions of SSYS and SMSACCT should not be
* altered.
*/
/*
* p_poolflag codes
*
* These flags are used to synchronize with the pool subsystem to allow
* re-binding of processes to new pools.
*/
/* Macro to convert proc pointer to a user block pointer */
/* Macro to reduce unnecessary calls to issig() */
/*
* Fast version of ISSIG.
* 1. uses register pointers to lwp and proc instead of reloading them.
* 2. uses bit-wise OR of tests, since the usual case is that none of them
* are true, this saves orcc's and branches.
* 3. load the signal flags instead of using sigisempty() macro which does
* a branch to convert to boolean.
*/
#define ISSIG_PENDING(t, lwp, p) \
((lwp)->lwp_cursig | \
sigcheck((p), (t)) | \
(p)->p_stopsig | \
(t)->t_dtrace_stop | \
(t)->t_dtrace_sig | \
/*
* Determine if there are any watchpoints active in the process.
*/
/* Reasons for calling issig() */
#define FORREAL 0 /* Usual side-effects */
/* 'what' values for stop(PR_SUSPENDED, what) */
#define SUSPEND_NORMAL 0
#define SUSPEND_PAUSE 1
/* pseudo-flag to lwp_create() */
#define NOCLASS (-1)
/* LWP stats updated via lwp_stats_update() */
typedef enum {
#ifdef _KERNEL
/* user profiling functions */
extern void profil_tick(uintptr_t);
/* process management functions */
extern void proc_detach(proc_t *);
extern void setrun_locked(kthread_t *);
extern void exit(int, int);
extern int proc_exit(int, int);
extern void proc_is_exiting(proc_t *);
extern void relvm(void);
#if defined(__x86)
#endif
extern void sigcld_delete(k_siginfo_t *);
extern void sigcld_repost(void);
extern void psig(void);
extern void stop(int, int);
extern int issig(int);
extern int jobstopped(proc_t *);
extern void trapsig(k_siginfo_t *, int);
extern int eat_signal(kthread_t *, int);
extern int signal_is_blocked(kthread_t *, int);
extern void sigdefault(proc_t *);
extern void pid_setmin(void);
extern void proc_entry_free(struct pid *);
extern void sprlock_proc(proc_t *);
extern void pid_init(void);
extern void init_mstate(kthread_t *, int);
extern int new_mstate(kthread_t *, int);
extern void restore_mstate(kthread_t *);
extern void term_mstate(kthread_t *);
extern void disable_msacct(proc_t *);
extern void syscall_mstate(int, int);
extern void set_proc_pre_sys(proc_t *p);
extern void set_proc_post_sys(proc_t *p);
extern void set_proc_sys(proc_t *p);
extern void set_proc_ast(proc_t *p);
extern void set_all_proc_sys(void);
/* thread function prototypes */
extern kthread_t *thread_create(
void (*proc)(),
void *arg,
int state,
extern void thread_exit(void) __NORETURN;
extern void thread_free(kthread_t *);
extern void thread_rele(kthread_t *);
extern void thread_join(kt_did_t);
extern int reaper(void);
extern void installctx(kthread_t *, void *, void (*)(), void (*)(),
void (*)(), void (*)(), void (*)(), void (*)());
void (*)(), void (*)(), void (*)(), void (*)());
extern void restorectx(kthread_t *);
extern void installpctx(proc_t *, void *, void (*)(), void (*)(),
void (*)(), void (*)(), void (*)());
extern int removepctx(proc_t *, void *, void (*)(), void (*)(),
void (*)(), void (*)(), void (*)());
extern void restorepctx(proc_t *);
extern kthread_t *thread_unpin(void);
extern void thread_init(void);
extern void tsd_create(uint_t *, void (*)(void *));
extern void tsd_destroy(uint_t *);
extern void *tsd_getcreate(uint_t *, void (*)(void *), void *(*)(void));
extern void tsd_exit(void);
/* lwp function prototypes */
extern klwp_t *lwp_create(
void (*proc)(),
proc_t *p,
int state,
int pri,
const k_sigset_t *smask,
int cid,
extern void lwp_create_done(kthread_t *);
extern void lwp_exit(void);
extern void lwp_pcb_exit(void);
extern void lwp_cleanup(void);
extern int lwp_suspend(kthread_t *);
extern void lwp_continue(kthread_t *);
extern void holdlwp(void);
extern void stoplwp(void);
extern int holdlwps(int);
extern int holdwatch(void);
extern void continuelwps(proc_t *);
extern int exitlwps(int);
extern void lwp_ctmpl_clear(klwp_t *);
extern void lwp_setrval(klwp_t *, int, int);
extern void lwp_freeregs(klwp_t *, int);
extern void lwp_stk_fini(klwp_t *);
extern void lwp_installctx(klwp_t *);
extern void lwp_rtt(void);
extern void lwp_rtt_initial(void);
extern void lwp_stat_update(lwp_stat_id_t, long);
/*
* Signal queue function prototypes. Must be here due to header ordering
* dependencies.
*/
extern void siginfofree(sigqueue_t *);
extern int sigwillqueue(int, int);
extern void sigqhdrfree(sigqhdr_t *);
k_sigset_t *, sigqueue_t *);
k_sigset_t *, sigqueue_t *);
extern int wstat(int, int);
extern int sendsig(int, k_siginfo_t *, void (*)());
#if defined(_SYSCALL32_IMPL)
extern int sendsig32(int, k_siginfo_t *, void (*)());
#endif
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_PROC_H */