Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > Vthread_impls > Vthread_MC_shared_impl
view VPThread.h @ 1:1d3157ac56c4
Updated to Nov 8 version of VMS -- added singleton, trans, etc
| author | SeanHalle |
|---|---|
| date | Thu, 11 Nov 2010 04:29:10 -0800 |
| parents | 4aca264971b5 |
| children | e960a8d18f7c |
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 /*Semantic layer-specific data sent inside a request from lib called in app
35 * to request handler called in MasterLoop
36 */
37 enum VPThreadReqType
38 {
39 make_mutex = 1,
40 mutex_lock,
41 mutex_unlock,
42 make_cond,
43 cond_wait,
44 cond_signal,
45 make_procr,
46 malloc_req,
47 free_req,
48 singleton,
49 atomic,
50 trans_start,
51 trans_end
52 };
54 struct _VPThreadSemReq
55 { enum VPThreadReqType reqType;
56 VirtProcr *requestingPr;
57 int32 mutexIdx;
58 int32 condIdx;
60 void *initData;
61 VirtProcrFnPtr fnPtr;
62 int32 coreToScheduleOnto;
64 int32 sizeToMalloc;
65 void *ptrToFree;
67 int32 singletonID;
68 void *endJumpPt;
70 PtrToAtomicFn fnToExecInMaster;
71 void *dataForFn;
73 int32 transID;
74 }
75 /* VPThreadSemReq */;
78 typedef struct
79 {
80 VirtProcr *VPCurrentlyExecuting;
81 PrivQueueStruc *waitingVPQ;
82 }
83 VPThdTrans;
86 typedef struct
87 {
88 //Standard stuff will be in most every semantic env
89 PrivQueueStruc **readyVPQs;
90 int32 numVirtPr;
91 int32 nextCoreToGetNewPr;
92 int32 primitiveStartTime;
94 //Specific to this semantic layer
95 VPThdMutex **mutexDynArray;
96 PrivDynArrayInfo *mutexDynArrayInfo;
98 VPThdCond **condDynArray;
99 PrivDynArrayInfo *condDynArrayInfo;
101 void *applicationGlobals;
103 //fix limit on num with dynArray
104 int32 singletonHasBeenExecutedFlags[NUM_STRUCS_IN_SEM_ENV];
105 VPThdTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
106 }
107 VPThdSemEnv;
110 typedef struct
111 {
112 int32 mutexIdx;
113 VirtProcr *holderOfLock;
114 PrivQueueStruc *waitingQueue;
115 }
116 VPThdMutex;
119 typedef struct
120 {
121 int32 condIdx;
122 PrivQueueStruc *waitingQueue;
123 VPThdMutex *partnerMutex;
124 }
125 VPThdCond;
127 typedef struct _TransListElem TransListElem;
128 struct _TransListElem
129 {
130 int32 transID;
131 TransListElem *nextTrans;
132 };
133 //TransListElem
135 typedef struct
136 {
137 int32 highestTransEntered;
138 TransListElem *lastTransEntered;
139 }
140 VPThdSemData;
143 //===========================================================================
145 inline void
146 VPThread__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
148 //=======================
150 inline VirtProcr *
151 VPThread__create_thread( VirtProcrFnPtr fnPtr, void *initData,
152 VirtProcr *creatingPr );
154 inline VirtProcr *
155 VPThread__create_thread_with_affinity( VirtProcrFnPtr fnPtr, void *initData,
156 VirtProcr *creatingPr, int32 coreToScheduleOnto );
158 inline void
159 VPThread__dissipate_thread( VirtProcr *procrToDissipate );
161 //=======================
162 inline void
163 VPThread__set_globals_to( void *globals );
165 inline void *
166 VPThread__give_globals();
168 //=======================
169 inline int32
170 VPThread__make_mutex( VirtProcr *animPr );
172 inline void
173 VPThread__mutex_lock( int32 mutexIdx, VirtProcr *acquiringPr );
175 inline void
176 VPThread__mutex_unlock( int32 mutexIdx, VirtProcr *releasingPr );
179 //=======================
180 inline int32
181 VPThread__make_cond( int32 ownedMutexIdx, VirtProcr *animPr);
183 inline void
184 VPThread__cond_wait( int32 condIdx, VirtProcr *waitingPr);
186 inline void *
187 VPThread__cond_signal( int32 condIdx, VirtProcr *signallingPr );
192 //========================= Internal use only =============================
193 inline void
194 VPThread__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
196 inline VirtProcr *
197 VPThread__schedule_virt_procr( void *_semEnv, int coreNum );
199 //=======================
200 inline void
201 VPThread__free_semantic_request( VPThdSemReq *semReq );
203 //=======================
205 void
206 VPThread__init();
208 void
209 VPThread__cleanup_after_shutdown();
211 #endif /* _VPThread_H */
