sched: change xx_timeout param from pid to tcb

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2024-06-05 23:48:53 +08:00 committed by Xiang Xiao
parent 92f8f9b8f8
commit 083dd03018
6 changed files with 17 additions and 36 deletions

View File

@ -57,7 +57,7 @@
* becomes non-empty.
*
* Input Parameters:
* pid - the task ID of the task to wakeup
* arg - the argument provided when the timeout was configured.
*
* Returned Value:
* None
@ -66,9 +66,9 @@
*
****************************************************************************/
static void nxmq_rcvtimeout(wdparm_t pid)
static void nxmq_rcvtimeout(wdparm_t arg)
{
FAR struct tcb_s *wtcb;
FAR struct tcb_s *wtcb = (FAR struct tcb_s *)(uintptr_t)arg;
irqstate_t flags;
/* Disable interrupts. This is necessary because an interrupt handler may
@ -77,17 +77,11 @@ static void nxmq_rcvtimeout(wdparm_t pid)
flags = enter_critical_section();
/* Get the TCB associated with this pid. It is possible that task may no
* longer be active when this watchdog goes off.
*/
wtcb = nxsched_get_tcb(pid);
/* It is also possible that an interrupt/context switch beat us to the
* punch and already changed the task's state.
*/
if (wtcb && wtcb->task_state == TSTATE_WAIT_MQNOTEMPTY)
if (wtcb->task_state == TSTATE_WAIT_MQNOTEMPTY)
{
/* Restart with task with a timeout error */
@ -202,8 +196,7 @@ file_mq_timedreceive_internal(FAR struct file *mq, FAR char *msg,
/* Start the watchdog */
wd_start(&rtcb->waitdog, ticks,
nxmq_rcvtimeout, nxsched_gettid());
wd_start(&rtcb->waitdog, ticks, nxmq_rcvtimeout, (wdparm_t)rtcb);
}
/* Get the message from the message queue */

View File

@ -56,7 +56,7 @@
* becomes non-full.
*
* Input Parameters:
* pid - the task ID of the task to wakeup
* arg - The argument that was provided when the timeout was configured.
*
* Returned Value:
* None
@ -65,9 +65,9 @@
*
****************************************************************************/
static void nxmq_sndtimeout(wdparm_t pid)
static void nxmq_sndtimeout(wdparm_t arg)
{
FAR struct tcb_s *wtcb;
FAR struct tcb_s *wtcb = (FAR struct tcb_s *)(uintptr_t)arg;
irqstate_t flags;
/* Disable interrupts. This is necessary because an interrupt handler may
@ -76,17 +76,11 @@ static void nxmq_sndtimeout(wdparm_t pid)
flags = enter_critical_section();
/* Get the TCB associated with this pid. It is possible that task may no
* longer be active when this watchdog goes off.
*/
wtcb = nxsched_get_tcb(pid);
/* It is also possible that an interrupt/context switch beat us to the
* punch and already changed the task's state.
*/
if (wtcb != NULL && wtcb->task_state == TSTATE_WAIT_MQNOTFULL)
if (wtcb->task_state == TSTATE_WAIT_MQNOTFULL)
{
/* Restart with task with a timeout error */
@ -242,7 +236,7 @@ file_mq_timedsend_internal(FAR struct file *mq, FAR const char *msg,
/* Start the watchdog and begin the wait for MQ not full */
wd_start(&rtcb->waitdog, ticks, nxmq_sndtimeout, nxsched_gettid());
wd_start(&rtcb->waitdog, ticks, nxmq_sndtimeout, (wdparm_t)rtcb);
/* And wait for the message queue to be non-empty */

View File

@ -151,7 +151,7 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
/* Start the watchdog */
wd_start(&rtcb->waitdog, ticks, nxsem_timeout, nxsched_gettid());
wd_start(&rtcb->waitdog, ticks, nxsem_timeout, (uintptr_t)rtcb);
/* Now perform the blocking wait. If nxsem_wait() fails, the
* negated errno value will be returned below.

View File

@ -107,7 +107,7 @@ int nxsem_tickwait(FAR sem_t *sem, uint32_t delay)
/* Start the watchdog with interrupts still disabled */
wd_start(&rtcb->waitdog, delay, nxsem_timeout, nxsched_gettid());
wd_start(&rtcb->waitdog, delay, nxsem_timeout, (uintptr_t)rtcb);
/* Now perform the blocking wait */

View File

@ -47,7 +47,7 @@
* semaphore is acquired.
*
* Input Parameters:
* pid - The task ID of the task to wakeup
* arg - The argument that was provided when the timeout was configured.
*
* Returned Value:
* None
@ -57,26 +57,20 @@
*
****************************************************************************/
void nxsem_timeout(wdparm_t pid)
void nxsem_timeout(wdparm_t arg)
{
FAR struct tcb_s *wtcb;
FAR struct tcb_s *wtcb = (FAR struct tcb_s *)(uintptr_t)arg;
irqstate_t flags;
/* Disable interrupts to avoid race conditions */
flags = enter_critical_section();
/* Get the TCB associated with this PID. It is possible that
* task may no longer be active when this watchdog goes off.
*/
wtcb = nxsched_get_tcb(pid);
/* It is also possible that an interrupt/context switch beat us to the
* punch and already changed the task's state.
*/
if (wtcb && wtcb->task_state == TSTATE_WAIT_SEM)
if (wtcb->task_state == TSTATE_WAIT_SEM)
{
/* Cancel the semaphore wait */

View File

@ -61,7 +61,7 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode);
/* Handle semaphore timer expiration */
void nxsem_timeout(wdparm_t pid);
void nxsem_timeout(wdparm_t arg);
/* Recover semaphore resources with a task or thread is destroyed */