http://www.freertos.org/a00125.html gives the prototype for the xTaskCreate() function, and says how stack sizes are specified. The stack is allocated from the heap as per the first link above.
My RAM is 10KBytes.
From that 1KB has to be reserved for the CSTACK.
13 tasks are created in my application. Total of 3328 bytes are allocated for the stack size of those tasks during xTaskCreate() function calls. Each task was given different stack sizes so that they will not have excess memory. (All having less than 100 minimum free stack each)
According to the map file the aggregation of RAM of all other files are around 1Kbytes.
Total of all above is (1K + 3.3K + 1K) 5.3K. However we cannot run the system with configTOTAL_HEAP_SIZE less than 8Kbytes.
Please explain what happens to the (8K - 5.3K) RAM, which is not used by my files/functions.
Do you really need the CSTACK once the tasks have started? CSTACK is normally used by main(), but after the scheduler has started each tasks have their own stacks and CSTACK is not required any more. You can then recycle CSTACK for other uses, and normally find its start address from the variables defined in the linker script. If that is the case or not depends on the port and microcontroller you are using. Some ports reuse CSTACK as an interrupt stack.
You cannot magic more RAM into a microcontroller, but you can select one from the same family that has more unless minimum recurring production code is really vital. However, another thing to consider is if you can cut down the number of tasks you have running. If some of the tasks perform periodic or run to completion functionality then you could implement them as timer callback functions instead of a task. All timer callbacks use the same stack as the timer task. If you can implement two tasks as timer callback functions, but add the timer task, overall you have still saved one entire stack of RAM.