/* 
 * process.h
 *
 * x-kernel v3.3
 *
 * Copyright (c) 1993,1991,1990,1996  Arizona Board of Regents
 *
 * $Revision: 1.2 $
 * $Date: 1997/04/29 22:49:18 $
 * 
 * HISTORY 
 * $Log: process.h,v $
 * Revision 1.2  1997/04/29 22:49:18  rrp
 * minor updates
 *
 * Revision 1.1  1996/01/30 21:03:30  slm
 * Initial revision
 *
 * Revision 1.3  1994/12/02  18:35:57  hkaram
 * Added declarations
 * ,
 *
 * 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
extern Semaphore 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__

void semInit( Semaphore *, unsigned );
void semWait( Semaphore *);
void semSignal( Semaphore *);
void mutexInit( Semaphore * );
void mutexLock( Semaphore *);
void mutexUnlock( Semaphore *);
void realP( Semaphore * );
void realV( Semaphore * );
void VAll(Semaphore *);
void realPforHost(Semaphore *);
void Yield(void);

#else

void semInit( );
void semWait( );
void semSignal( );
void mutexInit( );
void mutexLock( );
void mutexUnlock( );
void realP( );
void realV( );
void realPforHost( );
void Yield();

#endif __STDC__

extern Process *Active;
extern int	Signals;

#endif
