This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Where is the module name in this example?

Other Parts Discussed in Thread: SYSBIOS

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);

  • Jeff,
    The actual module name in the example is:  ti.sysbios.gates.GateHwi
    There isn’t a “generic” Gate module that you would call in a SYS/BIOS environment.  You should pick the specific type of gate you want (from package ti.sysbios.gates), then “use” that specific module in your application configuration (e.g., ti.sysbios.gates.GateHwi), and then call the corresponding module’s function names (e.g., GateHwi_create()).  
    The xdc.runtime package used under the kernel does have a “gate provider” interface that the above Gates use, but when you are using the kernel-level APIs, you should explicitly pick from the Gate types in the it.sysbios.gates package, and use those modules and APIs directly.
    Hope this helps clarify.
    Scott