/*
 *	Type definitions for C scheduler and occam support
 *	Copyright (C) 1998 Jim Moores
 *	Modifications (C) 1999-2004 Fred Barnes <frmb@kent.ac.uk>
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif


#ifndef SCHED_TYPES_H
#define SCHED_TYPES_H

#include <ukcthreads_types.h>
#include <sched_consts.h>

struct _sepflags {
	#if defined(BLOCKING_SYSCALLS)
		byte block_sync;		/* set when a blocking sys-call goes off */
	#else
		byte kbd_sync;			/* set when the keyboard goes off */
	#endif
	#if defined(PROCESS_PRIORITY)
		byte priority_sync;		/* set when a higher-priority process is known to be waiting */
	#else
		byte dummy0;
	#endif
	byte tim_sync;				/* set when a timer expires */
	#if defined(OOS_BUILD)
		byte interrupt_sync;		/* for OOS, set when an interrupt occurs */
	#else
		byte dummy2;
	#endif
#ifdef __GNUC__
} __attribute__ ((packed));
#else
};
#endif

typedef struct _sepflags sepflags;

typedef struct _sync_type {
	union {
		word combined_sync;
		sepflags s;
	} u;
	word *tptr;			/* used for Tptr */
#if defined(ENABLE_CPU_TIMERS)
	unsigned long long ftime;	/* holds the timeout of the first process on Tptr in CPU cycles */
#endif
#ifdef __GNUC__
} __attribute__ ((packed)) sync_type;
#else
} sync_type;
#endif

typedef struct _sched_vars_type {
	word *wptr;					/* +0 */
	word *fptr;					/* +4 */
	word *bptr;					/* +8 */
	int dummy0;					/* +12 */
#if defined(PROCESS_PRIORITY)
	word ppriority;					/* +16 */
	word pstate;					/* +20 */
	word *fptrq[MAX_PRIORITY_LEVELS];		/* +24 */
	word *bptrq[MAX_PRIORITY_LEVELS];		/* +152 */
#endif

} sched_vars_type;


#endif
