richards.h 1.47 KB
Newer Older
ram's avatar
ram committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
/* richards.h */
/* Richards benchmark in C++, translated from Smalltalk */
/* uh 2/2/89  */

#include "rbase.h" 
#include "tasks.h"

/*
// RBench class definition
*/

class RBench {
    private:
         TaskControlBlock *taskList, *currentTask;
         Identity currentTaskIdent;
         TaskControlBlock *taskTable[NTASKS];
         int layout;
         int holdCount, queuePacketCount;

         /* creation */
         void CreateDevice (Identity id, int prio,  Packet *work,
                           TaskState *state);
         void CreateHandler(Identity id, int prio,  Packet *work,
                           TaskState *state);
         void CreateIdler  (Identity id, int prio,  Packet *work,
                           TaskState *state);
         void CreateWorker (Identity id, int prio,  Packet *work,
                           TaskState *state);
         void EnterTask(Identity id, TaskControlBlock *t);

         /* scheduling */
         void Schedule();

         /* initializing */
         void InitScheduler();
         void InitTrace();
    public:
         /* task management */
         TaskControlBlock *FindTask(Identity id);
         TaskControlBlock *HoldSelf();
         TaskControlBlock *QueuePacket(Packet *p);
         TaskControlBlock *Release(Identity id);
         TaskControlBlock *Wait();
         /* tracing */
         BOOLEAN tracing;
         void Trace(Identity id);

         void Start(BOOLEAN askTrace);
};

RBench bm;		// benchmark currently executing