Interrupt handling in S state

Discussions and support about ChibiOS/RT, the free embedded RTOS.
Prathibha Prakash
Posts: 10
Joined: Sat Jun 22, 2019 6:15 pm

Interrupt handling in S state

Postby Prathibha Prakash » Sat Jun 22, 2019 6:33 pm

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?

User avatar
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

Postby Giovanni » Sat Jun 22, 2019 6:43 pm

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

Prathibha Prakash
Posts: 10
Joined: Sat Jun 22, 2019 6:15 pm

Re: Interrupt handling in S state

Postby Prathibha Prakash » Sun Jun 23, 2019 5:42 pm

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??

User avatar
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

Postby Giovanni » Sun Jun 23, 2019 5:55 pm

Hi,

I suggest you step by step through a context switch, this should make it clear.

Giovanni


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 22 guests