#ifndef LINUXMT_SCHED_H
#define LINUXMT_SCHED_H

#define MAX_TASKS 8

struct _task {
/* Executive stuff */
	__uint t_num;
	__registers t_regs;
	__pptr t_begcode, t_endcode, t_begdata, t_enddata, t_begstack, t_endstack; 
/* Scheduling + status variables */
	__s16 t_state;
	__uint t_count, t_priority;	/* Valuable scheduling elements */
	__u16 t_flags; /* Not defined yet */
	__u16 t_errno; /* Last error */
};

#define TASK_RUNNING 0x1
#define TASK_STOPPED 0x2
#define TASK_UNINTER 0x4

/* We use typedefs to avoid using struct foobar (*) */
typedef struct _task __task;
typedef struct _task * __ptask;

__task task[MAX_TASKS];

#define IDLE_TNUM 0
#define SCHED_TNUM 1
#define FORK_TNUM 2
#define FIRST_UTNUM 3

#define IDLE_TASK &task[IDLE_TNUM]
#define SCHED_TASK &task[SCHED_TNUM]
#define FORK_TASK &task[FORK_TNUM]
#define FIRST_UTASK &task[FIRST_UTNUM]

extern __ptask CURRENT, NEXT;
extern __ptask FORK_FROM, FORK_TO;
extern __uint CURNUM;

_FUNCTION(__uint build_task, ());
_FUNCTION(__uint alloc_task, (__ptask ptask));
_FUNCTION(void schedule, ()); 

#endif
