# HG changeset patch # User PhilipeLouchtch # Date 1393618610 -3600 # Node ID 2d96f0ad026e5e8f879879617001bd509b94f3d6 # Parent ad931059d1c473e340a5d0afecb06202bc0b0d19 Changes for longjmp version of PRT diff -r ad931059d1c4 -r 2d96f0ad026e PR__PI.h --- a/PR__PI.h Sun Oct 06 11:26:20 2013 -0700 +++ b/PR__PI.h Fri Feb 28 21:16:50 2014 +0100 @@ -1,124 +1,127 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR__PI_H -#define _PR__PI_H -#define _GNU_SOURCE - -#include - -//========================= Function Prototypes =========================== -/* MEANING OF WL PI SS int PROS - * These indicate which places the function is safe to use. They stand for: - * - * WL Wrapper Library -- wrapper lib code should only use these - * PI Plugin -- plugin code should only use these - * SS Startup and Shutdown -- designates these relate to startup & shutdown - * int32internal to PR -- should not be used in wrapper lib or plugin - * PROS means "OS functions for applications to use" - * - * PR_int__ functions touch internal PR data structs and are only safe - * to be used inside the master lock. However, occasionally, they appear - * in wrapper-lib or plugin code. In those cases, very careful analysis - * has been done to be sure no concurrency issues could arise. - * - * PR_WL__ functions are all safe for use outside the master lock. - * - * PROS are only safe for applications to use -- they're like a second - * language mixed in -- but they can't be used inside plugin code, and - * aren't meant for use in wrapper libraries, because they are themselves - * wrapper-library calls! - */ - -#define \ -PR_PI__create_slaveVP PR_int__create_slaveVP_helper - -//============== -//=== Lang Data -//= -#define \ -PR_PI__give_lang_data_from_slave PR_int__give_lang_data_from_slave -#define \ -PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave - -#define \ -PR_PI__give_num_cores PR_SS__give_num_cores - - -//============ -//=== Lang Env -//= -#define \ -PR_PI__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave -#define \ -PR_PI__give_lang_env_for_slave PR_int__give_lang_env_for_slave -#define \ -PR_PI__give_lang_env_from_process PR_int__give_lang_env_from_process - - -//========= -//=== Meta Task -//= -#define \ -PR_PI__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave -#define \ -PR_PI__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task - -SlaveVP * -PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); - -#define \ -PR_PI__free_lang_meta_task_and_remove_from_slave PR_int__free_lang_meta_task_and_remove_from_coll - -#define \ -PR_PI__free_lang_meta_task PR_int__free_lang_meta_task - -void -PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask ); -void -PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask ); - -//========== -//=== -//= -#define \ -PR_PI__give_ID_from_lang_meta_task PR__give_ID_from_lang_meta_task -#define \ -PR_PI__give_ID_from_slave PR__give_ID_from_slave - -//============= -//=== -//= -#define \ -PR_PI__put_slave_into_slot PR_int__put_slave_into_slot -#define \ -PR_PI__put_task_into_slot PR_int__put_task_into_slot - -PRReqst * -PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq ); - -#define \ -PR_PI__take_lang_reqst_from( req ) req->langReq - -void -PR_PI__resume_slave_in_PRServ( SlaveVP *slave ); - -#define \ -PR_PI__malloc PR_int__malloc -#define \ -PR_PI__malloc_aligned PR_int__malloc_aligned -#define \ -PR_PI__free PR_int__free - - -#define \ -PR_PI__throw_exception PR_int__throw_exception - -//================================================ -#endif /* _PR__PI_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PR__PI_H +#define _PR__PI_H +#define _GNU_SOURCE + +#include + +//========================= Function Prototypes =========================== +/* MEANING OF WL PI SS int PROS + * These indicate which places the function is safe to use. They stand for: + * + * WL Wrapper Library -- wrapper lib code should only use these + * PI Plugin -- plugin code should only use these + * SS Startup and Shutdown -- designates these relate to startup & shutdown + * int32internal to PR -- should not be used in wrapper lib or plugin + * PROS means "OS functions for applications to use" + * + * PR_int__ functions touch internal PR data structs and are only safe + * to be used inside the master lock. However, occasionally, they appear + * in wrapper-lib or plugin code. In those cases, very careful analysis + * has been done to be sure no concurrency issues could arise. + * + * PR_WL__ functions are all safe for use outside the master lock. + * + * PROS are only safe for applications to use -- they're like a second + * language mixed in -- but they can't be used inside plugin code, and + * aren't meant for use in wrapper libraries, because they are themselves + * wrapper-library calls! + */ + +//#define PR_PI__get_fresh_slaveVP PR_int__create_slaveVP_helper + +inline +SlaveVP * +PR_PI__get_fresh_slaveVP( BirthFnPtr fnPtr, void *dataParam ); + +//============== +//=== Lang Data +//= +#define \ +PR_PI__give_lang_data_from_slave PR_int__give_lang_data_from_slave +#define \ +PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave + +#define \ +PR_PI__give_num_cores PR_SS__give_num_cores + + +//============ +//=== Lang Env +//= +#define \ +PR_PI__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave +#define \ +PR_PI__give_lang_env_for_slave PR_int__give_lang_env_for_slave +#define \ +PR_PI__give_lang_env_from_process PR_int__give_lang_env_from_process + + +//========= +//=== Meta Task +//= +#define \ +PR_PI__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave +#define \ +PR_PI__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task + +SlaveVP * +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); + +#define \ +PR_PI__free_lang_meta_task_and_remove_from_slave PR_int__free_lang_meta_task_and_remove_from_coll + +#define \ +PR_PI__free_lang_meta_task PR_int__free_lang_meta_task + +void +PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask ); +void +PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask ); + +//========== +//=== +//= +#define \ +PR_PI__give_ID_from_lang_meta_task PR__give_ID_from_lang_meta_task +#define \ +PR_PI__give_ID_from_slave PR__give_ID_from_slave + +//============= +//=== +//= +#define \ +PR_PI__put_slave_into_slot PR_int__put_slave_into_slot +#define \ +PR_PI__put_task_into_slot PR_int__put_task_into_slot + +PRReqst * +PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq ); + +#define \ +PR_PI__take_lang_reqst_from( req ) req->langReq + +void +PR_PI__resume_slave_in_PRServ( SlaveVP *slave ); + +#define \ +PR_PI__malloc PR_int__malloc +#define \ +PR_PI__malloc_aligned PR_int__malloc_aligned +#define \ +PR_PI__free PR_int__free + + +#define \ +PR_PI__throw_exception PR_int__throw_exception + +//================================================ +#endif /* _PR__PI_H */ + diff -r ad931059d1c4 -r 2d96f0ad026e PR__structs__common.h --- a/PR__structs__common.h Sun Oct 06 11:26:20 2013 -0700 +++ b/PR__structs__common.h Fri Feb 28 21:16:50 2014 +0100 @@ -1,349 +1,354 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR__structs__common_H -#define _PR__structs__common_H -#define _GNU_SOURCE - -#include -#include - -//#include "PR_defs__turn_on_and_off.h" -#include -#include -#include - -#include //reqd by PRProcess -#include //reqd by PRProcess -#include //reqd by PRProcess -#include //reqd by PRLangEnv, in turn reqd by PRProcess - -//================================ Typedefs ================================= -//=== -//= -#define ZERO 0 - -//typedef unsigned long long TSCount; - -typedef struct _AnimSlot AnimSlot; -typedef struct _PRReqst PRReqst; -typedef struct _SlaveVP SlaveVP; -//typedef struct _MasterVP MasterVP; -typedef struct _IntervalProbe IntervalProbe; -typedef struct _PRLangEnv PRLangEnv; //a prolog -typedef struct _PRMetaTask PRMetaTask; //a prolog -typedef struct _PRLangData PRLangData; //a prolog -typedef struct _PRCollElem PRCollElem; //generic form of the prologs - -typedef bool32 (*SlaveAssigner) ( void *, AnimSlot* ); //langEnv, slot for HW info -typedef void (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv -typedef void *(*CreateHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv -typedef void (*LangShutdownHdlr) ( void * ); //langEnv -typedef void *(*LangDataCreator) ( SlaveVP * ); -typedef void (*LangDataFreer) ( void * ); //lang data to free -typedef void *(*LangMetaTaskCreator)( SlaveVP * ); //when slave has no meta task for magic num -typedef void (*LangMetaTaskFreer) ( void * ); //lang meta task to free -typedef void (*MakeSlaveReadyFn) ( SlaveVP *, void * ); //slave and langEnv -typedef void (*MakeTaskReadyFn) ( void *, void * ); //langTask and langEnv -typedef void (*BirthFnPtr) ( void *, SlaveVP * ); //initData, animSlv -typedef void BirthFn ( void *, SlaveVP * ); //initData, animSlv -typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); - //=========== MEASUREMENT STUFF ========== - MEAS__Insert_Counter_Handler - //======================================== - - -typedef struct - { //These are set by the plugin during startup and the application - char *assignerInfo; - char *appInfo; - char *inputInfo; - } -PRSysMetaInfo; - -//===================== Process Data Struct ====================== - -/*This structure holds all the information PR needs to manage a program. PR - * stores information about what percent of CPU time the program is getting, - * - */ - -typedef struct - { - int32 numEnvsWithWork; - void *resultToReturn; - - PRLangEnv **langEnvs; //used as a hash table - PRLangEnv **protoLangEnvsList; //for fast linear scan of envs - int32 numLangEnvs; //for fast linear scan of envs - - SlaveVP *seedSlv; - - int32 numLiveGenericSlvs; - int32 numLiveTasks; - - SlaveAssigner overrideAssigner; - - int32 numConsecutiveTasks; - - - //These are used to coord with an OS thread waiting for process to end - bool32 hasWaitingToEnd; - bool32 executionIsComplete; - pthread_mutex_t doneLock; - pthread_cond_t doneCond; - pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting - - //=========== MEASUREMENT STUFF ============= - IntervalProbe **intervalProbes; - PrivDynArrayInfo *dynIntervalProbesInfo; - HashTable *probeNameHashTbl; - int32 masterCreateProbeID; - float64 createPtInSecs; //real-clock time PR initialized - Histogram **measHists; - PrivDynArrayInfo *measHistsInfo; - MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; - MEAS__Insert_Master_Meas_Fields_into_MasterEnv; - MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; - MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; - MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; - MEAS__Insert_System_Meas_Fields_into_MasterEnv; - MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; - //========================================== - } -PRProcess; - - -//============= Request Related =========== -// - -enum PRReqstType //avoid starting enums at 0, for debug reasons - { - TaskCreate = 1, - TaskEnd, - SlvCreate, - SlvDissipate, - Language, - Service, //To invoke a PR provided equivalent of a language request (ex: probe) - Hardware, - IO, - OSCall, - LangShutdown, - ProcessEnd, - PRShutdown - }; - - -struct _PRReqst - { - enum PRReqstType reqType;//used for special forms that have PR behavior - void *langReq; - PRProcess *processReqIsIn; - int32 langMagicNumber; - SlaveVP *requestingSlave; - - BirthFnPtr birthFn; - void *initData; - int32 *ID; - - //The request handling structure is a bit messy.. for special forms, - // such as create and dissipate, the language inserts pointer to handler - // fn directly into the request.. might change to this for all requests - RequestHandler handler; //pointer to handler fn - CreateHandler createHdlr; //special because returns something - int32 createSuspendedGroup; //must be non-zero - - PRReqst *nextReqst; - }; -//PRReqst - -enum PRServiceReqType //These are equivalent to lang requests, but for - { // PR's services available directly to app, like OS - make_probe = 1, // and probe services -- like a PR-wide built-in lang - throw_excp, - openFile, - otherIO - }; - -typedef struct - { enum PRServiceReqType reqType; - SlaveVP *requestingSlv; - char *nameStr; //for create probe - char *msgStr; //for exception - void *exceptionData; - } -PRServiceReq; - - -//==================== Core data structures =================== - -typedef struct - { - //for future expansion - } -SlotPerfInfo; - -struct _AnimSlot - { - int32 workIsDone; - int32 needsWorkAssigned; - SlaveVP *slaveAssignedToSlot; - -// int32 slotIdx; //needed by Holistic Model's data gathering - int32 coreSlotIsOn; - SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core - }; -//AnimSlot - -enum VPtype - { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks - FreeTaskSlv, //When a suspended task ends, the slave becomes this - GenericSlv, //the VP is explicitly seen in the app code, or task suspends - SeedSlv, - Master_VP, - ShutdownVP, - IdleVP - }; - -/*This structure embodies the state of a slaveVP. It is reused for masterVP - * and shutdownVPs. - */ -struct _SlaveVP - { //The offsets of these fields are hard-coded into assembly - void *stackPtr; //save the core's stack ptr when suspend - void *framePtr; //save core's frame ptr when suspend - void *resumeInstrPtr; //save core's program-counter when suspend - void *coreCtlrFramePtr; //restore before jmp back to core controller - void *coreCtlrStackPtr; //restore before jmp back to core controller - - //============ below this, no fields are used in asm ============= - - void *startOfStack; //used to free, and to point slave to Fn - PRProcess *processSlaveIsIn; - enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. - int32 slaveNum; //each slave given it's seq in creation - int32 *ID; //App defines meaning of each int in array - int32 coreAnimatedBy; - int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID - //note, a scheduling decision is uniquely identified by the triple: - // -- used in record & replay - - //for comm -- between master and coreCtlr & btwn wrapper lib and plugin - AnimSlot *animSlotAssignedTo; - PRReqst *request; //wrapper lib puts in requests, plugin takes out - void *dataRetFromReq;//Return vals from plugin to Wrapper Lib - - //For language specific data that needs to be in the slave - //These are accessed directly for single-lang, but multi-lang places - // a holder here instead, then uses magic num to get lang's version - PRLangData **langDatas; //Lang saves lang-specific things in slave here - PRMetaTask **metaTasks; - -// PRGhostInfo *ghostInfo; - - //=========== MEASUREMENT STUFF ========== - MEAS__Insert_Meas_Fields_into_Slave; - float64 createPtInSecs; //time VP created, in seconds - //======================================== - -// int8 cacheLinePad[512 - sizeof(contents)]; //for false sharing - }; -//SlaveVP - - -enum PRMode - { SingleLang = 1, - StandaloneWTasks, - MultiLang - }; - - -//===================== These are prologs ==================== -//===A prolog is data immediately before pointer returned by a create function. -//= -struct _PRLangEnv - { //============== First two must match PRCollElem ============== - int32 langMagicNumber; //indexes into hash array of langEnvs in PRProcess - PRLangEnv *chainedLangEnv; //chains to langEnvs with same hash - //============================================================= - - SlaveAssigner workAssigner; - LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown - LangDataCreator langDataCreator; - LangMetaTaskCreator langMetaTaskCreator; - MakeSlaveReadyFn makeSlaveReadyFn; - MakeTaskReadyFn makeTaskReadyFn; - - //when multi-lang, master polls lang env's to find one with work in it.. - // in single-lang case, flag ignored, master always asks lang for work - int32 hasWork; - PRProcess *processEnvIsIn; - - int32 idxInProcess; //index into array of langEnvs in the process - - int32 numReadyWork; - - int32 numLiveWork; - PrivQueueStruc *waitingForWorkToEndQ; - }; -//PRLangEnv -- this is the prolog of every lang's lang env - -enum PRTaskType - { GenericSlave = 1, - SlotTask, - FreeTask - }; - -struct _PRMetaTask - { //============== First two must match PRCollElem ============== - int32 langMagicNumber; - PRMetaTask *chainedMetaTask; - //============================================================= - enum PRTaskType taskType; - int32 *ID; //is standard PR ID - PRProcess *processTaskIsIn; - SlaveVP *slaveAssignedTo; //not valid until task animated - BirthFnPtr birthFn; //This is the Fn executes as the task - void *initData; //The data taken by the function - LangMetaTaskFreer freer; - bool32 goAheadAndFree; - - //NOTE: info needed for "wait" functionality is inside lang's metaTask - }; -//PRMetaTask -- prolog of every lang's meta task - -struct _PRLangData - { //============== First two must match PRCollElem ============== - int32 langMagicNumber; - PRLangData *chainedLangData; - //============================================================= - LangDataFreer freer; - bool32 goAheadAndFree; - SlaveVP *slaveAssignedTo; - }; -//PRLangData -- this is the prolog of each lang's lang data - -struct _PRCollElem - { - int32 hash; - PRCollElem *chained; - }; -//PRCollElem -- this is generic form of all the prologs - - - -//========================= Extra Stuff Data Strucs ======================= -typedef struct - { - - } -PRExcp; //exception - - -#endif /* _PR__structs_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PR__structs__common_H +#define _PR__structs__common_H +#define _GNU_SOURCE + +#include +#include + +//#include "PR_defs__turn_on_and_off.h" +#include +#include +#include + +#include //reqd by PRProcess +#include //reqd by PRProcess +#include //reqd by PRProcess +#include //reqd by PRLangEnv, in turn reqd by PRProcess + +//================================ Typedefs ================================= +//=== +//= +#define ZERO 0 + +//typedef unsigned long long TSCount; + +typedef struct _AnimSlot AnimSlot; +typedef struct _PRReqst PRReqst; +typedef struct _SlaveVP SlaveVP; +//typedef struct _MasterVP MasterVP; +typedef struct _IntervalProbe IntervalProbe; +typedef struct _PRLangEnv PRLangEnv; //a prolog +typedef struct _PRMetaTask PRMetaTask; //a prolog +typedef struct _PRLangData PRLangData; //a prolog +typedef struct _PRCollElem PRCollElem; //generic form of the prologs + +typedef bool32 (*SlaveAssigner) ( void *, AnimSlot* ); //langEnv, slot for HW info +typedef void (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv +typedef void *(*CreateHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv +typedef void (*LangShutdownHdlr) ( void * ); //langEnv +typedef void *(*LangDataCreator) ( SlaveVP * ); +typedef void (*LangDataFreer) ( void * ); //lang data to free +typedef void *(*LangMetaTaskCreator)( SlaveVP * ); //when slave has no meta task for magic num +typedef void (*LangMetaTaskFreer) ( void * ); //lang meta task to free +typedef void (*MakeSlaveReadyFn) ( SlaveVP *, void * ); //slave and langEnv +typedef void (*MakeTaskReadyFn) ( void *, void * ); //langTask and langEnv +typedef void (*BirthFnPtr) ( void *, SlaveVP * ); //initData, animSlv +typedef void BirthFn ( void *, SlaveVP * ); //initData, animSlv +typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); + //=========== MEASUREMENT STUFF ========== + MEAS__Insert_Counter_Handler + //======================================== + + +typedef struct + { //These are set by the plugin during startup and the application + char *assignerInfo; + char *appInfo; + char *inputInfo; + } +PRSysMetaInfo; + +//===================== Process Data Struct ====================== + +/*This structure holds all the information PR needs to manage a program. PR + * stores information about what percent of CPU time the program is getting, + * + */ + +typedef struct + { + int32 numEnvsWithWork; + void *resultToReturn; + + PRLangEnv **langEnvs; //used as a hash table + PRLangEnv **protoLangEnvsList; //for fast linear scan of envs + int32 numLangEnvs; //for fast linear scan of envs + + SlaveVP *seedSlv; + + int32 numLiveGenericSlvs; + int32 numLiveTasks; + + SlaveAssigner overrideAssigner; + + int32 numConsecutiveTasks; + + + //These are used to coord with an OS thread waiting for process to end + bool32 hasWaitingToEnd; + bool32 executionIsComplete; + pthread_mutex_t doneLock; + pthread_cond_t doneCond; + pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting + + //=========== MEASUREMENT STUFF ============= + IntervalProbe **intervalProbes; + PrivDynArrayInfo *dynIntervalProbesInfo; + HashTable *probeNameHashTbl; + int32 masterCreateProbeID; + float64 createPtInSecs; //real-clock time PR initialized + Histogram **measHists; + PrivDynArrayInfo *measHistsInfo; + MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; + MEAS__Insert_Master_Meas_Fields_into_MasterEnv; + MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; + MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; + MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; + MEAS__Insert_System_Meas_Fields_into_MasterEnv; + MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; + //========================================== + } +PRProcess; + + +//============= Request Related =========== +// + +enum PRReqstType //avoid starting enums at 0, for debug reasons + { + TaskCreate = 1, + TaskEnd, + SlvCreate, + SlvDissipate, + Language, + Service, //To invoke a PR provided equivalent of a language request (ex: probe) + Hardware, + IO, + OSCall, + LangShutdown, + ProcessEnd, + PRShutdown + }; + + +struct _PRReqst + { + enum PRReqstType reqType;//used for special forms that have PR behavior + void *langReq; + PRProcess *processReqIsIn; + int32 langMagicNumber; + SlaveVP *requestingSlave; + + BirthFnPtr birthFn; + void *initData; + int32 *ID; + + //The request handling structure is a bit messy.. for special forms, + // such as create and dissipate, the language inserts pointer to handler + // fn directly into the request.. might change to this for all requests + RequestHandler handler; //pointer to handler fn + CreateHandler createHdlr; //special because returns something + int32 createSuspendedGroup; //must be non-zero + + PRReqst *nextReqst; + }; +//PRReqst + +enum PRServiceReqType //These are equivalent to lang requests, but for + { // PR's services available directly to app, like OS + make_probe = 1, // and probe services -- like a PR-wide built-in lang + throw_excp, + openFile, + otherIO + }; + +typedef struct + { enum PRServiceReqType reqType; + SlaveVP *requestingSlv; + char *nameStr; //for create probe + char *msgStr; //for exception + void *exceptionData; + } +PRServiceReq; + + +//==================== Core data structures =================== + +typedef struct + { + //for future expansion + } +SlotPerfInfo; + +struct _AnimSlot + { + int32 workIsDone; + int32 needsWorkAssigned; + SlaveVP *slaveAssignedToSlot; + +// int32 slotIdx; //needed by Holistic Model's data gathering + int32 coreSlotIsOn; + SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core + }; +//AnimSlot + +enum VPtype + { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks + FreeTaskSlv, //When a suspended task ends, the slave becomes this + GenericSlv, //the VP is explicitly seen in the app code, or task suspends + SeedSlv, + Master_VP, + ShutdownVP, + IdleVP + }; + +/*This structure embodies the state of a slaveVP. It is reused for masterVP + * and shutdownVPs. + */ +struct _SlaveVP + { //The offsets of these fields are hard-coded into assembly + void *stackPtr; //save the core's stack ptr when suspend + void *framePtr; //save core's frame ptr when suspend + void *resumeInstrPtr; //save core's program-counter when suspend + void *coreCtlrFramePtr; //restore before jmp back to core controller + void *coreCtlrStackPtr; //restore before jmp back to core controller + + //============ below this, no fields are used in asm ============= + + PRProcess *processSlaveIsIn; + enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. + int32 slaveNum; //each slave given it's seq in creation + int32 *ID; //App defines meaning of each int in array + int32 coreAnimatedBy; + int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID + //note, a scheduling decision is uniquely identified by the triple: + // -- used in record & replay + + //for comm -- between master and coreCtlr & btwn wrapper lib and plugin + AnimSlot *animSlotAssignedTo; + PRReqst *request; //wrapper lib puts in requests, plugin takes out + void *dataRetFromReq;//Return vals from plugin to Wrapper Lib + + //For language specific data that needs to be in the slave + //These are accessed directly for single-lang, but multi-lang places + // a holder here instead, then uses magic num to get lang's version + PRLangData **langDatas; //Lang saves lang-specific things in slave here + PRMetaTask **metaTasks; + + jmp_buf ctxt; + jmp_buf virginCtxt; + + BirthFnPtr birthFn; + void *initData; + +// PRGhostInfo *ghostInfo; + + //=========== MEASUREMENT STUFF ========== + MEAS__Insert_Meas_Fields_into_Slave; + float64 createPtInSecs; //time VP created, in seconds + //======================================== + +// int8 cacheLinePad[512 - sizeof(contents)]; //for false sharing + }; +//SlaveVP + + +enum PRMode + { SingleLang = 1, + StandaloneWTasks, + MultiLang + }; + + +//===================== These are prologs ==================== +//===A prolog is data immediately before pointer returned by a create function. +//= +struct _PRLangEnv + { //============== First two must match PRCollElem ============== + int32 langMagicNumber; //indexes into hash array of langEnvs in PRProcess + PRLangEnv *chainedLangEnv; //chains to langEnvs with same hash + //============================================================= + + SlaveAssigner workAssigner; + LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown + LangDataCreator langDataCreator; + LangMetaTaskCreator langMetaTaskCreator; + MakeSlaveReadyFn makeSlaveReadyFn; + MakeTaskReadyFn makeTaskReadyFn; + + //when multi-lang, master polls lang env's to find one with work in it.. + // in single-lang case, flag ignored, master always asks lang for work + int32 hasWork; + PRProcess *processEnvIsIn; + + int32 idxInProcess; //index into array of langEnvs in the process + + int32 numReadyWork; + + int32 numLiveWork; + PrivQueueStruc *waitingForWorkToEndQ; + }; +//PRLangEnv -- this is the prolog of every lang's lang env + +enum PRTaskType + { GenericSlave = 1, + SlotTask, + FreeTask + }; + +struct _PRMetaTask + { //============== First two must match PRCollElem ============== + int32 langMagicNumber; + PRMetaTask *chainedMetaTask; + //============================================================= + enum PRTaskType taskType; + int32 *ID; //is standard PR ID + PRProcess *processTaskIsIn; + SlaveVP *slaveAssignedTo; //not valid until task animated + BirthFnPtr birthFn; //This is the Fn executes as the task + void *initData; //The data taken by the function + LangMetaTaskFreer freer; + bool32 goAheadAndFree; + + //NOTE: info needed for "wait" functionality is inside lang's metaTask + }; +//PRMetaTask -- prolog of every lang's meta task + +struct _PRLangData + { //============== First two must match PRCollElem ============== + int32 langMagicNumber; + PRLangData *chainedLangData; + //============================================================= + LangDataFreer freer; + bool32 goAheadAndFree; + SlaveVP *slaveAssignedTo; + }; +//PRLangData -- this is the prolog of each lang's lang data + +struct _PRCollElem + { + int32 hash; + PRCollElem *chained; + }; +//PRCollElem -- this is generic form of all the prologs + + + +//========================= Extra Stuff Data Strucs ======================= +typedef struct + { + + } +PRExcp; //exception + + +#endif /* _PR__structs_H */ + diff -r ad931059d1c4 -r 2d96f0ad026e __brch__ML_lib --- a/__brch__ML_lib Sun Oct 06 11:26:20 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -This branch is for developing the multi-language capability in VMS. The idea is to define langlets, whose constructs can be freely mixed together inside application code. No need to separate into distinct modules. A single function can use constructs from all the different langlets together inside itself. - - -======== Background on branch naming ========= - -There are two kinds of branchs: ones used to develop features, and ones tuned to particular hardware. A given HW branch may combine features from several feature-branches, picking and choosing among them. - -After Feb 2012, branches are named by the scheme: - -feat____ - -HW__ - -where and follow the pattern: - - x __ - -Examples: - -feat__exp_array_malloc - -feat__rand_backoff__4x10_Intel_WestmereEx - -HW__1x4_Intel_SandyBridge - -HW__4x10_Intel_WestmereEx - -HW__1x4_AMD_mobile diff -r ad931059d1c4 -r 2d96f0ad026e __brch__ML_lib_longjmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/__brch__ML_lib_longjmp Fri Feb 28 21:16:50 2014 +0100 @@ -0,0 +1,28 @@ +This branch is for developing the multi-language capability in VMS. The idea is to define langlets, whose constructs can be freely mixed together inside application code. No need to separate into distinct modules. A single function can use constructs from all the different langlets together inside itself. + + +======== Background on branch naming ========= + +There are two kinds of branchs: ones used to develop features, and ones tuned to particular hardware. A given HW branch may combine features from several feature-branches, picking and choosing among them. + +After Feb 2012, branches are named by the scheme: + +feat____ + +HW__ + +where and follow the pattern: + + x __ + +Examples: + +feat__exp_array_malloc + +feat__rand_backoff__4x10_Intel_WestmereEx + +HW__1x4_Intel_SandyBridge + +HW__4x10_Intel_WestmereEx + +HW__1x4_AMD_mobile