#ifndef _QNX4_PROC_H
#define _QNX4_PROC_H

#ifndef __QNXNTO__

#include <setjmp.h>
#include <sys/sendmx.h>

typedef struct proc near *kent_t;

struct proc {
	struct	ucred *p_ucred;
	struct	filedesc *p_fd;
	kent_t	p_nxt;			/* next on list	 */
	char	p_sd[2];		/* up to two (socket) fds in msg */
	char	p_attach;		/* number of fd attaches done */
    enum { EMPTY, BUSY, ASLEEP, READY } p_stat;
	pid_t	p_pid;			/* pid received msg from */
	short	p_thread;		/* entry number */
	caddr_t	p_wchan;		/* wait channel */
	short	p_pri;			/* current priority */
#define p_acflag p_offset		/* accounting flags */
	u_short	p_offset;		/* offset for readmsg/writemsg */
	short	p_rval;			/* return value when thread is woken */
	caddr_t	p_stkbase;		/* base of thread stack */
	jmp_buf	p_regs;			/* registers */
};

/* stat codes */
#define	SSLEEP	1		/* awaiting an event */
#define	SWAIT	2		/* (abandoned state) */
#define	SRUN	3		/* running */
#define	SIDL	4		/* intermediate state in process creation */
#define	SZOMB	5		/* intermediate state in process termination */
#define	SSTOP	6		/* process being traced */

struct	prochd {
	struct	proc *ph_link;	/* linked list of running processes */
	struct	proc *ph_rlink;
};

extern kent_t curproc;
extern kent_t initproc, pageproc; /* process slots for init, pager */

int kconf(int nproc, int depth);
int init_callout(int);
kent_t pfind(pid_t pid);
int pcreat(int (*func)(), int prio, pid_t pid, caddr_t arg);
int goto_sleep(caddr_t wchan, int prio);
int unsleep(kent_t p);
int wakeup(caddr_t chan);
int timeout(int (*f)(void *), void *p, time_t msec);
int tsleep(caddr_t wchan, int prio, char *wmsg, long timo);
int near resched(void);
int chk_pid(pid_t pid);

#endif
#endif
