| rev |
line source |
|
Me@0
|
1 /*
|
|
Me@0
|
2 * Copyright 2009 OpenSourceStewardshipFoundation.org
|
|
Me@0
|
3 * Licensed under GNU General Public License version 2
|
|
Me@0
|
4 *
|
|
Me@0
|
5 * Author: seanhalle@yahoo.com
|
|
Me@0
|
6 *
|
|
Me@0
|
7 */
|
|
Me@0
|
8
|
|
Me@0
|
9 #ifndef _VPThread_H
|
|
Me@0
|
10 #define _VPThread_H
|
|
Me@0
|
11
|
|
Me@0
|
12 #include "VMS/VMS.h"
|
|
Me@0
|
13 #include "VMS/Queue_impl/PrivateQueue.h"
|
|
Me@0
|
14 #include "VMS/DynArray/DynArray.h"
|
|
Me@0
|
15
|
|
Me@0
|
16
|
|
Me@0
|
17 //===========================================================================
|
|
Me@0
|
18 #define INIT_NUM_MUTEX 10000
|
|
Me@0
|
19 #define INIT_NUM_COND 10000
|
|
Me@0
|
20 //===========================================================================
|
|
Me@0
|
21
|
|
Me@0
|
22 /*This header defines everything specific to the VPThread semantic plug-in
|
|
Me@0
|
23 */
|
|
Me@0
|
24 typedef struct _VPThreadSemReq VPThreadSemReq;
|
|
Me@0
|
25
|
|
Me@0
|
26
|
|
Me@0
|
27 /*Semantic layer-specific data sent inside a request from lib called in app
|
|
Me@0
|
28 * to request handler called in MasterLoop
|
|
Me@0
|
29 */
|
|
Me@0
|
30 enum VPThreadReqType
|
|
Me@0
|
31 {
|
|
Me@0
|
32 make_mutex = 1,
|
|
Me@0
|
33 mutex_lock,
|
|
Me@0
|
34 mutex_unlock,
|
|
Me@0
|
35 make_cond,
|
|
Me@0
|
36 cond_wait,
|
|
Me@0
|
37 cond_signal,
|
|
Me@0
|
38 make_procr
|
|
Me@0
|
39 };
|
|
Me@0
|
40
|
|
Me@0
|
41 struct _VPThreadSemReq
|
|
Me@0
|
42 { enum VPThreadReqType reqType;
|
|
Me@0
|
43 VirtProcr *requestingPr;
|
|
Me@0
|
44 int32 mutexIdx;
|
|
Me@0
|
45 int32 condIdx;
|
|
Me@0
|
46 void *initData;
|
|
Me@0
|
47 VirtProcrFnPtr fnPtr;
|
|
Me@0
|
48 }
|
|
Me@0
|
49 /* VPThreadSemReq */;
|
|
Me@0
|
50
|
|
Me@0
|
51 typedef struct
|
|
Me@0
|
52 {
|
|
Me@0
|
53 //Standard stuff will be in most every semantic env
|
|
Me@0
|
54 PrivQueueStruc **readyVPQs;
|
|
Me@0
|
55 int32 numVirtPr;
|
|
Me@0
|
56 int32 nextCoreToGetNewPr;
|
|
Me@0
|
57
|
|
Me@0
|
58 //Specific to this semantic layer
|
|
Me@0
|
59 int32 currMutexIdx;
|
|
Me@0
|
60 DynArray32 *mutexDynArray;
|
|
Me@0
|
61
|
|
Me@0
|
62 int32 currCondIdx;
|
|
Me@0
|
63 DynArray32 *condDynArray;
|
|
Me@0
|
64
|
|
Me@0
|
65 void *applicationGlobals;
|
|
Me@0
|
66 }
|
|
Me@0
|
67 VPThreadSemEnv;
|
|
Me@0
|
68
|
|
Me@0
|
69
|
|
Me@0
|
70 typedef struct
|
|
Me@0
|
71 {
|
|
Me@0
|
72 int32 mutexIdx;
|
|
Me@0
|
73 VirtProcr *holderOfLock;
|
|
Me@0
|
74 PrivQueueStruc *waitingQueue;
|
|
Me@0
|
75 }
|
|
Me@0
|
76 VPTMutex;
|
|
Me@0
|
77
|
|
Me@0
|
78
|
|
Me@0
|
79 typedef struct
|
|
Me@0
|
80 {
|
|
Me@0
|
81 int32 condIdx;
|
|
Me@0
|
82 PrivQueueStruc *waitingQueue;
|
|
Me@0
|
83 VPTMutex *partnerMutex;
|
|
Me@0
|
84 }
|
|
Me@0
|
85 VPTCond;
|
|
Me@0
|
86
|
|
Me@0
|
87
|
|
Me@0
|
88 //===========================================================================
|
|
Me@0
|
89
|
|
Me@0
|
90 void
|
|
Me@0
|
91 VPThread__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
|
|
Me@0
|
92
|
|
Me@0
|
93 //=======================
|
|
Me@0
|
94
|
|
Me@0
|
95 inline VirtProcr *
|
|
Me@0
|
96 VPThread__create_thread( VirtProcrFnPtr fnPtr, void *initData,
|
|
Me@0
|
97 VirtProcr *creatingPr );
|
|
Me@0
|
98
|
|
Me@0
|
99 void
|
|
Me@0
|
100 VPThread__dissipate_thread( VirtProcr *procrToDissipate );
|
|
Me@0
|
101
|
|
Me@0
|
102 //=======================
|
|
Me@0
|
103 void
|
|
Me@0
|
104 VPThread__set_globals_to( void *globals );
|
|
Me@0
|
105
|
|
Me@0
|
106 void *
|
|
Me@0
|
107 VPThread__give_globals();
|
|
Me@0
|
108
|
|
Me@0
|
109 //=======================
|
|
Me@0
|
110 int32
|
|
Me@0
|
111 VPThread__make_mutex( VirtProcr *animPr );
|
|
Me@0
|
112
|
|
Me@0
|
113 void
|
|
Me@0
|
114 VPThread__mutex_lock( int32 mutexIdx, VirtProcr *acquiringPr );
|
|
Me@0
|
115
|
|
Me@0
|
116 void
|
|
Me@0
|
117 VPThread__mutex_unlock( int32 mutexIdx, VirtProcr *releasingPr );
|
|
Me@0
|
118
|
|
Me@0
|
119
|
|
Me@0
|
120 //=======================
|
|
Me@0
|
121 int32
|
|
Me@0
|
122 VPThread__make_cond( int32 ownedMutexIdx, VirtProcr *animPr);
|
|
Me@0
|
123
|
|
Me@0
|
124 void
|
|
Me@0
|
125 VPThread__cond_wait( int32 condIdx, VirtProcr *waitingPr);
|
|
Me@0
|
126
|
|
Me@0
|
127 void *
|
|
Me@0
|
128 VPThread__cond_signal( int32 condIdx, VirtProcr *signallingPr );
|
|
Me@0
|
129
|
|
Me@0
|
130
|
|
Me@0
|
131
|
|
Me@0
|
132
|
|
Me@0
|
133 //========================= Internal use only =============================
|
|
Me@0
|
134 void
|
|
Me@0
|
135 VPThread__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
|
|
Me@0
|
136
|
|
Me@0
|
137 VirtProcr *
|
|
Me@0
|
138 VPThread__schedule_virt_procr( void *_semEnv, int coreNum );
|
|
Me@0
|
139
|
|
Me@0
|
140 //=======================
|
|
Me@0
|
141 void
|
|
Me@0
|
142 VPThread__free_semantic_request( VPThreadSemReq *semReq );
|
|
Me@0
|
143
|
|
Me@0
|
144 //=======================
|
|
Me@0
|
145
|
|
Me@0
|
146 void
|
|
Me@0
|
147 VPThread__init();
|
|
Me@0
|
148
|
|
Me@0
|
149 void
|
|
Me@0
|
150 VPThread__cleanup_after_shutdown();
|
|
Me@0
|
151
|
|
Me@0
|
152 #endif /* _VPThread_H */
|
|
Me@0
|
153
|