Simplify sys_check_core_locking() in contrib/ports/freertos

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Simplify sys_check_core_locking() in contrib/ports/freertos

Craig McQueen
For an LWIP_ASSERT_CORE_LOCKED() implementation under FreeRTOS -- in contrib/ports/freertos, it looks as though its definition of sys_check_core_locking() is more complicated than it needs to be.

There's no need for sys_lock_tcpip_core() etc, for use by LOCK_TCPIP_CORE() etc. It's sufficient for sys_mutex_lock() etc to use FreeRTOS recursive mutex, and then the default definition of LOCK_TCPIP_CORE() is fine.

sys_check_core_locking() can simply do:

    if ( lwip_tcpip_thread )
    {
        LWIP_ASSERT( "lwip_core_lock", sys_mutex_is_held( &lock_tcpip_core ) );
    }

While sys_mutex_is_held() can be defined as:

bool sys_mutex_is_held( sys_mutex_t *pxMutex )
{
    return ( xSemaphoreGetMutexHolder( *pxMutex ) == xTaskGetCurrentTaskHandle() );
}

--
Craig McQueen


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel