| 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@0
|
17 //This value is the number of hardware threads in the shared memory
|
|
Me@5
|
18 // machine -- make double that number scheduling slots, plus extra for master
|
|
Me@7
|
19 #define NUM_CORES 4
|
|
Me@5
|
20 #define NUM_SCHED_SLOTS 9
|
|
Me@0
|
21
|
|
Me@0
|
22 #define SUCCESS 0
|
|
Me@0
|
23
|
|
Me@13
|
24 //#define thdAttrs NULL //For PThreads
|
|
Me@0
|
25
|
|
Me@16
|
26 typedef struct _SchedSlot SchedSlot;
|
|
Me@16
|
27 typedef struct _SlaveReqst SlaveReqst;
|
|
Me@5
|
28 typedef struct _VirtProcr VirtProcr;
|
|
Me@0
|
29
|
|
Me@5
|
30 typedef bool8 (*SlaveScheduler) ( SchedSlot *, void * );
|
|
Me@0
|
31 typedef void (*RequestHandler) ( SlaveReqst * );
|
|
Me@5
|
32 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * );
|
|
Me@5
|
33 typedef void VirtProcrFn( void *, VirtProcr * );
|
|
Me@0
|
34
|
|
Me@16
|
35
|
|
Me@0
|
36 typedef struct
|
|
Me@0
|
37 {
|
|
Me@7
|
38 void *endThdPt;
|
|
Me@7
|
39 unsigned int coreNum;
|
|
Me@16
|
40 // void *framePtr;
|
|
Me@16
|
41 // void *stackPtr;
|
|
Me@0
|
42 }
|
|
Me@0
|
43 ThdParams;
|
|
Me@0
|
44
|
|
Me@16
|
45
|
|
Me@5
|
46 struct _SchedSlot
|
|
Me@5
|
47 {
|
|
Me@5
|
48 int workIsDone;
|
|
Me@5
|
49 int needsProcrAssigned;
|
|
Me@5
|
50 VirtProcr *procrAssignedToSlot;
|
|
Me@5
|
51 };
|
|
Me@16
|
52 //SchedSlot
|
|
Me@16
|
53
|
|
Me@5
|
54
|
|
Me@16
|
55 struct _SlaveReqst
|
|
Me@16
|
56 {
|
|
Me@16
|
57 VirtProcr *slaveFrom;
|
|
Me@16
|
58 int reqType; //for future when have I/O and OS services
|
|
Me@16
|
59 void *semReqData;
|
|
Me@16
|
60
|
|
Me@16
|
61 SlaveReqst *nextRequest;
|
|
Me@16
|
62 };
|
|
Me@16
|
63 //SlaveReqst
|
|
Me@5
|
64
|
|
Me@5
|
65 struct _VirtProcr
|
|
Me@13
|
66 { int procrID; //for debugging -- count up each time create
|
|
Me@16
|
67 int coreAnimatedBy;
|
|
Me@5
|
68 void *stackPtr;
|
|
Me@5
|
69 void *framePtr;
|
|
Me@5
|
70 void *nextInstrPt;
|
|
Me@16
|
71
|
|
Me@5
|
72 void *coreLoopStartPt; //allows proto-runtime to be linked later
|
|
Me@16
|
73 void *coreLoopFramePtr; //restore before jmp back to core loop
|
|
Me@16
|
74 void *coreLoopStackPtr; //restore before jmp back to core loop
|
|
Me@5
|
75
|
|
Me@5
|
76 void *initialData;
|
|
Me@5
|
77
|
|
Me@5
|
78 SchedSlot *schedSlot;
|
|
Me@5
|
79 SlaveReqst *requests;
|
|
Me@5
|
80
|
|
Me@5
|
81 void *semanticData;
|
|
Me@5
|
82 };
|
|
Me@16
|
83 //VirtProcr
|
|
Me@5
|
84
|
|
Me@5
|
85
|
|
Me@16
|
86
|
|
Me@0
|
87 typedef struct
|
|
Me@0
|
88 {
|
|
Me@5
|
89 SlaveScheduler slaveScheduler;
|
|
Me@5
|
90 RequestHandler requestHandler;
|
|
Me@0
|
91
|
|
Me@5
|
92 SchedSlot **schedSlots;
|
|
Me@5
|
93 SchedSlot **filledSlots;
|
|
Me@5
|
94 int numFilled;
|
|
Me@5
|
95
|
|
Me@0
|
96 int stillRunning;
|
|
Me@0
|
97
|
|
Me@5
|
98 VirtProcr *masterVirtPr;
|
|
Me@0
|
99 void *semanticEnv;
|
|
Me@5
|
100 void *OSEventStruc; //for future, when add I/O to BLIS
|
|
Me@16
|
101
|
|
Me@16
|
102 void *coreLoopShutDownPt; //addr to jump to to shut down a coreLoop
|
|
Me@0
|
103 }
|
|
Me@0
|
104 MasterEnv;
|
|
Me@0
|
105
|
|
Me@0
|
106
|
|
Me@16
|
107 //==========================================================
|
|
Me@0
|
108
|
|
Me@7
|
109 DWORD WINAPI coreLoop( LPVOID paramsIn );
|
|
Me@7
|
110 //void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
|
|
Me@7
|
111 void masterLoop( void *initData, VirtProcr *masterPr );
|
|
Me@0
|
112
|
|
Me@0
|
113
|
|
Me@0
|
114 //===================== Global Vars ===================
|
|
Me@0
|
115
|
|
Me@5
|
116
|
|
Me@13
|
117 HANDLE coreLoopThdHandles[ NUM_CORES ]; //windows handle to thread
|
|
Me@13
|
118 ThdParams *coreLoopThdParams[ NUM_CORES ];
|
|
Me@13
|
119 DWORD coreLoopThdIds[ NUM_CORES ];
|
|
Me@0
|
120
|
|
Me@13
|
121 //TODO: Debug: figure out if need to be volatile or not
|
|
Me@13
|
122 volatile MasterEnv *_VMSMasterEnv;
|
|
Me@5
|
123
|
|
Me@5
|
124 //workQ is global, static, and volatile so that core loop has its location
|
|
Me@5
|
125 // hard coded, and reloads every time through the loop -- that way don't
|
|
Me@5
|
126 // need to save any regs used by core loop (will see if this really works)
|
|
Me@13
|
127 volatile CASQueueStruc *_VMSWorkQ;
|
|
Me@0
|
128
|
|
Me@7
|
129 //==========================
|
|
Me@7
|
130 void
|
|
Me@7
|
131 VMS__init();
|
|
Me@7
|
132
|
|
Me@7
|
133 void
|
|
Me@7
|
134 VMS__start();
|
|
Me@7
|
135
|
|
Me@7
|
136 VirtProcr *
|
|
Me@7
|
137 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
|
|
Me@7
|
138
|
|
Me@7
|
139 inline void
|
|
Me@7
|
140 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
|
|
Me@7
|
141
|
|
Me@7
|
142 void
|
|
Me@7
|
143 VMS__suspend_processor( VirtProcr *callingPr );
|
|
Me@7
|
144
|
|
Me@13
|
145 //============================= Statistics ==================================
|
|
Me@13
|
146
|
|
Me@13
|
147 typedef unsigned long long TSCount;
|
|
Me@13
|
148
|
|
Me@13
|
149 #define saveTimeStampCountInto(low, high) \
|
|
Me@13
|
150 asm volatile("RDTSC; \
|
|
Me@13
|
151 movl %%eax, %0; \
|
|
Me@13
|
152 movl %%edx, %1;" \
|
|
Me@13
|
153 /* outputs */ : "=m" (low), "=m" (high)\
|
|
Me@13
|
154 /* inputs */ : \
|
|
Me@13
|
155 /* clobber */ : "%eax", "%edx" \
|
|
Me@13
|
156 );
|
|
Me@13
|
157
|
|
Me@13
|
158 inline TSCount getTSCount();
|
|
Me@13
|
159
|
|
Me@13
|
160 int numProcrsCreated;
|
|
Me@0
|
161
|
|
Me@0
|
162 #endif /* _VMS_H */
|
|
Me@0
|
163
|