FreeRTOS / FreeRTOS-Cellular-Interface

FreeRTOS Cellular Interface implementation of the 3GPP TS v27.007 standard.
MIT License
85 stars 59 forks source link

It seems that System would be locked or doesn't work properly when Mutex cannot get due to PlatformMutex_Lock doesn't have return value #156

Closed KeitaKashima closed 6 months ago

KeitaKashima commented 1 year ago

Hi, I wonder the system would be locked or not work properly if PlatformMutex_Lock API cannot get Mutex or happened the timeout of Mutex.

https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/ccbd0fcce06fcb7b842bed61f207523c8f271fcb/source/cellular_common_api.c#L211

    PlatformMutex_Lock( &pContext->PktRespMutex );    // It gets the Mutex however, the API doesn't have return value. So, the code cannot check timeout.
    pContext->cbEvents.networkRegistrationCallback = networkRegistrationCallback;
    pContext->cbEvents.pNetworkRegistrationCallbackContext = pCallbackContext;
    PlatformMutex_Unlock( &pContext->PktRespMutex );

Does it nerver happnened?

shubnil commented 1 year ago

HI @KeitaKashima , Thanks for bringing this up. We have not observed this. Do you have a use case where you are seeing this behavior

KeitaKashima commented 1 year ago

Hi @shubnil ,

Thank you for your reply. I have never seen the lock of the system here. I just checked the implementation of the Semaphore portion.

chinglee-iot commented 6 months ago

Hi @KeitaKashima, The PktRespMutex is used to protect the cellular context which can be accessed by the pktio thread and the application thread. The code with the mutex held should not block indefinitely, and no timeout is expected with the mutex lock operation. You can reference the example implementation in this file.