view SSR.h @ 19:b549ad140f18

chgd resumePr to resume_procr
author SeanHalle
date Thu, 11 Nov 2010 04:59:48 -0800
parents cee3eecc5c22
children 562e68094af7
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 */
30 enum SSRReqType
31 {
32 send_type = 1,
33 send_from_to,
34 receive_any, //order and grouping matter -- send before receive
35 receive_type, // and receive_any first of the receives -- Handlers
36 receive_from_to,// rely upon this ordering of enum
37 transfer_to,
38 transfer_out,
39 malloc_req,
40 free_req,
41 singleton,
42 atomic,
43 trans_start,
44 trans_end
45 };
47 struct _SSRSemReq
48 { enum SSRReqType reqType;
49 VirtProcr *sendPr;
50 VirtProcr *receivePr;
51 int32 msgType;
52 void *msg;
53 SSRSemReq *nextReqInHashEntry;
55 void *initData;
56 VirtProcrFnPtr fnPtr;
57 int32 coreToScheduleOnto;
59 int32 sizeToMalloc;
60 void *ptrToFree;
62 int32 singletonID;
63 void *endJumpPt;
65 PtrToAtomicFn fnToExecInMaster;
66 void *dataForFn;
68 int32 transID;
69 }
70 /* SSRSemReq */;
73 typedef struct
74 {
75 VirtProcr *VPCurrentlyExecuting;
76 PrivQueueStruc *waitingVPQ;
77 }
78 SSRTrans;
80 typedef struct
81 {
82 PrivQueueStruc **readyVPQs;
83 HashTable *commHashTbl;
84 int32 numVirtPr;
85 int32 nextCoreToGetNewPr;
86 int32 primitiveStartTime;
88 //fix limit on num with dynArray
89 int32 singletonHasBeenExecutedFlags[NUM_STRUCS_IN_SEM_ENV];
90 SSRTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
91 }
92 SSRSemEnv;
95 typedef struct _TransListElem TransListElem;
96 struct _TransListElem
97 {
98 int32 transID;
99 TransListElem *nextTrans;
100 };
101 //TransListElem
103 typedef struct
104 {
105 int32 highestTransEntered;
106 TransListElem *lastTransEntered;
107 }
108 SSRSemData;
110 //===========================================================================
112 void
113 SSR__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
115 int32
116 SSR__giveMinWorkUnitCycles( float32 percentOverhead );
118 void inline
119 SSR__start_primitive();
121 int32 inline
122 SSR__end_primitive_and_give_cycles();
124 int32
125 SSR__giveIdealNumWorkUnits();
127 int32
128 SSR__give_number_of_cores_to_schedule_onto();
130 //=======================
132 void
133 SSR__init();
135 void
136 SSR__cleanup_after_shutdown();
138 //=======================
140 inline VirtProcr *
141 SSR__create_procr_with( VirtProcrFnPtr fnPtr, void *initData,
142 VirtProcr *creatingPr );
144 inline VirtProcr *
145 SSR__create_procr_with_affinity( VirtProcrFnPtr fnPtr, void *initData,
146 VirtProcr *creatingPr, int32 coreToScheduleOnto);
148 void
149 SSR__dissipate_procr( VirtProcr *procrToDissipate );
151 //=======================
152 void *
153 SSR__malloc_to( int numBytes, VirtProcr *ownerPr );
155 void
156 SSR__free( void *ptrToFree, VirtProcr *owningPr );
158 void
159 SSR__transfer_ownership_of_from_to( void *data, VirtProcr *oldOwnerPr,
160 VirtProcr *newOwnerPr );
162 void
163 SSR__add_ownership_by_to( VirtProcr *newOwnerPr, void *data );
165 void
166 SSR__remove_ownership_by_from( VirtProcr *loserPr, void *dataLosing );
168 void
169 SSR__transfer_ownership_to_outside( void *dataToTransferOwnershipOf );
173 //=======================
174 void
175 SSR__send_of_type_to( VirtProcr *sendPr, void *msg, const int type,
176 VirtProcr *receivePr);
178 void
179 SSR__send_from_to( void *msg, VirtProcr *sendPr, VirtProcr *receivePr);
181 void *
182 SSR__receive_type_to( const int type, VirtProcr *receivePr );
184 void *
185 SSR__receive_from_to( VirtProcr *sendPr, VirtProcr *receivePr );
188 //======================= Concurrency Stuff ======================
189 void
190 SSR__start_singleton( int32 singletonID, void *endSingletonLabelAddr,
191 VirtProcr *animPr );
193 void
194 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
195 void *data, VirtProcr *animPr );
197 void
198 SSR__start_transaction( int32 transactionID, VirtProcr *animPr );
200 void
201 SSR__end_transaction( int32 transactionID, VirtProcr *animPr );
204 //========================= Internal use only =============================
205 void
206 SSR__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
208 VirtProcr *
209 SSR__schedule_virt_procr( void *_semEnv, int coreNum );
212 #endif /* _SSR_H */