Move CONFIG_MAX_TASKS check at earlier stage of task/thread creation
authorpradeep.ns <pradeep.ns@samsung.com>
Mon, 19 Jun 2017 17:08:13 +0000 (22:38 +0530)
committerpradeep.ns <pradeep.ns@samsung.com>
Thu, 29 Jun 2017 07:01:54 +0000 (12:31 +0530)
commitffcf729482c3637998d5dcd5e9e18d9978c5b2f7
treefc7a485699ab8e78cd6dd7ef8e22a7a88a81dee4
parent32f04468f5f38fd72ef5ffc0cf212608cac67f87
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>
os/kernel/init/os_start.c
os/kernel/sched/sched.h
os/kernel/sched/sched_releasetcb.c
os/kernel/task/task_create.c
os/kernel/task/task_setup.c