aboutsummaryrefslogtreecommitdiff
path: root/apps/systemlib/systemlib.c
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-10-01 00:02:38 -0700
committerpx4dev <px4@purgatory.org>2012-10-01 00:02:38 -0700
commit93c200d281e7488db95806840a6976b02d1afbe0 (patch)
tree606a24e6778f54c3d7fa9939f303d89f76161d4e /apps/systemlib/systemlib.c
parent6005077d54e6b96a5284752eedbd026ef7952341 (diff)
downloadpx4-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.c31
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, &param);
+
+ /* 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)