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.

TM4C1294KCPDT: Regarding Mutex create using GateMutex and GateMutexPri based on "Quality"

Part Number: TM4C1294KCPDT
Other Parts Discussed in Thread: SYSBIOS

Hi,

We can have BLOCKING or PREEMPTING qualities for mutex.

My question is,

Since quality is for a gate configuration, can I create mutex instances with different quality or I have to use single quality for all mutex instances in my entire application?

For Example,

I want to create the common functions for MutexCreate, MutexEnter, MutexLeave, MutexDelete functions. From these functions I will call either GateMutex or GateMutexPri functions based on a flag.

If the flag is FIFO,

then I want to create the mutex by using "GateMutex_Create" function and I want to set the quality as "BLOCKING".

If the flag is Priority,

I want to create the mutex by using "GateMutexPri_Create" function and I want to set the quality as "BLOCKING".

If the flag is InversionSafe,

I want to create the mutex by using "GateMutexPri_Create" function and I want to set the quality as "PREEMPTING".

 

Is this possible or not by doing any parameter configuration during params_init() call?

With regards,

Iyyappan.

  • You can make different types of Gates in your application and then upcast them and use the IGateProvider module. For example

    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/IGateProvider.h>
    #include <ti/sysbios/gates/GateMutex.h>
    #include <ti/sysbios/gates/GateMutexPri.h>

    someTask {
    GateMutex_Params gmParams; GateMutex_Handle gmHandle; GateMutexPri_Params gmpParams; GateMutexPri_Handle gmpHandle; IGateProvider_Handle gateHandle1; IGateProvider_Handle gateHandle2; IArg key1; IArg key2;
    /* Make a GateMutex instance and upCast. Params are optional here since there are no parameters for this module. */ GateMutex_Params_init(&gmParams); gmHandle = GateMutex_create(&gmParams, Error_IGNORE); gateHandle1 = GateMutex_Handle_upCast(gmHandle);
    /* Make a GateMutexPri instance and upCast. Again the params are optional... */
    GateMutexPri_Params_init(&gmpParams); gmpHandle = GateMutexPri_create(&gmpParams, Error_IGNORE); gateHandle2 = GateMutexPri_Handle_upCast(gmpHandle); /* Example of generically using the two different gates */
    key1 = IGateProvider_enter(gateHandle1); key2 = IGateProvider_enter(gateHandle2); IGateProvider_leave(gateHandle2, key2); IGateProvider_leave(gateHandle1, key1);

    You can use the IGateProvider module to query the qualities of the gate modules also.

    Todd

  • Hi Todd,

    Thanks for your reply. I checked with your suggestion. I created the mutex whatever you suggested in the reply. 

    After creating that I called IGateProvider_query to get the quality. I got always TRUE as the return value even though I passed different qualities to check. To know that I started debugging. When we call IGateProvider_query function it will go to below function only.

    This function available in C:\ti\xdctools_3_32_01_22_core\packages\xdc\runtime\IGateProvider.h location.

    In this __inst->query is points to the GateMutexPri_query and GateMutex_query only (Refer below).

      

    Location for above two functions

    C:\ti\tirtos_tivac_2_16_00_08\products\bios_6_45_01_29\packages\ti\sysbios\gates\GateMutex.c for GateMutex_query function.

    C:\ti\tirtos_tivac_2_16_00_08\products\bios_6_45_01_29\packages\ti\sysbios\gates\GateMutexPri.c for GateMutexPri_query function.

    These functions will always return TRUE only. I Put the breakpoints in those functions and checked.

    If this is the case means how we will get the exact usage of quality?

    I am using TI-RTOS version - 2.16 and BIOS version 6.45.

    regards,

    Iyyappan.

  • Iyyappan,

    Both GateMutex and GateMutexPri can "block" the calling task (call it TaskA). By "block", I mean that some other task could have already entered the gate, so TaskA will block on the semaphore in the GateMutex_enter (or GateMutexPri_enter) call.

    Similarly with the "preempting" quality. Let a task (call it TaskA again) own the gate (e.g. has successfully returned from GateMutex_enter (or GateMutexPri_enter or IGateProvider_enter)), if a higher priority thread (e.g. Hwi, Swi or higher priority Task) becomes ready to run, that higher priority thread will preempt TaskA.

    When are cases where the query returns false? GateHwi disables interrupts in GateHwi_enter. So when the running thread calls GateHwi_enter, it will not block since it is the running task. Once you return from GateHwi_enter, the thread that owns the gate cannot be preempted since all interrupts are disabled (and you should not be making kernel calls that impact the scheduler while you own the gate).

    We made the query functions in case you just have a IGateProvider_Handle and need to know more about it before using it.

    Todd

  • Hi Todd,

    I understand whatever you are saying. But still my doubt is uncleared. My question is "Can we create explicitly two priority mutex instances, one with quality BLOCKING and another with quality PREEMPTIVE?".

    regards,

    Iyyappan.

  • Hi lyypappan.

    No. These are read-only qualities of the GateMutex and GateMutexPri modules.

    Todd