view VMS.h @ 7:f96e4b3b35c7

Added win thds
author Me
date Tue, 01 Jun 2010 05:32:41 -0700
parents 6c518bda83fe
children 4b58b9a2527b
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 _VMS_H
10 #define _VMS_H
12 #include "VMS_primitive_data_types.h"
13 #include "Queue_impl/BlockingQueue.h"
14 #include <windows.h>
16 //This value is the number of hardware threads in the shared memory
17 // machine -- make double that number scheduling slots, plus extra for master
18 #define NUM_CORES 4
19 #define NUM_SCHED_SLOTS 9
21 #define SUCCESS 0
23 #define thdAttrs NULL
25 typedef struct _WorkUnit WorkUnit;
26 typedef struct _VirtProcr VirtProcr;
27 typedef struct _SlaveReqst SlaveReqst;
28 typedef struct _SchedSlot SchedSlot;
30 typedef bool8 (*SlaveScheduler) ( SchedSlot *, void * );
31 typedef void (*RequestHandler) ( SlaveReqst * );
32 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * );
33 typedef void VirtProcrFn( void *, VirtProcr * );
35 typedef struct
36 {
37 void *endThdPt;
38 unsigned int coreNum;
39 }
40 ThdParams;
42 struct _SchedSlot
43 {
44 int workIsDone;
45 int needsProcrAssigned;
46 VirtProcr *procrAssignedToSlot;
47 };
50 struct _VirtProcr
51 {
52 void *stackPtr;
53 void *framePtr;
54 void *nextInstrPt;
55 void *coreLoopStartPt; //allows proto-runtime to be linked later
57 void *initialData;
59 SchedSlot *schedSlot;
60 SlaveReqst *requests;
62 void *semanticData;
63 };
66 //When optimize make a separate flat array in here for each flag in SchedSlot
67 //So that polling done flags is fast.. not sure even worth it, though..
68 typedef struct
69 {
70 SlaveScheduler slaveScheduler;
71 RequestHandler requestHandler;
73 SchedSlot **schedSlots;
74 SchedSlot **filledSlots;
75 int numFilled;
77 int stillRunning;
79 VirtProcr *masterVirtPr;
80 void *semanticEnv;
81 void *OSEventStruc; //for future, when add I/O to BLIS
82 }
83 MasterEnv;
87 struct _SlaveReqst
88 {
89 VirtProcr *slaveFrom;
90 int reqType; //for future when have I/O and OS services
91 void *semReqData;
93 SlaveReqst *nextRequest;
94 };
97 DWORD WINAPI coreLoop( LPVOID paramsIn );
98 //void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
99 void masterLoop( void *initData, VirtProcr *masterPr );
102 //===================== Global Vars ===================
105 HANDLE coreLoopThds[ NUM_CORES ]; //windows handle to thread
106 ThdParams *thdParams[ NUM_CORES ];
107 DWORD thdIds[ NUM_CORES ];
109 volatile MasterEnv *_VMSMasterEnv;
111 //workQ is global, static, and volatile so that core loop has its location
112 // hard coded, and reloads every time through the loop -- that way don't
113 // need to save any regs used by core loop (will see if this really works)
114 volatile QueueStruc *_VMSWorkQ;
116 //==========================
117 void
118 VMS__init();
120 void
121 VMS__start();
123 VirtProcr *
124 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
126 inline void
127 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
129 void
130 VMS__suspend_processor( VirtProcr *callingPr );
133 #endif /* _VMS_H */