1. A method of providing memory management in a Real-Time Operating System (RTOS) based system, the method comprising: creating, by a task generator, a plurality of tasks with a two level stack scheme including a first-level stack and a second-level stack; scheduling, by a task scheduler, a first task for execution by moving a stack pointer from the first-level stack to the second-level stack; determining whether the first task is pre-empted; allocating the second-level stack to the first task in a second state if the first task is not pre-empted; changing, by the task scheduler, an active task for execution; determining whether the first task relinquishes control from the second state and is waiting for a resource; moving the stack pointer back from the second-level stack to the first-level stack if the first task relinquishes itself; and providing the second-level stack for use by a second task.