mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-08-06 07:00:05 +08:00
feat(lwip): Add to prevent switch to tcpip thread between mbox post and sem wait
This commit is contained in:
@ -344,8 +344,17 @@ tcpip_send_msg_wait_sem(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem)
|
||||
TCPIP_MSG_VAR_REF(msg).type = TCPIP_MSG_API;
|
||||
TCPIP_MSG_VAR_REF(msg).msg.api_msg.function = fn;
|
||||
TCPIP_MSG_VAR_REF(msg).msg.api_msg.msg = apimsg;
|
||||
#if ESP_LWIP
|
||||
u8_t prio = sys_thread_priority_get(NULL); // add to prevent switch to tcpip thread between mbox post and sem wait
|
||||
if((TCPIP_THREAD_PRIO + 1) > prio) {
|
||||
sys_thread_priority_set(NULL, TCPIP_THREAD_PRIO + 1); // set priority higher than tcpip thread
|
||||
}
|
||||
#endif
|
||||
sys_mbox_post(&mbox, &TCPIP_MSG_VAR_REF(msg));
|
||||
sys_arch_sem_wait(sem, 0);
|
||||
#if ESP_LWIP
|
||||
sys_thread_priority_set(NULL, prio);
|
||||
#endif
|
||||
TCPIP_MSG_VAR_FREE(msg);
|
||||
return ERR_OK;
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
@ -438,6 +438,16 @@ sys_arch_msleep(int ms)
|
||||
vTaskDelay(ms / portTICK_RATE_MS);
|
||||
}
|
||||
|
||||
u8_t sys_thread_priority_get(sys_thread_t thread_handle)
|
||||
{
|
||||
return (u8_t)uxTaskPriorityGet(thread_handle);
|
||||
}
|
||||
|
||||
void sys_thread_priority_set(sys_thread_t thread_handle, u8_t priority)
|
||||
{
|
||||
vTaskPrioritySet(thread_handle, (UBaseType_t)priority);
|
||||
}
|
||||
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
|
||||
static void sys_thread_sem_free(int index, void *data) // destructor for TLS semaphore
|
||||
|
@ -48,6 +48,24 @@ typedef xTaskHandle sys_thread_t;
|
||||
#define sys_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define sys_sem_set_invalid( x ) ( ( *x ) = NULL )
|
||||
|
||||
/**
|
||||
* Get thread priority througth thread_handle
|
||||
*
|
||||
* @param task_handle
|
||||
*
|
||||
* @return thread priority
|
||||
*/
|
||||
u8_t sys_thread_priority_get(sys_thread_t thread_handle);
|
||||
|
||||
/**
|
||||
* Set thread priority througth thread_handle
|
||||
*
|
||||
* @param task_handle
|
||||
*
|
||||
* @param priority
|
||||
*/
|
||||
void sys_thread_priority_set(sys_thread_t thread_handle, u8_t priority);
|
||||
|
||||
#define LWIP_COMPAT_MUTEX 0
|
||||
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
|
Reference in New Issue
Block a user