comparison SSR.h @ 17:bf57b83019e5

Added atomic fn exec, singleton, trans start and end and fixed bus (contd) Fixed double-free of waiting requests bug Fixed place didn't clone in request handling Changed malloc and free handler prototypes
author Me
date Tue, 02 Nov 2010 16:57:45 -0700
parents 6c6d7fbd7e25
children cee3eecc5c22
comparison
equal deleted inserted replaced
3:fe94b8373e65 4:90aa5dbcdc81
11 11
12 #include "VMS/Queue_impl/PrivateQueue.h" 12 #include "VMS/Queue_impl/PrivateQueue.h"
13 #include "VMS/Hash_impl/PrivateHash.h" 13 #include "VMS/Hash_impl/PrivateHash.h"
14 #include "VMS/VMS.h" 14 #include "VMS/VMS.h"
15 15
16
17 //===========================================================================
18
19 #define NUM_STRUCS_IN_SEM_ENV 1000
20
21 //===========================================================================
16 /*This header defines everything specific to the SSR semantic plug-in 22 /*This header defines everything specific to the SSR semantic plug-in
17 */ 23 */
18 typedef struct _SSRSemReq SSRSemReq; 24 typedef struct _SSRSemReq SSRSemReq;
19 25 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
26 //===========================================================================
20 27
21 /*Semantic layer-specific data sent inside a request from lib called in app 28 /*Semantic layer-specific data sent inside a request from lib called in app
22 * to request handler called in MasterLoop 29 * to request handler called in MasterLoop
23 */ 30 */
24 enum SSRReqType 31 enum SSRReqType
27 send_from_to, 34 send_from_to,
28 receive_any, //order and grouping matter -- send before receive 35 receive_any, //order and grouping matter -- send before receive
29 receive_type, // and receive_any first of the receives -- Handlers 36 receive_type, // and receive_any first of the receives -- Handlers
30 receive_from_to,// rely upon this ordering of enum 37 receive_from_to,// rely upon this ordering of enum
31 transfer_to, 38 transfer_to,
32 transfer_out 39 transfer_out,
40 malloc_req,
41 free_req,
42 singleton,
43 atomic,
44 trans_start,
45 trans_end
33 }; 46 };
34 47
35 struct _SSRSemReq 48 struct _SSRSemReq
36 { enum SSRReqType reqType; 49 { enum SSRReqType reqType;
37 VirtProcr *sendPr; 50 VirtProcr *sendPr;
38 VirtProcr *receivePr; 51 VirtProcr *receivePr;
39 int32 msgType; 52 int32 msgType;
40 void *msg; 53 void *msg;
41 SSRSemReq *nextReqInHashEntry; 54 SSRSemReq *nextReqInHashEntry;
55
56 void *initData;
57 VirtProcrFnPtr fnPtr;
58 int32 coreToScheduleOnto;
59
60 int32 sizeToMalloc;
61 void *ptrToFree;
62
63 int32 singletonID;
64 void *endJumpPt;
65
66 PtrToAtomicFn fnToExecInMaster;
67 void *dataForFn;
68
69 int32 transID;
42 } 70 }
43 /* SSRSemReq */; 71 /* SSRSemReq */;
72
73
74 typedef struct
75 {
76 VirtProcr *VPCurrentlyExecuting;
77 PrivQueueStruc *waitingVPQ;
78 }
79 SSRTrans;
44 80
45 typedef struct 81 typedef struct
46 { 82 {
47 PrivQueueStruc **readyVPQs; 83 PrivQueueStruc **readyVPQs;
48 HashTable *commHashTbl; 84 HashTable *commHashTbl;
49 int32 numVirtPr; 85 int32 numVirtPr;
50 int32 nextCoreToGetNewPr; 86 int32 nextCoreToGetNewPr;
51 int32 primitiveStartTime; 87 int32 primitiveStartTime;
88
89 //fix limit on num with dynArray
90 int32 singletonHasBeenExecutedFlags[NUM_STRUCS_IN_SEM_ENV];
91 SSRTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
52 } 92 }
53 SSRSemEnv; 93 SSRSemEnv;
54 94
55 95
96 typedef struct _TransListElem TransListElem;
97 struct _TransListElem
98 {
99 int32 transID;
100 TransListElem *nextTrans;
101 };
102
103 typedef struct
104 {
105 int32 highestTransEntered;
106 TransListElem *lastTransEntered;
107 }
108 SSRSemData;
109
56 //=========================================================================== 110 //===========================================================================
57 111
58 void 112 void
59 SSR__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData ); 113 SSR__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
60 114
67 int32 inline 121 int32 inline
68 SSR__end_primitive_and_give_cycles(); 122 SSR__end_primitive_and_give_cycles();
69 123
70 int32 124 int32
71 SSR__giveIdealNumWorkUnits(); 125 SSR__giveIdealNumWorkUnits();
126
127 int32
128 SSR__give_number_of_cores_to_schedule_onto();
72 129
73 //======================= 130 //=======================
74 131
75 void 132 void
76 SSR__init(); 133 SSR__init();
82 139
83 inline VirtProcr * 140 inline VirtProcr *
84 SSR__create_procr_with( VirtProcrFnPtr fnPtr, void *initData, 141 SSR__create_procr_with( VirtProcrFnPtr fnPtr, void *initData,
85 VirtProcr *creatingPr ); 142 VirtProcr *creatingPr );
86 143
144 inline VirtProcr *
145 SSR__create_procr_with_affinity( VirtProcrFnPtr fnPtr, void *initData,
146 VirtProcr *creatingPr, int32 coreToScheduleOnto);
147
87 void 148 void
88 SSR__dissipate_procr( VirtProcr *procrToDissipate ); 149 SSR__dissipate_procr( VirtProcr *procrToDissipate );
89 150
90 //======================= 151 //=======================
91 void * 152 void *
92 SSR__malloc_size_to( int numBytes, VirtProcr *ownerPr ); 153 SSR__malloc_to( int numBytes, VirtProcr *ownerPr );
154
155 void
156 SSR__free( void *ptrToFree, VirtProcr *owningPr );
93 157
94 void 158 void
95 SSR__transfer_ownership_of_from_to( void *data, VirtProcr *oldOwnerPr, 159 SSR__transfer_ownership_of_from_to( void *data, VirtProcr *oldOwnerPr,
96 VirtProcr *newOwnerPr ); 160 VirtProcr *newOwnerPr );
97 161
119 183
120 void * 184 void *
121 SSR__receive_from_to( VirtProcr *sendPr, VirtProcr *receivePr ); 185 SSR__receive_from_to( VirtProcr *sendPr, VirtProcr *receivePr );
122 186
123 187
124 //======================= 188 //======================= Concurrency Stuff ======================
125 189 void
126 void 190 SSR__start_singleton( int32 singletonID, void *endSingletonLabelAddr,
127 SSR__free_semantic_request( SSRSemReq *semReq ); 191 VirtProcr *animPr );
192
193 void
194 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
195 void *data, VirtProcr *animPr );
196
197 void
198 SSR__start_transaction( int32 transactionID, VirtProcr *animPr );
199
200 void
201 SSR__end_transaction( int32 transactionID, VirtProcr *animPr );
128 202
129 203
130 //========================= Internal use only ============================= 204 //========================= Internal use only =============================
131 void 205 void
132 SSR__Request_Handler( VirtProcr *requestingPr, void *_semEnv ); 206 SSR__Request_Handler( VirtProcr *requestingPr, void *_semEnv );