annotate VMS.h @ 7:f96e4b3b35c7

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