diff options
author | px4dev <px4@purgatory.org> | 2012-10-01 00:02:38 -0700 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2012-10-01 00:02:38 -0700 |
commit | 93c200d281e7488db95806840a6976b02d1afbe0 (patch) | |
tree | 606a24e6778f54c3d7fa9939f303d89f76161d4e /apps/systemlib/systemlib.c | |
parent | 6005077d54e6b96a5284752eedbd026ef7952341 (diff) | |
download | px4-firmware-93c200d281e7488db95806840a6976b02d1afbe0.tar.gz px4-firmware-93c200d281e7488db95806840a6976b02d1afbe0.tar.bz2 px4-firmware-93c200d281e7488db95806840a6976b02d1afbe0.zip |
Add new 'task_spawn' interface for starting new tasks in the PX4 world
Diffstat (limited to 'apps/systemlib/systemlib.c')
-rw-r--r-- | apps/systemlib/systemlib.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/apps/systemlib/systemlib.c b/apps/systemlib/systemlib.c index 4c7aae83e..3d46a17a8 100644 --- a/apps/systemlib/systemlib.c +++ b/apps/systemlib/systemlib.c @@ -68,10 +68,10 @@ const struct __multiport_info multiport_info = { ****************************************************************************/ /**************************************************************************** - * Public Functions + * Private Functions ****************************************************************************/ -void kill_task(FAR _TCB *tcb, FAR void *arg); +static void kill_task(FAR _TCB *tcb, FAR void *arg); /**************************************************************************** * user_start @@ -116,11 +116,36 @@ void killall() sched_foreach(kill_task, NULL); } -void kill_task(FAR _TCB *tcb, FAR void *arg) +static void kill_task(FAR _TCB *tcb, FAR void *arg) { kill(tcb->pid, SIGUSR1); } +int task_spawn(const char *name, int scheduler, int priority, int stack_size, main_t entry, const char *argv[]) +{ + int pid; + + sched_lock(); + + /* create the task */ + pid = task_create(name, priority, stack_size, entry, argv); + + if (pid > 0) { + + /* configure the scheduler */ + struct sched_param param; + + param.sched_priority = priority; + sched_setscheduler(pid, scheduler, ¶m); + + /* XXX do any other private task accounting here */ + } + + sched_unlock(); + + return pid; +} + #define PX4_BOARD_ID_FMU (5) int fmu_get_board_info(struct fmu_board_info_s *info) |