MQX_CHECK_VALIDITY

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MQX_CHECK_VALIDITY

跳至解决方案
1,096 次查看
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 项奖励
回复
1 解答
922 次查看
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 项奖励
回复
1 回复
923 次查看
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 项奖励
回复