Hi,
When I read SYS/BIOS User Guide v6.41, page 116/256, I cannot find the module name in the gate example.
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 explain it to me?
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. 4.3.1 Preemption-Based Gate Implementations The following implementations of gates use some form of preemption disabling: • ti.sysbios.gates.GateHwi • ti.sysbios.gates.GateSwi • ti.sysbios.gates.GateTask 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);