aboutsummaryrefslogtreecommitdiff
path: root/apps/systemlib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/systemlib')
-rw-r--r--apps/systemlib/systemlib.c31
-rw-r--r--apps/systemlib/systemlib.h8
2 files changed, 36 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)
diff --git a/apps/systemlib/systemlib.h b/apps/systemlib/systemlib.h
index add47f440..da1524435 100644
--- a/apps/systemlib/systemlib.h
+++ b/apps/systemlib/systemlib.h
@@ -50,6 +50,14 @@ __EXPORT int reboot(void);
/** Sends SIGUSR1 to all processes */
__EXPORT void killall(void);
+/** Starts a task and performs any specific accounting, scheduler setup, etc. */
+__EXPORT int task_spawn(const char *name,
+ int priority,
+ int scheduler,
+ int stack_size,
+ main_t entry,
+ const char *argv[]);
+
enum MULT_PORTS {
MULT_0_US2_RXTX = 0,
MULT_1_US2_FLOW,