MQX_CHECK_VALIDITY

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX_CHECK_VALIDITY

Jump to solution
498 Views
alessandrobiasc
Contributor I

Hi all,

             I have a general question about the code executed if MQX_CHECK_VALIDITY is set.

This is an example of _lwsem_post from MQX 4.2.2 :

_mqx_uint _lwsem_post

(

    LWSEM_STRUCT_PTR sem_ptr

)

{ /* Body */

/* ...... */

#if MQX_CHECK_VALIDITY

    if (sem_ptr->VALID != LWSEM_VALID)

    {

        _KLOGX2(KLOG_lwsem_post, MQX_INVALID_LWSEM);

        return (MQX_INVALID_LWSEM);

    } /* Endif */

#endif /* MQX_CHECK_VALIDITY */

/* ...... */

My question is:

  • Why this code is executed without any kind of mutual exclusion (mutex, interrupt disable, ...) ? The current task can be preempted during the check and another task can "validate/invalidate" the lwsem. I'm missing something in the implementation (sorry for this) ?

Regards,

    Alessandro.

0 Kudos
1 Solution
324 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Alessandro,

Actually, this code is executed with interrupt disable, it is wrapped in the macro.  Please check the macro _KLOGX2 defines.

#define _KLOGX2(fn,p1) _KLOG(_klog_log(KLOG_FUNCTION_EXIT, \

   (_mqx_max_type)(fn), (_mqx_max_type)(p1), (_mqx_max_type)0, (_mqx_max_type)0, (_mqx_max_type)0);)

void _klog_log

(

    _mqx_uint type,

    _mqx_max_type p1,

    _mqx_max_type p2,

    _mqx_max_type p3,

    _mqx_max_type p4,

    _mqx_max_type p5

)

{ /* Body */

...

_INT_DISABLE();
_lwlog_write(LOG_KERNEL_LOG_NUMBER, (_mqx_max_type)type, p1, p2, p3, p4, p5,
                calling_pc);
_INT_ENABLE();

...

}

 


Have a great day,
Daniel

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
1 Reply
325 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Alessandro,

Actually, this code is executed with interrupt disable, it is wrapped in the macro.  Please check the macro _KLOGX2 defines.

#define _KLOGX2(fn,p1) _KLOG(_klog_log(KLOG_FUNCTION_EXIT, \

   (_mqx_max_type)(fn), (_mqx_max_type)(p1), (_mqx_max_type)0, (_mqx_max_type)0, (_mqx_max_type)0);)

void _klog_log

(

    _mqx_uint type,

    _mqx_max_type p1,

    _mqx_max_type p2,

    _mqx_max_type p3,

    _mqx_max_type p4,

    _mqx_max_type p5

)

{ /* Body */

...

_INT_DISABLE();
_lwlog_write(LOG_KERNEL_LOG_NUMBER, (_mqx_max_type)type, p1, p2, p3, p4, p5,
                calling_pc);
_INT_ENABLE();

...

}

 


Have a great day,
Daniel

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos