comparison VPThread.h @ 0:4aca264971b5

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