feat(class): add usb_osal_thread_schedule_other to allow the applications which use the struct usbh_xxx to exit properly before free struct usbh_xxx
Signed-off-by: sakumisu <1203593632@qq.com>
This commit is contained in:
@@ -25,6 +25,18 @@ void usb_osal_thread_delete(usb_osal_thread_t thread)
|
||||
vTaskDelete(thread);
|
||||
}
|
||||
|
||||
void usb_osal_thread_schedule_other(void)
|
||||
{
|
||||
TaskHandle_t xCurrentTask = xTaskGetCurrentTaskHandle();
|
||||
const UBaseType_t old_priority = uxTaskPriorityGet(xCurrentTask);
|
||||
|
||||
vTaskPrioritySet(xCurrentTask, tskIDLE_PRIORITY);
|
||||
|
||||
taskYIELD();
|
||||
|
||||
vTaskPrioritySet(xCurrentTask, old_priority);
|
||||
}
|
||||
|
||||
usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count)
|
||||
{
|
||||
return (usb_osal_sem_t)xSemaphoreCreateCounting(1, initial_count);
|
||||
|
||||
@@ -30,6 +30,18 @@ void usb_osal_thread_delete(usb_osal_thread_t thread)
|
||||
vTaskDelete(thread);
|
||||
}
|
||||
|
||||
void usb_osal_thread_schedule_other(void)
|
||||
{
|
||||
TaskHandle_t xCurrentTask = xTaskGetCurrentTaskHandle();
|
||||
const UBaseType_t old_priority = uxTaskPriorityGet(xCurrentTask);
|
||||
|
||||
vTaskPrioritySet(xCurrentTask, tskIDLE_PRIORITY);
|
||||
|
||||
taskYIELD();
|
||||
|
||||
vTaskPrioritySet(xCurrentTask, old_priority);
|
||||
}
|
||||
|
||||
usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count)
|
||||
{
|
||||
usb_osal_sem_t sem = (usb_osal_sem_t)xSemaphoreCreateCounting(1, initial_count);
|
||||
|
||||
@@ -55,6 +55,18 @@ void usb_osal_thread_delete(usb_osal_thread_t thread)
|
||||
}
|
||||
}
|
||||
|
||||
void usb_osal_thread_schedule_other(void)
|
||||
{
|
||||
UINT32 task_id = LOS_CurTaskIDGet();
|
||||
const UINT16 old_priority = LOS_TaskPriGet(task_id);
|
||||
|
||||
LOS_TaskPriSet(task_id, OS_TASK_PRIORITY_LOWEST);
|
||||
|
||||
LOS_TaskYield();
|
||||
|
||||
LOS_TaskPriSet(task_id, old_priority);
|
||||
}
|
||||
|
||||
usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count)
|
||||
{
|
||||
UINT32 sem_handle;
|
||||
|
||||
@@ -63,6 +63,18 @@ void usb_osal_thread_delete(usb_osal_thread_t thread)
|
||||
kthread_delete(pid);
|
||||
}
|
||||
|
||||
void usb_osal_thread_schedule_other(void)
|
||||
{
|
||||
struct tcb_s *tcb = nxsched_self();
|
||||
const int old_priority = tcb->sched_priority;
|
||||
|
||||
nxsched_set_priority(tcb, SCHED_PRIORITY_MIN);
|
||||
|
||||
sched_yield();
|
||||
|
||||
nxsched_set_priority(tcb, old_priority);
|
||||
}
|
||||
|
||||
usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -34,6 +34,23 @@ void usb_osal_thread_delete(usb_osal_thread_t thread)
|
||||
rt_thread_delete(thread);
|
||||
}
|
||||
|
||||
void usb_osal_thread_schedule_other(void)
|
||||
{
|
||||
rt_thread_t self = rt_thread_self();
|
||||
rt_uint8_t priority;
|
||||
#if (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 0))
|
||||
const rt_uint8_t old_priority = RT_SCHED_PRIV(self).current_priority;
|
||||
#else
|
||||
const rt_uint8_t old_priority = self->current_priority;
|
||||
#endif
|
||||
priority = RT_THREAD_PRIORITY_MAX - 1;
|
||||
rt_thread_control(self, RT_THREAD_CTRL_CHANGE_PRIORITY, (void *)&priority);
|
||||
|
||||
rt_thread_yield();
|
||||
|
||||
rt_thread_control(self, RT_THREAD_CTRL_CHANGE_PRIORITY, (void *)&old_priority);
|
||||
}
|
||||
|
||||
usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count)
|
||||
{
|
||||
usb_osal_sem_t sem = (usb_osal_sem_t)rt_sem_create("usbh_sem", initial_count, RT_IPC_FLAG_FIFO);
|
||||
|
||||
@@ -69,6 +69,18 @@ void usb_osal_thread_delete(usb_osal_thread_t thread)
|
||||
tx_byte_release(thread);
|
||||
}
|
||||
|
||||
void usb_osal_thread_schedule_other(void)
|
||||
{
|
||||
TX_THREAD *current_thread = tx_thread_identify();
|
||||
const UINT old_priority = current_thread->tx_thread_priority;
|
||||
|
||||
tx_thread_priority_change(current_thread, TX_MAX_PRIORITIES - 1, &old_priority);
|
||||
|
||||
tx_thread_relinquish();
|
||||
|
||||
tx_thread_priority_change(current_thread, old_priority, &old_priority);
|
||||
}
|
||||
|
||||
usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count)
|
||||
{
|
||||
TX_SEMAPHORE *sem_ptr = TX_NULL;
|
||||
|
||||
@@ -74,6 +74,22 @@ void usb_osal_thread_delete(usb_osal_thread_t thread)
|
||||
k_free(thread);
|
||||
}
|
||||
|
||||
void usb_osal_thread_schedule_other(void)
|
||||
{
|
||||
#if (KERNELVERSION >= 0x3070000)
|
||||
struct k_thread *current_thread = k_sched_current_thread_query();
|
||||
#else
|
||||
struct k_thread *current_thread = z_current_get();
|
||||
#endif
|
||||
const int old_priority = k_thread_priority_get(current_thread);
|
||||
|
||||
k_thread_priority_set(current_thread, K_LOWEST_APPLICATION_THREAD_PRIO);
|
||||
|
||||
k_yield();
|
||||
|
||||
k_thread_priority_set(current_thread, old_priority);
|
||||
}
|
||||
|
||||
usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count)
|
||||
{
|
||||
struct k_sem *sem;
|
||||
|
||||
Reference in New Issue
Block a user