summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunJ <[email protected]>2026-01-13 17:31:29 +0800
committersakumisu <[email protected]>2026-01-22 21:16:27 +0800
commitaf556f4f03949bf44e02ba02683596a10859bd65 (patch)
tree96870662fd37dd2f242685380001401dfc0aad43
parent901adfe19bd9da64f48195cdcb36838d4ce4d34b (diff)
refactor(osal): replace NuttX internal APIs with POSIX APIs
Replace nxsched_self() and nxsched_set_priority() with standard POSIX sched_getparam() and sched_setparam() in usb_osal_thread_schedule_other(). This improves portability and follows POSIX standards for thread priority management. Change-Id: I2e637268f77e200fbdee3e7713cba1b115976696 Signed-off-by: SunJ <[email protected]>
-rw-r--r--osal/usb_osal_nuttx.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/osal/usb_osal_nuttx.c b/osal/usb_osal_nuttx.c
index 49911573..1a44fb48 100644
--- a/osal/usb_osal_nuttx.c
+++ b/osal/usb_osal_nuttx.c
@@ -65,14 +65,23 @@ void usb_osal_thread_delete(usb_osal_thread_t thread)
void usb_osal_thread_schedule_other(void)
{
- struct tcb_s *tcb = nxsched_self();
- const int old_priority = tcb->sched_priority;
+ struct sched_param param;
+ int old_priority;
- nxsched_set_priority(tcb, SCHED_PRIORITY_MIN);
+ /* Get current priority (pid=0 means current task) */
+ assert(sched_getparam(0, &param) == 0);
+ old_priority = param.sched_priority;
+ /* Set to minimum priority to yield CPU to other tasks */
+ param.sched_priority = SCHED_PRIORITY_MIN;
+ assert(sched_setparam(0, &param) == 0);
+
+ /* Yield CPU to other tasks */
sched_yield();
- nxsched_set_priority(tcb, old_priority);
+ /* Restore original priority */
+ param.sched_priority = old_priority;
+ assert(sched_setparam(0, &param) == 0);
}
usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count)