VMS/VMS_Implementations/VMS_impls/VMS__MC_shared_impl

view VMS__PI.c @ 248:da08f9717024

Moved VMS_defs__turn_on_and_off.h outside of VMS repo, into project repo
author Sean Halle <seanhalle@yahoo.com>
date Sat, 21 Jul 2012 15:20:40 -0700
parents f1267bc7b342
children f5b110414453
line source
1 /*
2 * Copyright 2010 OpenSourceStewardshipFoundation
3 *
4 * Licensed under BSD
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <malloc.h>
11 #include <inttypes.h>
12 #include <sys/time.h>
14 #include "VMS.h"
17 /* MEANING OF WL PI SS int
18 * These indicate which places the function is safe to use. They stand for:
19 * WL: Wrapper Library
20 * PI: Plugin
21 * SS: Startup and Shutdown
22 * int: internal to the VMS implementation
23 */
25 //========================= Local Declarations ========================
26 void inline
27 handleMakeProbe( VMSSemReq *semReq, void *semEnv, ResumeSlvFnPtr resumeFn );
29 void inline
30 handleThrowException( VMSSemReq *semReq, void *semEnv, ResumeSlvFnPtr resumeFn );
31 //=======================================================================
34 VMSReqst *
35 VMS_PI__take_next_request_out_of( SlaveVP *slaveWithReq )
36 { VMSReqst *req;
38 req = slaveWithReq->requests;
39 if( req == NULL ) return NULL;
41 slaveWithReq->requests = slaveWithReq->requests->nextReqst;
42 return req;
43 }
47 /*May 2012
48 *CHANGED IMPL -- now a macro in header file
49 *
50 *Turn function into macro that just accesses the request field
51 *
52 inline void *
53 VMS_PI__take_sem_reqst_from( VMSReqst *req )
54 {
55 return req->semReqData;
56 }
57 */
60 /* This is for OS requests and VMS infrastructure requests, such as to create
61 * a probe -- a probe is inside the heart of VMS-core, it's not part of any
62 * language -- but it's also a semantic thing that's triggered from and used
63 * in the application.. so it crosses abstractions.. so, need some special
64 * pattern here for handling such requests.
65 * Doing this just like it were a second language sharing VMS-core.
66 *
67 * This is called from the language's request handler when it sees a request
68 * of type VMSSemReq
69 *
70 * TODO: Later change this, to give probes their own separate plugin & have
71 * VMS-core steer the request to appropriate plugin
72 * Do the same for OS calls -- look later at it..
73 */
74 void inline
75 VMS_PI__handle_VMSSemReq( VMSReqst *req, SlaveVP *requestingSlv, void *semEnv,
76 ResumeSlvFnPtr resumeFn )
77 { VMSSemReq *semReq;
79 semReq = VMS_PI__take_sem_reqst_from(req);
80 if( semReq == NULL ) return;
81 switch( semReq->reqType ) //sem handlers are all in other file
82 {
83 case make_probe: handleMakeProbe( semReq, semEnv, resumeFn);
84 break;
85 case throw_excp: handleThrowException( semReq, semEnv, resumeFn);
86 break;
87 }
88 }
90 /*
91 */
92 void inline
93 handleMakeProbe( VMSSemReq *semReq, void *semEnv, ResumeSlvFnPtr resumeFn )
94 { IntervalProbe *newProbe;
96 newProbe = VMS_int__malloc( sizeof(IntervalProbe) );
97 newProbe->nameStr = VMS_int__strDup( semReq->nameStr );
98 newProbe->hist = NULL;
99 newProbe->schedChoiceWasRecorded = FALSE;
101 //This runs in masterVP, so no race-condition worries
102 newProbe->probeID =
103 addToDynArray( newProbe, _VMSMasterEnv->dynIntervalProbesInfo );
105 semReq->requestingSlv->dataRetFromReq = newProbe;
107 //This in inside VMS, while resume_slaveVP fn is inside language, so pass
108 // pointer from lang to here, then call it.
109 (*resumeFn)( semReq->requestingSlv, semEnv );
110 }
112 void inline
113 handleThrowException( VMSSemReq *semReq, void *semEnv, ResumeSlvFnPtr resumeFn )
114 {
115 VMS_int__throw_exception( semReq->msgStr, semReq->requestingSlv, semReq->exceptionData );
117 (*resumeFn)( semReq->requestingSlv, semEnv );
118 }