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.

Key for entering GateMP multiple times

In IPC (version ipc_1_23_05_40), I call gate enter/leave like this:

IArg key;
key = GateMP_enter(gateHandle);
GateMP_leave(gateHandle, key);

What if I entered the gate multiple times?
will this work?

IArg key;
key = GateMP_enter(gateHandle);
key = GateMP_enter(gateHandle);
GateMP_leave(gateHandle, key);
GateMP_leave(gateHandle, key);

Or I should create 2 keys? Like this:

IArg key1, key2;
key1 = GateMP_enter(gateHandle);
key2 = GateMP_enter(gateHandle);
GateMP_leave(gateHandle, key1);
GateMP_leave(gateHandle, key2);
  • Hi,

    You should not enter a GateMP multiple times in a thread.  GateMP is meant to be a mutex between threads and processors.

    Sorry, ignore the line above.  You should be able to call GateMP_enter multiple times.  We do check whether you are nesting the calls.
    Ideally you should use 2 different keys but you have it in the wrong order.  Should be:

    IArg key1, key2;
    key1 = GateMP_enter(gateHandle);
    key2 = GateMP_enter(gateHandle);
    GateMP_leave(gateHandle, key2);
    GateMP_leave(gateHandle, key1);
    

    Judah