sched: change xx_timeout param from pid to tcb
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
92f8f9b8f8
commit
083dd03018
|
@ -57,7 +57,7 @@
|
||||||
* becomes non-empty.
|
* becomes non-empty.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pid - the task ID of the task to wakeup
|
* arg - the argument provided when the timeout was configured.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* 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;
|
irqstate_t flags;
|
||||||
|
|
||||||
/* Disable interrupts. This is necessary because an interrupt handler may
|
/* 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();
|
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
|
/* It is also possible that an interrupt/context switch beat us to the
|
||||||
* punch and already changed the task's state.
|
* 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 */
|
/* 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 */
|
/* Start the watchdog */
|
||||||
|
|
||||||
wd_start(&rtcb->waitdog, ticks,
|
wd_start(&rtcb->waitdog, ticks, nxmq_rcvtimeout, (wdparm_t)rtcb);
|
||||||
nxmq_rcvtimeout, nxsched_gettid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the message from the message queue */
|
/* Get the message from the message queue */
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
* becomes non-full.
|
* becomes non-full.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pid - the task ID of the task to wakeup
|
* arg - The argument that was provided when the timeout was configured.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* 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;
|
irqstate_t flags;
|
||||||
|
|
||||||
/* Disable interrupts. This is necessary because an interrupt handler may
|
/* 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();
|
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
|
/* It is also possible that an interrupt/context switch beat us to the
|
||||||
* punch and already changed the task's state.
|
* 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 */
|
/* 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 */
|
/* 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 */
|
/* And wait for the message queue to be non-empty */
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
|
||||||
|
|
||||||
/* Start the watchdog */
|
/* 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
|
/* Now perform the blocking wait. If nxsem_wait() fails, the
|
||||||
* negated errno value will be returned below.
|
* negated errno value will be returned below.
|
||||||
|
|
|
@ -107,7 +107,7 @@ int nxsem_tickwait(FAR sem_t *sem, uint32_t delay)
|
||||||
|
|
||||||
/* Start the watchdog with interrupts still disabled */
|
/* 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 */
|
/* Now perform the blocking wait */
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
* semaphore is acquired.
|
* semaphore is acquired.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pid - The task ID of the task to wakeup
|
* arg - The argument that was provided when the timeout was configured.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* 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;
|
irqstate_t flags;
|
||||||
|
|
||||||
/* Disable interrupts to avoid race conditions */
|
/* Disable interrupts to avoid race conditions */
|
||||||
|
|
||||||
flags = enter_critical_section();
|
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
|
/* It is also possible that an interrupt/context switch beat us to the
|
||||||
* punch and already changed the task's state.
|
* 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 */
|
/* Cancel the semaphore wait */
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode);
|
||||||
|
|
||||||
/* Handle semaphore timer expiration */
|
/* 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 */
|
/* Recover semaphore resources with a task or thread is destroyed */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue