Hi,
When I read TI SYS/BIOS User Guide v6.41, page 116/256, I cannot find the
module name in the gate in the below code example. I wonder whether my
comprehension has problem or the writing is not accurate. Because it is not
answered on TI e2e forum, I post it here for help.
"As shown in the examples that follow, the actual module name for the
implementation is used instead of "Gate" in the function name."
Could you understand the above statement and the code snippet? I would like
to get your view.
Thanks,
////////////
For Gates that function by disabling preemption, it is possible that
multiple threads would call Gate_enter(), but preemption should not be
restored until all of the threads have called Gate_leave(). This
functionality is provided through the use of a key. A call to Gate_enter()
returns a key that must then be passed back to Gate_leave(). Only the
outermost call to Gate_enter() returns the correct key for restoring
preemption.
As shown in the examples that follow, the actual module name for the
implementation is used instead of "Gate" in the function name.
Runtime example: The following C code protects a critical region with a
Gate. This example uses a GateHwi, which disables and enables interrupts as
the locking mechanism.
code:---
UInt gateKey;
GateHwi_Handle gateHwi;
GateHwi_Params prms;
Error_Block eb;
Error_init(&eb);
GateHwi_Params_init(&prms);
gateHwi = GateHwi_create(&prms, &eb);
if (gateHwi == NULL) {
System_abort("Gate create failed");
}
/* Simultaneous operations on a global variable by multiple
* threads could cause problems, so modifications to the global
* variable are protected with a Gate. */
gateKey = GateHwi_enter(gateHwi);
myGlobalVar = 7;
GateHwi_leave(gateHwi, gateKey);
Where is "the module name" in this example?
Started by ●August 8, 2015
Reply by ●August 8, 20152015-08-08
On Saturday, August 8, 2015 at 3:16:55 PM UTC-7, Robert Willy wrote:> Hi, > > When I read TI SYS/BIOS User Guide v6.41, page 116/256, I cannot find the > module name in the gate in the below code example. I wonder whether my > comprehension has problem or the writing is not accurate. Because it is not > answered on TI e2e forum, I post it here for help. > > > > "As shown in the examples that follow, the actual module name for the > implementation is used instead of "Gate" in the function name." > > Could you understand the above statement and the code snippet? I would like > to get your view. > > > > Thanks, > > > //////////// > > For Gates that function by disabling preemption, it is possible that > multiple threads would call Gate_enter(), but preemption should not be > restored until all of the threads have called Gate_leave(). This > functionality is provided through the use of a key. A call to Gate_enter() > returns a key that must then be passed back to Gate_leave(). Only the > outermost call to Gate_enter() returns the correct key for restoring > preemption. > > As shown in the examples that follow, the actual module name for the > implementation is used instead of "Gate" in the function name. > > Runtime example: The following C code protects a critical region with a > Gate. This example uses a GateHwi, which disables and enables interrupts as > the locking mechanism. > > code:--- > UInt gateKey; > GateHwi_Handle gateHwi; > GateHwi_Params prms; > Error_Block eb; > Error_init(&eb); > GateHwi_Params_init(&prms); > gateHwi = GateHwi_create(&prms, &eb); > if (gateHwi == NULL) { > System_abort("Gate create failed"); > } > /* Simultaneous operations on a global variable by multiple > * threads could cause problems, so modifications to the global > * variable are protected with a Gate. */ > gateKey = GateHwi_enter(gateHwi); > myGlobalVar = 7; > GateHwi_leave(gateHwi, gateKey);After reading other help source, it turns out that it means the change: GateHwi_leave(gate, gateKey); ====> GateHwi_leave(gateHwi, gateKey); i.e. it is already done. Thanks,







