Skip to content

Conversation

@xiaoxiang781216
Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 commented Aug 29, 2020

Summary

Model the host signal handling as NuttX's irq. The next step is:
1.Save/restore context with ucontext API
2.trigger the context switch by signal

Impact

Testing

@xiaoxiang781216
Copy link
Contributor Author

@sebastianene07 please review this patch. To make #1602 enter the mainline, I would suggest you don't put all code into one patch, it's better to split that patch into two:
1.Replace setjmp/longjmp with ucontext API
2.Implement preemptable oneshot timer

@xiaoxiang781216 xiaoxiang781216 force-pushed the preempt branch 2 times, most recently from 22a0164 to 206c14c Compare August 30, 2020 04:51

void up_disable_irq(int irq)
{
signal(irq, SIG_IGN);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAYBE: We can use the same mechanism from up_enable_irq to specify a blocking signal mask with pthread_sigmask as signal(..) specifies the behaviour for the entire process(is like blocking the interrupts on all CPUs).

Copy link
Contributor Author

@xiaoxiang781216 xiaoxiang781216 Aug 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pthread_sigmask can only block the current thread, it's hard to block all threads directly with signal API. That's why I simply change the signal handle to ignore. BTW, up_disable_irq just make the linker happy, nobody really call it.

*
****************************************************************************/

void up_enable_irq(int irq)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: This function will enable interrupts for a CPU. The behaviour is that child threads will copy the signal mask upon creation. Do you think it's better for us to block all the signals in sim_idle_trampoline except the SIGUSR1 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to unmask the signal on all threads because we can simulate the hardware behaviour more closely.

* Private Types
****************************************************************************/

union sigset_u

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GG ! This looks good

@sebastianene07
Copy link

sebastianene07 commented Aug 30, 2020

@sebastianene07 please review this patch. To make #1602 enter the mainline, I would suggest you don't put all code into one patch, it's better to split that patch into two:
1.Replace setjmp/longjmp with ucontext API
2.Implement preemptable oneshot timer

I think this is a good idea to split the patch as it makes the review more efficient. Thanks !

@sebastianene07
Copy link

@sebastianene07 please review this patch. To make #1602 enter the mainline, I would suggest you don't put all code into one patch, it's better to split that patch into two:
1.Replace setjmp/longjmp with ucontext API
2.Implement preemptable oneshot timer

I will rebase my patches on top of this, once this enters master

Sebastian Ene and others added 2 commits September 2, 2020 05:33
to avoid the host signal process interrupt the execution of NuttX critical section

Signed-off-by: Sebastian Ene <nuttx@fitbit.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants