changeset 4:ee229dfdc891 Dev_libs

Merge
author Sean Halle <seanhalle@yahoo.com>
date Sun, 21 Jul 2013 13:44:17 -0700
parents 26458f2b5c23 c68d04a82e0b
children 700105fd15b7 972ce554264c
files PR__WL.h PR__common.h PR__common_structs.h
diffstat 15 files changed, 1954 insertions(+), 1922 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.hgeol	Sun Jul 21 13:44:17 2013 -0700
     1.3 @@ -0,0 +1,14 @@
     1.4 +
     1.5 +[patterns]
     1.6 +**.py = native
     1.7 +**.txt = native
     1.8 +**.c = native
     1.9 +**.h = native
    1.10 +**.cpp = native
    1.11 +**.java = native
    1.12 +**.class = bin
    1.13 +**.jar = bin
    1.14 +**.sh = native
    1.15 +**.pl = native
    1.16 +**.jpg = bin
    1.17 +**.gif = bin
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/.hgignore	Sun Jul 21 13:44:17 2013 -0700
     2.3 @@ -0,0 +1,12 @@
     2.4 +nbproject
     2.5 +Makefile
     2.6 +build
     2.7 +dist
     2.8 +src/Default
     2.9 +src/.settings
    2.10 +src/.cproject
    2.11 +src/.project
    2.12 +.dep.inc
    2.13 +glob:.cproject
    2.14 +glob:.project
    2.15 +glob:Debug
     3.1 --- a/Defines/MEAS__macros_to_be_moved_to_langs.h	Sun Jul 21 13:41:59 2013 -0700
     3.2 +++ b/Defines/MEAS__macros_to_be_moved_to_langs.h	Sun Jul 21 13:44:17 2013 -0700
     3.3 @@ -1,64 +1,64 @@
     3.4 -/*
     3.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
     3.6 - *  Licensed under GNU General Public License version 2
     3.7 - *
     3.8 - * Author: seanhalle@yahoo.com
     3.9 - * 
    3.10 - */
    3.11 -
    3.12 -#ifndef  _PR_LANG_SPEC_DEFS_H
    3.13 -#define	_PR_LANG_SPEC_DEFS_H
    3.14 -
    3.15 -
    3.16 -
    3.17 -//===================  Language-specific Measurement Stuff ===================
    3.18 -//
    3.19 -//TODO:  move these into the language implementation directories
    3.20 -//
    3.21 -
    3.22 -
    3.23 -//===========================================================================
    3.24 -//VCilk
    3.25 -
    3.26 -#ifdef VCILK
    3.27 -
    3.28 -/*These defines are used in the macros below*/
    3.29 -#define spawnHistIdx      1 //note: starts at 1
    3.30 -#define syncHistIdx       2
    3.31 -
    3.32 -#define MEAS__Make_Meas_Hists_for_VCilk( slave, magicNum ) \
    3.33 - do \
    3.34 - { VCilkLangEnv * \
    3.35 -   langEnv = PR_PI__get_lang_env_from_slave( slave, magicNum ); \ 
    3.36 -   langEnv->measHistsInfo = \
    3.37 -          makePrivDynArrayOfSize( (void***)&(_PRTopEnv->measHists), 200); \
    3.38 -   histInfo = langEnv->measHistsInfo;
    3.39 -    makeAMeasHist( histInfo, spawnHistIdx,      "Spawn",        50, 0, 200 ) \
    3.40 -    makeAMeasHist( histInfo, syncHistIdx,       "Sync",         50, 0, 200 ) \
    3.41 - }while(FALSE); /* macro magic to protect local vars from name collision */
    3.42 -
    3.43 -#define Meas_startSpawn fixme; /* changed names -- added __Cilk to end*/
    3.44 -    
    3.45 -#define Meas_startSpawn__Cilk \
    3.46 -    int32 startStamp, endStamp; \
    3.47 -    saveLowTimeStampCountInto( startStamp ); \
    3.48 -
    3.49 -#define Meas_endSpawn__Cilk \
    3.50 -    saveLowTimeStampCountInto( endStamp ); \
    3.51 -    addIntervalToHist( startStamp, endStamp, \
    3.52 -                             _PRTopEnv->measHists[ spawnHistIdx ] );
    3.53 -
    3.54 -#define Meas_startSync__Cilk \
    3.55 -    int32 startStamp, endStamp; \
    3.56 -    saveLowTimeStampCountInto( startStamp ); \
    3.57 -
    3.58 -#define Meas_endSync__Cilk \
    3.59 -    saveLowTimeStampCountInto( endStamp ); \
    3.60 -    addIntervalToHist( startStamp, endStamp, \
    3.61 -                             _PRTopEnv->measHists[ syncHistIdx ] );
    3.62 -#endif
    3.63 -
    3.64 -//===========================================================================
    3.65 -
    3.66 -#endif	/* _PR_DEFS_H */
    3.67 -
    3.68 +/*
    3.69 + *  Copyright 2009 OpenSourceResearchInstitute.org
    3.70 + *  Licensed under GNU General Public License version 2
    3.71 + *
    3.72 + * Author: seanhalle@yahoo.com
    3.73 + * 
    3.74 + */
    3.75 +
    3.76 +#ifndef  _PR_LANG_SPEC_DEFS_H
    3.77 +#define	_PR_LANG_SPEC_DEFS_H
    3.78 +
    3.79 +
    3.80 +
    3.81 +//===================  Language-specific Measurement Stuff ===================
    3.82 +//
    3.83 +//TODO:  move these into the language implementation directories
    3.84 +//
    3.85 +
    3.86 +
    3.87 +//===========================================================================
    3.88 +//VCilk
    3.89 +
    3.90 +#ifdef VCILK
    3.91 +
    3.92 +/*These defines are used in the macros below*/
    3.93 +#define spawnHistIdx      1 //note: starts at 1
    3.94 +#define syncHistIdx       2
    3.95 +
    3.96 +#define MEAS__Make_Meas_Hists_for_VCilk( slave, magicNum ) \
    3.97 + do \
    3.98 + { VCilkLangEnv * \
    3.99 +   langEnv = PR_PI__get_lang_env_from_slave( slave, magicNum ); \ 
   3.100 +   langEnv->measHistsInfo = \
   3.101 +          makePrivDynArrayOfSize( (void***)&(_PRTopEnv->measHists), 200); \
   3.102 +   histInfo = langEnv->measHistsInfo;
   3.103 +    makeAMeasHist( histInfo, spawnHistIdx,      "Spawn",        50, 0, 200 ) \
   3.104 +    makeAMeasHist( histInfo, syncHistIdx,       "Sync",         50, 0, 200 ) \
   3.105 + }while(FALSE); /* macro magic to protect local vars from name collision */
   3.106 +
   3.107 +#define Meas_startSpawn fixme; /* changed names -- added __Cilk to end*/
   3.108 +    
   3.109 +#define Meas_startSpawn__Cilk \
   3.110 +    int32 startStamp, endStamp; \
   3.111 +    saveLowTimeStampCountInto( startStamp ); \
   3.112 +
   3.113 +#define Meas_endSpawn__Cilk \
   3.114 +    saveLowTimeStampCountInto( endStamp ); \
   3.115 +    addIntervalToHist( startStamp, endStamp, \
   3.116 +                             _PRTopEnv->measHists[ spawnHistIdx ] );
   3.117 +
   3.118 +#define Meas_startSync__Cilk \
   3.119 +    int32 startStamp, endStamp; \
   3.120 +    saveLowTimeStampCountInto( startStamp ); \
   3.121 +
   3.122 +#define Meas_endSync__Cilk \
   3.123 +    saveLowTimeStampCountInto( endStamp ); \
   3.124 +    addIntervalToHist( startStamp, endStamp, \
   3.125 +                             _PRTopEnv->measHists[ syncHistIdx ] );
   3.126 +#endif
   3.127 +
   3.128 +//===========================================================================
   3.129 +
   3.130 +#endif	/* _PR_DEFS_H */
   3.131 +
     4.1 --- a/Defines/PR_defs.h	Sun Jul 21 13:41:59 2013 -0700
     4.2 +++ b/Defines/PR_defs.h	Sun Jul 21 13:44:17 2013 -0700
     4.3 @@ -1,43 +1,43 @@
     4.4 -/*
     4.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
     4.6 - *  Licensed under GNU General Public License version 2
     4.7 - *
     4.8 - * Author: seanhalle@yahoo.com
     4.9 - * 
    4.10 - */
    4.11 -
    4.12 -#ifndef  _PR_DEFS_MAIN_H
    4.13 -#define	_PR_DEFS_MAIN_H
    4.14 -#define _GNU_SOURCE
    4.15 -
    4.16 -//===========================  PR-wide defs  ===============================
    4.17 -
    4.18 -#define SUCCESS 0
    4.19 -
    4.20 -   //only after macro-expansion are the defs of writePrivQ, aso looked up
    4.21 -   // so these defs can be at the top, and writePrivQ defined later on..
    4.22 -#define writePRQ     writePrivQ
    4.23 -#define readPRQ      readPrivQ
    4.24 -#define makePRQ      makePrivQ
    4.25 -#define numInPRQ     numInPrivQ
    4.26 -#define PRQueueStruc PrivQueueStruc
    4.27 -
    4.28 -
    4.29 -/*The language should re-define this, but need a default in case it doesn't*/
    4.30 -#ifndef _LANG_NAME_
    4.31 -#define _LANG_NAME_ ""
    4.32 -#endif
    4.33 -
    4.34 -//======================  Hardware Constants ============================
    4.35 -#include "PR_defs__HW_constants.h"
    4.36 -
    4.37 -//======================  Macros  ======================
    4.38 -   //for turning macros and other PR features on and off
    4.39 -#include "PR_defs__turn_on_and_off.h"
    4.40 -
    4.41 -#include "../Services_Offered_by_PR/Debugging/DEBUG__macros.h"
    4.42 -#include "../Services_Offered_by_PR/Measurement_and_Stats/MEAS__macros.h"
    4.43 -
    4.44 -//===========================================================================
    4.45 -#endif	/*  */
    4.46 -
    4.47 +/*
    4.48 + *  Copyright 2009 OpenSourceResearchInstitute.org
    4.49 + *  Licensed under GNU General Public License version 2
    4.50 + *
    4.51 + * Author: seanhalle@yahoo.com
    4.52 + * 
    4.53 + */
    4.54 +
    4.55 +#ifndef  _PR_DEFS_MAIN_H
    4.56 +#define	_PR_DEFS_MAIN_H
    4.57 +#define _GNU_SOURCE
    4.58 +
    4.59 +//===========================  PR-wide defs  ===============================
    4.60 +
    4.61 +#define SUCCESS 0
    4.62 +
    4.63 +   //only after macro-expansion are the defs of writePrivQ, aso looked up
    4.64 +   // so these defs can be at the top, and writePrivQ defined later on..
    4.65 +#define writePRQ     writePrivQ
    4.66 +#define readPRQ      readPrivQ
    4.67 +#define makePRQ      makePrivQ
    4.68 +#define numInPRQ     numInPrivQ
    4.69 +#define PRQueueStruc PrivQueueStruc
    4.70 +
    4.71 +
    4.72 +/*The language should re-define this, but need a default in case it doesn't*/
    4.73 +#ifndef _LANG_NAME_
    4.74 +#define _LANG_NAME_ ""
    4.75 +#endif
    4.76 +
    4.77 +//======================  Hardware Constants ============================
    4.78 +#include "PR_defs__HW_constants.h"
    4.79 +
    4.80 +//======================  Macros  ======================
    4.81 +   //for turning macros and other PR features on and off
    4.82 +#include "PR_defs__turn_on_and_off.h"
    4.83 +
    4.84 +#include "../Services_Offered_by_PR/Debugging/DEBUG__macros.h"
    4.85 +#include "../Services_Offered_by_PR/Measurement_and_Stats/MEAS__macros.h"
    4.86 +
    4.87 +//===========================================================================
    4.88 +#endif	/*  */
    4.89 +
     5.1 --- a/Defines/PR_defs__HW_constants.h	Sun Jul 21 13:41:59 2013 -0700
     5.2 +++ b/Defines/PR_defs__HW_constants.h	Sun Jul 21 13:44:17 2013 -0700
     5.3 @@ -1,67 +1,67 @@
     5.4 -/*
     5.5 - *  Copyright 2012 OpenSourceResearchInstitute
     5.6 - *  Licensed under BSD
     5.7 - *
     5.8 - * Author: seanhalle@yahoo.com
     5.9 - * 
    5.10 - */
    5.11 -
    5.12 -#ifndef _PR_HW_SPEC_DEFS_H
    5.13 -#define	_PR_HW_SPEC_DEFS_H
    5.14 -#define _GNU_SOURCE
    5.15 -
    5.16 -
    5.17 -//=========================  Hardware related Constants =====================
    5.18 -   //This value is the number of hardware threads in the shared memory
    5.19 -   // machine
    5.20 -#define NUM_CORES        4
    5.21 -   //Now, check if sequential mode is on, and set num cores to 1, so that
    5.22 -   // lang plugin code doesn't have to check for sequential mode
    5.23 -#ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE
    5.24 -   #undef  NUM_CORES
    5.25 -   #define NUM_CORES 1
    5.26 -#endif
    5.27 -
    5.28 -
    5.29 -   //tradeoff amortizing master fixed overhead vs imbalance potential
    5.30 -   // when work-stealing, can make bigger, at risk of losing cache affinity
    5.31 -#define NUM_ANIM_SLOTS  1
    5.32 -
    5.33 -   //number of PRLangEnv structs created inside a process -- can't start more
    5.34 -   // than this many langlets inside a single process
    5.35 -#define NUM_IN_COLLECTION 64
    5.36 -
    5.37 -   //These are for backoff inside core-loop, which reduces lock contention
    5.38 -#define NUM_REPS_W_NO_WORK_BEFORE_YIELD      10
    5.39 -#define NUM_REPS_W_NO_WORK_BEFORE_BACKOFF    2
    5.40 -#define MASTERLOCK_RETRIES_BEFORE_YIELD      100
    5.41 -#define NUM_TRIES_BEFORE_DO_BACKOFF          10
    5.42 -#define GET_LOCK_BACKOFF_WEIGHT 100
    5.43 -   
    5.44 -   // stack size in virtual processors created
    5.45 -#define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */
    5.46 -
    5.47 -   // memory for PR_int__malloc
    5.48 -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x8000000 /* 128M */
    5.49 -
    5.50 -   //Frequency of TS counts -- have to do tests to verify
    5.51 -   //NOTE: turn off (in BIOS)  TURBO-BOOST and SPEED-STEP else won't be const
    5.52 -#define TSCOUNT_FREQ 3180000000
    5.53 -#define TSC_LOW_CYCLES 27
    5.54 -#define TSC_LOWHI_CYCLES 45
    5.55 -
    5.56 -#define CACHE_LINE_SZ  256
    5.57 -#define PAGE_SIZE     4096
    5.58 -
    5.59 -//To prevent false-sharing, aligns a variable to a cache-line boundary.
    5.60 -//No need to use for local vars because those are never shared between cores
    5.61 -#define __align_to_cacheline__ __attribute__ ((aligned(CACHE_LINE_SZ)))
    5.62 -
    5.63 -//aligns a pointer to cacheline. The memory area has to contain at least
    5.64 -//CACHE_LINE_SZ bytes more then needed
    5.65 -#define __align_address(ptr) ((void*)(((uintptr_t)(ptr))&((uintptr_t)(~0x0FF))))
    5.66 -
    5.67 -//===========================================================================
    5.68 -
    5.69 -#endif	/* _PR_DEFS_H */
    5.70 -
    5.71 +/*
    5.72 + *  Copyright 2012 OpenSourceResearchInstitute
    5.73 + *  Licensed under BSD
    5.74 + *
    5.75 + * Author: seanhalle@yahoo.com
    5.76 + * 
    5.77 + */
    5.78 +
    5.79 +#ifndef _PR_HW_SPEC_DEFS_H
    5.80 +#define	_PR_HW_SPEC_DEFS_H
    5.81 +#define _GNU_SOURCE
    5.82 +
    5.83 +
    5.84 +//=========================  Hardware related Constants =====================
    5.85 +   //This value is the number of hardware threads in the shared memory
    5.86 +   // machine
    5.87 +#define NUM_CORES        4
    5.88 +   //Now, check if sequential mode is on, and set num cores to 1, so that
    5.89 +   // lang plugin code doesn't have to check for sequential mode
    5.90 +#ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE
    5.91 +   #undef  NUM_CORES
    5.92 +   #define NUM_CORES 1
    5.93 +#endif
    5.94 +
    5.95 +
    5.96 +   //tradeoff amortizing master fixed overhead vs imbalance potential
    5.97 +   // when work-stealing, can make bigger, at risk of losing cache affinity
    5.98 +#define NUM_ANIM_SLOTS  1
    5.99 +
   5.100 +   //number of PRLangEnv structs created inside a process -- can't start more
   5.101 +   // than this many langlets inside a single process
   5.102 +#define NUM_IN_COLLECTION 64
   5.103 +
   5.104 +   //These are for backoff inside core-loop, which reduces lock contention
   5.105 +#define NUM_REPS_W_NO_WORK_BEFORE_YIELD      10
   5.106 +#define NUM_REPS_W_NO_WORK_BEFORE_BACKOFF    2
   5.107 +#define MASTERLOCK_RETRIES_BEFORE_YIELD      100
   5.108 +#define NUM_TRIES_BEFORE_DO_BACKOFF          10
   5.109 +#define GET_LOCK_BACKOFF_WEIGHT 100
   5.110 +   
   5.111 +   // stack size in virtual processors created
   5.112 +#define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */
   5.113 +
   5.114 +   // memory for PR_int__malloc
   5.115 +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x8000000 /* 128M */
   5.116 +
   5.117 +   //Frequency of TS counts -- have to do tests to verify
   5.118 +   //NOTE: turn off (in BIOS)  TURBO-BOOST and SPEED-STEP else won't be const
   5.119 +#define TSCOUNT_FREQ 3180000000
   5.120 +#define TSC_LOW_CYCLES 27
   5.121 +#define TSC_LOWHI_CYCLES 45
   5.122 +
   5.123 +#define CACHE_LINE_SZ  256
   5.124 +#define PAGE_SIZE     4096
   5.125 +
   5.126 +//To prevent false-sharing, aligns a variable to a cache-line boundary.
   5.127 +//No need to use for local vars because those are never shared between cores
   5.128 +#define __align_to_cacheline__ __attribute__ ((aligned(CACHE_LINE_SZ)))
   5.129 +
   5.130 +//aligns a pointer to cacheline. The memory area has to contain at least
   5.131 +//CACHE_LINE_SZ bytes more then needed
   5.132 +#define __align_address(ptr) ((void*)(((uintptr_t)(ptr))&((uintptr_t)(~0x0FF))))
   5.133 +
   5.134 +//===========================================================================
   5.135 +
   5.136 +#endif	/* _PR_DEFS_H */
   5.137 +
     6.1 --- a/PR.h	Sun Jul 21 13:41:59 2013 -0700
     6.2 +++ b/PR.h	Sun Jul 21 13:44:17 2013 -0700
     6.3 @@ -1,100 +1,100 @@
     6.4 -/*
     6.5 - *  Copyright 2012 OpenSourceResearchInstitute.org
     6.6 - *  Licensed under GNU General Public License version 2
     6.7 - *
     6.8 - * Author: seanhalle@yahoo.com
     6.9 - * 
    6.10 - */
    6.11 -
    6.12 -#ifndef _PR_H
    6.13 -#define	_PR_H
    6.14 -#define _GNU_SOURCE
    6.15 -
    6.16 -#include "DynArray/DynArray.h"
    6.17 -#include "Hash_impl/PrivateHash.h"
    6.18 -#include "Histogram/Histogram.h"
    6.19 -#include "Queue_impl/PrivateQueue.h"
    6.20 -
    6.21 -#include "PR_primitive_data_types.h"
    6.22 -#include "Services_Offered_by_PR/Memory_Handling/vmalloc.h"
    6.23 -
    6.24 -#include <pthread.h>
    6.25 -#include <sys/time.h>
    6.26 -
    6.27 -//=================  Defines: included from separate files  =================
    6.28 -//
    6.29 -// Note: ALL defines are in other files, none are in here
    6.30 -//
    6.31 -#include "Defines/PR_defs.h"
    6.32 -
    6.33 -
    6.34 -//================================ Typedefs =================================
    6.35 -//
    6.36 -#include "PR__structs.h"
    6.37 -
    6.38 -//============================ HW Dependent Fns ================================
    6.39 -
    6.40 -#include "HW_Dependent_Primitives/PR__HW_measurement.h"
    6.41 -#include "HW_Dependent_Primitives/PR__primitives.h"
    6.42 -
    6.43 -
    6.44 -//=============================  Global Vars ================================
    6.45 -
    6.46 -volatile TopEnv      *_PRTopEnv __align_to_cacheline__;
    6.47 -
    6.48 -   //these are global, but only used for startup and shutdown
    6.49 -pthread_t       coreCtlrThdHandles[ NUM_CORES ]; //pthread's virt-procr state
    6.50 -ThdParams      *coreCtlrThdParams [ NUM_CORES ];
    6.51 -
    6.52 -pthread_mutex_t suspendLock;
    6.53 -pthread_cond_t  suspendCond;
    6.54 -
    6.55 -//=========================  Function Prototypes  ===========================
    6.56 -/* MEANING OF   WL  PI  SS  int PROS
    6.57 - * These indicate which places the function is safe to use.  They stand for:
    6.58 - * 
    6.59 - * WL   Wrapper Library -- wrapper lib code should only use these
    6.60 - * PI   Plugin          -- plugin code should only use these
    6.61 - * SS   Startup and Shutdown -- designates these relate to startup & shutdown
    6.62 - * int32internal to PR -- should not be used in wrapper lib or plugin
    6.63 - * PROS means "OS functions for applications to use"
    6.64 - * 
    6.65 - * PR_int__ functions touch internal PR data structs and are only safe
    6.66 - *  to be used inside the master lock.  However, occasionally, they appear
    6.67 - * in wrapper-lib or plugin code.  In those cases, very careful analysis
    6.68 - * has been done to be sure no concurrency issues could arise.
    6.69 - * 
    6.70 - * PR_WL__ functions are all safe for use outside the master lock.
    6.71 - * 
    6.72 - * PR_OS are only safe for applications to use -- they're like a second
    6.73 - * language mixed in -- but they can't be used inside plugin code, and
    6.74 - * aren't meant for use in wrapper libraries, because they are themselves
    6.75 - * wrapper-library calls!
    6.76 - */
    6.77 -
    6.78 -inline bool32 masterFunction( AnimSlot  *slot );
    6.79 -
    6.80 -//============== include internally used fn prototypes ================
    6.81 -
    6.82 -//include fn prototypes used internally in the proto-runtime implementation
    6.83 -#include "PR__int.h"
    6.84 -
    6.85 -//include fn prototypes used by plugin
    6.86 -#include "PR__PI.h"
    6.87 -
    6.88 -//include fn prototype used by wrapper library
    6.89 -#include "PR__WL.h"
    6.90 -
    6.91 -//=================================
    6.92 -#define implement_me() printf("Unimpl Fn: \n%s \n%s : %d\n", __FILE__, __FUNCTION__, __LINE__)
    6.93 -//#define fix_me printf("Fix me at: \n%s \n%s : %s\n", __FILE__, __FUNCTION__, __LINE__)
    6.94 -
    6.95 -
    6.96 -//========================= Services =======================
    6.97 -#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h"
    6.98 -#include "Services_Offered_by_PR/Services_Language/PRServ.h"
    6.99 -//#include  "Services_Offered_by_PR/Services_Language/libPRServ.h"
   6.100 -
   6.101 -//================================================
   6.102 -#endif	/* _PR_H */
   6.103 -
   6.104 +/*
   6.105 + *  Copyright 2012 OpenSourceResearchInstitute.org
   6.106 + *  Licensed under GNU General Public License version 2
   6.107 + *
   6.108 + * Author: seanhalle@yahoo.com
   6.109 + * 
   6.110 + */
   6.111 +
   6.112 +#ifndef _PR_H
   6.113 +#define	_PR_H
   6.114 +#define _GNU_SOURCE
   6.115 +
   6.116 +#include "DynArray/DynArray.h"
   6.117 +#include "Hash_impl/PrivateHash.h"
   6.118 +#include "Histogram/Histogram.h"
   6.119 +#include "Queue_impl/PrivateQueue.h"
   6.120 +
   6.121 +#include "PR_primitive_data_types.h"
   6.122 +#include "Services_Offered_by_PR/Memory_Handling/vmalloc.h"
   6.123 +
   6.124 +#include <pthread.h>
   6.125 +#include <sys/time.h>
   6.126 +
   6.127 +//=================  Defines: included from separate files  =================
   6.128 +//
   6.129 +// Note: ALL defines are in other files, none are in here
   6.130 +//
   6.131 +#include "Defines/PR_defs.h"
   6.132 +
   6.133 +
   6.134 +//================================ Typedefs =================================
   6.135 +//
   6.136 +#include "PR__structs.h"
   6.137 +
   6.138 +//============================ HW Dependent Fns ================================
   6.139 +
   6.140 +#include "HW_Dependent_Primitives/PR__HW_measurement.h"
   6.141 +#include "HW_Dependent_Primitives/PR__primitives.h"
   6.142 +
   6.143 +
   6.144 +//=============================  Global Vars ================================
   6.145 +
   6.146 +volatile TopEnv      *_PRTopEnv __align_to_cacheline__;
   6.147 +
   6.148 +   //these are global, but only used for startup and shutdown
   6.149 +pthread_t       coreCtlrThdHandles[ NUM_CORES ]; //pthread's virt-procr state
   6.150 +ThdParams      *coreCtlrThdParams [ NUM_CORES ];
   6.151 +
   6.152 +pthread_mutex_t suspendLock;
   6.153 +pthread_cond_t  suspendCond;
   6.154 +
   6.155 +//=========================  Function Prototypes  ===========================
   6.156 +/* MEANING OF   WL  PI  SS  int PROS
   6.157 + * These indicate which places the function is safe to use.  They stand for:
   6.158 + * 
   6.159 + * WL   Wrapper Library -- wrapper lib code should only use these
   6.160 + * PI   Plugin          -- plugin code should only use these
   6.161 + * SS   Startup and Shutdown -- designates these relate to startup & shutdown
   6.162 + * int32internal to PR -- should not be used in wrapper lib or plugin
   6.163 + * PROS means "OS functions for applications to use"
   6.164 + * 
   6.165 + * PR_int__ functions touch internal PR data structs and are only safe
   6.166 + *  to be used inside the master lock.  However, occasionally, they appear
   6.167 + * in wrapper-lib or plugin code.  In those cases, very careful analysis
   6.168 + * has been done to be sure no concurrency issues could arise.
   6.169 + * 
   6.170 + * PR_WL__ functions are all safe for use outside the master lock.
   6.171 + * 
   6.172 + * PR_OS are only safe for applications to use -- they're like a second
   6.173 + * language mixed in -- but they can't be used inside plugin code, and
   6.174 + * aren't meant for use in wrapper libraries, because they are themselves
   6.175 + * wrapper-library calls!
   6.176 + */
   6.177 +
   6.178 +inline bool32 masterFunction( AnimSlot  *slot );
   6.179 +
   6.180 +//============== include internally used fn prototypes ================
   6.181 +
   6.182 +//include fn prototypes used internally in the proto-runtime implementation
   6.183 +#include "PR__int.h"
   6.184 +
   6.185 +//include fn prototypes used by plugin
   6.186 +#include "PR__PI.h"
   6.187 +
   6.188 +//include fn prototype used by wrapper library
   6.189 +#include "PR__WL.h"
   6.190 +
   6.191 +//=================================
   6.192 +#define implement_me() printf("Unimpl Fn: \n%s \n%s : %d\n", __FILE__, __FUNCTION__, __LINE__)
   6.193 +//#define fix_me printf("Fix me at: \n%s \n%s : %s\n", __FILE__, __FUNCTION__, __LINE__)
   6.194 +
   6.195 +
   6.196 +//========================= Services =======================
   6.197 +#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h"
   6.198 +#include "Services_Offered_by_PR/Services_Language/PRServ.h"
   6.199 +//#include  "Services_Offered_by_PR/Services_Language/libPRServ.h"
   6.200 +
   6.201 +//================================================
   6.202 +#endif	/* _PR_H */
   6.203 +
     7.1 --- a/PR__PI.h	Sun Jul 21 13:41:59 2013 -0700
     7.2 +++ b/PR__PI.h	Sun Jul 21 13:44:17 2013 -0700
     7.3 @@ -1,195 +1,195 @@
     7.4 -/*
     7.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
     7.6 - *  Licensed under GNU General Public License version 2
     7.7 - *
     7.8 - * Author: seanhalle@yahoo.com
     7.9 - * 
    7.10 - */
    7.11 -
    7.12 -#ifndef _PR__PI_H
    7.13 -#define	_PR__PI_H
    7.14 -#define _GNU_SOURCE
    7.15 -
    7.16 -
    7.17 -#include "PR_primitive_data_types.h"
    7.18 -
    7.19 -//=========================  Function Prototypes  ===========================
    7.20 -/* MEANING OF   WL  PI  SS  int PROS
    7.21 - * These indicate which places the function is safe to use.  They stand for:
    7.22 - * 
    7.23 - * WL   Wrapper Library -- wrapper lib code should only use these
    7.24 - * PI   Plugin          -- plugin code should only use these
    7.25 - * SS   Startup and Shutdown -- designates these relate to startup & shutdown
    7.26 - * int32internal to PR -- should not be used in wrapper lib or plugin
    7.27 - * PROS means "OS functions for applications to use"
    7.28 - * 
    7.29 - * PR_int__ functions touch internal PR data structs and are only safe
    7.30 - *  to be used inside the master lock.  However, occasionally, they appear
    7.31 - * in wrapper-lib or plugin code.  In those cases, very careful analysis
    7.32 - * has been done to be sure no concurrency issues could arise.
    7.33 - * 
    7.34 - * PR_WL__ functions are all safe for use outside the master lock.
    7.35 - * 
    7.36 - * PROS are only safe for applications to use -- they're like a second
    7.37 - * language mixed in -- but they can't be used inside plugin code, and
    7.38 - * aren't meant for use in wrapper libraries, because they are themselves
    7.39 - * wrapper-library calls!
    7.40 - */
    7.41 -
    7.42 -#define \
    7.43 -PR_PI__create_slaveVP   PR_int__create_slaveVP_helper
    7.44 -
    7.45 -//==============
    7.46 -//=== Lang Data
    7.47 -//=
    7.48 -#define \
    7.49 -PR_PI__give_lang_data_from_slave   PR_int__give_lang_data_from_slave
    7.50 -#define \
    7.51 -PR_SS__give_lang_data_from_slave   PR_int__give_lang_data_from_slave
    7.52 -
    7.53 -
    7.54 -//============
    7.55 -//=== Lang Env
    7.56 -//=
    7.57 -#define \
    7.58 -PR_PI__give_proto_lang_env_for_slave   PR_int__give_proto_lang_env_for_slave
    7.59 -#define \
    7.60 -PR_PI__give_lang_env_for_slave   PR_int__give_lang_env_for_slave
    7.61 -#define \
    7.62 -PR_PI__give_lang_env_from_process   PR_int__give_lang_env_from_process
    7.63 -
    7.64 -
    7.65 -//=========
    7.66 -//=== Meta Task
    7.67 -//=
    7.68 -#define \
    7.69 -PR_PI__give_lang_meta_task_from_slave    PR_int__give_lang_meta_task_from_slave
    7.70 -#define \
    7.71 -PR_PI__give_prolog_of_lang_meta_task   PR_int__give_prolog_of_lang_meta_task
    7.72 -
    7.73 -SlaveVP *
    7.74 -PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask );
    7.75 -
    7.76 -#define \
    7.77 -PR_PI__free_lang_meta_task_and_remove_from_slave    PR_int__free_lang_meta_task_and_remove_from_coll
    7.78 -
    7.79 -#define \
    7.80 -PR_PI__free_lang_meta_task    PR_int__free_lang_meta_task
    7.81 -
    7.82 -void
    7.83 -PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask );
    7.84 -void
    7.85 -PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask );
    7.86 -
    7.87 -//==========
    7.88 -//===
    7.89 -//=
    7.90 -#define \
    7.91 -PR_PI__give_ID_from_lang_meta_task   PR__give_ID_from_lang_meta_task
    7.92 -#define \
    7.93 -PR_PI__give_ID_from_slave   PR__give_ID_from_slave
    7.94 -
    7.95 -//=============
    7.96 -//===
    7.97 -//=
    7.98 -#define \
    7.99 -PR_PI__put_slave_into_slot   PR_int__put_slave_into_slot
   7.100 -#define \
   7.101 -PR_PI__put_task_into_slot    PR_int__put_task_into_slot
   7.102 -
   7.103 -PRReqst *
   7.104 -PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq );
   7.105 -
   7.106 -#define \
   7.107 -PR_PI__take_lang_reqst_from( req )   req->langReq
   7.108 -
   7.109 -void
   7.110 -PR_PI__resume_slave_in_PRServ( SlaveVP *slave );
   7.111 -
   7.112 -#define \
   7.113 -PR_PI__malloc   PR_int__malloc
   7.114 -#define \
   7.115 -PR_PI__malloc_aligned   PR_int__malloc_aligned
   7.116 -#define \
   7.117 -PR_PI__free  PR_int__free
   7.118 -
   7.119 -
   7.120 -#define \
   7.121 -PR_PI__throw_exception   PR_int__throw_exception
   7.122 -
   7.123 -//===============  Startup and Shutdown  ================
   7.124 -//===
   7.125 -//=
   7.126 -void
   7.127 -PR_SS__create_topEnv();
   7.128 -
   7.129 -AnimSlot **
   7.130 -PR_SS__create_anim_slots( int32 coreSlotsAreOn );
   7.131 -
   7.132 -void
   7.133 -PR_SS__create_the_coreCtlr_OS_threads();
   7.134 -
   7.135 -//===================
   7.136 -void *
   7.137 -PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum );
   7.138 -
   7.139 -void
   7.140 -PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum );
   7.141 -void
   7.142 -PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP,
   7.143 -                                  int32 magicNum );
   7.144 -void
   7.145 -PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 
   7.146 -                                              SlaveVP *seedVP, int32 magicNum );
   7.147 -void
   7.148 -PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, 
   7.149 -                                              SlaveVP *seedVP, int32 magicNum );
   7.150 -void
   7.151 -PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP,
   7.152 -                                                               int32 magicNum );
   7.153 -void
   7.154 -PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP,
   7.155 -                                                               int32 magicNum );
   7.156 -//===================
   7.157 -
   7.158 -void
   7.159 -PR_SS__end_process_normally( PRProcess *process );
   7.160 -
   7.161 -void
   7.162 -PR_SS__shutdown_OS_threads();
   7.163 -
   7.164 -SlaveVP* 
   7.165 -PR_SS__create_shutdown_slave();
   7.166 -
   7.167 -void
   7.168 -PR_SS__cleanup_at_end_of_shutdown();
   7.169 - 
   7.170 -void
   7.171 -PR_SS__print_out_measurements();
   7.172 -
   7.173 -void
   7.174 -PR_SS__wait_for_PR_to_shutdown();
   7.175 -
   7.176 -
   7.177 -//=============================
   7.178 -//===
   7.179 -//=
   7.180 -
   7.181 -#define \
   7.182 -PR_SS__give_proto_lang_env_for_slave   PR_int__give_proto_lang_env_for_slave
   7.183 -
   7.184 -#define \
   7.185 -PR_SS__give_lang_meta_task_from_slave   PR_int__give_lang_meta_task_from_slave
   7.186 -#define \
   7.187 -PR_SS__give_lang_env_for_slave   PR_int__give_lang_env_for_slave
   7.188 -#define \
   7.189 -PR_SS__give_lang_env_from_process   PR_int__give_lang_env_from_process
   7.190 -
   7.191 -#define \
   7.192 -PR_SS__malloc  PR_WL__malloc /*SS happens outside the Master*/
   7.193 -#define \
   7.194 -PR_SS__free    PR_WL__free
   7.195 -
   7.196 -//================================================
   7.197 -#endif	/* _PR__PI_H */
   7.198 -
   7.199 +/*
   7.200 + *  Copyright 2009 OpenSourceResearchInstitute.org
   7.201 + *  Licensed under GNU General Public License version 2
   7.202 + *
   7.203 + * Author: seanhalle@yahoo.com
   7.204 + * 
   7.205 + */
   7.206 +
   7.207 +#ifndef _PR__PI_H
   7.208 +#define	_PR__PI_H
   7.209 +#define _GNU_SOURCE
   7.210 +
   7.211 +
   7.212 +#include "PR_primitive_data_types.h"
   7.213 +
   7.214 +//=========================  Function Prototypes  ===========================
   7.215 +/* MEANING OF   WL  PI  SS  int PROS
   7.216 + * These indicate which places the function is safe to use.  They stand for:
   7.217 + * 
   7.218 + * WL   Wrapper Library -- wrapper lib code should only use these
   7.219 + * PI   Plugin          -- plugin code should only use these
   7.220 + * SS   Startup and Shutdown -- designates these relate to startup & shutdown
   7.221 + * int32internal to PR -- should not be used in wrapper lib or plugin
   7.222 + * PROS means "OS functions for applications to use"
   7.223 + * 
   7.224 + * PR_int__ functions touch internal PR data structs and are only safe
   7.225 + *  to be used inside the master lock.  However, occasionally, they appear
   7.226 + * in wrapper-lib or plugin code.  In those cases, very careful analysis
   7.227 + * has been done to be sure no concurrency issues could arise.
   7.228 + * 
   7.229 + * PR_WL__ functions are all safe for use outside the master lock.
   7.230 + * 
   7.231 + * PROS are only safe for applications to use -- they're like a second
   7.232 + * language mixed in -- but they can't be used inside plugin code, and
   7.233 + * aren't meant for use in wrapper libraries, because they are themselves
   7.234 + * wrapper-library calls!
   7.235 + */
   7.236 +
   7.237 +#define \
   7.238 +PR_PI__create_slaveVP   PR_int__create_slaveVP_helper
   7.239 +
   7.240 +//==============
   7.241 +//=== Lang Data
   7.242 +//=
   7.243 +#define \
   7.244 +PR_PI__give_lang_data_from_slave   PR_int__give_lang_data_from_slave
   7.245 +#define \
   7.246 +PR_SS__give_lang_data_from_slave   PR_int__give_lang_data_from_slave
   7.247 +
   7.248 +
   7.249 +//============
   7.250 +//=== Lang Env
   7.251 +//=
   7.252 +#define \
   7.253 +PR_PI__give_proto_lang_env_for_slave   PR_int__give_proto_lang_env_for_slave
   7.254 +#define \
   7.255 +PR_PI__give_lang_env_for_slave   PR_int__give_lang_env_for_slave
   7.256 +#define \
   7.257 +PR_PI__give_lang_env_from_process   PR_int__give_lang_env_from_process
   7.258 +
   7.259 +
   7.260 +//=========
   7.261 +//=== Meta Task
   7.262 +//=
   7.263 +#define \
   7.264 +PR_PI__give_lang_meta_task_from_slave    PR_int__give_lang_meta_task_from_slave
   7.265 +#define \
   7.266 +PR_PI__give_prolog_of_lang_meta_task   PR_int__give_prolog_of_lang_meta_task
   7.267 +
   7.268 +SlaveVP *
   7.269 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask );
   7.270 +
   7.271 +#define \
   7.272 +PR_PI__free_lang_meta_task_and_remove_from_slave    PR_int__free_lang_meta_task_and_remove_from_coll
   7.273 +
   7.274 +#define \
   7.275 +PR_PI__free_lang_meta_task    PR_int__free_lang_meta_task
   7.276 +
   7.277 +void
   7.278 +PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask );
   7.279 +void
   7.280 +PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask );
   7.281 +
   7.282 +//==========
   7.283 +//===
   7.284 +//=
   7.285 +#define \
   7.286 +PR_PI__give_ID_from_lang_meta_task   PR__give_ID_from_lang_meta_task
   7.287 +#define \
   7.288 +PR_PI__give_ID_from_slave   PR__give_ID_from_slave
   7.289 +
   7.290 +//=============
   7.291 +//===
   7.292 +//=
   7.293 +#define \
   7.294 +PR_PI__put_slave_into_slot   PR_int__put_slave_into_slot
   7.295 +#define \
   7.296 +PR_PI__put_task_into_slot    PR_int__put_task_into_slot
   7.297 +
   7.298 +PRReqst *
   7.299 +PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq );
   7.300 +
   7.301 +#define \
   7.302 +PR_PI__take_lang_reqst_from( req )   req->langReq
   7.303 +
   7.304 +void
   7.305 +PR_PI__resume_slave_in_PRServ( SlaveVP *slave );
   7.306 +
   7.307 +#define \
   7.308 +PR_PI__malloc   PR_int__malloc
   7.309 +#define \
   7.310 +PR_PI__malloc_aligned   PR_int__malloc_aligned
   7.311 +#define \
   7.312 +PR_PI__free  PR_int__free
   7.313 +
   7.314 +
   7.315 +#define \
   7.316 +PR_PI__throw_exception   PR_int__throw_exception
   7.317 +
   7.318 +//===============  Startup and Shutdown  ================
   7.319 +//===
   7.320 +//=
   7.321 +void
   7.322 +PR_SS__create_topEnv();
   7.323 +
   7.324 +AnimSlot **
   7.325 +PR_SS__create_anim_slots( int32 coreSlotsAreOn );
   7.326 +
   7.327 +void
   7.328 +PR_SS__create_the_coreCtlr_OS_threads();
   7.329 +
   7.330 +//===================
   7.331 +void *
   7.332 +PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum );
   7.333 +
   7.334 +void
   7.335 +PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum );
   7.336 +void
   7.337 +PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP,
   7.338 +                                  int32 magicNum );
   7.339 +void
   7.340 +PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 
   7.341 +                                              SlaveVP *seedVP, int32 magicNum );
   7.342 +void
   7.343 +PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, 
   7.344 +                                              SlaveVP *seedVP, int32 magicNum );
   7.345 +void
   7.346 +PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP,
   7.347 +                                                               int32 magicNum );
   7.348 +void
   7.349 +PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP,
   7.350 +                                                               int32 magicNum );
   7.351 +//===================
   7.352 +
   7.353 +void
   7.354 +PR_SS__end_process_normally( PRProcess *process );
   7.355 +
   7.356 +void
   7.357 +PR_SS__shutdown_OS_threads();
   7.358 +
   7.359 +SlaveVP* 
   7.360 +PR_SS__create_shutdown_slave();
   7.361 +
   7.362 +void
   7.363 +PR_SS__cleanup_at_end_of_shutdown();
   7.364 + 
   7.365 +void
   7.366 +PR_SS__print_out_measurements();
   7.367 +
   7.368 +void
   7.369 +PR_SS__wait_for_PR_to_shutdown();
   7.370 +
   7.371 +
   7.372 +//=============================
   7.373 +//===
   7.374 +//=
   7.375 +
   7.376 +#define \
   7.377 +PR_SS__give_proto_lang_env_for_slave   PR_int__give_proto_lang_env_for_slave
   7.378 +
   7.379 +#define \
   7.380 +PR_SS__give_lang_meta_task_from_slave   PR_int__give_lang_meta_task_from_slave
   7.381 +#define \
   7.382 +PR_SS__give_lang_env_for_slave   PR_int__give_lang_env_for_slave
   7.383 +#define \
   7.384 +PR_SS__give_lang_env_from_process   PR_int__give_lang_env_from_process
   7.385 +
   7.386 +#define \
   7.387 +PR_SS__malloc  PR_WL__malloc /*SS happens outside the Master*/
   7.388 +#define \
   7.389 +PR_SS__free    PR_WL__free
   7.390 +
   7.391 +//================================================
   7.392 +#endif	/* _PR__PI_H */
   7.393 +
     8.1 --- a/PR__WL.h	Sun Jul 21 13:41:59 2013 -0700
     8.2 +++ b/PR__WL.h	Sun Jul 21 13:44:17 2013 -0700
     8.3 @@ -1,154 +1,154 @@
     8.4 -/*
     8.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
     8.6 - *  Licensed under GNU General Public License version 2
     8.7 - *
     8.8 - * Author: seanhalle@yahoo.com
     8.9 - * 
    8.10 - */
    8.11 -
    8.12 - 
    8.13 - 
    8.14 -/* This header defines the PR functions available to the language's
    8.15 - *  wrapper library.
    8.16 - */
    8.17 - 
    8.18 -#ifndef _PR__WL_H
    8.19 -#define	_PR__WL_H
    8.20 -#define _GNU_SOURCE
    8.21 -
    8.22 -#include "PR__common/PR__primitive_data_types.h"
    8.23 -#include "PR__common/PR__common_structs.h"
    8.24 -//=========================  Function Prototypes  ===========================
    8.25 -/* MEANING OF   WL  PI  SS  int PROS
    8.26 - * These indicate which places the function is safe to use.  They stand for:
    8.27 - * 
    8.28 - * WL   Wrapper Library -- wrapper lib code should only use these
    8.29 - * PI   Plugin          -- plugin code should only use these
    8.30 - * SS   Startup and Shutdown -- designates these relate to startup & shutdown
    8.31 - * int32internal to PR -- should not be used in wrapper lib or plugin
    8.32 - * PROS means "OS functions for applications to use"
    8.33 - * 
    8.34 - * PR_int__ functions touch internal PR data structs and are only safe
    8.35 - *  to be used inside the master lock.  However, occasionally, they appear
    8.36 - * in wrapper-lib or plugin code.  In those cases, very careful analysis
    8.37 - * has been done to be sure no concurrency issues could arise.
    8.38 - * 
    8.39 - * PR_WL__ functions are all safe for use outside the master lock.
    8.40 - * 
    8.41 - * PROS are only safe for applications to use -- they're like a second
    8.42 - * language mixed in -- but they can't be used inside plugin code, and
    8.43 - * aren't meant for use in wrapper libraries, because they are themselves
    8.44 - * wrapper-library calls!
    8.45 - */
    8.46 -
    8.47 -//============== Top level Fns called from main   ===============
    8.48 -void
    8.49 -PR__start();
    8.50 -
    8.51 -PRProcess *
    8.52 -PR__create_process( BirthFnPtr seed_Fn, void *seedData );
    8.53 -
    8.54 -void
    8.55 -PR__end_seedVP( SlaveVP *seedSlv );
    8.56 -
    8.57 -void
    8.58 -PR__end_process_from_inside( SlaveVP *seedSlv );
    8.59 -
    8.60 -void *
    8.61 -PR__give_results_from_process_when_ready( PRProcess *process );
    8.62 -
    8.63 -void
    8.64 -PR__wait_for_process_to_end( PRProcess *process );
    8.65 -
    8.66 -void
    8.67 -PR__wait_for_all_activity_to_end();
    8.68 -
    8.69 -void
    8.70 -PR__shutdown();
    8.71 -
    8.72 -#define \
    8.73 -PR__create_taskID_of_size   PR_WL__create_taskID_of_size
    8.74 -
    8.75 -inline
    8.76 -int32 *
    8.77 -PR__give_ID_from_slave( SlaveVP *animSlv, int32 magicNumber );
    8.78 -
    8.79 -inline
    8.80 -int32 *
    8.81 -PR__give_ID_from_lang_meta_task( void *_task );
    8.82 -
    8.83 -#define \
    8.84 -PR__malloc  PR_WL__malloc
    8.85 -
    8.86 -#define \
    8.87 -PR__free    PR_WL__free
    8.88 -
    8.89 -
    8.90 -
    8.91 -//============== include internally used fn prototypes ================
    8.92 -#include "PR__int.h"
    8.93 -
    8.94 -
    8.95 -#define \
    8.96 -PR_WL__create_slaveVP   PR_int__create_slaveVP_helper
    8.97 -
    8.98 -#define \
    8.99 -PR_WL__give_lang_meta_task_from_slave   PR_int__give_lang_meta_task_from_slave
   8.100 -
   8.101 -#define \
   8.102 -PR_WL__give_prolog_of_lang_meta_task   PR_int__give_prolog_of_lang_meta_task
   8.103 -
   8.104 -//==============  Request Related  ===============
   8.105 -
   8.106 -void
   8.107 -PR_WL__suspend_slaveVP_and_send_req( SlaveVP *callingSlv );
   8.108 -
   8.109 -inline void
   8.110 -PR_WL__add_lang_request_in_mallocd_PRReqst( void *langReqData, 
   8.111 -                                                          SlaveVP *callingSlv );
   8.112 -
   8.113 -inline void
   8.114 -PR_WL__send_lang_request( void *langReq, RequestHandler handler, 
   8.115 -                                          SlaveVP *callingSlv, int32 magicNum );
   8.116 -
   8.117 -void
   8.118 -PR_WL__send_create_slaveVP_req( void *langReq, int32 *ID, CreateHandler handler, 
   8.119 -                                SlaveVP *reqstingSlv, int32 magicNum );
   8.120 -
   8.121 -void inline
   8.122 -PR_WL__send_end_slave_req( void *langReq, RequestHandler handler, 
   8.123 -                                       SlaveVP *slvToDissipate, int32 magicNum );
   8.124 -
   8.125 -inline void
   8.126 -PR_WL__send_service_request( void *langReqData, SlaveVP *callingSlv );
   8.127 -
   8.128 -inline void
   8.129 -PR_WL__send_lang_shutdown_request( SlaveVP *callingSlv, int32 magicNum );
   8.130 -
   8.131 -inline 
   8.132 -int32 *
   8.133 -PR_WL__create_taskID_of_size( int32 numInts );
   8.134 -
   8.135 -//======================== MEASUREMENT ======================
   8.136 -uint64
   8.137 -PR_WL__give_num_plugin_cycles();
   8.138 -uint32
   8.139 -PR_WL__give_num_plugin_animations();
   8.140 -
   8.141 -
   8.142 -//========================= Utilities =======================
   8.143 -void
   8.144 -PR_WL__throw_exception( char *msgStr, SlaveVP *reqstSlv,  PRExcp *excpData );
   8.145 -#define PR_App__throw_exception PR_WL__throw_exception
   8.146 -
   8.147 -
   8.148 -//=======================================================================
   8.149 -
   8.150 -//========================= Services =======================
   8.151 -//#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h"
   8.152 -//#include  "Services_Offered_by_PR/Services_Language/PRServ.h"
   8.153 -//#include  "Services_Offered_by_PR/Services_Language/libPRServ.h"
   8.154 -
   8.155 -//================================================
   8.156 -#endif	/* _PR_H */
   8.157 -
   8.158 +/*
   8.159 + *  Copyright 2009 OpenSourceResearchInstitute.org
   8.160 + *  Licensed under GNU General Public License version 2
   8.161 + *
   8.162 + * Author: seanhalle@yahoo.com
   8.163 + * 
   8.164 + */
   8.165 +
   8.166 + 
   8.167 + 
   8.168 +/* This header defines the PR functions available to the language's
   8.169 + *  wrapper library.
   8.170 + */
   8.171 + 
   8.172 +#ifndef _PR__WL_H
   8.173 +#define	_PR__WL_H
   8.174 +#define _GNU_SOURCE
   8.175 +
   8.176 +#include "PR__common/PR__primitive_data_types.h"
   8.177 +#include "PR__common/PR__common_structs.h"
   8.178 +//=========================  Function Prototypes  ===========================
   8.179 +/* MEANING OF   WL  PI  SS  int PROS
   8.180 + * These indicate which places the function is safe to use.  They stand for:
   8.181 + * 
   8.182 + * WL   Wrapper Library -- wrapper lib code should only use these
   8.183 + * PI   Plugin          -- plugin code should only use these
   8.184 + * SS   Startup and Shutdown -- designates these relate to startup & shutdown
   8.185 + * int32internal to PR -- should not be used in wrapper lib or plugin
   8.186 + * PROS means "OS functions for applications to use"
   8.187 + * 
   8.188 + * PR_int__ functions touch internal PR data structs and are only safe
   8.189 + *  to be used inside the master lock.  However, occasionally, they appear
   8.190 + * in wrapper-lib or plugin code.  In those cases, very careful analysis
   8.191 + * has been done to be sure no concurrency issues could arise.
   8.192 + * 
   8.193 + * PR_WL__ functions are all safe for use outside the master lock.
   8.194 + * 
   8.195 + * PROS are only safe for applications to use -- they're like a second
   8.196 + * language mixed in -- but they can't be used inside plugin code, and
   8.197 + * aren't meant for use in wrapper libraries, because they are themselves
   8.198 + * wrapper-library calls!
   8.199 + */
   8.200 +
   8.201 +//============== Top level Fns called from main   ===============
   8.202 +void
   8.203 +PR__start();
   8.204 +
   8.205 +PRProcess *
   8.206 +PR__create_process( BirthFnPtr seed_Fn, void *seedData );
   8.207 +
   8.208 +void
   8.209 +PR__end_seedVP( SlaveVP *seedSlv );
   8.210 +
   8.211 +void
   8.212 +PR__end_process_from_inside( SlaveVP *seedSlv );
   8.213 +
   8.214 +void *
   8.215 +PR__give_results_from_process_when_ready( PRProcess *process );
   8.216 +
   8.217 +void
   8.218 +PR__wait_for_process_to_end( PRProcess *process );
   8.219 +
   8.220 +void
   8.221 +PR__wait_for_all_activity_to_end();
   8.222 +
   8.223 +void
   8.224 +PR__shutdown();
   8.225 +
   8.226 +#define \
   8.227 +PR__create_taskID_of_size   PR_WL__create_taskID_of_size
   8.228 +
   8.229 +inline
   8.230 +int32 *
   8.231 +PR__give_ID_from_slave( SlaveVP *animSlv, int32 magicNumber );
   8.232 +
   8.233 +inline
   8.234 +int32 *
   8.235 +PR__give_ID_from_lang_meta_task( void *_task );
   8.236 +
   8.237 +#define \
   8.238 +PR__malloc  PR_WL__malloc
   8.239 +
   8.240 +#define \
   8.241 +PR__free    PR_WL__free
   8.242 +
   8.243 +
   8.244 +
   8.245 +//============== include internally used fn prototypes ================
   8.246 +#include "PR__int.h"
   8.247 +
   8.248 +
   8.249 +#define \
   8.250 +PR_WL__create_slaveVP   PR_int__create_slaveVP_helper
   8.251 +
   8.252 +#define \
   8.253 +PR_WL__give_lang_meta_task_from_slave   PR_int__give_lang_meta_task_from_slave
   8.254 +
   8.255 +#define \
   8.256 +PR_WL__give_prolog_of_lang_meta_task   PR_int__give_prolog_of_lang_meta_task
   8.257 +
   8.258 +//==============  Request Related  ===============
   8.259 +
   8.260 +void
   8.261 +PR_WL__suspend_slaveVP_and_send_req( SlaveVP *callingSlv );
   8.262 +
   8.263 +inline void
   8.264 +PR_WL__add_lang_request_in_mallocd_PRReqst( void *langReqData, 
   8.265 +                                                          SlaveVP *callingSlv );
   8.266 +
   8.267 +inline void
   8.268 +PR_WL__send_lang_request( void *langReq, RequestHandler handler, 
   8.269 +                                          SlaveVP *callingSlv, int32 magicNum );
   8.270 +
   8.271 +void
   8.272 +PR_WL__send_create_slaveVP_req( void *langReq, int32 *ID, CreateHandler handler, 
   8.273 +                                SlaveVP *reqstingSlv, int32 magicNum );
   8.274 +
   8.275 +void inline
   8.276 +PR_WL__send_end_slave_req( void *langReq, RequestHandler handler, 
   8.277 +                                       SlaveVP *slvToDissipate, int32 magicNum );
   8.278 +
   8.279 +inline void
   8.280 +PR_WL__send_service_request( void *langReqData, SlaveVP *callingSlv );
   8.281 +
   8.282 +inline void
   8.283 +PR_WL__send_lang_shutdown_request( SlaveVP *callingSlv, int32 magicNum );
   8.284 +
   8.285 +inline 
   8.286 +int32 *
   8.287 +PR_WL__create_taskID_of_size( int32 numInts );
   8.288 +
   8.289 +//======================== MEASUREMENT ======================
   8.290 +uint64
   8.291 +PR_WL__give_num_plugin_cycles();
   8.292 +uint32
   8.293 +PR_WL__give_num_plugin_animations();
   8.294 +
   8.295 +
   8.296 +//========================= Utilities =======================
   8.297 +void
   8.298 +PR_WL__throw_exception( char *msgStr, SlaveVP *reqstSlv,  PRExcp *excpData );
   8.299 +#define PR_App__throw_exception PR_WL__throw_exception
   8.300 +
   8.301 +
   8.302 +//=======================================================================
   8.303 +
   8.304 +//========================= Services =======================
   8.305 +//#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h"
   8.306 +//#include  "Services_Offered_by_PR/Services_Language/PRServ.h"
   8.307 +//#include  "Services_Offered_by_PR/Services_Language/libPRServ.h"
   8.308 +
   8.309 +//================================================
   8.310 +#endif	/* _PR_H */
   8.311 +
     9.1 --- a/PR__common.h	Sun Jul 21 13:41:59 2013 -0700
     9.2 +++ b/PR__common.h	Sun Jul 21 13:44:17 2013 -0700
     9.3 @@ -1,77 +1,77 @@
     9.4 -/*
     9.5 - *  Copyright 2012 OpenSourceResearchInstitute.org
     9.6 - *  Licensed under GNU General Public License version 2
     9.7 - *
     9.8 - * Author: seanhalle@yahoo.com
     9.9 - * 
    9.10 - */
    9.11 -
    9.12 -#ifndef _PR_H
    9.13 -#define	_PR_H
    9.14 -#define _GNU_SOURCE
    9.15 -
    9.16 -//#include "DynArray/DynArray.h"
    9.17 -//#include "Hash_impl/PrivateHash.h"
    9.18 -//#include "Histogram/Histogram.h"
    9.19 -//#include "Queue_impl/PrivateQueue.h"
    9.20 -
    9.21 -#include "PR__primitive_data_types.h"
    9.22 -#include "PR__common_structs.h"
    9.23 -//#include "Services_Offered_by_PR/Memory_Handling/vmalloc.h"
    9.24 -
    9.25 -//#include <pthread.h>
    9.26 -//#include <sys/time.h>
    9.27 -
    9.28 -//=================  Defines: included from separate files  =================
    9.29 -//
    9.30 -// Note: ALL defines are in other files, none are in here
    9.31 -//
    9.32 -//#include "Defines/PR_defs.h"
    9.33 -
    9.34 -
    9.35 -//================================ Typedefs =================================
    9.36 -//
    9.37 -//#include "PR__structs.h"
    9.38 -
    9.39 -//============================ HW Dependent Fns ================================
    9.40 -
    9.41 -//#include "HW_Dependent_Primitives/PR__HW_measurement.h"
    9.42 -//#include "HW_Dependent_Primitives/PR__primitives.h"
    9.43 -
    9.44 -
    9.45 -//=============================  Global Vars ================================
    9.46 -
    9.47 -//volatile TopEnv      *_PRTopEnv __align_to_cacheline__;
    9.48 -
    9.49 -   //these are global, but only used for startup and shutdown
    9.50 -//pthread_t       coreCtlrThdHandles[ NUM_CORES ]; //pthread's virt-procr state
    9.51 -//ThdParams      *coreCtlrThdParams [ NUM_CORES ];
    9.52 -
    9.53 -//pthread_mutex_t suspendLock;
    9.54 -//pthread_cond_t  suspendCond;
    9.55 -
    9.56 -
    9.57 -//============== include internally used fn prototypes ================
    9.58 -
    9.59 -//include fn prototypes used internally in the proto-runtime implementation
    9.60 -//#include "PR__int.h"
    9.61 -
    9.62 -//include fn prototypes used by plugin
    9.63 -//#include "PR__PI.h"
    9.64 -
    9.65 -//include fn prototype used by wrapper library
    9.66 -//#include "PR__WL.h"
    9.67 -
    9.68 -//=================================
    9.69 -#define implement_me() printf("Unimpl Fn: \n%s \n%s : %d\n", __FILE__, __FUNCTION__, __LINE__)
    9.70 -//#define fix_me printf("Fix me at: \n%s \n%s : %s\n", __FILE__, __FUNCTION__, __LINE__)
    9.71 -
    9.72 -
    9.73 -//========================= Services =======================
    9.74 -//#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h"
    9.75 -//#include "Services_Offered_by_PR/Services_Language/PRServ.h"
    9.76 -//#include  "Services_Offered_by_PR/Services_Language/libPRServ.h"
    9.77 -
    9.78 -//================================================
    9.79 -#endif	/* _PR_H */
    9.80 -
    9.81 +/*
    9.82 + *  Copyright 2012 OpenSourceResearchInstitute.org
    9.83 + *  Licensed under GNU General Public License version 2
    9.84 + *
    9.85 + * Author: seanhalle@yahoo.com
    9.86 + * 
    9.87 + */
    9.88 +
    9.89 +#ifndef _PR_H
    9.90 +#define	_PR_H
    9.91 +#define _GNU_SOURCE
    9.92 +
    9.93 +//#include "DynArray/DynArray.h"
    9.94 +//#include "Hash_impl/PrivateHash.h"
    9.95 +//#include "Histogram/Histogram.h"
    9.96 +//#include "Queue_impl/PrivateQueue.h"
    9.97 +
    9.98 +#include "PR__primitive_data_types.h"
    9.99 +#include "PR__common_structs.h"
   9.100 +//#include "Services_Offered_by_PR/Memory_Handling/vmalloc.h"
   9.101 +
   9.102 +//#include <pthread.h>
   9.103 +//#include <sys/time.h>
   9.104 +
   9.105 +//=================  Defines: included from separate files  =================
   9.106 +//
   9.107 +// Note: ALL defines are in other files, none are in here
   9.108 +//
   9.109 +//#include "Defines/PR_defs.h"
   9.110 +
   9.111 +
   9.112 +//================================ Typedefs =================================
   9.113 +//
   9.114 +//#include "PR__structs.h"
   9.115 +
   9.116 +//============================ HW Dependent Fns ================================
   9.117 +
   9.118 +//#include "HW_Dependent_Primitives/PR__HW_measurement.h"
   9.119 +//#include "HW_Dependent_Primitives/PR__primitives.h"
   9.120 +
   9.121 +
   9.122 +//=============================  Global Vars ================================
   9.123 +
   9.124 +//volatile TopEnv      *_PRTopEnv __align_to_cacheline__;
   9.125 +
   9.126 +   //these are global, but only used for startup and shutdown
   9.127 +//pthread_t       coreCtlrThdHandles[ NUM_CORES ]; //pthread's virt-procr state
   9.128 +//ThdParams      *coreCtlrThdParams [ NUM_CORES ];
   9.129 +
   9.130 +//pthread_mutex_t suspendLock;
   9.131 +//pthread_cond_t  suspendCond;
   9.132 +
   9.133 +
   9.134 +//============== include internally used fn prototypes ================
   9.135 +
   9.136 +//include fn prototypes used internally in the proto-runtime implementation
   9.137 +//#include "PR__int.h"
   9.138 +
   9.139 +//include fn prototypes used by plugin
   9.140 +//#include "PR__PI.h"
   9.141 +
   9.142 +//include fn prototype used by wrapper library
   9.143 +//#include "PR__WL.h"
   9.144 +
   9.145 +//=================================
   9.146 +#define implement_me() printf("Unimpl Fn: \n%s \n%s : %d\n", __FILE__, __FUNCTION__, __LINE__)
   9.147 +//#define fix_me printf("Fix me at: \n%s \n%s : %s\n", __FILE__, __FUNCTION__, __LINE__)
   9.148 +
   9.149 +
   9.150 +//========================= Services =======================
   9.151 +//#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h"
   9.152 +//#include "Services_Offered_by_PR/Services_Language/PRServ.h"
   9.153 +//#include  "Services_Offered_by_PR/Services_Language/libPRServ.h"
   9.154 +
   9.155 +//================================================
   9.156 +#endif	/* _PR_H */
   9.157 +
    10.1 --- a/PR__common_structs.h	Sun Jul 21 13:41:59 2013 -0700
    10.2 +++ b/PR__common_structs.h	Sun Jul 21 13:44:17 2013 -0700
    10.3 @@ -1,431 +1,431 @@
    10.4 -/*
    10.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
    10.6 - *  Licensed under GNU General Public License version 2
    10.7 - *
    10.8 - * Author: seanhalle@yahoo.com
    10.9 - * 
   10.10 - */
   10.11 -
   10.12 -#ifndef _PR__structs_H
   10.13 -#define	_PR__structs_H
   10.14 -#define _GNU_SOURCE
   10.15 -
   10.16 -//#include <pthread.h>
   10.17 -//#include <sys/time.h>
   10.18 -
   10.19 -
   10.20 -//================================ Typedefs =================================
   10.21 -//===
   10.22 -//=
   10.23 -#define ZERO 0
   10.24 -
   10.25 -//typedef unsigned long long    TSCount;
   10.26 -
   10.27 -//typedef struct _AnimSlot      AnimSlot;
   10.28 -//typedef struct _PRReqst       PRReqst;
   10.29 -typedef struct _SlaveVP       SlaveVP;
   10.30 -//typedef struct _MasterVP      MasterVP;
   10.31 -typedef struct _IntervalProbe IntervalProbe;
   10.32 -//typedef struct _PRLangEnv     PRLangEnv;  //a prolog
   10.33 -typedef struct _PRMetaTask    PRMetaTask; //a prolog
   10.34 -//typedef struct _PRLangData    PRLangData; //a prolog
   10.35 -//typedef struct _PRCollElem    PRCollElem; //generic form of the prologs
   10.36 -
   10.37 -//typedef bool32   (*SlaveAssigner)  ( void *, AnimSlot* ); //langEnv, slot for HW info
   10.38 -typedef void     (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv
   10.39 -typedef void    *(*CreateHandler)  ( void *, SlaveVP *, void * ); //req, slv, langEnv
   10.40 -typedef void     (*LangShutdownHdlr) ( void * ); //langEnv
   10.41 -typedef void    *(*LangDataCreator)  ( SlaveVP * ); 
   10.42 -typedef void     (*LangDataFreer)    ( void * ); //lang data to free
   10.43 -typedef void    *(*LangMetaTaskCreator)( SlaveVP * );  //when slave has no meta task for magic num 
   10.44 -typedef void     (*LangMetaTaskFreer)  ( void * ); //lang meta task to free
   10.45 -//typedef void     (*MakeSlaveReadyFn)   ( SlaveVP *, void * ); //slave and langEnv
   10.46 -//typedef void     (*MakeTaskReadyFn)    ( void *, void * ); //langTask and langEnv
   10.47 -typedef void     (*BirthFnPtr)  ( void *, SlaveVP * ); //initData, animSlv
   10.48 -typedef void       BirthFn      ( void *, SlaveVP * ); //initData, animSlv
   10.49 -//typedef void     (*ResumeSlvFnPtr) ( SlaveVP *, void * );
   10.50 -      //=========== MEASUREMENT STUFF ==========
   10.51 -//        MEAS__Insert_Counter_Handler
   10.52 -      //========================================
   10.53 -
   10.54 -//============================ HW Dependent Fns ================================
   10.55 -
   10.56 -//#include "HW_Dependent_Primitives/PR__HW_measurement.h"
   10.57 -//#include "HW_Dependent_Primitives/PR__primitives.h"
   10.58 -
   10.59 -
   10.60 -typedef struct
   10.61 - { //These are set by the plugin during startup and the application
   10.62 -   char *assignerInfo;
   10.63 -   char *appInfo;
   10.64 -   char *inputInfo;
   10.65 - }
   10.66 -PRSysMetaInfo;
   10.67 -
   10.68 -//=====================  Process Data Struct  ======================
   10.69 -
   10.70 -/*This structure holds all the information PR needs to manage a program.  PR
   10.71 - * stores information about what percent of CPU time the program is getting, 
   10.72 - * 
   10.73 - */
   10.74 -/*
   10.75 -typedef struct
   10.76 - { 
   10.77 -   int32     numEnvsWithWork;
   10.78 -   void     *resultToReturn;
   10.79 -    
   10.80 -   PRLangEnv **langEnvs;     //used as a hash table
   10.81 -   PRLangEnv **protoLangEnvsList; //for fast linear scan of envs
   10.82 -   int32      numLangEnvs;   //for fast linear scan of envs
   10.83 -    
   10.84 -   SlaveVP        *seedSlv;
   10.85 -   
   10.86 -   int32           numLiveGenericSlvs;
   10.87 -   int32           numLiveTasks;
   10.88 -
   10.89 -   SlaveAssigner   overrideAssigner;
   10.90 -  
   10.91 -   
   10.92 -   
   10.93 -      //These are used to coord with an OS thread waiting for process to end
   10.94 -   bool32          hasWaitingToEnd;
   10.95 -   bool32          executionIsComplete;
   10.96 -   pthread_mutex_t doneLock;
   10.97 -   pthread_cond_t  doneCond;   
   10.98 -   pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting
   10.99 -
  10.100 -      //=========== MEASUREMENT STUFF =============
  10.101 -       IntervalProbe   **intervalProbes;
  10.102 -       PrivDynArrayInfo *dynIntervalProbesInfo;
  10.103 -       HashTable        *probeNameHashTbl;
  10.104 -       int32             masterCreateProbeID;
  10.105 -       float64           createPtInSecs; //real-clock time PR initialized
  10.106 -       Histogram       **measHists;
  10.107 -       PrivDynArrayInfo *measHistsInfo;
  10.108 -       MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
  10.109 -       MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
  10.110 -       MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
  10.111 -       MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
  10.112 -       MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
  10.113 -       MEAS__Insert_System_Meas_Fields_into_MasterEnv;
  10.114 -       MEAS__Insert_Counter_Meas_Fields_into_MasterEnv;
  10.115 -      //==========================================
  10.116 - }
  10.117 -PRProcess;
  10.118 -*/
  10.119 -
  10.120 -//============= Request Related ===========
  10.121 -//
  10.122 -
  10.123 -enum PRReqstType  //avoid starting enums at 0, for debug reasons
  10.124 - {
  10.125 -   TaskCreate = 1,
  10.126 -   TaskEnd,
  10.127 -   SlvCreate,
  10.128 -   SlvDissipate,
  10.129 -   Language,
  10.130 -   Service,       //To invoke a PR provided equivalent of a language request (ex: probe)
  10.131 -   Hardware,
  10.132 -   IO,
  10.133 -   OSCall, 
  10.134 -   LangShutdown,
  10.135 -   ProcessEnd,
  10.136 -   PRShutdown
  10.137 - };
  10.138 -
  10.139 -
  10.140 -struct _PRReqst
  10.141 - {
  10.142 -   enum PRReqstType   reqType;//used for special forms that have PR behavior
  10.143 -   void              *langReq;
  10.144 -   PRProcess         *processReqIsIn;
  10.145 -   int32              langMagicNumber;
  10.146 -   SlaveVP           *requestingSlave;
  10.147 -   
  10.148 -   BirthFnPtr      topLevelFn;
  10.149 -   void              *initData;
  10.150 -   int32             *ID;
  10.151 -   
  10.152 -      //The request handling structure is a bit messy..  for special forms, 
  10.153 -      // such as create and dissipate, the language inserts pointer to handler
  10.154 -      // fn directly into the request..  might change to this for all requests
  10.155 -   RequestHandler    handler; //pointer to handler fn 
  10.156 -   CreateHandler     createHdlr; //special because returns something
  10.157 -   int32             createSuspendedGroup; //must be non-zero
  10.158 -   
  10.159 -   PRReqst *nextReqst;
  10.160 - };
  10.161 -//PRReqst
  10.162 -
  10.163 -enum PRServiceReqType   //These are equivalent to lang requests, but for
  10.164 - {                    // PR's services available directly to app, like OS
  10.165 -   make_probe = 1,    // and probe services -- like a PR-wide built-in lang
  10.166 -   throw_excp,
  10.167 -   openFile,
  10.168 -   otherIO
  10.169 - };
  10.170 -
  10.171 -typedef struct
  10.172 - { enum PRServiceReqType   reqType;
  10.173 -   SlaveVP             *requestingSlv;
  10.174 -   char                *nameStr;  //for create probe
  10.175 -   char                *msgStr;   //for exception
  10.176 -   void                *exceptionData;
  10.177 - }
  10.178 -PRServiceReq;
  10.179 -
  10.180 -
  10.181 -//====================  Core data structures  ===================
  10.182 -
  10.183 -typedef struct
  10.184 - {
  10.185 -   //for future expansion
  10.186 - }
  10.187 -SlotPerfInfo;
  10.188 -
  10.189 -struct _AnimSlot
  10.190 - {
  10.191 -   int32         workIsDone;
  10.192 -   int32         needsWorkAssigned;
  10.193 -   SlaveVP      *slaveAssignedToSlot;
  10.194 -   
  10.195 -   int32         slotIdx;  //needed by Holistic Model's data gathering
  10.196 -   int32         coreSlotIsOn;
  10.197 -   SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core
  10.198 - };
  10.199 -//AnimSlot
  10.200 -
  10.201 -enum VPtype 
  10.202 - { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks
  10.203 -   FreeTaskSlv,   //When a suspended task ends, the slave becomes this
  10.204 -   GenericSlv,     //the VP is explicitly seen in the app code, or task suspends
  10.205 -   SeedSlv,
  10.206 -   Master_VP,
  10.207 -   ShutdownVP,
  10.208 -   IdleVP
  10.209 - };
  10.210 - 
  10.211 -/*This structure embodies the state of a slaveVP.  It is reused for masterVP
  10.212 - * and shutdownVPs.
  10.213 - */
  10.214 -struct _SlaveVP
  10.215 - {    //The offsets of these fields are hard-coded into assembly
  10.216 -   void       *stackPtr;         //save the core's stack ptr when suspend
  10.217 -   void       *framePtr;         //save core's frame ptr when suspend
  10.218 -   void       *resumeInstrPtr;   //save core's program-counter when suspend
  10.219 -   void       *coreCtlrFramePtr; //restore before jmp back to core controller
  10.220 -   void       *coreCtlrStackPtr; //restore before jmp back to core controller
  10.221 -   
  10.222 -      //============ below this, no fields are used in asm =============
  10.223 -   
  10.224 -   void       *startOfStack;  //used to free, and to point slave to Fn
  10.225 -   PRProcess  *processSlaveIsIn;
  10.226 -   enum VPtype typeOfVP;      //Slave vs Master vs Shutdown..
  10.227 -   int32       slaveNum;      //each slave given it's seq in creation
  10.228 -   int32      *ID;       //App defines meaning of each int in array
  10.229 -   int32       coreAnimatedBy; 
  10.230 -   int32       numTimesAssignedToASlot;   //Each assign is for one work-unit, so is an ID
  10.231 -      //note, a scheduling decision is uniquely identified by the triple:
  10.232 -      // <slaveNum, coreAnimatedBy, numTimesAssignedToASlot> -- used in record & replay
  10.233 -   
  10.234 -      //for comm -- between master and coreCtlr & btwn wrapper lib and plugin
  10.235 -   AnimSlot   *animSlotAssignedTo;
  10.236 -   PRReqst    *request;      //wrapper lib puts in requests, plugin takes out
  10.237 -   void       *dataRetFromReq;//Return vals from plugin to Wrapper Lib
  10.238 -
  10.239 -      //For language specific data that needs to be in the slave
  10.240 -      //These are accessed  directly for single-lang, but multi-lang places
  10.241 -      // a holder here instead, then uses magic num to get lang's version
  10.242 -   PRLangData  **langDatas;  //Lang saves lang-specific things in slave here
  10.243 -   PRMetaTask  **metaTasks;
  10.244 -
  10.245 -        //=========== MEASUREMENT STUFF ==========
  10.246 -         MEAS__Insert_Meas_Fields_into_Slave;
  10.247 -         float64     createPtInSecs;  //time VP created, in seconds
  10.248 -        //========================================
  10.249 -         
  10.250 -//   int8       cacheLinePad[512 - sizeof(contents)]; //for false sharing
  10.251 - };
  10.252 -//SlaveVP
  10.253 -
  10.254 - 
  10.255 -enum PRMode
  10.256 - { SingleLang = 1,
  10.257 -   StandaloneWTasks,
  10.258 -   MultiLang      
  10.259 - };
  10.260 - 
  10.261 -/* The one and only global variable, holds many odds and ends
  10.262 - */
  10.263 -typedef struct
  10.264 - {    //The offsets of these fields are hard-coded into assembly
  10.265 -   void            *coreCtlrReturnPt;    //offset to this field used in asm
  10.266 -   int8             falseSharePad1[256 - sizeof(void*)];
  10.267 -   int32            masterLock;          //offset to this field used in asm
  10.268 -   int8             falseSharePad2[256 - sizeof(int32)];
  10.269 -   int32            wrapperLock;         //offset to this field used in asm
  10.270 -   int8             falseSharePad3[256 - sizeof(int32)];
  10.271 -   int32            mallocLock;          //offset to this field used in asm
  10.272 -   int8             falseSharePad4[256 - sizeof(int32)];
  10.273 -      //============ below this, no fields are used in asm =============
  10.274 -
  10.275 -      //Basic PR infrastructure
  10.276 -//   enum PRMode      mode;
  10.277 -   SlaveVP        **masterVPs;
  10.278 -   AnimSlot      ***allAnimSlots;
  10.279 -   PrivQueueStruc  *slaveRecycleQ;
  10.280 -   SlaveVP         *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
  10.281 -   SlaveVP         *idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
  10.282 -   
  10.283 -      //Memory management related
  10.284 -   MallocArrays    *freeLists;
  10.285 -   int32            amtOfOutstandingMem;//total currently allocated
  10.286 -
  10.287 -      //Random number seeds -- random nums used in various places  
  10.288 -   uint32_t         seed1;
  10.289 -   uint32_t         seed2;
  10.290 -
  10.291 -   PRSysMetaInfo   *metaInfo; //info about this PR system -- vers, build, etc
  10.292 -   
  10.293 -   //============== This only used by multi-lang mode ============
  10.294 -   PRProcess      **processes;
  10.295 -   int32            numProcesses;
  10.296 -   int32            currProcessIdx;    //used to choose which process gets slot
  10.297 -   int32            firstProcessReady; //use while starting up coreCtlr
  10.298 -   
  10.299 -      //initialize flags for waiting for activity within PR to complete
  10.300 -   bool32           allActivityIsDone;
  10.301 -   pthread_mutex_t  activityDoneLock;
  10.302 -   pthread_cond_t   activityDoneCond;   
  10.303 -
  10.304 -   SlaveAssigner    overrideAssigner;
  10.305 -   
  10.306 -   //============== Below this is only used by single-lang mode ==============
  10.307 -   void            *protoLangEnv;
  10.308 -      //Slave creation -- global count of slaves existing, across langs and processes
  10.309 -   int32            numSlavesCreated;  //used to give unique ID to processor
  10.310 -   int32            numTasksCreated;   //to give unique ID to a task
  10.311 -   int32            numSlavesAlive;
  10.312 -
  10.313 -   bool32          *coreIsDone;
  10.314 -   int32            numCoresDone;
  10.315 -   int32            shutdownInitiated;
  10.316 -   
  10.317 -   
  10.318 -      //=========== MEASUREMENT STUFF =============
  10.319 -       IntervalProbe   **intervalProbes;
  10.320 -       PrivDynArrayInfo *dynIntervalProbesInfo;
  10.321 -       HashTable        *probeNameHashTbl;
  10.322 -       int32             masterCreateProbeID;
  10.323 -       float64           createPtInSecs; //real-clock time PR initialized
  10.324 -       Histogram       **measHists;
  10.325 -       PrivDynArrayInfo *measHistsInfo;
  10.326 -       MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
  10.327 -       MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
  10.328 -       MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
  10.329 -       MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
  10.330 -       MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
  10.331 -       MEAS__Insert_System_Meas_Fields_into_MasterEnv;
  10.332 -       MEAS__Insert_Counter_Meas_Fields_into_MasterEnv;
  10.333 -      //==========================================
  10.334 - }
  10.335 -TopEnv;
  10.336 -
  10.337 -
  10.338 -//===================== These are prologs ====================
  10.339 -//===A prolog is data immediately before pointer returned by a create function.
  10.340 -//=
  10.341 -struct _PRLangEnv
  10.342 - { //============== First two must match PRCollElem ==============
  10.343 -   int32     langMagicNumber; //indexes into hash array of langEnvs in PRProcess
  10.344 -   PRLangEnv *chainedLangEnv;   //chains to langEnvs with same hash
  10.345 -   //=============================================================
  10.346 -   
  10.347 -   SlaveAssigner    workAssigner;
  10.348 -   LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown
  10.349 -   LangDataCreator  langDataCreator;
  10.350 -   LangMetaTaskCreator langMetaTaskCreator;
  10.351 -   MakeSlaveReadyFn makeSlaveReadyFn;
  10.352 -   MakeTaskReadyFn  makeTaskReadyFn;
  10.353 -     
  10.354 -      //when multi-lang, master polls lang env's to find one with work in it..
  10.355 -      // in single-lang case, flag ignored, master always asks lang for work
  10.356 -   int32           hasWork;
  10.357 -   PRProcess      *processEnvIsIn;
  10.358 -   
  10.359 -   int32           idxInProcess; //index into array of langEnvs in the process
  10.360 -   
  10.361 -   int32           numReadyWork;
  10.362 -   
  10.363 -   int32           numLiveWork;
  10.364 -   PrivQueueStruc *waitingForWorkToEndQ;
  10.365 - };
  10.366 -//PRLangEnv -- this is the prolog of every lang's lang env
  10.367 -
  10.368 -enum PRTaskType
  10.369 - { GenericSlave = 1,
  10.370 -   SlotTask,
  10.371 -   FreeTask
  10.372 - };
  10.373 -
  10.374 -struct _PRMetaTask
  10.375 - { //============== First two must match PRCollElem ==============
  10.376 -   int32           langMagicNumber;
  10.377 -   PRMetaTask     *chainedMetaTask;
  10.378 -   //=============================================================
  10.379 -   enum PRTaskType taskType;
  10.380 -   int32          *ID;              //is standard PR ID
  10.381 -   PRProcess      *processTaskIsIn;
  10.382 -   SlaveVP        *slaveAssignedTo; //not valid until task animated
  10.383 -   BirthFnPtr   topLevelFn;      //This is the Fn executes as the task
  10.384 -   void           *initData;        //The data taken by the function
  10.385 -   LangMetaTaskFreer freer;
  10.386 -   bool32          goAheadAndFree;
  10.387 -
  10.388 -   //NOTE: info needed for "wait" functionality is inside lang's metaTask
  10.389 - };
  10.390 -//PRMetaTask -- prolog of every lang's meta task
  10.391 -
  10.392 -struct _PRLangData
  10.393 - { //============== First two must match PRCollElem ==============
  10.394 -   int32         langMagicNumber;
  10.395 -   PRLangData   *chainedLangData;
  10.396 -   //=============================================================
  10.397 -   LangDataFreer  freer;
  10.398 -   bool32         goAheadAndFree;
  10.399 -   SlaveVP       *slaveAssignedTo;
  10.400 - };
  10.401 -//PRLangData -- this is the prolog of each lang's lang data
  10.402 -
  10.403 -struct _PRCollElem
  10.404 - {
  10.405 -   int32       hash;
  10.406 -   PRCollElem *chained;
  10.407 - };
  10.408 -//PRCollElem -- this is generic form of all the prologs
  10.409 -
  10.410 -
  10.411 -
  10.412 -//=========================  Extra Stuff Data Strucs  =======================
  10.413 -typedef struct
  10.414 - {
  10.415 -
  10.416 - }
  10.417 -PRExcp; //exception
  10.418 -
  10.419 -//=======================  OS Thread related  ===============================
  10.420 -
  10.421 -void * coreController( void *paramsIn );  //standard PThreads fn prototype
  10.422 -void * coreCtlr_Seq( void *paramsIn );  //standard PThreads fn prototype
  10.423 -void animationMaster( void *initData, SlaveVP *masterVP );
  10.424 -
  10.425 -
  10.426 -typedef struct
  10.427 - {
  10.428 -   void           *endThdPt;
  10.429 -   unsigned int    coreNum;
  10.430 - }
  10.431 -ThdParams;
  10.432 -
  10.433 -#endif	/* _PR__structs_H */
  10.434 -
  10.435 +/*
  10.436 + *  Copyright 2009 OpenSourceResearchInstitute.org
  10.437 + *  Licensed under GNU General Public License version 2
  10.438 + *
  10.439 + * Author: seanhalle@yahoo.com
  10.440 + * 
  10.441 + */
  10.442 +
  10.443 +#ifndef _PR__structs_H
  10.444 +#define	_PR__structs_H
  10.445 +#define _GNU_SOURCE
  10.446 +
  10.447 +//#include <pthread.h>
  10.448 +//#include <sys/time.h>
  10.449 +
  10.450 +
  10.451 +//================================ Typedefs =================================
  10.452 +//===
  10.453 +//=
  10.454 +#define ZERO 0
  10.455 +
  10.456 +//typedef unsigned long long    TSCount;
  10.457 +
  10.458 +//typedef struct _AnimSlot      AnimSlot;
  10.459 +//typedef struct _PRReqst       PRReqst;
  10.460 +typedef struct _SlaveVP       SlaveVP;
  10.461 +//typedef struct _MasterVP      MasterVP;
  10.462 +typedef struct _IntervalProbe IntervalProbe;
  10.463 +//typedef struct _PRLangEnv     PRLangEnv;  //a prolog
  10.464 +typedef struct _PRMetaTask    PRMetaTask; //a prolog
  10.465 +//typedef struct _PRLangData    PRLangData; //a prolog
  10.466 +//typedef struct _PRCollElem    PRCollElem; //generic form of the prologs
  10.467 +
  10.468 +//typedef bool32   (*SlaveAssigner)  ( void *, AnimSlot* ); //langEnv, slot for HW info
  10.469 +typedef void     (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv
  10.470 +typedef void    *(*CreateHandler)  ( void *, SlaveVP *, void * ); //req, slv, langEnv
  10.471 +typedef void     (*LangShutdownHdlr) ( void * ); //langEnv
  10.472 +typedef void    *(*LangDataCreator)  ( SlaveVP * ); 
  10.473 +typedef void     (*LangDataFreer)    ( void * ); //lang data to free
  10.474 +typedef void    *(*LangMetaTaskCreator)( SlaveVP * );  //when slave has no meta task for magic num 
  10.475 +typedef void     (*LangMetaTaskFreer)  ( void * ); //lang meta task to free
  10.476 +//typedef void     (*MakeSlaveReadyFn)   ( SlaveVP *, void * ); //slave and langEnv
  10.477 +//typedef void     (*MakeTaskReadyFn)    ( void *, void * ); //langTask and langEnv
  10.478 +typedef void     (*BirthFnPtr)  ( void *, SlaveVP * ); //initData, animSlv
  10.479 +typedef void       BirthFn      ( void *, SlaveVP * ); //initData, animSlv
  10.480 +//typedef void     (*ResumeSlvFnPtr) ( SlaveVP *, void * );
  10.481 +      //=========== MEASUREMENT STUFF ==========
  10.482 +//        MEAS__Insert_Counter_Handler
  10.483 +      //========================================
  10.484 +
  10.485 +//============================ HW Dependent Fns ================================
  10.486 +
  10.487 +//#include "HW_Dependent_Primitives/PR__HW_measurement.h"
  10.488 +//#include "HW_Dependent_Primitives/PR__primitives.h"
  10.489 +
  10.490 +
  10.491 +typedef struct
  10.492 + { //These are set by the plugin during startup and the application
  10.493 +   char *assignerInfo;
  10.494 +   char *appInfo;
  10.495 +   char *inputInfo;
  10.496 + }
  10.497 +PRSysMetaInfo;
  10.498 +
  10.499 +//=====================  Process Data Struct  ======================
  10.500 +
  10.501 +/*This structure holds all the information PR needs to manage a program.  PR
  10.502 + * stores information about what percent of CPU time the program is getting, 
  10.503 + * 
  10.504 + */
  10.505 +/*
  10.506 +typedef struct
  10.507 + { 
  10.508 +   int32     numEnvsWithWork;
  10.509 +   void     *resultToReturn;
  10.510 +    
  10.511 +   PRLangEnv **langEnvs;     //used as a hash table
  10.512 +   PRLangEnv **protoLangEnvsList; //for fast linear scan of envs
  10.513 +   int32      numLangEnvs;   //for fast linear scan of envs
  10.514 +    
  10.515 +   SlaveVP        *seedSlv;
  10.516 +   
  10.517 +   int32           numLiveGenericSlvs;
  10.518 +   int32           numLiveTasks;
  10.519 +
  10.520 +   SlaveAssigner   overrideAssigner;
  10.521 +  
  10.522 +   
  10.523 +   
  10.524 +      //These are used to coord with an OS thread waiting for process to end
  10.525 +   bool32          hasWaitingToEnd;
  10.526 +   bool32          executionIsComplete;
  10.527 +   pthread_mutex_t doneLock;
  10.528 +   pthread_cond_t  doneCond;   
  10.529 +   pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting
  10.530 +
  10.531 +      //=========== MEASUREMENT STUFF =============
  10.532 +       IntervalProbe   **intervalProbes;
  10.533 +       PrivDynArrayInfo *dynIntervalProbesInfo;
  10.534 +       HashTable        *probeNameHashTbl;
  10.535 +       int32             masterCreateProbeID;
  10.536 +       float64           createPtInSecs; //real-clock time PR initialized
  10.537 +       Histogram       **measHists;
  10.538 +       PrivDynArrayInfo *measHistsInfo;
  10.539 +       MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
  10.540 +       MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
  10.541 +       MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
  10.542 +       MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
  10.543 +       MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
  10.544 +       MEAS__Insert_System_Meas_Fields_into_MasterEnv;
  10.545 +       MEAS__Insert_Counter_Meas_Fields_into_MasterEnv;
  10.546 +      //==========================================
  10.547 + }
  10.548 +PRProcess;
  10.549 +*/
  10.550 +
  10.551 +//============= Request Related ===========
  10.552 +//
  10.553 +
  10.554 +enum PRReqstType  //avoid starting enums at 0, for debug reasons
  10.555 + {
  10.556 +   TaskCreate = 1,
  10.557 +   TaskEnd,
  10.558 +   SlvCreate,
  10.559 +   SlvDissipate,
  10.560 +   Language,
  10.561 +   Service,       //To invoke a PR provided equivalent of a language request (ex: probe)
  10.562 +   Hardware,
  10.563 +   IO,
  10.564 +   OSCall, 
  10.565 +   LangShutdown,
  10.566 +   ProcessEnd,
  10.567 +   PRShutdown
  10.568 + };
  10.569 +
  10.570 +
  10.571 +struct _PRReqst
  10.572 + {
  10.573 +   enum PRReqstType   reqType;//used for special forms that have PR behavior
  10.574 +   void              *langReq;
  10.575 +   PRProcess         *processReqIsIn;
  10.576 +   int32              langMagicNumber;
  10.577 +   SlaveVP           *requestingSlave;
  10.578 +   
  10.579 +   BirthFnPtr      topLevelFn;
  10.580 +   void              *initData;
  10.581 +   int32             *ID;
  10.582 +   
  10.583 +      //The request handling structure is a bit messy..  for special forms, 
  10.584 +      // such as create and dissipate, the language inserts pointer to handler
  10.585 +      // fn directly into the request..  might change to this for all requests
  10.586 +   RequestHandler    handler; //pointer to handler fn 
  10.587 +   CreateHandler     createHdlr; //special because returns something
  10.588 +   int32             createSuspendedGroup; //must be non-zero
  10.589 +   
  10.590 +   PRReqst *nextReqst;
  10.591 + };
  10.592 +//PRReqst
  10.593 +
  10.594 +enum PRServiceReqType   //These are equivalent to lang requests, but for
  10.595 + {                    // PR's services available directly to app, like OS
  10.596 +   make_probe = 1,    // and probe services -- like a PR-wide built-in lang
  10.597 +   throw_excp,
  10.598 +   openFile,
  10.599 +   otherIO
  10.600 + };
  10.601 +
  10.602 +typedef struct
  10.603 + { enum PRServiceReqType   reqType;
  10.604 +   SlaveVP             *requestingSlv;
  10.605 +   char                *nameStr;  //for create probe
  10.606 +   char                *msgStr;   //for exception
  10.607 +   void                *exceptionData;
  10.608 + }
  10.609 +PRServiceReq;
  10.610 +
  10.611 +
  10.612 +//====================  Core data structures  ===================
  10.613 +
  10.614 +typedef struct
  10.615 + {
  10.616 +   //for future expansion
  10.617 + }
  10.618 +SlotPerfInfo;
  10.619 +
  10.620 +struct _AnimSlot
  10.621 + {
  10.622 +   int32         workIsDone;
  10.623 +   int32         needsWorkAssigned;
  10.624 +   SlaveVP      *slaveAssignedToSlot;
  10.625 +   
  10.626 +   int32         slotIdx;  //needed by Holistic Model's data gathering
  10.627 +   int32         coreSlotIsOn;
  10.628 +   SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core
  10.629 + };
  10.630 +//AnimSlot
  10.631 +
  10.632 +enum VPtype 
  10.633 + { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks
  10.634 +   FreeTaskSlv,   //When a suspended task ends, the slave becomes this
  10.635 +   GenericSlv,     //the VP is explicitly seen in the app code, or task suspends
  10.636 +   SeedSlv,
  10.637 +   Master_VP,
  10.638 +   ShutdownVP,
  10.639 +   IdleVP
  10.640 + };
  10.641 + 
  10.642 +/*This structure embodies the state of a slaveVP.  It is reused for masterVP
  10.643 + * and shutdownVPs.
  10.644 + */
  10.645 +struct _SlaveVP
  10.646 + {    //The offsets of these fields are hard-coded into assembly
  10.647 +   void       *stackPtr;         //save the core's stack ptr when suspend
  10.648 +   void       *framePtr;         //save core's frame ptr when suspend
  10.649 +   void       *resumeInstrPtr;   //save core's program-counter when suspend
  10.650 +   void       *coreCtlrFramePtr; //restore before jmp back to core controller
  10.651 +   void       *coreCtlrStackPtr; //restore before jmp back to core controller
  10.652 +   
  10.653 +      //============ below this, no fields are used in asm =============
  10.654 +   
  10.655 +   void       *startOfStack;  //used to free, and to point slave to Fn
  10.656 +   PRProcess  *processSlaveIsIn;
  10.657 +   enum VPtype typeOfVP;      //Slave vs Master vs Shutdown..
  10.658 +   int32       slaveNum;      //each slave given it's seq in creation
  10.659 +   int32      *ID;       //App defines meaning of each int in array
  10.660 +   int32       coreAnimatedBy; 
  10.661 +   int32       numTimesAssignedToASlot;   //Each assign is for one work-unit, so is an ID
  10.662 +      //note, a scheduling decision is uniquely identified by the triple:
  10.663 +      // <slaveNum, coreAnimatedBy, numTimesAssignedToASlot> -- used in record & replay
  10.664 +   
  10.665 +      //for comm -- between master and coreCtlr & btwn wrapper lib and plugin
  10.666 +   AnimSlot   *animSlotAssignedTo;
  10.667 +   PRReqst    *request;      //wrapper lib puts in requests, plugin takes out
  10.668 +   void       *dataRetFromReq;//Return vals from plugin to Wrapper Lib
  10.669 +
  10.670 +      //For language specific data that needs to be in the slave
  10.671 +      //These are accessed  directly for single-lang, but multi-lang places
  10.672 +      // a holder here instead, then uses magic num to get lang's version
  10.673 +   PRLangData  **langDatas;  //Lang saves lang-specific things in slave here
  10.674 +   PRMetaTask  **metaTasks;
  10.675 +
  10.676 +        //=========== MEASUREMENT STUFF ==========
  10.677 +         MEAS__Insert_Meas_Fields_into_Slave;
  10.678 +         float64     createPtInSecs;  //time VP created, in seconds
  10.679 +        //========================================
  10.680 +         
  10.681 +//   int8       cacheLinePad[512 - sizeof(contents)]; //for false sharing
  10.682 + };
  10.683 +//SlaveVP
  10.684 +
  10.685 + 
  10.686 +enum PRMode
  10.687 + { SingleLang = 1,
  10.688 +   StandaloneWTasks,
  10.689 +   MultiLang      
  10.690 + };
  10.691 + 
  10.692 +/* The one and only global variable, holds many odds and ends
  10.693 + */
  10.694 +typedef struct
  10.695 + {    //The offsets of these fields are hard-coded into assembly
  10.696 +   void            *coreCtlrReturnPt;    //offset to this field used in asm
  10.697 +   int8             falseSharePad1[256 - sizeof(void*)];
  10.698 +   int32            masterLock;          //offset to this field used in asm
  10.699 +   int8             falseSharePad2[256 - sizeof(int32)];
  10.700 +   int32            wrapperLock;         //offset to this field used in asm
  10.701 +   int8             falseSharePad3[256 - sizeof(int32)];
  10.702 +   int32            mallocLock;          //offset to this field used in asm
  10.703 +   int8             falseSharePad4[256 - sizeof(int32)];
  10.704 +      //============ below this, no fields are used in asm =============
  10.705 +
  10.706 +      //Basic PR infrastructure
  10.707 +//   enum PRMode      mode;
  10.708 +   SlaveVP        **masterVPs;
  10.709 +   AnimSlot      ***allAnimSlots;
  10.710 +   PrivQueueStruc  *slaveRecycleQ;
  10.711 +   SlaveVP         *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
  10.712 +   SlaveVP         *idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
  10.713 +   
  10.714 +      //Memory management related
  10.715 +   MallocArrays    *freeLists;
  10.716 +   int32            amtOfOutstandingMem;//total currently allocated
  10.717 +
  10.718 +      //Random number seeds -- random nums used in various places  
  10.719 +   uint32_t         seed1;
  10.720 +   uint32_t         seed2;
  10.721 +
  10.722 +   PRSysMetaInfo   *metaInfo; //info about this PR system -- vers, build, etc
  10.723 +   
  10.724 +   //============== This only used by multi-lang mode ============
  10.725 +   PRProcess      **processes;
  10.726 +   int32            numProcesses;
  10.727 +   int32            currProcessIdx;    //used to choose which process gets slot
  10.728 +   int32            firstProcessReady; //use while starting up coreCtlr
  10.729 +   
  10.730 +      //initialize flags for waiting for activity within PR to complete
  10.731 +   bool32           allActivityIsDone;
  10.732 +   pthread_mutex_t  activityDoneLock;
  10.733 +   pthread_cond_t   activityDoneCond;   
  10.734 +
  10.735 +   SlaveAssigner    overrideAssigner;
  10.736 +   
  10.737 +   //============== Below this is only used by single-lang mode ==============
  10.738 +   void            *protoLangEnv;
  10.739 +      //Slave creation -- global count of slaves existing, across langs and processes
  10.740 +   int32            numSlavesCreated;  //used to give unique ID to processor
  10.741 +   int32            numTasksCreated;   //to give unique ID to a task
  10.742 +   int32            numSlavesAlive;
  10.743 +
  10.744 +   bool32          *coreIsDone;
  10.745 +   int32            numCoresDone;
  10.746 +   int32            shutdownInitiated;
  10.747 +   
  10.748 +   
  10.749 +      //=========== MEASUREMENT STUFF =============
  10.750 +       IntervalProbe   **intervalProbes;
  10.751 +       PrivDynArrayInfo *dynIntervalProbesInfo;
  10.752 +       HashTable        *probeNameHashTbl;
  10.753 +       int32             masterCreateProbeID;
  10.754 +       float64           createPtInSecs; //real-clock time PR initialized
  10.755 +       Histogram       **measHists;
  10.756 +       PrivDynArrayInfo *measHistsInfo;
  10.757 +       MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
  10.758 +       MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
  10.759 +       MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
  10.760 +       MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
  10.761 +       MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
  10.762 +       MEAS__Insert_System_Meas_Fields_into_MasterEnv;
  10.763 +       MEAS__Insert_Counter_Meas_Fields_into_MasterEnv;
  10.764 +      //==========================================
  10.765 + }
  10.766 +TopEnv;
  10.767 +
  10.768 +
  10.769 +//===================== These are prologs ====================
  10.770 +//===A prolog is data immediately before pointer returned by a create function.
  10.771 +//=
  10.772 +struct _PRLangEnv
  10.773 + { //============== First two must match PRCollElem ==============
  10.774 +   int32     langMagicNumber; //indexes into hash array of langEnvs in PRProcess
  10.775 +   PRLangEnv *chainedLangEnv;   //chains to langEnvs with same hash
  10.776 +   //=============================================================
  10.777 +   
  10.778 +   SlaveAssigner    workAssigner;
  10.779 +   LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown
  10.780 +   LangDataCreator  langDataCreator;
  10.781 +   LangMetaTaskCreator langMetaTaskCreator;
  10.782 +   MakeSlaveReadyFn makeSlaveReadyFn;
  10.783 +   MakeTaskReadyFn  makeTaskReadyFn;
  10.784 +     
  10.785 +      //when multi-lang, master polls lang env's to find one with work in it..
  10.786 +      // in single-lang case, flag ignored, master always asks lang for work
  10.787 +   int32           hasWork;
  10.788 +   PRProcess      *processEnvIsIn;
  10.789 +   
  10.790 +   int32           idxInProcess; //index into array of langEnvs in the process
  10.791 +   
  10.792 +   int32           numReadyWork;
  10.793 +   
  10.794 +   int32           numLiveWork;
  10.795 +   PrivQueueStruc *waitingForWorkToEndQ;
  10.796 + };
  10.797 +//PRLangEnv -- this is the prolog of every lang's lang env
  10.798 +
  10.799 +enum PRTaskType
  10.800 + { GenericSlave = 1,
  10.801 +   SlotTask,
  10.802 +   FreeTask
  10.803 + };
  10.804 +
  10.805 +struct _PRMetaTask
  10.806 + { //============== First two must match PRCollElem ==============
  10.807 +   int32           langMagicNumber;
  10.808 +   PRMetaTask     *chainedMetaTask;
  10.809 +   //=============================================================
  10.810 +   enum PRTaskType taskType;
  10.811 +   int32          *ID;              //is standard PR ID
  10.812 +   PRProcess      *processTaskIsIn;
  10.813 +   SlaveVP        *slaveAssignedTo; //not valid until task animated
  10.814 +   BirthFnPtr   topLevelFn;      //This is the Fn executes as the task
  10.815 +   void           *initData;        //The data taken by the function
  10.816 +   LangMetaTaskFreer freer;
  10.817 +   bool32          goAheadAndFree;
  10.818 +
  10.819 +   //NOTE: info needed for "wait" functionality is inside lang's metaTask
  10.820 + };
  10.821 +//PRMetaTask -- prolog of every lang's meta task
  10.822 +
  10.823 +struct _PRLangData
  10.824 + { //============== First two must match PRCollElem ==============
  10.825 +   int32         langMagicNumber;
  10.826 +   PRLangData   *chainedLangData;
  10.827 +   //=============================================================
  10.828 +   LangDataFreer  freer;
  10.829 +   bool32         goAheadAndFree;
  10.830 +   SlaveVP       *slaveAssignedTo;
  10.831 + };
  10.832 +//PRLangData -- this is the prolog of each lang's lang data
  10.833 +
  10.834 +struct _PRCollElem
  10.835 + {
  10.836 +   int32       hash;
  10.837 +   PRCollElem *chained;
  10.838 + };
  10.839 +//PRCollElem -- this is generic form of all the prologs
  10.840 +
  10.841 +
  10.842 +
  10.843 +//=========================  Extra Stuff Data Strucs  =======================
  10.844 +typedef struct
  10.845 + {
  10.846 +
  10.847 + }
  10.848 +PRExcp; //exception
  10.849 +
  10.850 +//=======================  OS Thread related  ===============================
  10.851 +
  10.852 +void * coreController( void *paramsIn );  //standard PThreads fn prototype
  10.853 +void * coreCtlr_Seq( void *paramsIn );  //standard PThreads fn prototype
  10.854 +void animationMaster( void *initData, SlaveVP *masterVP );
  10.855 +
  10.856 +
  10.857 +typedef struct
  10.858 + {
  10.859 +   void           *endThdPt;
  10.860 +   unsigned int    coreNum;
  10.861 + }
  10.862 +ThdParams;
  10.863 +
  10.864 +#endif	/* _PR__structs_H */
  10.865 +
    11.1 --- a/PR__int.h	Sun Jul 21 13:41:59 2013 -0700
    11.2 +++ b/PR__int.h	Sun Jul 21 13:44:17 2013 -0700
    11.3 @@ -1,244 +1,244 @@
    11.4 -/*
    11.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
    11.6 - *  Licensed under GNU General Public License version 2
    11.7 - *
    11.8 - * Author: seanhalle@yahoo.com
    11.9 - * 
   11.10 - */
   11.11 -
   11.12 -#ifndef _PR_INT_H
   11.13 -#define	_PR_INT_H
   11.14 -#define _GNU_SOURCE
   11.15 -
   11.16 -
   11.17 -/* MEANING OF   WL  PI  SS  int
   11.18 - * These indicate which places the function is safe to use.  They stand for:
   11.19 - * WL: Wrapper Library
   11.20 - * PI: Plugin 
   11.21 - * SS: Startup and Shutdown
   11.22 - * int: internal to the PR implementation
   11.23 - */
   11.24 -
   11.25 -inline
   11.26 -void
   11.27 -PR_int__reset_slaveVP_to_BirthFn( SlaveVP *slaveVP, BirthFnPtr fnPtr,
   11.28 -                              void    *dataParam);
   11.29 -
   11.30 -inline
   11.31 -void
   11.32 -PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr,
   11.33 -                              void    *param);
   11.34 -
   11.35 -inline
   11.36 -void
   11.37 -PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr,
   11.38 -                             void    *param1, void *param2);
   11.39 -
   11.40 -//===========================================================================
   11.41 -//
   11.42 -//===========================================================================
   11.43 -inline
   11.44 -SlaveVP *
   11.45 -PR_int__create_slaveVP_helper( BirthFnPtr fnPtr, void *dataParam );
   11.46 -
   11.47 -inline
   11.48 -SlaveVP *
   11.49 -PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam, PRProcess *process );
   11.50 -
   11.51 -SlaveVP *
   11.52 -PR_int__get_recycled_slot_slave( );
   11.53 -
   11.54 -SlaveVP *
   11.55 -PR_int__create_slot_slave( );
   11.56 -
   11.57 -inline 
   11.58 -void
   11.59 -PR_int__replace_with_new_slot_slv( SlaveVP *slave );
   11.60 -
   11.61 -void 
   11.62 -idle_fn(void* data, SlaveVP *animatingSlv);
   11.63 -
   11.64 -inline
   11.65 -void
   11.66 -PR_int__put_task_into_slot( void *task, AnimSlot *slot );
   11.67 -
   11.68 -inline
   11.69 -void
   11.70 -PR_int__put_slave_into_slot( SlaveVP *slave, AnimSlot *slot );
   11.71 -
   11.72 -void inline
   11.73 -PRHandle__ServiceReq(  SlaveVP *requestingSlv );
   11.74 -
   11.75 -void
   11.76 -PR_int__free_slaveVP( SlaveVP *slave );
   11.77 -
   11.78 -void
   11.79 -PR_int__recycle_slaveVP( SlaveVP *slave );
   11.80 -
   11.81 -void
   11.82 -freeLangDataAsElem( void *elem );
   11.83 -
   11.84 -void
   11.85 -freeMetaTaskAsElem( void *elem );
   11.86 -
   11.87 -
   11.88 -//=============================
   11.89 -//=== Lange Env
   11.90 -//=
   11.91 -inline 
   11.92 -void *
   11.93 -PR_int__give_lang_env( PRLangEnv *protoLangEnv );
   11.94 -
   11.95 -inline 
   11.96 -PRLangEnv *
   11.97 -PR_int__give_proto_lang_env( void *langEnv );
   11.98 -
   11.99 -//inline
  11.100 -void *
  11.101 -PR_int__create_lang_env_in_process( int32 size, PRProcess *process, int32 magicNum );
  11.102 -
  11.103 -inline
  11.104 -void *
  11.105 -PR_int__remove_lang_env_from_process_and_free( void *langEnv );
  11.106 -
  11.107 -inline
  11.108 -void *
  11.109 -PR_int__give_lang_env_of_req( PRReqst *req, SlaveVP *requestingSlv );
  11.110 -
  11.111 -inline
  11.112 -void *
  11.113 -PR_int__give_lang_env_for_slave( SlaveVP *slave, int32 magicNum );
  11.114 -//No WL version -- not safe!  if use env in WL, be sure data rd & wr is stable
  11.115 -
  11.116 -inline
  11.117 -PRLangEnv *
  11.118 -PR_int__give_proto_lang_env_for_slave( SlaveVP *slave, int32 magicNumber );
  11.119 -//No WL version -- not safe!  if use env in WL, be sure data rd & wr is stable
  11.120 -
  11.121 -inline
  11.122 -void *
  11.123 -PR_int__give_lang_env_from_process( PRProcess *process, int32 magicNum );
  11.124 -//No WL version -- not safe!  if use env in WL, be sure data rd & wr is stable
  11.125 -
  11.126 -inline
  11.127 -PRLangEnv *
  11.128 -PR_int__give_proto_lang_env_from_process( PRProcess *process, int32 magicNum );
  11.129 -
  11.130 -//=======================
  11.131 -//=== Meta Task
  11.132 -//=
  11.133 -inline 
  11.134 -PRMetaTask *
  11.135 -PR_int__give_prolog_of_lang_meta_task( void *task );
  11.136 -
  11.137 -inline
  11.138 -void *
  11.139 -PR_int__give_lang_meta_task_of_prolog( PRMetaTask *metaTask);
  11.140 -
  11.141 -inline
  11.142 -void *
  11.143 -PR_int__create_lang_meta_task( int32 size, LangMetaTaskFreer freer, int32 magicNum );
  11.144 -
  11.145 -inline
  11.146 -void *
  11.147 -PR_int__create_lang_meta_task_in_slave( int32 size, LangMetaTaskFreer freer,
  11.148 -                                        SlaveVP *slave, int32 magicNum );
  11.149 -
  11.150 -inline
  11.151 -PRMetaTask *
  11.152 -PR_int__create_generic_slave_meta_task( void *initData );
  11.153 -
  11.154 -void
  11.155 -PR_int__free_lang_meta_task_and_remove_from_coll( void *langMetaTask );
  11.156 -
  11.157 -inline
  11.158 -void
  11.159 -PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave );
  11.160 -
  11.161 -inline
  11.162 -void
  11.163 -PR_int__insert_lang_meta_task_into_slave__ML( void *langMetaTask, SlaveVP *slave );
  11.164 -
  11.165 -inline
  11.166 -void *
  11.167 -PR_int__give_lang_meta_task_from_slave( SlaveVP *slave, int32 magicNumer );
  11.168 -
  11.169 -inline
  11.170 -SlaveVP *
  11.171 -PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask );
  11.172 -
  11.173 -//==============
  11.174 -//=== Lang Data
  11.175 -//=
  11.176 -inline
  11.177 -void *
  11.178 -PR_PI__create_lang_data_in_slave( int32 size, LangDataFreer freer,
  11.179 -                                   SlaveVP *slave, int32 magicNum );
  11.180 -
  11.181 -inline
  11.182 -void *
  11.183 -PR_int__give_lang_data_from_slave( SlaveVP *slave, int32 magicNumer );
  11.184 -#define PR_WL__give_lang_data  PR_int__give_lang_data_from_slave
  11.185 -
  11.186 -inline
  11.187 -void *
  11.188 -PR_int__give_lang_data_of_prolog( PRLangData *langData);
  11.189 -
  11.190 -//==================================================
  11.191 -//===  Collection
  11.192 -//=
  11.193 -PRCollElem ** //return an array of pointers
  11.194 -PR_int__make_collection_of_size( int32 numInColl );
  11.195 -
  11.196 -inline
  11.197 -void
  11.198 -PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash );
  11.199 -
  11.200 -inline
  11.201 -void *
  11.202 -PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll );
  11.203 -
  11.204 -inline
  11.205 -void
  11.206 -PR_int__remove_elem_from_collection( int32 hash, PRCollElem **coll );
  11.207 -
  11.208 -inline
  11.209 -void
  11.210 -PR_int__set_collection_to_empty( PRCollElem **coll );
  11.211 -
  11.212 -inline
  11.213 -void
  11.214 -PR_int__apply_Fn_to_all_in_collection( void (*Fn)(void *), PRCollElem **coll );
  11.215 -
  11.216 -//===========
  11.217 -//===
  11.218 -//=
  11.219 -void
  11.220 -PR_int__error( char *msgStr );
  11.221 -
  11.222 -void
  11.223 -PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData );
  11.224 -
  11.225 -char *
  11.226 -PR_int__strDup( char *str );
  11.227 -
  11.228 -inline void
  11.229 -PR_int__get_wrapper_lock();
  11.230 -
  11.231 -inline void
  11.232 -PR_int__get_malloc_lock();
  11.233 -
  11.234 -#define PR_int__release_master_lock()  _PRTopEnv->masterLock  = UNLOCKED
  11.235 -
  11.236 -#define PR_int__release_wrapper_lock() _PRTopEnv->wrapperLock = UNLOCKED
  11.237 -
  11.238 -#define PR_int__release_malloc_lock()  _PRTopEnv->mallocLock  = UNLOCKED
  11.239 -
  11.240 -inline uint32_t
  11.241 -PR_int__randomNumber();
  11.242 -
  11.243 -inline void
  11.244 -PR_int__backoff_for_TooLongToGetLock( int32 numTriesToGetLock );
  11.245 -
  11.246 -#endif	/* _PR_INT_H */
  11.247 -
  11.248 +/*
  11.249 + *  Copyright 2009 OpenSourceResearchInstitute.org
  11.250 + *  Licensed under GNU General Public License version 2
  11.251 + *
  11.252 + * Author: seanhalle@yahoo.com
  11.253 + * 
  11.254 + */
  11.255 +
  11.256 +#ifndef _PR_INT_H
  11.257 +#define	_PR_INT_H
  11.258 +#define _GNU_SOURCE
  11.259 +
  11.260 +
  11.261 +/* MEANING OF   WL  PI  SS  int
  11.262 + * These indicate which places the function is safe to use.  They stand for:
  11.263 + * WL: Wrapper Library
  11.264 + * PI: Plugin 
  11.265 + * SS: Startup and Shutdown
  11.266 + * int: internal to the PR implementation
  11.267 + */
  11.268 +
  11.269 +inline
  11.270 +void
  11.271 +PR_int__reset_slaveVP_to_BirthFn( SlaveVP *slaveVP, BirthFnPtr fnPtr,
  11.272 +                              void    *dataParam);
  11.273 +
  11.274 +inline
  11.275 +void
  11.276 +PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr,
  11.277 +                              void    *param);
  11.278 +
  11.279 +inline
  11.280 +void
  11.281 +PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr,
  11.282 +                             void    *param1, void *param2);
  11.283 +
  11.284 +//===========================================================================
  11.285 +//
  11.286 +//===========================================================================
  11.287 +inline
  11.288 +SlaveVP *
  11.289 +PR_int__create_slaveVP_helper( BirthFnPtr fnPtr, void *dataParam );
  11.290 +
  11.291 +inline
  11.292 +SlaveVP *
  11.293 +PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam, PRProcess *process );
  11.294 +
  11.295 +SlaveVP *
  11.296 +PR_int__get_recycled_slot_slave( );
  11.297 +
  11.298 +SlaveVP *
  11.299 +PR_int__create_slot_slave( );
  11.300 +
  11.301 +inline 
  11.302 +void
  11.303 +PR_int__replace_with_new_slot_slv( SlaveVP *slave );
  11.304 +
  11.305 +void 
  11.306 +idle_fn(void* data, SlaveVP *animatingSlv);
  11.307 +
  11.308 +inline
  11.309 +void
  11.310 +PR_int__put_task_into_slot( void *task, AnimSlot *slot );
  11.311 +
  11.312 +inline
  11.313 +void
  11.314 +PR_int__put_slave_into_slot( SlaveVP *slave, AnimSlot *slot );
  11.315 +
  11.316 +void inline
  11.317 +PRHandle__ServiceReq(  SlaveVP *requestingSlv );
  11.318 +
  11.319 +void
  11.320 +PR_int__free_slaveVP( SlaveVP *slave );
  11.321 +
  11.322 +void
  11.323 +PR_int__recycle_slaveVP( SlaveVP *slave );
  11.324 +
  11.325 +void
  11.326 +freeLangDataAsElem( void *elem );
  11.327 +
  11.328 +void
  11.329 +freeMetaTaskAsElem( void *elem );
  11.330 +
  11.331 +
  11.332 +//=============================
  11.333 +//=== Lange Env
  11.334 +//=
  11.335 +inline 
  11.336 +void *
  11.337 +PR_int__give_lang_env( PRLangEnv *protoLangEnv );
  11.338 +
  11.339 +inline 
  11.340 +PRLangEnv *
  11.341 +PR_int__give_proto_lang_env( void *langEnv );
  11.342 +
  11.343 +//inline
  11.344 +void *
  11.345 +PR_int__create_lang_env_in_process( int32 size, PRProcess *process, int32 magicNum );
  11.346 +
  11.347 +inline
  11.348 +void *
  11.349 +PR_int__remove_lang_env_from_process_and_free( void *langEnv );
  11.350 +
  11.351 +inline
  11.352 +void *
  11.353 +PR_int__give_lang_env_of_req( PRReqst *req, SlaveVP *requestingSlv );
  11.354 +
  11.355 +inline
  11.356 +void *
  11.357 +PR_int__give_lang_env_for_slave( SlaveVP *slave, int32 magicNum );
  11.358 +//No WL version -- not safe!  if use env in WL, be sure data rd & wr is stable
  11.359 +
  11.360 +inline
  11.361 +PRLangEnv *
  11.362 +PR_int__give_proto_lang_env_for_slave( SlaveVP *slave, int32 magicNumber );
  11.363 +//No WL version -- not safe!  if use env in WL, be sure data rd & wr is stable
  11.364 +
  11.365 +inline
  11.366 +void *
  11.367 +PR_int__give_lang_env_from_process( PRProcess *process, int32 magicNum );
  11.368 +//No WL version -- not safe!  if use env in WL, be sure data rd & wr is stable
  11.369 +
  11.370 +inline
  11.371 +PRLangEnv *
  11.372 +PR_int__give_proto_lang_env_from_process( PRProcess *process, int32 magicNum );
  11.373 +
  11.374 +//=======================
  11.375 +//=== Meta Task
  11.376 +//=
  11.377 +inline 
  11.378 +PRMetaTask *
  11.379 +PR_int__give_prolog_of_lang_meta_task( void *task );
  11.380 +
  11.381 +inline
  11.382 +void *
  11.383 +PR_int__give_lang_meta_task_of_prolog( PRMetaTask *metaTask);
  11.384 +
  11.385 +inline
  11.386 +void *
  11.387 +PR_int__create_lang_meta_task( int32 size, LangMetaTaskFreer freer, int32 magicNum );
  11.388 +
  11.389 +inline
  11.390 +void *
  11.391 +PR_int__create_lang_meta_task_in_slave( int32 size, LangMetaTaskFreer freer,
  11.392 +                                        SlaveVP *slave, int32 magicNum );
  11.393 +
  11.394 +inline
  11.395 +PRMetaTask *
  11.396 +PR_int__create_generic_slave_meta_task( void *initData );
  11.397 +
  11.398 +void
  11.399 +PR_int__free_lang_meta_task_and_remove_from_coll( void *langMetaTask );
  11.400 +
  11.401 +inline
  11.402 +void
  11.403 +PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave );
  11.404 +
  11.405 +inline
  11.406 +void
  11.407 +PR_int__insert_lang_meta_task_into_slave__ML( void *langMetaTask, SlaveVP *slave );
  11.408 +
  11.409 +inline
  11.410 +void *
  11.411 +PR_int__give_lang_meta_task_from_slave( SlaveVP *slave, int32 magicNumer );
  11.412 +
  11.413 +inline
  11.414 +SlaveVP *
  11.415 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask );
  11.416 +
  11.417 +//==============
  11.418 +//=== Lang Data
  11.419 +//=
  11.420 +inline
  11.421 +void *
  11.422 +PR_PI__create_lang_data_in_slave( int32 size, LangDataFreer freer,
  11.423 +                                   SlaveVP *slave, int32 magicNum );
  11.424 +
  11.425 +inline
  11.426 +void *
  11.427 +PR_int__give_lang_data_from_slave( SlaveVP *slave, int32 magicNumer );
  11.428 +#define PR_WL__give_lang_data  PR_int__give_lang_data_from_slave
  11.429 +
  11.430 +inline
  11.431 +void *
  11.432 +PR_int__give_lang_data_of_prolog( PRLangData *langData);
  11.433 +
  11.434 +//==================================================
  11.435 +//===  Collection
  11.436 +//=
  11.437 +PRCollElem ** //return an array of pointers
  11.438 +PR_int__make_collection_of_size( int32 numInColl );
  11.439 +
  11.440 +inline
  11.441 +void
  11.442 +PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash );
  11.443 +
  11.444 +inline
  11.445 +void *
  11.446 +PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll );
  11.447 +
  11.448 +inline
  11.449 +void
  11.450 +PR_int__remove_elem_from_collection( int32 hash, PRCollElem **coll );
  11.451 +
  11.452 +inline
  11.453 +void
  11.454 +PR_int__set_collection_to_empty( PRCollElem **coll );
  11.455 +
  11.456 +inline
  11.457 +void
  11.458 +PR_int__apply_Fn_to_all_in_collection( void (*Fn)(void *), PRCollElem **coll );
  11.459 +
  11.460 +//===========
  11.461 +//===
  11.462 +//=
  11.463 +void
  11.464 +PR_int__error( char *msgStr );
  11.465 +
  11.466 +void
  11.467 +PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData );
  11.468 +
  11.469 +char *
  11.470 +PR_int__strDup( char *str );
  11.471 +
  11.472 +inline void
  11.473 +PR_int__get_wrapper_lock();
  11.474 +
  11.475 +inline void
  11.476 +PR_int__get_malloc_lock();
  11.477 +
  11.478 +#define PR_int__release_master_lock()  _PRTopEnv->masterLock  = UNLOCKED
  11.479 +
  11.480 +#define PR_int__release_wrapper_lock() _PRTopEnv->wrapperLock = UNLOCKED
  11.481 +
  11.482 +#define PR_int__release_malloc_lock()  _PRTopEnv->mallocLock  = UNLOCKED
  11.483 +
  11.484 +inline uint32_t
  11.485 +PR_int__randomNumber();
  11.486 +
  11.487 +inline void
  11.488 +PR_int__backoff_for_TooLongToGetLock( int32 numTriesToGetLock );
  11.489 +
  11.490 +#endif	/* _PR_INT_H */
  11.491 +
    12.1 --- a/PR__primitive_data_types.h	Sun Jul 21 13:41:59 2013 -0700
    12.2 +++ b/PR__primitive_data_types.h	Sun Jul 21 13:44:17 2013 -0700
    12.3 @@ -1,42 +1,42 @@
    12.4 -/*
    12.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
    12.6 - *  Licensed under GNU General Public License version 2
    12.7 - *  
    12.8 - * Author: seanhalle@yahoo.com
    12.9 - *  
   12.10 -
   12.11 - */
   12.12 -
   12.13 -#ifndef _PRIMITIVE_DATA_TYPES_H
   12.14 -#define _PRIMITIVE_DATA_TYPES_H
   12.15 -
   12.16 -
   12.17 -/*For portability, need primitive data types that have a well defined
   12.18 - * size, and well-defined layout into bytes
   12.19 - *To do this, provide standard aliases for all primitive data types
   12.20 - *These aliases must be used in all functions instead of the ANSI types
   12.21 - *
   12.22 - *When PR is used together with BLIS, these definitions will be replaced
   12.23 - * inside each specialization module according to the compiler used in
   12.24 - * that module and the hardware being specialized to.
   12.25 - */
   12.26 -typedef char               bool8;
   12.27 -typedef char               int8;
   12.28 -typedef char               uint8;
   12.29 -typedef short              int16;
   12.30 -typedef unsigned short     uint16;
   12.31 -typedef int                int32;
   12.32 -typedef unsigned int       uint32;
   12.33 -typedef unsigned int       bool32;
   12.34 -typedef long long          int64;
   12.35 -typedef unsigned long long uint64;
   12.36 -typedef float              float32;
   12.37 -typedef double             float64;
   12.38 -//typedef double double      float128;  //GCC doesn't like this
   12.39 -#define float128 double double
   12.40 -
   12.41 -#define TRUE  1
   12.42 -#define FALSE 0
   12.43 -
   12.44 -#endif	/* _PRIMITIVE_DATA_TYPES_H */
   12.45 -
   12.46 +/*
   12.47 + *  Copyright 2009 OpenSourceResearchInstitute.org
   12.48 + *  Licensed under GNU General Public License version 2
   12.49 + *  
   12.50 + * Author: seanhalle@yahoo.com
   12.51 + *  
   12.52 +
   12.53 + */
   12.54 +
   12.55 +#ifndef _PRIMITIVE_DATA_TYPES_H
   12.56 +#define _PRIMITIVE_DATA_TYPES_H
   12.57 +
   12.58 +
   12.59 +/*For portability, need primitive data types that have a well defined
   12.60 + * size, and well-defined layout into bytes
   12.61 + *To do this, provide standard aliases for all primitive data types
   12.62 + *These aliases must be used in all functions instead of the ANSI types
   12.63 + *
   12.64 + *When PR is used together with BLIS, these definitions will be replaced
   12.65 + * inside each specialization module according to the compiler used in
   12.66 + * that module and the hardware being specialized to.
   12.67 + */
   12.68 +typedef char               bool8;
   12.69 +typedef char               int8;
   12.70 +typedef char               uint8;
   12.71 +typedef short              int16;
   12.72 +typedef unsigned short     uint16;
   12.73 +typedef int                int32;
   12.74 +typedef unsigned int       uint32;
   12.75 +typedef unsigned int       bool32;
   12.76 +typedef long long          int64;
   12.77 +typedef unsigned long long uint64;
   12.78 +typedef float              float32;
   12.79 +typedef double             float64;
   12.80 +//typedef double double      float128;  //GCC doesn't like this
   12.81 +#define float128 double double
   12.82 +
   12.83 +#define TRUE  1
   12.84 +#define FALSE 0
   12.85 +
   12.86 +#endif	/* _PRIMITIVE_DATA_TYPES_H */
   12.87 +
    13.1 --- a/PR__primitives.h	Sun Jul 21 13:41:59 2013 -0700
    13.2 +++ b/PR__primitives.h	Sun Jul 21 13:44:17 2013 -0700
    13.3 @@ -1,57 +1,57 @@
    13.4 -/*
    13.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
    13.6 - *  Licensed under GNU General Public License version 2
    13.7 - *
    13.8 - * Author: seanhalle@yahoo.com
    13.9 - * 
   13.10 - */
   13.11 -
   13.12 -#ifndef  _PR__PRIMITIVES_H
   13.13 -#define	_PR__PRIMITIVES_H
   13.14 -#define _GNU_SOURCE
   13.15 -
   13.16 -void 
   13.17 -recordCoreCtlrReturnLabelAddr(void **returnAddress);
   13.18 -
   13.19 -void 
   13.20 -switchToSlv(SlaveVP *nextSlave);
   13.21 -
   13.22 -void 
   13.23 -switchToCoreCtlr(SlaveVP *nextSlave);
   13.24 -
   13.25 -void 
   13.26 -masterSwitchToCoreCtlr(SlaveVP *nextSlave);
   13.27 -
   13.28 -void 
   13.29 -startUpBirthFn();
   13.30 -
   13.31 -void 
   13.32 -jmpToOneParamFn();
   13.33 -
   13.34 -void 
   13.35 -jmpToTwoParamFn();
   13.36 -
   13.37 -void
   13.38 -asmTerminateCoreCtlr(SlaveVP *currSlv);
   13.39 -void
   13.40 -asmTerminateCoreCtlrSeq(SlaveVP *animatingSlv);
   13.41 -
   13.42 -#define flushRegisters() \
   13.43 -        asm volatile ("":::"%rbx", "%r12", "%r13","%r14","%r15")
   13.44 -
   13.45 -void
   13.46 -PR_int__save_return_into_ptd_to_loc_then_do_ret(void *ptdToLoc);
   13.47 -
   13.48 -void
   13.49 -PR_int__return_to_addr_in_ptd_to_loc(void *ptdToLoc);
   13.50 -
   13.51 -inline void
   13.52 -PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr,
   13.53 -                              void    *param);
   13.54 -
   13.55 -inline void
   13.56 -PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr,
   13.57 -                              void    *param1, void *param2);
   13.58 -
   13.59 -#endif	/* _PR__HW_DEPENDENT_H */
   13.60 -
   13.61 +/*
   13.62 + *  Copyright 2009 OpenSourceResearchInstitute.org
   13.63 + *  Licensed under GNU General Public License version 2
   13.64 + *
   13.65 + * Author: seanhalle@yahoo.com
   13.66 + * 
   13.67 + */
   13.68 +
   13.69 +#ifndef  _PR__PRIMITIVES_H
   13.70 +#define	_PR__PRIMITIVES_H
   13.71 +#define _GNU_SOURCE
   13.72 +
   13.73 +void 
   13.74 +recordCoreCtlrReturnLabelAddr(void **returnAddress);
   13.75 +
   13.76 +void 
   13.77 +switchToSlv(SlaveVP *nextSlave);
   13.78 +
   13.79 +void 
   13.80 +switchToCoreCtlr(SlaveVP *nextSlave);
   13.81 +
   13.82 +void 
   13.83 +masterSwitchToCoreCtlr(SlaveVP *nextSlave);
   13.84 +
   13.85 +void 
   13.86 +startUpBirthFn();
   13.87 +
   13.88 +void 
   13.89 +jmpToOneParamFn();
   13.90 +
   13.91 +void 
   13.92 +jmpToTwoParamFn();
   13.93 +
   13.94 +void
   13.95 +asmTerminateCoreCtlr(SlaveVP *currSlv);
   13.96 +void
   13.97 +asmTerminateCoreCtlrSeq(SlaveVP *animatingSlv);
   13.98 +
   13.99 +#define flushRegisters() \
  13.100 +        asm volatile ("":::"%rbx", "%r12", "%r13","%r14","%r15")
  13.101 +
  13.102 +void
  13.103 +PR_int__save_return_into_ptd_to_loc_then_do_ret(void *ptdToLoc);
  13.104 +
  13.105 +void
  13.106 +PR_int__return_to_addr_in_ptd_to_loc(void *ptdToLoc);
  13.107 +
  13.108 +inline void
  13.109 +PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr,
  13.110 +                              void    *param);
  13.111 +
  13.112 +inline void
  13.113 +PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr,
  13.114 +                              void    *param1, void *param2);
  13.115 +
  13.116 +#endif	/* _PR__HW_DEPENDENT_H */
  13.117 +
    14.1 --- a/PR__structs.h	Sun Jul 21 13:41:59 2013 -0700
    14.2 +++ b/PR__structs.h	Sun Jul 21 13:44:17 2013 -0700
    14.3 @@ -1,432 +1,432 @@
    14.4 -/*
    14.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
    14.6 - *  Licensed under GNU General Public License version 2
    14.7 - *
    14.8 - * Author: seanhalle@yahoo.com
    14.9 - * 
   14.10 - */
   14.11 -
   14.12 -#ifndef _PR__structs_H
   14.13 -#define	_PR__structs_H
   14.14 -#define _GNU_SOURCE
   14.15 -
   14.16 -#include "PR_primitive_data_types.h"
   14.17 -
   14.18 -#include <pthread.h>
   14.19 -#include <sys/time.h>
   14.20 -
   14.21 -
   14.22 -//================================ Typedefs =================================
   14.23 -//===
   14.24 -//=
   14.25 -#define ZERO 0
   14.26 -
   14.27 -typedef unsigned long long    TSCount;
   14.28 -
   14.29 -typedef struct _AnimSlot      AnimSlot;
   14.30 -typedef struct _PRReqst       PRReqst;
   14.31 -typedef struct _SlaveVP       SlaveVP;
   14.32 -typedef struct _MasterVP      MasterVP;
   14.33 -typedef struct _IntervalProbe IntervalProbe;
   14.34 -typedef struct _PRLangEnv     PRLangEnv;  //a prolog
   14.35 -typedef struct _PRMetaTask    PRMetaTask; //a prolog
   14.36 -typedef struct _PRLangData    PRLangData; //a prolog
   14.37 -typedef struct _PRCollElem    PRCollElem; //generic form of the prologs
   14.38 -
   14.39 -typedef bool32   (*SlaveAssigner)  ( void *, AnimSlot* ); //langEnv, slot for HW info
   14.40 -typedef void     (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv
   14.41 -typedef void    *(*CreateHandler)  ( void *, SlaveVP *, void * ); //req, slv, langEnv
   14.42 -typedef void     (*LangShutdownHdlr) ( void * ); //langEnv
   14.43 -typedef void    *(*LangDataCreator)  ( SlaveVP * ); 
   14.44 -typedef void     (*LangDataFreer)    ( void * ); //lang data to free
   14.45 -typedef void    *(*LangMetaTaskCreator)( SlaveVP * );  //when slave has no meta task for magic num 
   14.46 -typedef void     (*LangMetaTaskFreer)  ( void * ); //lang meta task to free
   14.47 -typedef void     (*MakeSlaveReadyFn)   ( SlaveVP *, void * ); //slave and langEnv
   14.48 -typedef void     (*MakeTaskReadyFn)    ( void *, void * ); //langTask and langEnv
   14.49 -typedef void     (*BirthFnPtr)  ( void *, SlaveVP * ); //initData, animSlv
   14.50 -typedef void       BirthFn      ( void *, SlaveVP * ); //initData, animSlv
   14.51 -typedef void     (*ResumeSlvFnPtr) ( SlaveVP *, void * );
   14.52 -      //=========== MEASUREMENT STUFF ==========
   14.53 -        MEAS__Insert_Counter_Handler
   14.54 -      //========================================
   14.55 -
   14.56 -//============================ HW Dependent Fns ================================
   14.57 -
   14.58 -#include "HW_Dependent_Primitives/PR__HW_measurement.h"
   14.59 -#include "HW_Dependent_Primitives/PR__primitives.h"
   14.60 -
   14.61 -
   14.62 -typedef struct
   14.63 - { //These are set by the plugin during startup and the application
   14.64 -   char *assignerInfo;
   14.65 -   char *appInfo;
   14.66 -   char *inputInfo;
   14.67 - }
   14.68 -PRSysMetaInfo;
   14.69 -
   14.70 -//=====================  Process Data Struct  ======================
   14.71 -
   14.72 -/*This structure holds all the information PR needs to manage a program.  PR
   14.73 - * stores information about what percent of CPU time the program is getting, 
   14.74 - * 
   14.75 - */
   14.76 -typedef struct
   14.77 - { 
   14.78 -   int32     numEnvsWithWork;
   14.79 -   void     *resultToReturn;
   14.80 -    
   14.81 -   PRLangEnv **langEnvs;     //used as a hash table
   14.82 -   PRLangEnv **protoLangEnvsList; //for fast linear scan of envs
   14.83 -   int32      numLangEnvs;   //for fast linear scan of envs
   14.84 -    
   14.85 -   SlaveVP        *seedSlv;
   14.86 -   
   14.87 -   int32           numLiveGenericSlvs;
   14.88 -   int32           numLiveTasks;
   14.89 -
   14.90 -   SlaveAssigner   overrideAssigner;
   14.91 -  
   14.92 -   
   14.93 -   
   14.94 -      //These are used to coord with an OS thread waiting for process to end
   14.95 -   bool32          hasWaitingToEnd;
   14.96 -   bool32          executionIsComplete;
   14.97 -   pthread_mutex_t doneLock;
   14.98 -   pthread_cond_t  doneCond;   
   14.99 -   pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting
  14.100 -
  14.101 -      //=========== MEASUREMENT STUFF =============
  14.102 -       IntervalProbe   **intervalProbes;
  14.103 -       PrivDynArrayInfo *dynIntervalProbesInfo;
  14.104 -       HashTable        *probeNameHashTbl;
  14.105 -       int32             masterCreateProbeID;
  14.106 -       float64           createPtInSecs; //real-clock time PR initialized
  14.107 -       Histogram       **measHists;
  14.108 -       PrivDynArrayInfo *measHistsInfo;
  14.109 -       MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
  14.110 -       MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
  14.111 -       MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
  14.112 -       MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
  14.113 -       MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
  14.114 -       MEAS__Insert_System_Meas_Fields_into_MasterEnv;
  14.115 -       MEAS__Insert_Counter_Meas_Fields_into_MasterEnv;
  14.116 -      //==========================================
  14.117 - }
  14.118 -PRProcess;
  14.119 -
  14.120 -
  14.121 -//============= Request Related ===========
  14.122 -//
  14.123 -
  14.124 -enum PRReqstType  //avoid starting enums at 0, for debug reasons
  14.125 - {
  14.126 -   TaskCreate = 1,
  14.127 -   TaskEnd,
  14.128 -   SlvCreate,
  14.129 -   SlvDissipate,
  14.130 -   Language,
  14.131 -   Service,       //To invoke a PR provided equivalent of a language request (ex: probe)
  14.132 -   Hardware,
  14.133 -   IO,
  14.134 -   OSCall, 
  14.135 -   LangShutdown,
  14.136 -   ProcessEnd,
  14.137 -   PRShutdown
  14.138 - };
  14.139 -
  14.140 -
  14.141 -struct _PRReqst
  14.142 - {
  14.143 -   enum PRReqstType   reqType;//used for special forms that have PR behavior
  14.144 -   void              *langReq;
  14.145 -   PRProcess         *processReqIsIn;
  14.146 -   int32              langMagicNumber;
  14.147 -   SlaveVP           *requestingSlave;
  14.148 -   
  14.149 -   BirthFnPtr      topLevelFn;
  14.150 -   void              *initData;
  14.151 -   int32             *ID;
  14.152 -   
  14.153 -      //The request handling structure is a bit messy..  for special forms, 
  14.154 -      // such as create and dissipate, the language inserts pointer to handler
  14.155 -      // fn directly into the request..  might change to this for all requests
  14.156 -   RequestHandler    handler; //pointer to handler fn 
  14.157 -   CreateHandler     createHdlr; //special because returns something
  14.158 -   int32             createSuspendedGroup; //must be non-zero
  14.159 -   
  14.160 -   PRReqst *nextReqst;
  14.161 - };
  14.162 -//PRReqst
  14.163 -
  14.164 -enum PRServiceReqType   //These are equivalent to lang requests, but for
  14.165 - {                    // PR's services available directly to app, like OS
  14.166 -   make_probe = 1,    // and probe services -- like a PR-wide built-in lang
  14.167 -   throw_excp,
  14.168 -   openFile,
  14.169 -   otherIO
  14.170 - };
  14.171 -
  14.172 -typedef struct
  14.173 - { enum PRServiceReqType   reqType;
  14.174 -   SlaveVP             *requestingSlv;
  14.175 -   char                *nameStr;  //for create probe
  14.176 -   char                *msgStr;   //for exception
  14.177 -   void                *exceptionData;
  14.178 - }
  14.179 -PRServiceReq;
  14.180 -
  14.181 -
  14.182 -//====================  Core data structures  ===================
  14.183 -
  14.184 -typedef struct
  14.185 - {
  14.186 -   //for future expansion
  14.187 - }
  14.188 -SlotPerfInfo;
  14.189 -
  14.190 -struct _AnimSlot
  14.191 - {
  14.192 -   int32         workIsDone;
  14.193 -   int32         needsWorkAssigned;
  14.194 -   SlaveVP      *slaveAssignedToSlot;
  14.195 -   
  14.196 -   int32         slotIdx;  //needed by Holistic Model's data gathering
  14.197 -   int32         coreSlotIsOn;
  14.198 -   SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core
  14.199 - };
  14.200 -//AnimSlot
  14.201 -
  14.202 -enum VPtype 
  14.203 - { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks
  14.204 -   FreeTaskSlv,   //When a suspended task ends, the slave becomes this
  14.205 -   GenericSlv,     //the VP is explicitly seen in the app code, or task suspends
  14.206 -   SeedSlv,
  14.207 -   Master_VP,
  14.208 -   ShutdownVP,
  14.209 -   IdleVP
  14.210 - };
  14.211 - 
  14.212 -/*This structure embodies the state of a slaveVP.  It is reused for masterVP
  14.213 - * and shutdownVPs.
  14.214 - */
  14.215 -struct _SlaveVP
  14.216 - {    //The offsets of these fields are hard-coded into assembly
  14.217 -   void       *stackPtr;         //save the core's stack ptr when suspend
  14.218 -   void       *framePtr;         //save core's frame ptr when suspend
  14.219 -   void       *resumeInstrPtr;   //save core's program-counter when suspend
  14.220 -   void       *coreCtlrFramePtr; //restore before jmp back to core controller
  14.221 -   void       *coreCtlrStackPtr; //restore before jmp back to core controller
  14.222 -   
  14.223 -      //============ below this, no fields are used in asm =============
  14.224 -   
  14.225 -   void       *startOfStack;  //used to free, and to point slave to Fn
  14.226 -   PRProcess  *processSlaveIsIn;
  14.227 -   enum VPtype typeOfVP;      //Slave vs Master vs Shutdown..
  14.228 -   int32       slaveNum;      //each slave given it's seq in creation
  14.229 -   int32      *ID;       //App defines meaning of each int in array
  14.230 -   int32       coreAnimatedBy; 
  14.231 -   int32       numTimesAssignedToASlot;   //Each assign is for one work-unit, so is an ID
  14.232 -      //note, a scheduling decision is uniquely identified by the triple:
  14.233 -      // <slaveNum, coreAnimatedBy, numTimesAssignedToASlot> -- used in record & replay
  14.234 -   
  14.235 -      //for comm -- between master and coreCtlr & btwn wrapper lib and plugin
  14.236 -   AnimSlot   *animSlotAssignedTo;
  14.237 -   PRReqst    *request;      //wrapper lib puts in requests, plugin takes out
  14.238 -   void       *dataRetFromReq;//Return vals from plugin to Wrapper Lib
  14.239 -
  14.240 -      //For language specific data that needs to be in the slave
  14.241 -      //These are accessed  directly for single-lang, but multi-lang places
  14.242 -      // a holder here instead, then uses magic num to get lang's version
  14.243 -   PRLangData  **langDatas;  //Lang saves lang-specific things in slave here
  14.244 -   PRMetaTask  **metaTasks;
  14.245 -
  14.246 -        //=========== MEASUREMENT STUFF ==========
  14.247 -         MEAS__Insert_Meas_Fields_into_Slave;
  14.248 -         float64     createPtInSecs;  //time VP created, in seconds
  14.249 -        //========================================
  14.250 -         
  14.251 -//   int8       cacheLinePad[512 - sizeof(contents)]; //for false sharing
  14.252 - };
  14.253 -//SlaveVP
  14.254 -
  14.255 - 
  14.256 -enum PRMode
  14.257 - { SingleLang = 1,
  14.258 -   StandaloneWTasks,
  14.259 -   MultiLang      
  14.260 - };
  14.261 - 
  14.262 -/* The one and only global variable, holds many odds and ends
  14.263 - */
  14.264 -typedef struct
  14.265 - {    //The offsets of these fields are hard-coded into assembly
  14.266 -   void            *coreCtlrReturnPt;    //offset to this field used in asm
  14.267 -   int8             falseSharePad1[256 - sizeof(void*)];
  14.268 -   int32            masterLock;          //offset to this field used in asm
  14.269 -   int8             falseSharePad2[256 - sizeof(int32)];
  14.270 -   int32            wrapperLock;         //offset to this field used in asm
  14.271 -   int8             falseSharePad3[256 - sizeof(int32)];
  14.272 -   int32            mallocLock;          //offset to this field used in asm
  14.273 -   int8             falseSharePad4[256 - sizeof(int32)];
  14.274 -      //============ below this, no fields are used in asm =============
  14.275 -
  14.276 -      //Basic PR infrastructure
  14.277 -//   enum PRMode      mode;
  14.278 -   SlaveVP        **masterVPs;
  14.279 -   AnimSlot      ***allAnimSlots;
  14.280 -   PrivQueueStruc  *slaveRecycleQ;
  14.281 -   SlaveVP         *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
  14.282 -   SlaveVP         *idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
  14.283 -   
  14.284 -      //Memory management related
  14.285 -   MallocArrays    *freeLists;
  14.286 -   int32            amtOfOutstandingMem;//total currently allocated
  14.287 -
  14.288 -      //Random number seeds -- random nums used in various places  
  14.289 -   uint32_t         seed1;
  14.290 -   uint32_t         seed2;
  14.291 -
  14.292 -   PRSysMetaInfo   *metaInfo; //info about this PR system -- vers, build, etc
  14.293 -   
  14.294 -   //============== This only used by multi-lang mode ============
  14.295 -   PRProcess      **processes;
  14.296 -   int32            numProcesses;
  14.297 -   int32            currProcessIdx;    //used to choose which process gets slot
  14.298 -   int32            firstProcessReady; //use while starting up coreCtlr
  14.299 -   
  14.300 -      //initialize flags for waiting for activity within PR to complete
  14.301 -   bool32           allActivityIsDone;
  14.302 -   pthread_mutex_t  activityDoneLock;
  14.303 -   pthread_cond_t   activityDoneCond;   
  14.304 -
  14.305 -   SlaveAssigner    overrideAssigner;
  14.306 -   
  14.307 -   //============== Below this is only used by single-lang mode ==============
  14.308 -   void            *protoLangEnv;
  14.309 -      //Slave creation -- global count of slaves existing, across langs and processes
  14.310 -   int32            numSlavesCreated;  //used to give unique ID to processor
  14.311 -   int32            numTasksCreated;   //to give unique ID to a task
  14.312 -   int32            numSlavesAlive;
  14.313 -
  14.314 -   bool32          *coreIsDone;
  14.315 -   int32            numCoresDone;
  14.316 -   int32            shutdownInitiated;
  14.317 -   
  14.318 -   
  14.319 -      //=========== MEASUREMENT STUFF =============
  14.320 -       IntervalProbe   **intervalProbes;
  14.321 -       PrivDynArrayInfo *dynIntervalProbesInfo;
  14.322 -       HashTable        *probeNameHashTbl;
  14.323 -       int32             masterCreateProbeID;
  14.324 -       float64           createPtInSecs; //real-clock time PR initialized
  14.325 -       Histogram       **measHists;
  14.326 -       PrivDynArrayInfo *measHistsInfo;
  14.327 -       MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
  14.328 -       MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
  14.329 -       MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
  14.330 -       MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
  14.331 -       MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
  14.332 -       MEAS__Insert_System_Meas_Fields_into_MasterEnv;
  14.333 -       MEAS__Insert_Counter_Meas_Fields_into_MasterEnv;
  14.334 -      //==========================================
  14.335 - }
  14.336 -TopEnv;
  14.337 -
  14.338 -
  14.339 -//===================== These are prologs ====================
  14.340 -//===A prolog is data immediately before pointer returned by a create function.
  14.341 -//=
  14.342 -struct _PRLangEnv
  14.343 - { //============== First two must match PRCollElem ==============
  14.344 -   int32     langMagicNumber; //indexes into hash array of langEnvs in PRProcess
  14.345 -   PRLangEnv *chainedLangEnv;   //chains to langEnvs with same hash
  14.346 -   //=============================================================
  14.347 -   
  14.348 -   SlaveAssigner    workAssigner;
  14.349 -   LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown
  14.350 -   LangDataCreator  langDataCreator;
  14.351 -   LangMetaTaskCreator langMetaTaskCreator;
  14.352 -   MakeSlaveReadyFn makeSlaveReadyFn;
  14.353 -   MakeTaskReadyFn  makeTaskReadyFn;
  14.354 -     
  14.355 -      //when multi-lang, master polls lang env's to find one with work in it..
  14.356 -      // in single-lang case, flag ignored, master always asks lang for work
  14.357 -   int32           hasWork;
  14.358 -   PRProcess      *processEnvIsIn;
  14.359 -   
  14.360 -   int32           idxInProcess; //index into array of langEnvs in the process
  14.361 -   
  14.362 -   int32           numReadyWork;
  14.363 -   
  14.364 -   int32           numLiveWork;
  14.365 -   PrivQueueStruc *waitingForWorkToEndQ;
  14.366 - };
  14.367 -//PRLangEnv -- this is the prolog of every lang's lang env
  14.368 -
  14.369 -enum PRTaskType
  14.370 - { GenericSlave = 1,
  14.371 -   SlotTask,
  14.372 -   FreeTask
  14.373 - };
  14.374 -
  14.375 -struct _PRMetaTask
  14.376 - { //============== First two must match PRCollElem ==============
  14.377 -   int32           langMagicNumber;
  14.378 -   PRMetaTask     *chainedMetaTask;
  14.379 -   //=============================================================
  14.380 -   enum PRTaskType taskType;
  14.381 -   int32          *ID;              //is standard PR ID
  14.382 -   PRProcess      *processTaskIsIn;
  14.383 -   SlaveVP        *slaveAssignedTo; //not valid until task animated
  14.384 -   BirthFnPtr   topLevelFn;      //This is the Fn executes as the task
  14.385 -   void           *initData;        //The data taken by the function
  14.386 -   LangMetaTaskFreer freer;
  14.387 -   bool32          goAheadAndFree;
  14.388 -
  14.389 -   //NOTE: info needed for "wait" functionality is inside lang's metaTask
  14.390 - };
  14.391 -//PRMetaTask -- prolog of every lang's meta task
  14.392 -
  14.393 -struct _PRLangData
  14.394 - { //============== First two must match PRCollElem ==============
  14.395 -   int32         langMagicNumber;
  14.396 -   PRLangData   *chainedLangData;
  14.397 -   //=============================================================
  14.398 -   LangDataFreer  freer;
  14.399 -   bool32         goAheadAndFree;
  14.400 -   SlaveVP       *slaveAssignedTo;
  14.401 - };
  14.402 -//PRLangData -- this is the prolog of each lang's lang data
  14.403 -
  14.404 -struct _PRCollElem
  14.405 - {
  14.406 -   int32       hash;
  14.407 -   PRCollElem *chained;
  14.408 - };
  14.409 -//PRCollElem -- this is generic form of all the prologs
  14.410 -
  14.411 -
  14.412 -
  14.413 -//=========================  Extra Stuff Data Strucs  =======================
  14.414 -typedef struct
  14.415 - {
  14.416 -
  14.417 - }
  14.418 -PRExcp; //exception
  14.419 -
  14.420 -//=======================  OS Thread related  ===============================
  14.421 -
  14.422 -void * coreController( void *paramsIn );  //standard PThreads fn prototype
  14.423 -void * coreCtlr_Seq( void *paramsIn );  //standard PThreads fn prototype
  14.424 -void animationMaster( void *initData, SlaveVP *masterVP );
  14.425 -
  14.426 -
  14.427 -typedef struct
  14.428 - {
  14.429 -   void           *endThdPt;
  14.430 -   unsigned int    coreNum;
  14.431 - }
  14.432 -ThdParams;
  14.433 -
  14.434 -#endif	/* _PR__structs_H */
  14.435 -
  14.436 +/*
  14.437 + *  Copyright 2009 OpenSourceResearchInstitute.org
  14.438 + *  Licensed under GNU General Public License version 2
  14.439 + *
  14.440 + * Author: seanhalle@yahoo.com
  14.441 + * 
  14.442 + */
  14.443 +
  14.444 +#ifndef _PR__structs_H
  14.445 +#define	_PR__structs_H
  14.446 +#define _GNU_SOURCE
  14.447 +
  14.448 +#include "PR_primitive_data_types.h"
  14.449 +
  14.450 +#include <pthread.h>
  14.451 +#include <sys/time.h>
  14.452 +
  14.453 +
  14.454 +//================================ Typedefs =================================
  14.455 +//===
  14.456 +//=
  14.457 +#define ZERO 0
  14.458 +
  14.459 +typedef unsigned long long    TSCount;
  14.460 +
  14.461 +typedef struct _AnimSlot      AnimSlot;
  14.462 +typedef struct _PRReqst       PRReqst;
  14.463 +typedef struct _SlaveVP       SlaveVP;
  14.464 +typedef struct _MasterVP      MasterVP;
  14.465 +typedef struct _IntervalProbe IntervalProbe;
  14.466 +typedef struct _PRLangEnv     PRLangEnv;  //a prolog
  14.467 +typedef struct _PRMetaTask    PRMetaTask; //a prolog
  14.468 +typedef struct _PRLangData    PRLangData; //a prolog
  14.469 +typedef struct _PRCollElem    PRCollElem; //generic form of the prologs
  14.470 +
  14.471 +typedef bool32   (*SlaveAssigner)  ( void *, AnimSlot* ); //langEnv, slot for HW info
  14.472 +typedef void     (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv
  14.473 +typedef void    *(*CreateHandler)  ( void *, SlaveVP *, void * ); //req, slv, langEnv
  14.474 +typedef void     (*LangShutdownHdlr) ( void * ); //langEnv
  14.475 +typedef void    *(*LangDataCreator)  ( SlaveVP * ); 
  14.476 +typedef void     (*LangDataFreer)    ( void * ); //lang data to free
  14.477 +typedef void    *(*LangMetaTaskCreator)( SlaveVP * );  //when slave has no meta task for magic num 
  14.478 +typedef void     (*LangMetaTaskFreer)  ( void * ); //lang meta task to free
  14.479 +typedef void     (*MakeSlaveReadyFn)   ( SlaveVP *, void * ); //slave and langEnv
  14.480 +typedef void     (*MakeTaskReadyFn)    ( void *, void * ); //langTask and langEnv
  14.481 +typedef void     (*BirthFnPtr)  ( void *, SlaveVP * ); //initData, animSlv
  14.482 +typedef void       BirthFn      ( void *, SlaveVP * ); //initData, animSlv
  14.483 +typedef void     (*ResumeSlvFnPtr) ( SlaveVP *, void * );
  14.484 +      //=========== MEASUREMENT STUFF ==========
  14.485 +        MEAS__Insert_Counter_Handler
  14.486 +      //========================================
  14.487 +
  14.488 +//============================ HW Dependent Fns ================================
  14.489 +
  14.490 +#include "HW_Dependent_Primitives/PR__HW_measurement.h"
  14.491 +#include "HW_Dependent_Primitives/PR__primitives.h"
  14.492 +
  14.493 +
  14.494 +typedef struct
  14.495 + { //These are set by the plugin during startup and the application
  14.496 +   char *assignerInfo;
  14.497 +   char *appInfo;
  14.498 +   char *inputInfo;
  14.499 + }
  14.500 +PRSysMetaInfo;
  14.501 +
  14.502 +//=====================  Process Data Struct  ======================
  14.503 +
  14.504 +/*This structure holds all the information PR needs to manage a program.  PR
  14.505 + * stores information about what percent of CPU time the program is getting, 
  14.506 + * 
  14.507 + */
  14.508 +typedef struct
  14.509 + { 
  14.510 +   int32     numEnvsWithWork;
  14.511 +   void     *resultToReturn;
  14.512 +    
  14.513 +   PRLangEnv **langEnvs;     //used as a hash table
  14.514 +   PRLangEnv **protoLangEnvsList; //for fast linear scan of envs
  14.515 +   int32      numLangEnvs;   //for fast linear scan of envs
  14.516 +    
  14.517 +   SlaveVP        *seedSlv;
  14.518 +   
  14.519 +   int32           numLiveGenericSlvs;
  14.520 +   int32           numLiveTasks;
  14.521 +
  14.522 +   SlaveAssigner   overrideAssigner;
  14.523 +  
  14.524 +   
  14.525 +   
  14.526 +      //These are used to coord with an OS thread waiting for process to end
  14.527 +   bool32          hasWaitingToEnd;
  14.528 +   bool32          executionIsComplete;
  14.529 +   pthread_mutex_t doneLock;
  14.530 +   pthread_cond_t  doneCond;   
  14.531 +   pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting
  14.532 +
  14.533 +      //=========== MEASUREMENT STUFF =============
  14.534 +       IntervalProbe   **intervalProbes;
  14.535 +       PrivDynArrayInfo *dynIntervalProbesInfo;
  14.536 +       HashTable        *probeNameHashTbl;
  14.537 +       int32             masterCreateProbeID;
  14.538 +       float64           createPtInSecs; //real-clock time PR initialized
  14.539 +       Histogram       **measHists;
  14.540 +       PrivDynArrayInfo *measHistsInfo;
  14.541 +       MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
  14.542 +       MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
  14.543 +       MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
  14.544 +       MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
  14.545 +       MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
  14.546 +       MEAS__Insert_System_Meas_Fields_into_MasterEnv;
  14.547 +       MEAS__Insert_Counter_Meas_Fields_into_MasterEnv;
  14.548 +      //==========================================
  14.549 + }
  14.550 +PRProcess;
  14.551 +
  14.552 +
  14.553 +//============= Request Related ===========
  14.554 +//
  14.555 +
  14.556 +enum PRReqstType  //avoid starting enums at 0, for debug reasons
  14.557 + {
  14.558 +   TaskCreate = 1,
  14.559 +   TaskEnd,
  14.560 +   SlvCreate,
  14.561 +   SlvDissipate,
  14.562 +   Language,
  14.563 +   Service,       //To invoke a PR provided equivalent of a language request (ex: probe)
  14.564 +   Hardware,
  14.565 +   IO,
  14.566 +   OSCall, 
  14.567 +   LangShutdown,
  14.568 +   ProcessEnd,
  14.569 +   PRShutdown
  14.570 + };
  14.571 +
  14.572 +
  14.573 +struct _PRReqst
  14.574 + {
  14.575 +   enum PRReqstType   reqType;//used for special forms that have PR behavior
  14.576 +   void              *langReq;
  14.577 +   PRProcess         *processReqIsIn;
  14.578 +   int32              langMagicNumber;
  14.579 +   SlaveVP           *requestingSlave;
  14.580 +   
  14.581 +   BirthFnPtr      topLevelFn;
  14.582 +   void              *initData;
  14.583 +   int32             *ID;
  14.584 +   
  14.585 +      //The request handling structure is a bit messy..  for special forms, 
  14.586 +      // such as create and dissipate, the language inserts pointer to handler
  14.587 +      // fn directly into the request..  might change to this for all requests
  14.588 +   RequestHandler    handler; //pointer to handler fn 
  14.589 +   CreateHandler     createHdlr; //special because returns something
  14.590 +   int32             createSuspendedGroup; //must be non-zero
  14.591 +   
  14.592 +   PRReqst *nextReqst;
  14.593 + };
  14.594 +//PRReqst
  14.595 +
  14.596 +enum PRServiceReqType   //These are equivalent to lang requests, but for
  14.597 + {                    // PR's services available directly to app, like OS
  14.598 +   make_probe = 1,    // and probe services -- like a PR-wide built-in lang
  14.599 +   throw_excp,
  14.600 +   openFile,
  14.601 +   otherIO
  14.602 + };
  14.603 +
  14.604 +typedef struct
  14.605 + { enum PRServiceReqType   reqType;
  14.606 +   SlaveVP             *requestingSlv;
  14.607 +   char                *nameStr;  //for create probe
  14.608 +   char                *msgStr;   //for exception
  14.609 +   void                *exceptionData;
  14.610 + }
  14.611 +PRServiceReq;
  14.612 +
  14.613 +
  14.614 +//====================  Core data structures  ===================
  14.615 +
  14.616 +typedef struct
  14.617 + {
  14.618 +   //for future expansion
  14.619 + }
  14.620 +SlotPerfInfo;
  14.621 +
  14.622 +struct _AnimSlot
  14.623 + {
  14.624 +   int32         workIsDone;
  14.625 +   int32         needsWorkAssigned;
  14.626 +   SlaveVP      *slaveAssignedToSlot;
  14.627 +   
  14.628 +   int32         slotIdx;  //needed by Holistic Model's data gathering
  14.629 +   int32         coreSlotIsOn;
  14.630 +   SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core
  14.631 + };
  14.632 +//AnimSlot
  14.633 +
  14.634 +enum VPtype 
  14.635 + { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks
  14.636 +   FreeTaskSlv,   //When a suspended task ends, the slave becomes this
  14.637 +   GenericSlv,     //the VP is explicitly seen in the app code, or task suspends
  14.638 +   SeedSlv,
  14.639 +   Master_VP,
  14.640 +   ShutdownVP,
  14.641 +   IdleVP
  14.642 + };
  14.643 + 
  14.644 +/*This structure embodies the state of a slaveVP.  It is reused for masterVP
  14.645 + * and shutdownVPs.
  14.646 + */
  14.647 +struct _SlaveVP
  14.648 + {    //The offsets of these fields are hard-coded into assembly
  14.649 +   void       *stackPtr;         //save the core's stack ptr when suspend
  14.650 +   void       *framePtr;         //save core's frame ptr when suspend
  14.651 +   void       *resumeInstrPtr;   //save core's program-counter when suspend
  14.652 +   void       *coreCtlrFramePtr; //restore before jmp back to core controller
  14.653 +   void       *coreCtlrStackPtr; //restore before jmp back to core controller
  14.654 +   
  14.655 +      //============ below this, no fields are used in asm =============
  14.656 +   
  14.657 +   void       *startOfStack;  //used to free, and to point slave to Fn
  14.658 +   PRProcess  *processSlaveIsIn;
  14.659 +   enum VPtype typeOfVP;      //Slave vs Master vs Shutdown..
  14.660 +   int32       slaveNum;      //each slave given it's seq in creation
  14.661 +   int32      *ID;       //App defines meaning of each int in array
  14.662 +   int32       coreAnimatedBy; 
  14.663 +   int32       numTimesAssignedToASlot;   //Each assign is for one work-unit, so is an ID
  14.664 +      //note, a scheduling decision is uniquely identified by the triple:
  14.665 +      // <slaveNum, coreAnimatedBy, numTimesAssignedToASlot> -- used in record & replay
  14.666 +   
  14.667 +      //for comm -- between master and coreCtlr & btwn wrapper lib and plugin
  14.668 +   AnimSlot   *animSlotAssignedTo;
  14.669 +   PRReqst    *request;      //wrapper lib puts in requests, plugin takes out
  14.670 +   void       *dataRetFromReq;//Return vals from plugin to Wrapper Lib
  14.671 +
  14.672 +      //For language specific data that needs to be in the slave
  14.673 +      //These are accessed  directly for single-lang, but multi-lang places
  14.674 +      // a holder here instead, then uses magic num to get lang's version
  14.675 +   PRLangData  **langDatas;  //Lang saves lang-specific things in slave here
  14.676 +   PRMetaTask  **metaTasks;
  14.677 +
  14.678 +        //=========== MEASUREMENT STUFF ==========
  14.679 +         MEAS__Insert_Meas_Fields_into_Slave;
  14.680 +         float64     createPtInSecs;  //time VP created, in seconds
  14.681 +        //========================================
  14.682 +         
  14.683 +//   int8       cacheLinePad[512 - sizeof(contents)]; //for false sharing
  14.684 + };
  14.685 +//SlaveVP
  14.686 +
  14.687 + 
  14.688 +enum PRMode
  14.689 + { SingleLang = 1,
  14.690 +   StandaloneWTasks,
  14.691 +   MultiLang      
  14.692 + };
  14.693 + 
  14.694 +/* The one and only global variable, holds many odds and ends
  14.695 + */
  14.696 +typedef struct
  14.697 + {    //The offsets of these fields are hard-coded into assembly
  14.698 +   void            *coreCtlrReturnPt;    //offset to this field used in asm
  14.699 +   int8             falseSharePad1[256 - sizeof(void*)];
  14.700 +   int32            masterLock;          //offset to this field used in asm
  14.701 +   int8             falseSharePad2[256 - sizeof(int32)];
  14.702 +   int32            wrapperLock;         //offset to this field used in asm
  14.703 +   int8             falseSharePad3[256 - sizeof(int32)];
  14.704 +   int32            mallocLock;          //offset to this field used in asm
  14.705 +   int8             falseSharePad4[256 - sizeof(int32)];
  14.706 +      //============ below this, no fields are used in asm =============
  14.707 +
  14.708 +      //Basic PR infrastructure
  14.709 +//   enum PRMode      mode;
  14.710 +   SlaveVP        **masterVPs;
  14.711 +   AnimSlot      ***allAnimSlots;
  14.712 +   PrivQueueStruc  *slaveRecycleQ;
  14.713 +   SlaveVP         *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
  14.714 +   SlaveVP         *idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
  14.715 +   
  14.716 +      //Memory management related
  14.717 +   MallocArrays    *freeLists;
  14.718 +   int32            amtOfOutstandingMem;//total currently allocated
  14.719 +
  14.720 +      //Random number seeds -- random nums used in various places  
  14.721 +   uint32_t         seed1;
  14.722 +   uint32_t         seed2;
  14.723 +
  14.724 +   PRSysMetaInfo   *metaInfo; //info about this PR system -- vers, build, etc
  14.725 +   
  14.726 +   //============== This only used by multi-lang mode ============
  14.727 +   PRProcess      **processes;
  14.728 +   int32            numProcesses;
  14.729 +   int32            currProcessIdx;    //used to choose which process gets slot
  14.730 +   int32            firstProcessReady; //use while starting up coreCtlr
  14.731 +   
  14.732 +      //initialize flags for waiting for activity within PR to complete
  14.733 +   bool32           allActivityIsDone;
  14.734 +   pthread_mutex_t  activityDoneLock;
  14.735 +   pthread_cond_t   activityDoneCond;   
  14.736 +
  14.737 +   SlaveAssigner    overrideAssigner;
  14.738 +   
  14.739 +   //============== Below this is only used by single-lang mode ==============
  14.740 +   void            *protoLangEnv;
  14.741 +      //Slave creation -- global count of slaves existing, across langs and processes
  14.742 +   int32            numSlavesCreated;  //used to give unique ID to processor
  14.743 +   int32            numTasksCreated;   //to give unique ID to a task
  14.744 +   int32            numSlavesAlive;
  14.745 +
  14.746 +   bool32          *coreIsDone;
  14.747 +   int32            numCoresDone;
  14.748 +   int32            shutdownInitiated;
  14.749 +   
  14.750 +   
  14.751 +      //=========== MEASUREMENT STUFF =============
  14.752 +       IntervalProbe   **intervalProbes;
  14.753 +       PrivDynArrayInfo *dynIntervalProbesInfo;
  14.754 +       HashTable        *probeNameHashTbl;
  14.755 +       int32             masterCreateProbeID;
  14.756 +       float64           createPtInSecs; //real-clock time PR initialized
  14.757 +       Histogram       **measHists;
  14.758 +       PrivDynArrayInfo *measHistsInfo;
  14.759 +       MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
  14.760 +       MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
  14.761 +       MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
  14.762 +       MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
  14.763 +       MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
  14.764 +       MEAS__Insert_System_Meas_Fields_into_MasterEnv;
  14.765 +       MEAS__Insert_Counter_Meas_Fields_into_MasterEnv;
  14.766 +      //==========================================
  14.767 + }
  14.768 +TopEnv;
  14.769 +
  14.770 +
  14.771 +//===================== These are prologs ====================
  14.772 +//===A prolog is data immediately before pointer returned by a create function.
  14.773 +//=
  14.774 +struct _PRLangEnv
  14.775 + { //============== First two must match PRCollElem ==============
  14.776 +   int32     langMagicNumber; //indexes into hash array of langEnvs in PRProcess
  14.777 +   PRLangEnv *chainedLangEnv;   //chains to langEnvs with same hash
  14.778 +   //=============================================================
  14.779 +   
  14.780 +   SlaveAssigner    workAssigner;
  14.781 +   LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown
  14.782 +   LangDataCreator  langDataCreator;
  14.783 +   LangMetaTaskCreator langMetaTaskCreator;
  14.784 +   MakeSlaveReadyFn makeSlaveReadyFn;
  14.785 +   MakeTaskReadyFn  makeTaskReadyFn;
  14.786 +     
  14.787 +      //when multi-lang, master polls lang env's to find one with work in it..
  14.788 +      // in single-lang case, flag ignored, master always asks lang for work
  14.789 +   int32           hasWork;
  14.790 +   PRProcess      *processEnvIsIn;
  14.791 +   
  14.792 +   int32           idxInProcess; //index into array of langEnvs in the process
  14.793 +   
  14.794 +   int32           numReadyWork;
  14.795 +   
  14.796 +   int32           numLiveWork;
  14.797 +   PrivQueueStruc *waitingForWorkToEndQ;
  14.798 + };
  14.799 +//PRLangEnv -- this is the prolog of every lang's lang env
  14.800 +
  14.801 +enum PRTaskType
  14.802 + { GenericSlave = 1,
  14.803 +   SlotTask,
  14.804 +   FreeTask
  14.805 + };
  14.806 +
  14.807 +struct _PRMetaTask
  14.808 + { //============== First two must match PRCollElem ==============
  14.809 +   int32           langMagicNumber;
  14.810 +   PRMetaTask     *chainedMetaTask;
  14.811 +   //=============================================================
  14.812 +   enum PRTaskType taskType;
  14.813 +   int32          *ID;              //is standard PR ID
  14.814 +   PRProcess      *processTaskIsIn;
  14.815 +   SlaveVP        *slaveAssignedTo; //not valid until task animated
  14.816 +   BirthFnPtr   topLevelFn;      //This is the Fn executes as the task
  14.817 +   void           *initData;        //The data taken by the function
  14.818 +   LangMetaTaskFreer freer;
  14.819 +   bool32          goAheadAndFree;
  14.820 +
  14.821 +   //NOTE: info needed for "wait" functionality is inside lang's metaTask
  14.822 + };
  14.823 +//PRMetaTask -- prolog of every lang's meta task
  14.824 +
  14.825 +struct _PRLangData
  14.826 + { //============== First two must match PRCollElem ==============
  14.827 +   int32         langMagicNumber;
  14.828 +   PRLangData   *chainedLangData;
  14.829 +   //=============================================================
  14.830 +   LangDataFreer  freer;
  14.831 +   bool32         goAheadAndFree;
  14.832 +   SlaveVP       *slaveAssignedTo;
  14.833 + };
  14.834 +//PRLangData -- this is the prolog of each lang's lang data
  14.835 +
  14.836 +struct _PRCollElem
  14.837 + {
  14.838 +   int32       hash;
  14.839 +   PRCollElem *chained;
  14.840 + };
  14.841 +//PRCollElem -- this is generic form of all the prologs
  14.842 +
  14.843 +
  14.844 +
  14.845 +//=========================  Extra Stuff Data Strucs  =======================
  14.846 +typedef struct
  14.847 + {
  14.848 +
  14.849 + }
  14.850 +PRExcp; //exception
  14.851 +
  14.852 +//=======================  OS Thread related  ===============================
  14.853 +
  14.854 +void * coreController( void *paramsIn );  //standard PThreads fn prototype
  14.855 +void * coreCtlr_Seq( void *paramsIn );  //standard PThreads fn prototype
  14.856 +void animationMaster( void *initData, SlaveVP *masterVP );
  14.857 +
  14.858 +
  14.859 +typedef struct
  14.860 + {
  14.861 +   void           *endThdPt;
  14.862 +   unsigned int    coreNum;
  14.863 + }
  14.864 +ThdParams;
  14.865 +
  14.866 +#endif	/* _PR__structs_H */
  14.867 +
    15.1 --- a/__README_repo_purpose__.txt	Sun Jul 21 13:41:59 2013 -0700
    15.2 +++ b/__README_repo_purpose__.txt	Sun Jul 21 13:44:17 2013 -0700
    15.3 @@ -1,16 +1,22 @@
    15.4 -
    15.5 -This repository contains the common definitions that are used by all the other sub-directories..
    15.6 -
    15.7 -That is, the wrapper libraries, as well as the core implementations of both PR and the language, all include the files from this directory.
    15.8 -
    15.9 -Any includes that are needed by multiple other repositories are held in this repository.
   15.10 -
   15.11 -Hence, this repo will be included with the application, along with the language's wrapper lib and PR's wrapper lib.
   15.12 -
   15.13 -This repo will also be included in the place where a given leaf-level proto-runtime library is developed, and where each upper level proto-runtime library is developed.
   15.14 -
   15.15 -And, it will be included where the language's plugin dynamic library is developed.
   15.16 -
   15.17 -So, any defines or function prototypes, or data structs that are needed in two or more of those places are included in here.
   15.18 -
   15.19 -Note that because this repo is included in the application development environment, anything in it will be visible to application code..  hence, the less it has the better.
   15.20 \ No newline at end of file
   15.21 +
   15.22 +There are Four distinct kinds of compiled entities in a proto-runtime universal system: An application executable, a leaf-level proto-runtime dynamic library, one or more upper-level proto-runtime dynamic libraries, and a language plugin dynamic library.  In addition, multiple language wrapper libraries will be statically included into the application, and those all share a set of PR includes that are for use by language wrapper libraries.
   15.23 +
   15.24 +That gives a total of five distinct places where PR includes are needed.
   15.25 +
   15.26 +Each of those kinds has its own repository of include files.  The things in the include repository are structure typedefs, function prototypes, global variable declarations, and so on.
   15.27 +
   15.28 +This repository contains the common definitions that are used by all the other include repositories..
   15.29 +
   15.30 +That is, the PR application-includes, plugin-includes, wrapper library standard includes, and both leaf and upper PR dynamic libraries all include the files from this repository.
   15.31 +
   15.32 +Hence, each of those include-repos in turn has this common repo as a sub-repo.
   15.33 +
   15.34 +The intent is to only have here the includes that are needed by more than one of the others, then leave any includes that are unique to a single of those kinds of compile to just the include repository for that kind.
   15.35 +
   15.36 +Hence, by transitivity, this repo will be brought along as a sub-repo in the include-repo that main.c of the application uses, by the include-repo of each language, which in turn includes the wrapper-lib repo, which in turn includes this common repo, and it will be included as a sub-repo in the project where a given leaf-level proto-runtime library is developed, and where each upper level proto-runtime library is developed.
   15.37 +
   15.38 +And, it will be included where the language's plugin dynamic library is developed, and where its wrapper library is developed.
   15.39 +
   15.40 +So, any defines or function prototypes, or data structs that are needed in two or more of those places are included in here.
   15.41 +
   15.42 +Note that because this repo is included in the application development environment, anything in it will be visible to application code..  hence, the less it has the better.