Hi,in the demos ChibiOS/demos/various/RT-ARMCM4-USELIB it started the main thread then it sleep for some finite seconds.So when I looked at the sequence of actions taken,I can see a context switch occured..
chThdSleep --> chSysLock() --> chThdSleepS --> chSchGoSleepTimeoutS --> chSchGoSleepS --> chSysSwitch-->port switch..
So currently the stack pointer is at thread1 so it can't call unlock since the lock was taken by main thread and the system state is S.But in S state the regular interrupts are disabled,so how it will handle the interrupts without leaving the S state?
Interrupt handling in S state
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Interrupt handling in S state
Hi,
Common question
Inside that sequence there is a context switch, the thread switched-in leaves the S-lock state on its side. The system never -stays- in S-lock state.
The sequence is always lock->switch->unlock, no delays inside.
Giovanni
Common question
Inside that sequence there is a context switch, the thread switched-in leaves the S-lock state on its side. The system never -stays- in S-lock state.
The sequence is always lock->switch->unlock, no delays inside.
Giovanni
-
- Posts: 10
- Joined: Sat Jun 22, 2019 6:15 pm
Re: Interrupt handling in S state
But after context switch from main thread the pointer is at thread1 and it will start running it.Lock is taken from main so it should unlock it from main,so how to leave S-state??
main thread --> chSysLock --> Context switch(pointer at thread1 in S state) How to unlock from thread1?To unlock we need to return to main thread??
main thread --> chSysLock --> Context switch(pointer at thread1 in S state) How to unlock from thread1?To unlock we need to return to main thread??
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Interrupt handling in S state
Hi,
I suggest you step by step through a context switch, this should make it clear.
Giovanni
I suggest you step by step through a context switch, this should make it clear.
Giovanni
Who is online
Users browsing this forum: No registered users and 22 guests