sched/spawn: Support task_spawnattr_[set|get]stacksize in kernel mode

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
Xiang Xiao
2022-10-20 03:10:23 +08:00
committed by Masayuki Ishikawa
parent 55083b31a9
commit b9b032af72
6 changed files with 10 additions and 32 deletions
-2
View File
@@ -106,12 +106,10 @@ int exec_spawn(FAR const char *filename, FAR char * const *argv,
bin->priority = attr->priority; bin->priority = attr->priority;
} }
#ifndef CONFIG_BUILD_KERNEL
if (attr->stacksize > 0) if (attr->stacksize > 0)
{ {
bin->stacksize = attr->stacksize; bin->stacksize = attr->stacksize;
} }
#endif
} }
/* Disable pre-emption so that the executed module does /* Disable pre-emption so that the executed module does
+8 -14
View File
@@ -87,12 +87,10 @@ struct posix_spawnattr_s
#endif #endif
sigset_t sigmask; /* Signals to be masked */ sigset_t sigmask; /* Signals to be masked */
size_t stacksize; /* Task stack size (non-standard) */
#ifndef CONFIG_BUILD_KERNEL #ifndef CONFIG_BUILD_KERNEL
/* Used only by task_spawn (non-standard) */ FAR void *stackaddr; /* Task stack address (non-standard) */
FAR void *stackaddr; /* Task stack address */
size_t stacksize; /* Task stack size */
#endif #endif
#ifdef CONFIG_SCHED_SPORADIC #ifdef CONFIG_SCHED_SPORADIC
@@ -203,25 +201,21 @@ int posix_spawnattr_setschedpolicy(FAR posix_spawnattr_t *attr, int policy);
int posix_spawnattr_setsigmask(FAR posix_spawnattr_t *attr, int posix_spawnattr_setsigmask(FAR posix_spawnattr_t *attr,
FAR const sigset_t *sigmask); FAR const sigset_t *sigmask);
/* Non-standard get/set spawn attributes interfaces for use only with /* Non-standard get/set spawn attributes interfaces */
* task_spawn()
*/ int task_spawnattr_getstacksize(FAR const posix_spawnattr_t *attr,
FAR size_t *stacksize);
int task_spawnattr_setstacksize(FAR posix_spawnattr_t *attr,
size_t stacksize);
#ifndef CONFIG_BUILD_KERNEL #ifndef CONFIG_BUILD_KERNEL
int task_spawnattr_getstackaddr(FAR const posix_spawnattr_t *attr, int task_spawnattr_getstackaddr(FAR const posix_spawnattr_t *attr,
FAR void **stackaddr); FAR void **stackaddr);
int task_spawnattr_setstackaddr(FAR posix_spawnattr_t *attr, int task_spawnattr_setstackaddr(FAR posix_spawnattr_t *attr,
FAR void *stackaddr); FAR void *stackaddr);
int task_spawnattr_getstacksize(FAR const posix_spawnattr_t *attr,
FAR size_t *stacksize);
int task_spawnattr_setstacksize(FAR posix_spawnattr_t *attr,
size_t stacksize);
#else #else
# define task_spawnattr_getstackaddr(attr, addr) (*(addr) = NULL, 0) # define task_spawnattr_getstackaddr(attr, addr) (*(addr) = NULL, 0)
# define task_spawnattr_setstackaddr(attr, addr) (0) # define task_spawnattr_setstackaddr(attr, addr) (0)
# define task_spawnattr_getstacksize(attr, size) (*(size) = 0, 0)
# define task_spawnattr_setstacksize(attr, size) (0)
#endif #endif
/* Non standard debug functions */ /* Non standard debug functions */
+2 -6
View File
@@ -23,21 +23,17 @@
CSRCS += lib_psfa_addaction.c lib_psfa_addclose.c lib_psfa_adddup2.c CSRCS += lib_psfa_addaction.c lib_psfa_addclose.c lib_psfa_adddup2.c
CSRCS += lib_psfa_addopen.c lib_psfa_destroy.c lib_psfa_init.c CSRCS += lib_psfa_addopen.c lib_psfa_destroy.c lib_psfa_init.c
ifeq ($(CONFIG_DEBUG_FEATURES),y)
CSRCS += lib_psfa_dump.c
endif
CSRCS += lib_psa_getflags.c lib_psa_getschedparam.c lib_psa_getschedpolicy.c CSRCS += lib_psa_getflags.c lib_psa_getschedparam.c lib_psa_getschedpolicy.c
CSRCS += lib_psa_init.c lib_psa_setflags.c lib_psa_setschedparam.c CSRCS += lib_psa_init.c lib_psa_setflags.c lib_psa_setschedparam.c
CSRCS += lib_psa_setschedpolicy.c lib_psa_getsigmask.c lib_psa_setsigmask.c CSRCS += lib_psa_setschedpolicy.c lib_psa_getsigmask.c lib_psa_setsigmask.c
CSRCS += lib_psa_getstackaddr.c lib_psa_setstackaddr.c
ifneq ($(CONFIG_BUILD_KERNEL),y) ifneq ($(CONFIG_BUILD_KERNEL),y)
CSRCS += lib_psa_getstackaddr.c lib_psa_setstackaddr.c
CSRCS += lib_psa_getstacksize.c lib_psa_setstacksize.c CSRCS += lib_psa_getstacksize.c lib_psa_setstacksize.c
endif endif
ifeq ($(CONFIG_DEBUG_FEATURES),y) ifeq ($(CONFIG_DEBUG_FEATURES),y)
CSRCS += lib_psa_dump.c CSRCS += lib_psfa_dump.c lib_psa_dump.c
endif endif
# Add the spawn directory to the build # Add the spawn directory to the build
-4
View File
@@ -28,8 +28,6 @@
#include <spawn.h> #include <spawn.h>
#include <assert.h> #include <assert.h>
#ifndef CONFIG_BUILD_KERNEL
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -59,5 +57,3 @@ int task_spawnattr_getstacksize(FAR const posix_spawnattr_t *attr,
*stacksize = attr->stacksize; *stacksize = attr->stacksize;
return OK; return OK;
} }
#endif /* !CONFIG_BUILD_KERNEL */
-2
View File
@@ -98,11 +98,9 @@ int posix_spawnattr_init(posix_spawnattr_t *attr)
attr->budget.tv_nsec = param.sched_ss_init_budget.tv_nsec; attr->budget.tv_nsec = param.sched_ss_init_budget.tv_nsec;
#endif #endif
#ifndef CONFIG_ARCH_ADDRENV
/* Default stack size */ /* Default stack size */
attr->stacksize = CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE; attr->stacksize = CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE;
#endif
return OK; return OK;
} }
-4
View File
@@ -28,8 +28,6 @@
#include <spawn.h> #include <spawn.h>
#include <assert.h> #include <assert.h>
#ifndef CONFIG_BUILD_KERNEL
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -59,5 +57,3 @@ int task_spawnattr_setstacksize(FAR posix_spawnattr_t *attr,
attr->stacksize = stacksize; attr->stacksize = stacksize;
return OK; return OK;
} }
#endif /* !CONFIG_BUILD_KERNEL */