/* 
 * process.h
 *
 * x-kernel v3.3
 *
 * Copyright (c) 1993,1991,1990,1996  Arizona Board of Regents
 *
 * $Revision: 1.3 $
 * $Date: 1996/02/01 15:18:54 $
 * 
 * HISTORY 
 * $Log: process.h,v $
 * Revision 1.3  1996/02/01  15:18:54  slm
 * Updated copyright and version.
 *
 * Revision 1.2  1995/08/28  16:12:51  acb
 * Initial revision for x3.3
 *
 * Revision 1.2  1994/11/22  21:17:15  hkaram
 * Removed defn of Pfi
 *
 * Revision 1.1  1994/10/26  20:17:36  hkaram
 * Initial revision
 */

#ifndef process_h
#define process_h

#include "xtype.h"
#include "scout_queue.h"
#include "scout_thread.h"
#include "scout_thread_arch.h"

/* the "normal" priority for process creation */
#define STD_PRIO       THREAD_PRIO_MAX
#define THREAD_MAXPRIO THREAD_PRIO_MAX
#define THREAD_MINPRIO THREAD_PRIO_STD /* clock thread */

#ifdef MASTER_LOCK
#define xk_master_lock()      mutexLock(&master_lock)
#define xk_master_unlock()    mutexUnlock(&master_lock)
#else
#define xk_master_lock()      
#define xk_master_unlock()    
#endif

#ifndef NULL
#define NULL 0
#endif

typedef struct _Process {
  long 			*stack, *stacklimit;
  short			prio;
  struct _Process *	link;
  int			extrastuff;
  int			index;
  Thread		thread;
} Process;

typedef struct sSemaphore {
  int			 count;
  struct Queue		 waitingQ;
} Semaphore;


#ifdef __STDC__

extern bool CreateProcess(void *r, int pri, int nargs, ... );
extern void semInit( Semaphore *, unsigned );
extern void semWait( Semaphore *);
extern void semSignal( Semaphore *);
extern void mutexInit( Semaphore * );
extern void mutexLock( Semaphore *);
extern void mutexUnlock( Semaphore *);
extern void realPforHost( Semaphore * );
extern void VAll( Semaphore * );
extern void realP( Semaphore * );
extern void realV( Semaphore * );

#endif __STDC__

extern Process *Active;
extern int	SignalsPossible;

#endif
