Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > SSR_impls > SSR__MC_shared_impl
view SSR.h @ 21:ad29ff7a0209
Buggy version of singltons -- data plus Fn singletons now -- about to fix
| author | Me |
|---|---|
| date | Sat, 13 Nov 2010 14:38:33 -0800 |
| parents | 562e68094af7 |
| children | fef69b887df4 |
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 _SSR_H
10 #define _SSR_H
12 #include "VMS/Queue_impl/PrivateQueue.h"
13 #include "VMS/Hash_impl/PrivateHash.h"
14 #include "VMS/VMS.h"
17 //===========================================================================
18 #define NUM_STRUCS_IN_SEM_ENV 1000
20 //===========================================================================
21 /*This header defines everything specific to the SSR semantic plug-in
22 */
23 typedef struct _SSRSemReq SSRSemReq;
24 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
25 //===========================================================================
27 /*Semantic layer-specific data sent inside a request from lib called in app
28 * to request handler called in MasterLoop
29 */
31 typedef struct
32 {
33 VirtProcr *VPCurrentlyExecuting;
34 PrivQueueStruc *waitingVPQ;
35 }
36 SSRTrans;
38 typedef struct
39 {
40 int32 hasBeenStarted;
41 int32 hasFinished;
42 void *endInstrAddr;
43 PrivQueueStruc *waitQ;
44 }
45 SSRSingleton;
47 enum SSRReqType
48 {
49 send_type = 1,
50 send_from_to,
51 receive_any, //order and grouping matter -- send before receive
52 receive_type, // and receive_any first of the receives -- Handlers
53 receive_from_to,// rely upon this ordering of enum
54 transfer_to,
55 transfer_out,
56 malloc_req,
57 free_req,
58 singleton_fn_start,
59 singleton_fn_end,
60 singleton_data_start,
61 singleton_data_end,
62 atomic,
63 trans_start,
64 trans_end
65 };
67 struct _SSRSemReq
68 { enum SSRReqType reqType;
69 VirtProcr *sendPr;
70 VirtProcr *receivePr;
71 int32 msgType;
72 void *msg;
73 SSRSemReq *nextReqInHashEntry;
75 void *initData;
76 VirtProcrFnPtr fnPtr;
77 int32 coreToScheduleOnto;
79 int32 sizeToMalloc;
80 void *ptrToFree;
82 int32 singletonID;
83 SSRSingleton **singletonAddr;
85 PtrToAtomicFn fnToExecInMaster;
86 void *dataForFn;
88 int32 transID;
89 }
90 /* SSRSemReq */;
93 typedef struct
94 {
95 PrivQueueStruc **readyVPQs;
96 HashTable *commHashTbl;
97 int32 numVirtPr;
98 int32 nextCoreToGetNewPr;
99 int32 primitiveStartTime;
101 //fix limit on num with dynArray
102 SSRSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
103 SSRTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
104 }
105 SSRSemEnv;
108 typedef struct _TransListElem TransListElem;
109 struct _TransListElem
110 {
111 int32 transID;
112 TransListElem *nextTrans;
113 };
114 //TransListElem
116 typedef struct
117 {
118 int32 highestTransEntered;
119 TransListElem *lastTransEntered;
120 }
121 SSRSemData;
123 //===========================================================================
125 void
126 SSR__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
128 int32
129 SSR__giveMinWorkUnitCycles( float32 percentOverhead );
131 void
132 SSR__start_primitive();
134 int32
135 SSR__end_primitive_and_give_cycles();
137 int32
138 SSR__giveIdealNumWorkUnits();
140 int32
141 SSR__give_number_of_cores_to_schedule_onto();
143 //=======================
145 void
146 SSR__init();
148 void
149 SSR__cleanup_after_shutdown();
151 //=======================
153 VirtProcr *
154 SSR__create_procr_with( VirtProcrFnPtr fnPtr, void *initData,
155 VirtProcr *creatingPr );
157 VirtProcr *
158 SSR__create_procr_with_affinity( VirtProcrFnPtr fnPtr, void *initData,
159 VirtProcr *creatingPr, int32 coreToScheduleOnto);
161 void
162 SSR__dissipate_procr( VirtProcr *procrToDissipate );
164 //=======================
165 void *
166 SSR__malloc_to( int numBytes, VirtProcr *ownerPr );
168 void
169 SSR__free( void *ptrToFree, VirtProcr *owningPr );
171 void
172 SSR__transfer_ownership_of_from_to( void *data, VirtProcr *oldOwnerPr,
173 VirtProcr *newOwnerPr );
175 void
176 SSR__add_ownership_by_to( VirtProcr *newOwnerPr, void *data );
178 void
179 SSR__remove_ownership_by_from( VirtProcr *loserPr, void *dataLosing );
181 void
182 SSR__transfer_ownership_to_outside( void *dataToTransferOwnershipOf );
186 //=======================
187 void
188 SSR__send_of_type_to( VirtProcr *sendPr, void *msg, const int type,
189 VirtProcr *receivePr);
191 void
192 SSR__send_from_to( void *msg, VirtProcr *sendPr, VirtProcr *receivePr);
194 void *
195 SSR__receive_type_to( const int type, VirtProcr *receivePr );
197 void *
198 SSR__receive_from_to( VirtProcr *sendPr, VirtProcr *receivePr );
201 //======================= Concurrency Stuff ======================
202 void
203 SSR__start_fn_singleton( int32 singletonID, VirtProcr *animPr );
205 void
206 SSR__end_fn_singleton( int32 singletonID, VirtProcr *animPr );
208 void
209 SSR__start_data_singleton( SSRSingleton **singeltonAddr, VirtProcr *animPr );
211 void
212 SSR__end_data_singleton( SSRSingleton **singletonAddr, VirtProcr *animPr );
214 void
215 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
216 void *data, VirtProcr *animPr );
218 void
219 SSR__start_transaction( int32 transactionID, VirtProcr *animPr );
221 void
222 SSR__end_transaction( int32 transactionID, VirtProcr *animPr );
225 //========================= Internal use only =============================
226 void
227 SSR__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
229 VirtProcr *
230 SSR__schedule_virt_procr( void *_semEnv, int coreNum );
233 #endif /* _SSR_H */
