# stack pointing wrong?

**URL:** <https://forums.freertos.org/t/stack-pointing-wrong/3767>\
**Category:** Kernel\
**Created:** [September 6, 2010, 5:53pm UTC](https://forums.freertos.org/t/stack-pointing-wrong/3767 "2010-09-06T17:53:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 6, 2010, 5:53pm UTC](https://forums.freertos.org/t/stack-pointing-wrong/3767/1 "2010-09-06T17:53:19Z")

</div>

**[stevend8](https://sourceforge.net/u/stevend8/)** wrote on [Monday, September 06, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/a387b604/#cda8):

hey all,

i have made a basic task scheduler with some elements of the RTOS system  
for example i use the same SAVE\_CONTEXT and RESTORE\_CONTEXT and initialise stack

this is my main:

```
//main includes
#include "Main.h"
#include "Config.h"
#include "Scheduler.h"
//task includes
#include "KnipperLed.h"
/*
 * Create task and then start scheduler
 */
void main()
{
	createTask(knipperLed, 5);	//(address task, priority)
	startScheduler();	
	//here prog never comes
}

```

but i have one problem: if the scheduler starts, the stack points to  
the createTask from my main routine instead of to the task?

how is that possible with the same initialise stack and restore\_context?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 6, 2010, 6:08pm UTC](https://forums.freertos.org/t/stack-pointing-wrong/3767/2 "2010-09-06T18:08:00Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Monday, September 06, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/a387b604/#482f):

This forum has enough to do to support its own RTOS without supporting yours too.

I presume you have kept in all the copyright notices?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 7, 2010, 7:54am UTC](https://forums.freertos.org/t/stack-pointing-wrong/3767/3 "2010-09-07T07:54:42Z")

</div>

**[stevend8](https://sourceforge.net/u/stevend8/)** wrote on [Tuesday, September 07, 2010](https://sourceforge.net/p/freertos/discussion/382005/thread/a387b604/#88a7):

nervermind…

of course i referenced to freeRTOS
