annotate VMS.h @ 23:aa634ef7cc35

Full VMS test -- works
author Me
date Wed, 30 Jun 2010 13:11:06 -0700
parents c3e6c3fda84e
children 2b161e1a50ee
rev   line source
Me@0 1 /*
Me@0 2 * Copyright 2009 OpenSourceStewardshipFoundation.org
Me@0 3 * Licensed under GNU General Public License version 2
Me@0 4 *
Me@0 5 * Author: seanhalle@yahoo.com
Me@0 6 *
Me@0 7 */
Me@0 8
Me@0 9 #ifndef _VMS_H
Me@0 10 #define _VMS_H
Me@0 11
Me@0 12 #include "VMS_primitive_data_types.h"
Me@0 13 #include "Queue_impl/BlockingQueue.h"
Me@7 14 #include <windows.h>
Me@13 15 #include <winbase.h>
Me@0 16
Me@23 17 //This value is the number of hardware threads in the shared memory
Me@23 18 // machine
Me@23 19 #define NUM_CORES 4
Me@23 20
Me@23 21 // make double-num-cores scheduling slots, plus extra for master
Me@23 22 #define NUM_SCHED_SLOTS (2 * NUM_CORES + 1)
Me@23 23
Me@23 24 //128K stack.. compromise, want 10K virtPr
Me@23 25 #define VIRT_PROCR_STACK_SIZE 0x100000
Me@0 26
Me@0 27 #define SUCCESS 0
Me@0 28
Me@13 29 //#define thdAttrs NULL //For PThreads
Me@0 30
Me@16 31 typedef struct _SchedSlot SchedSlot;
Me@23 32 typedef struct _SlaveReqst VMSReqst;
Me@5 33 typedef struct _VirtProcr VirtProcr;
Me@0 34
Me@23 35 typedef VirtProcr * (*SlaveScheduler) ( void * ); //semEnv
Me@23 36 typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv
Me@23 37 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr
Me@23 38 typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr
Me@16 39
Me@0 40 typedef struct
Me@0 41 {
Me@7 42 void *endThdPt;
Me@7 43 unsigned int coreNum;
Me@16 44 // void *framePtr;
Me@16 45 // void *stackPtr;
Me@0 46 }
Me@0 47 ThdParams;
Me@0 48
Me@16 49
Me@5 50 struct _SchedSlot
Me@5 51 {
Me@5 52 int workIsDone;
Me@5 53 int needsProcrAssigned;
Me@5 54 VirtProcr *procrAssignedToSlot;
Me@5 55 };
Me@16 56 //SchedSlot
Me@16 57
Me@23 58 enum ReqstType
Me@23 59 {
Me@23 60 semantic = 1,
Me@23 61 dissipate,
Me@23 62 IO
Me@23 63 };
Me@5 64
Me@16 65 struct _SlaveReqst
Me@16 66 {
Me@23 67 // VirtProcr *virtProcrFrom;
Me@23 68 enum ReqstType reqType; //used for dissipate and in future for IO requests
Me@23 69 void *semReqData;
Me@16 70
Me@23 71 VMSReqst *nextReqst;
Me@16 72 };
Me@16 73 //SlaveReqst
Me@5 74
Me@5 75 struct _VirtProcr
Me@13 76 { int procrID; //for debugging -- count up each time create
Me@16 77 int coreAnimatedBy;
Me@23 78 void *startOfStack;
Me@5 79 void *stackPtr;
Me@5 80 void *framePtr;
Me@5 81 void *nextInstrPt;
Me@16 82
Me@5 83 void *coreLoopStartPt; //allows proto-runtime to be linked later
Me@16 84 void *coreLoopFramePtr; //restore before jmp back to core loop
Me@16 85 void *coreLoopStackPtr; //restore before jmp back to core loop
Me@5 86
Me@5 87 void *initialData;
Me@5 88
Me@5 89 SchedSlot *schedSlot;
Me@23 90 VMSReqst *requests;
Me@5 91
Me@5 92 void *semanticData;
Me@5 93 };
Me@16 94 //VirtProcr
Me@5 95
Me@5 96
Me@16 97
Me@0 98 typedef struct
Me@0 99 {
Me@5 100 SlaveScheduler slaveScheduler;
Me@5 101 RequestHandler requestHandler;
Me@0 102
Me@5 103 SchedSlot **schedSlots;
Me@5 104 SchedSlot **filledSlots;
Me@5 105 int numFilled;
Me@5 106
Me@0 107 int stillRunning;
Me@0 108
Me@5 109 VirtProcr *masterVirtPr;
Me@0 110 void *semanticEnv;
Me@5 111 void *OSEventStruc; //for future, when add I/O to BLIS
Me@16 112
Me@16 113 void *coreLoopShutDownPt; //addr to jump to to shut down a coreLoop
Me@0 114 }
Me@0 115 MasterEnv;
Me@0 116
Me@0 117
Me@16 118 //==========================================================
Me@0 119
Me@7 120 DWORD WINAPI coreLoop( LPVOID paramsIn );
Me@7 121 //void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
Me@7 122 void masterLoop( void *initData, VirtProcr *masterPr );
Me@0 123
Me@0 124
Me@0 125 //===================== Global Vars ===================
Me@0 126
Me@5 127
Me@13 128 HANDLE coreLoopThdHandles[ NUM_CORES ]; //windows handle to thread
Me@13 129 ThdParams *coreLoopThdParams[ NUM_CORES ];
Me@13 130 DWORD coreLoopThdIds[ NUM_CORES ];
Me@0 131
Me@13 132 //TODO: Debug: figure out if need to be volatile or not
Me@13 133 volatile MasterEnv *_VMSMasterEnv;
Me@5 134
Me@5 135 //workQ is global, static, and volatile so that core loop has its location
Me@5 136 // hard coded, and reloads every time through the loop -- that way don't
Me@5 137 // need to save any regs used by core loop (will see if this really works)
Me@13 138 volatile CASQueueStruc *_VMSWorkQ;
Me@0 139
Me@7 140 //==========================
Me@7 141 void
Me@7 142 VMS__init();
Me@7 143
Me@7 144 void
Me@7 145 VMS__start();
Me@7 146
Me@7 147 VirtProcr *
Me@7 148 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
Me@7 149
Me@23 150 VirtProcr *
Me@23 151 VMS__create_the_shutdown_procr();
Me@23 152
Me@7 153 inline void
Me@7 154 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
Me@7 155
Me@7 156 void
Me@23 157 VMS__send_dissipate_request( VirtProcr *procrToDissipate );
Me@23 158
Me@23 159 void
Me@23 160 VMS__remove_and_free_top_request( VirtProcr *reqstingPr );
Me@23 161
Me@23 162 void
Me@23 163 VMS__suspend_procr( VirtProcr *callingPr );
Me@23 164
Me@23 165 void
Me@23 166 VMS__dissipate_procr( VirtProcr *prToDissipate );
Me@23 167
Me@23 168 void
Me@23 169 VMS__shutdown();
Me@7 170
Me@13 171 //============================= Statistics ==================================
Me@13 172
Me@13 173 typedef unsigned long long TSCount;
Me@13 174
Me@13 175 #define saveTimeStampCountInto(low, high) \
Me@13 176 asm volatile("RDTSC; \
Me@13 177 movl %%eax, %0; \
Me@13 178 movl %%edx, %1;" \
Me@13 179 /* outputs */ : "=m" (low), "=m" (high)\
Me@13 180 /* inputs */ : \
Me@13 181 /* clobber */ : "%eax", "%edx" \
Me@13 182 );
Me@13 183
Me@13 184 inline TSCount getTSCount();
Me@13 185
Me@23 186 //===================== Debug ==========================
Me@13 187 int numProcrsCreated;
Me@0 188
Me@23 189
Me@0 190 #endif /* _VMS_H */
Me@0 191