sim: fix signal deliver calling error on sim platform

since the signal deliver handler should be called in signal owner task.

Change-Id: Ic55c08d1a880069864eddda8dab945ce677792d7
This commit is contained in:
mage1
2021-03-16 17:27:26 +08:00
parent 1da573d2b0
commit f5805d25c0
6 changed files with 75 additions and 72 deletions
+15 -12
View File
@@ -127,18 +127,6 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
rtcb = this_task();
sinfo("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of
* a kludge. This would be unsafe in a truly multi-threaded,
* interrupt driven environment.
*/
if (rtcb->xcp.sigdeliver)
{
sinfo("Delivering signals TCB=%p\n", rtcb);
((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
rtcb->xcp.sigdeliver = NULL;
}
/* Reset scheduler parameters */
nxsched_resume_scheduler(rtcb);
@@ -147,5 +135,20 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
up_longjmp(rtcb->xcp.regs, 1);
}
else
{
/* The way that we handle signals in the simulation is kind of
* a kludge. This would be unsafe in a truly multi-threaded,
* interrupt driven environment.
*/
rtcb = this_task();
if (rtcb->xcp.sigdeliver)
{
sinfo("Delivering signals TCB=%p\n", rtcb);
((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
rtcb->xcp.sigdeliver = NULL;
}
}
}
}
-12
View File
@@ -80,18 +80,6 @@ void up_exit(int status)
tcb = this_task();
sinfo("New Active Task TCB=%p\n", tcb);
/* The way that we handle signals in the simulation is kind of
* a kludge. This would be unsafe in a truly multi-threaded, interrupt
* driven environment.
*/
if (tcb->xcp.sigdeliver)
{
sinfo("Delivering signals TCB=%p\n", tcb);
((sig_deliver_t)tcb->xcp.sigdeliver)(tcb);
tcb->xcp.sigdeliver = NULL;
}
/* Then switch contexts */
up_longjmp(tcb->xcp.regs, 1);
+15 -12
View File
@@ -96,18 +96,6 @@ void up_release_pending(void)
rtcb = this_task();
sinfo("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of
* a kludge. This would be unsafe in a truly multi-threaded,
* interrupt driven environment.
*/
if (rtcb->xcp.sigdeliver)
{
sinfo("Delivering signals TCB=%p\n", rtcb);
((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
rtcb->xcp.sigdeliver = NULL;
}
/* Update scheduler parameters */
nxsched_resume_scheduler(rtcb);
@@ -116,5 +104,20 @@ void up_release_pending(void)
up_longjmp(rtcb->xcp.regs, 1);
}
else
{
/* The way that we handle signals in the simulation is kind of
* a kludge. This would be unsafe in a truly multi-threaded,
* interrupt driven environment.
*/
rtcb = this_task();
if (rtcb->xcp.sigdeliver)
{
sinfo("Delivering signals TCB=%p\n", rtcb);
((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
rtcb->xcp.sigdeliver = NULL;
}
}
}
}
+15 -12
View File
@@ -151,18 +151,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
rtcb = this_task();
sinfo("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of
* a kludge. This would be unsafe in a truly multi-threaded,
* interrupt driven environment.
*/
if (rtcb->xcp.sigdeliver)
{
sinfo("Delivering signals TCB=%p\n", rtcb);
((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
rtcb->xcp.sigdeliver = NULL;
}
/* Update scheduler parameters */
nxsched_resume_scheduler(rtcb);
@@ -171,6 +159,21 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
up_longjmp(rtcb->xcp.regs, 1);
}
else
{
/* The way that we handle signals in the simulation is kind of
* a kludge. This would be unsafe in a truly multi-threaded,
* interrupt driven environment.
*/
rtcb = this_task();
if (rtcb->xcp.sigdeliver)
{
sinfo("Delivering signals TCB=%p\n", rtcb);
((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
rtcb->xcp.sigdeliver = NULL;
}
}
}
}
}
+15 -12
View File
@@ -139,18 +139,6 @@ int up_cpu_paused(int cpu)
rtcb = current_task(cpu);
/* The way that we handle signals in the simulation is kind of a
* kludge. This would be unsafe in a truly multi-threaded,
* interrupt driven environment.
*/
if (rtcb->xcp.sigdeliver)
{
sinfo("CPU%d: Delivering signals TCB=%p\n", cpu, rtcb);
((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
rtcb->xcp.sigdeliver = NULL;
}
#ifdef CONFIG_SCHED_INSTRUMENTATION
/* Notify that we have resumed */
@@ -165,6 +153,21 @@ int up_cpu_paused(int cpu)
up_longjmp(rtcb->xcp.regs, 1);
}
else
{
/* The way that we handle signals in the simulation is kind of
* a kludge. This would be unsafe in a truly multi-threaded,
* interrupt driven environment.
*/
rtcb = this_task();
if (rtcb->xcp.sigdeliver)
{
sinfo("CPU%d: Delivering signals TCB=%p\n", this_cpu(), rtcb);
((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
rtcb->xcp.sigdeliver = NULL;
}
}
return OK;
}
+15 -12
View File
@@ -111,18 +111,6 @@ void up_unblock_task(FAR struct tcb_s *tcb)
rtcb = this_task();
sinfo("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of
* a kludge. This would be unsafe in a truly multi-threaded,
* interrupt driven environment.
*/
if (rtcb->xcp.sigdeliver)
{
sinfo("Delivering signals TCB=%p\n", rtcb);
((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
rtcb->xcp.sigdeliver = NULL;
}
/* Update scheduler parameters */
nxsched_resume_scheduler(rtcb);
@@ -131,5 +119,20 @@ void up_unblock_task(FAR struct tcb_s *tcb)
up_longjmp(rtcb->xcp.regs, 1);
}
else
{
/* The way that we handle signals in the simulation is kind of
* a kludge. This would be unsafe in a truly multi-threaded,
* interrupt driven environment.
*/
rtcb = this_task();
if (rtcb->xcp.sigdeliver)
{
sinfo("Delivering signals TCB=%p\n", rtcb);
((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
rtcb->xcp.sigdeliver = NULL;
}
}
}
}