Move CONFIG_MAX_TASKS check at earlier stage of task/thread creation
Existing overhead:
-----------------
Currently following steps involved before returning error.
1) Allocates the kernel memory for tcb struct
2) Allocates the user/kernel stack memory
3) Allocates the memory for group using group_allocate()
4) Associates file descriptors with the new task
5) Try to assign the pid for the new task
6) task_assignpid() does a check and returns error if already CONFIG_MAX_TASKS are alive in the system.
7) Once the error is returned, OS calles sched_release_tcb to deallocate/freeup the tcb, stack and group memory.
This feature address above concern as follows.
1) Tracks the number of tasks alive in the system at any point of time
2) Makes the early check, whether CONFIG_MAX_TASKS are already alive in the system, before proceeding further
3) If already CONFIG_MAX_TASKS are alive in the system, just return with ERROR
This avoids the overhead in the OS which is mentioned in the top 1 to 7
Signed-off-by: pradeep.ns <pradeep.ns@samsung.com>