diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/VPThread.h	Fri Sep 17 11:34:02 2010 -0700
     1.3 @@ -0,0 +1,153 @@
     1.4 +/*
     1.5 + *  Copyright 2009 OpenSourceStewardshipFoundation.org
     1.6 + *  Licensed under GNU General Public License version 2
     1.7 + *
     1.8 + * Author: seanhalle@yahoo.com
     1.9 + *
    1.10 + */
    1.11 +
    1.12 +#ifndef _VPThread_H
    1.13 +#define	_VPThread_H
    1.14 +
    1.15 +#include "VMS/VMS.h"
    1.16 +#include "VMS/Queue_impl/PrivateQueue.h"
    1.17 +#include "VMS/DynArray/DynArray.h"
    1.18 +
    1.19 +
    1.20 +//===========================================================================
    1.21 +#define INIT_NUM_MUTEX 10000
    1.22 +#define INIT_NUM_COND  10000
    1.23 +//===========================================================================
    1.24 +
    1.25 +/*This header defines everything specific to the VPThread semantic plug-in
    1.26 + */
    1.27 +typedef struct _VPThreadSemReq   VPThreadSemReq;
    1.28 +
    1.29 +
    1.30 +/*Semantic layer-specific data sent inside a request from lib called in app
    1.31 + * to request handler called in MasterLoop
    1.32 + */
    1.33 +enum VPThreadReqType
    1.34 + {
    1.35 +   make_mutex = 1,
    1.36 +   mutex_lock,
    1.37 +   mutex_unlock,
    1.38 +   make_cond,
    1.39 +   cond_wait,
    1.40 +   cond_signal,
    1.41 +   make_procr
    1.42 + };
    1.43 +
    1.44 +struct _VPThreadSemReq
    1.45 + { enum VPThreadReqType reqType;
    1.46 +   VirtProcr           *requestingPr;
    1.47 +   int32                mutexIdx;
    1.48 +   int32                condIdx;
    1.49 +   void                *initData;
    1.50 +   VirtProcrFnPtr       fnPtr;
    1.51 + }
    1.52 +/* VPThreadSemReq */;
    1.53 +
    1.54 +typedef struct
    1.55 + {
    1.56 +      //Standard stuff will be in most every semantic env
    1.57 +   PrivQueueStruc **readyVPQs;
    1.58 +   int32            numVirtPr;
    1.59 +   int32            nextCoreToGetNewPr;
    1.60 +
    1.61 +      //Specific to this semantic layer
    1.62 +   int32            currMutexIdx;
    1.63 +   DynArray32      *mutexDynArray;
    1.64 +   
    1.65 +   int32            currCondIdx;
    1.66 +   DynArray32      *condDynArray;
    1.67 +
    1.68 +   void            *applicationGlobals;
    1.69 + }
    1.70 +VPThreadSemEnv;
    1.71 +
    1.72 +
    1.73 +typedef struct
    1.74 + {
    1.75 +   int32           mutexIdx;
    1.76 +   VirtProcr      *holderOfLock;
    1.77 +   PrivQueueStruc *waitingQueue;
    1.78 + }
    1.79 +VPTMutex;
    1.80 +
    1.81 +
    1.82 +typedef struct
    1.83 + {
    1.84 +   int32           condIdx;
    1.85 +   PrivQueueStruc *waitingQueue;
    1.86 +   VPTMutex       *partnerMutex;
    1.87 + }
    1.88 +VPTCond;
    1.89 +
    1.90 +
    1.91 +//===========================================================================
    1.92 +
    1.93 +void
    1.94 +VPThread__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
    1.95 +
    1.96 +//=======================
    1.97 +
    1.98 +inline VirtProcr *
    1.99 +VPThread__create_thread( VirtProcrFnPtr fnPtr, void *initData,
   1.100 +                          VirtProcr *creatingPr );
   1.101 +
   1.102 +void
   1.103 +VPThread__dissipate_thread( VirtProcr *procrToDissipate );
   1.104 +
   1.105 +//=======================
   1.106 +void
   1.107 +VPThread__set_globals_to( void *globals );
   1.108 +
   1.109 +void *
   1.110 +VPThread__give_globals();
   1.111 +
   1.112 +//=======================
   1.113 +int32
   1.114 +VPThread__make_mutex( VirtProcr *animPr );
   1.115 +
   1.116 +void
   1.117 +VPThread__mutex_lock( int32 mutexIdx, VirtProcr *acquiringPr );
   1.118 +                                                    
   1.119 +void
   1.120 +VPThread__mutex_unlock( int32 mutexIdx, VirtProcr *releasingPr );
   1.121 +
   1.122 +
   1.123 +//=======================
   1.124 +int32
   1.125 +VPThread__make_cond( int32 ownedMutexIdx, VirtProcr *animPr);
   1.126 +
   1.127 +void
   1.128 +VPThread__cond_wait( int32 condIdx, VirtProcr *waitingPr);
   1.129 +
   1.130 +void *
   1.131 +VPThread__cond_signal( int32 condIdx, VirtProcr *signallingPr );
   1.132 +
   1.133 +
   1.134 +
   1.135 +
   1.136 +//=========================  Internal use only  =============================
   1.137 +void
   1.138 +VPThread__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
   1.139 +
   1.140 +VirtProcr *
   1.141 +VPThread__schedule_virt_procr( void *_semEnv, int coreNum );
   1.142 +
   1.143 +//=======================
   1.144 +void
   1.145 +VPThread__free_semantic_request( VPThreadSemReq *semReq );
   1.146 +
   1.147 +//=======================
   1.148 +
   1.149 +void
   1.150 +VPThread__init();
   1.151 +
   1.152 +void
   1.153 +VPThread__cleanup_after_shutdown();
   1.154 +
   1.155 +#endif	/* _VPThread_H */
   1.156 +