px4_task_spawn_cmd: launch kernel thread in protected/kernel build on kernel side

Also task name is accessible only in kernel side for protected/kernel build

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
Jukka Laitinen 2021-01-14 15:20:49 +02:00 committed by Daniel Agar
parent 8185e2a384
commit 3aab4d2daf
1 changed files with 6 additions and 1 deletions

View File

@ -42,6 +42,7 @@
#include <px4_platform_common/tasks.h>
#include <nuttx/board.h>
#include <nuttx/kthread.h>
#include <sys/wait.h>
#include <stdbool.h>
@ -67,8 +68,12 @@ int px4_task_spawn_cmd(const char *name, int scheduler, int priority, int stack_
clearenv();
#endif
#if !defined(__KERNEL__)
/* create the task */
int pid = task_create(name, priority, stack_size, entry, argv);
#else
int pid = kthread_create(name, priority, stack_size, entry, argv);
#endif
if (pid > 0) {
/* configure the scheduler */
@ -88,7 +93,7 @@ int px4_task_delete(int pid)
const char *px4_get_taskname(void)
{
#if CONFIG_TASK_NAME_SIZE > 0
#if CONFIG_TASK_NAME_SIZE > 0 && (defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT))
FAR struct tcb_s *thisproc = nxsched_self();
return thisproc->name;