General query regarding Nuttx context switching and TCB structure.

123 views
Skip to first unread message

Megha Sinha

unread,
Mar 21, 2020, 11:50:57 AM3/21/20
to NuttX
Hello

I am relatively new to RTOS concepts, so please excuse my ignorance. 
I am studying Nuttx as part of my project along side other RTOSes

I found two major difference between Nuttx and other RTOSes.

1. Nuttx uses SVC for context switch while most other RTOSes uses PendSV. PendSV in other RTOSes are obviously very low priority, while in Nuttx SVS priority is raised.

2. It is a common practice to keep stack pointer for the TCB as the first entry of TCB structure. In Nuttx this is different. If I understood correctly, stack_alloc_ptr is the stack pointer which is relatively somewhere in the middle of the task structure.

Can someone please explain to me the above two changes and the significance of why it is designed like this?
 

Thank you

Nathan Hartman

unread,
Mar 24, 2020, 10:47:09 PM3/24/20
to NuttX
Hi,

I noticed that no one replied to you yet.

I don't know the answer to your question, but NuttX has become an Apache.org podling, and all discussions are now taking place at the d...@nuttx.apache.org mailing list. You can subscribe from this page: https://nuttx.apache.org/community/ and post your question there and you'll probably get a quick response. We have NuttX developers and users in almost every time zone. :-)

Cheers,
Nathan

Nathan Hartman

unread,
Mar 24, 2020, 10:48:37 PM3/24/20
to NuttX
On Tuesday, March 24, 2020 at 10:47:09 PM UTC-4, Nathan Hartman wrote:
I don't know the answer to your question, but NuttX has become an Apache.org podling, and all discussions are now taking place at the d...@nuttx.apache.org mailing list. You can subscribe from this page: https://nuttx.apache.org/community/ and post your question there and you'll probably get a quick response. We have NuttX developers and users in almost every time zone. :-)


Also, that mailing list is archived here:

 

Xiang Xiao

unread,
Mar 25, 2020, 11:26:04 AM3/25/20
to NuttX
On Sat, Mar 21, 2020 at 11:51 PM Megha Sinha <sinha.m...@gmail.com> wrote:
>
> Hello
>
> I am relatively new to RTOS concepts, so please excuse my ignorance.
> I am studying Nuttx as part of my project along side other RTOSes
>
> I found two major difference between Nuttx and other RTOSes.
>
> 1. Nuttx uses SVC for context switch while most other RTOSes uses PendSV. PendSV in other RTOSes are obviously very low priority, while in Nuttx SVS priority is raised.
>

Several reasons what I can imagine:
1.PendSV only exist on Cortex-M as far as I know, it's hard to apply
the functionality to other architecture(e.g. Cortex-A/R).
2.NuttX support syscall from userspace(most other RTOS lack this
functionality), SVC unify the implementation of the context switch and
syscall.
3.The unused PendSV can be used for Zero Latency Interrupts:
https://cwiki.apache.org/confluence/display/NUTTX/High+Performance%2C+Zero+Latency+Interrupts
but the user has to find other mechanism if RTOS(e.g. FreeRTOS) use
PendSV for scheduling.

> 2. It is a common practice to keep stack pointer for the TCB as the first entry of TCB structure. In Nuttx this is different. If I understood correctly, stack_alloc_ptr is the stack pointer which is relatively somewhere in the middle of the task structure.
>

stack_alloc_ptr always point to the begining of the stack(the lowest
address), not at the middle of the stack. TCB is allocated from the
global heap not from the stack(some RTOS reserve TCB from the
begin/end of stack).

> Can someone please explain to me the above two changes and the significance of why it is designed like this?
>
>
> Thank you
>
> --
> You received this message because you are subscribed to the Google Groups "NuttX" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nuttx+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nuttx/b2b23cfe-f2ad-424d-904f-9b85df206e21%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages