Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > Vthread_impls > Vthread_MC_shared_impl
view VPThread.h @ 6:ce4ad44fcc23
make hardware independent and port to 64bit
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Thu, 16 Jun 2011 14:39:38 +0200 |
| parents | 505d3c674ce8 |
| children | bbcb6fadb60f f593241c2db9 |
line source
1 /*
2 * Copyright 2009 OpenSourceStewardshipFoundation.org
3 * Licensed under GNU General Public License version 2
4 *
5 * Author: seanhalle@yahoo.com
6 *
7 */
9 #ifndef _VPThread_H
10 #define _VPThread_H
12 #include "VMS/VMS.h"
13 #include "VMS/Queue_impl/PrivateQueue.h"
14 #include "VMS/DynArray/DynArray.h"
17 /*This header defines everything specific to the VPThread semantic plug-in
18 */
21 //===========================================================================
22 #define INIT_NUM_MUTEX 10000
23 #define INIT_NUM_COND 10000
25 #define NUM_STRUCS_IN_SEM_ENV 1000
26 //===========================================================================
28 //===========================================================================
29 typedef struct _VPThreadSemReq VPThdSemReq;
30 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
31 //===========================================================================
34 /*WARNING: assembly hard-codes position of endInstrAddr as first field
35 */
36 typedef struct
37 {
38 void *endInstrAddr;
39 int32 hasBeenStarted;
40 int32 hasFinished;
41 PrivQueueStruc *waitQ;
42 }
43 VPThdSingleton;
45 /*Semantic layer-specific data sent inside a request from lib called in app
46 * to request handler called in MasterLoop
47 */
48 enum VPThreadReqType
49 {
50 make_mutex = 1,
51 mutex_lock,
52 mutex_unlock,
53 make_cond,
54 cond_wait,
55 cond_signal,
56 make_procr,
57 malloc_req,
58 free_req,
59 singleton_fn_start,
60 singleton_fn_end,
61 singleton_data_start,
62 singleton_data_end,
63 atomic,
64 trans_start,
65 trans_end
66 };
68 struct _VPThreadSemReq
69 { enum VPThreadReqType reqType;
70 VirtProcr *requestingPr;
71 int32 mutexIdx;
72 int32 condIdx;
74 void *initData;
75 VirtProcrFnPtr fnPtr;
76 int32 coreToScheduleOnto;
78 size_t sizeToMalloc;
79 void *ptrToFree;
81 int32 singletonID;
82 VPThdSingleton **singletonPtrAddr;
84 PtrToAtomicFn fnToExecInMaster;
85 void *dataForFn;
87 int32 transID;
88 }
89 /* VPThreadSemReq */;
92 typedef struct
93 {
94 VirtProcr *VPCurrentlyExecuting;
95 PrivQueueStruc *waitingVPQ;
96 }
97 VPThdTrans;
100 typedef struct
101 {
102 int32 mutexIdx;
103 VirtProcr *holderOfLock;
104 PrivQueueStruc *waitingQueue;
105 }
106 VPThdMutex;
109 typedef struct
110 {
111 int32 condIdx;
112 PrivQueueStruc *waitingQueue;
113 VPThdMutex *partnerMutex;
114 }
115 VPThdCond;
117 typedef struct _TransListElem TransListElem;
118 struct _TransListElem
119 {
120 int32 transID;
121 TransListElem *nextTrans;
122 };
123 //TransListElem
125 typedef struct
126 {
127 int32 highestTransEntered;
128 TransListElem *lastTransEntered;
129 }
130 VPThdSemData;
133 typedef struct
134 {
135 //Standard stuff will be in most every semantic env
136 PrivQueueStruc **readyVPQs;
137 int32 numVirtPr;
138 int32 nextCoreToGetNewPr;
139 int32 primitiveStartTime;
141 //Specific to this semantic layer
142 VPThdMutex **mutexDynArray;
143 PrivDynArrayInfo *mutexDynArrayInfo;
145 VPThdCond **condDynArray;
146 PrivDynArrayInfo *condDynArrayInfo;
148 void *applicationGlobals;
150 //fix limit on num with dynArray
151 VPThdSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
153 VPThdTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
154 }
155 VPThdSemEnv;
158 //===========================================================================
160 inline void
161 VPThread__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
163 //=======================
165 inline VirtProcr *
166 VPThread__create_thread( VirtProcrFnPtr fnPtr, void *initData,
167 VirtProcr *creatingPr );
169 inline VirtProcr *
170 VPThread__create_thread_with_affinity( VirtProcrFnPtr fnPtr, void *initData,
171 VirtProcr *creatingPr, int32 coreToScheduleOnto );
173 inline void
174 VPThread__dissipate_thread( VirtProcr *procrToDissipate );
176 //=======================
177 inline void
178 VPThread__set_globals_to( void *globals );
180 inline void *
181 VPThread__give_globals();
183 //=======================
184 inline int32
185 VPThread__make_mutex( VirtProcr *animPr );
187 inline void
188 VPThread__mutex_lock( int32 mutexIdx, VirtProcr *acquiringPr );
190 inline void
191 VPThread__mutex_unlock( int32 mutexIdx, VirtProcr *releasingPr );
194 //=======================
195 inline int32
196 VPThread__make_cond( int32 ownedMutexIdx, VirtProcr *animPr);
198 inline void
199 VPThread__cond_wait( int32 condIdx, VirtProcr *waitingPr);
201 inline void *
202 VPThread__cond_signal( int32 condIdx, VirtProcr *signallingPr );
205 //=======================
206 void
207 VPThread__start_fn_singleton( int32 singletonID, VirtProcr *animPr );
209 void
210 VPThread__end_fn_singleton( int32 singletonID, VirtProcr *animPr );
212 void
213 VPThread__start_data_singleton( VPThdSingleton **singeltonAddr, VirtProcr *animPr );
215 void
216 VPThread__end_data_singleton( VPThdSingleton **singletonAddr, VirtProcr *animPr );
218 void
219 VPThread__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
220 void *data, VirtProcr *animPr );
222 void
223 VPThread__start_transaction( int32 transactionID, VirtProcr *animPr );
225 void
226 VPThread__end_transaction( int32 transactionID, VirtProcr *animPr );
230 //========================= Internal use only =============================
231 inline void
232 VPThread__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
234 inline VirtProcr *
235 VPThread__schedule_virt_procr( void *_semEnv, int coreNum );
237 //=======================
238 inline void
239 VPThread__free_semantic_request( VPThdSemReq *semReq );
241 //=======================
243 void *
244 VPThread__malloc( size_t sizeToMalloc, VirtProcr *animPr );
246 void
247 VPThread__init();
249 void
250 VPThread__cleanup_after_shutdown();
252 void inline
253 resume_procr( VirtProcr *procr, VPThdSemEnv *semEnv );
255 #endif /* _VPThread_H */
