// npx.hpp - Non-Preemptive eXecutive Header
//           Copyright 1990 by Cnapse
//           Written by: M. de Champlain

#include "std.h"
#include "list.h"

typedef word   *reg;
typedef enum { TERMINATED, READY, RUNNING, SUSPENDED } taskState;

class Task {
friend class StateQ;
friend class ReadyQ;
    LINK       n;
    reg        sp;
    word      *stackBase;
    taskState  state;
    void      (*taskStartingAddress)();
    word       stackSizeInBytes;
    Task      *self;
    Task      *parent;
    void       Schedule(void); 
public:
    Task(void  (*task)(), word stackSize) { taskStartingAddress = task;
                                            stackSizeInBytes    = stackSize; }
    Task *Start(void);
    Task *Self(void);
    Task *Parent(void);
    void  ReSchedule(void);
    void  Terminate(Task *id);
    void  Suspend(Task *id);
    void  Resume(Task *id);
};

extern Task *running;
