Squashed commit of the following:
sched/: Convert legitimate uses of task_create() to nxtask_create(). Review handling of returned values from all uses of kthread_create() (as well as nxtask_create()). graphics/: Review return values for all calls to kthread_start() because it no longer returns an errno. drivers/: threads started by drivers should be kernel threads, not user tasks. Review return values for all calls to kthread_start() because it no longer returns an errno. configs/: threads started by board bringup logic should be kernel threads, not user tasksi (part 2 of 2). sched/task: Add nxtask_create(). Kthread_create() and nxtask_create() are internal OS functions and should not modify the errno variable. configs/: threads started by board bringup logic should be kernel threads, not user tasks.
This commit is contained in:
parent
1550ef2f54
commit
50ca32e254
2
TODO
2
TODO
@ -258,7 +258,7 @@ o Task/Scheduler (sched/)
|
||||
message queue used in the OS. I am keeping this issue
|
||||
open because (1) there are some known remaining calls that
|
||||
that will modify the errno (such as dup(), dup2(),
|
||||
task_create(), task_activate(), kthread_create(), exec(), mq_open(),
|
||||
task_activate(), kthread_create(), exec(), mq_open(),
|
||||
mq_close(), and others) and (2) there may still be calls that
|
||||
create cancellation points. Need to check things like open(),
|
||||
close(), read(), write(), and possibly others.
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -209,9 +210,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -225,8 +226,9 @@ int lpc31_usbhost_initialize(void)
|
||||
|
||||
/* Start a thread to handle device connection. */
|
||||
|
||||
pid = task_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)ehci_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)ehci_waiter, (FAR char * const *)NULL);
|
||||
if (pid < 0)
|
||||
{
|
||||
uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret);
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -240,9 +241,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/mmcsd.h>
|
||||
@ -301,9 +302,9 @@ static int nsh_usbhostinitialize(void)
|
||||
|
||||
syslog(LOG_ERR, "ERROR: Start nsh_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_MCB1700_USBHOST_PRIO,
|
||||
CONFIG_MCB1700_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_MCB1700_USBHOST_PRIO,
|
||||
CONFIG_MCB1700_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -208,9 +209,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -239,9 +240,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -239,9 +240,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -230,8 +231,9 @@ int lpc31_usbhost_initialize(void)
|
||||
|
||||
/* Start a thread to handle device connection. */
|
||||
|
||||
pid = task_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)ehci_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO,i
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)ehci_waiter, (FAR char * const *)NULL);
|
||||
if (pid < 0)
|
||||
{
|
||||
uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret);
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/mmcsd.h>
|
||||
@ -301,9 +302,9 @@ static int nsh_usbhostinitialize(void)
|
||||
|
||||
syslog(LOG_ERR, "ERROR: Start nsh_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_LPC1766STK_USBHOST_PRIO,
|
||||
CONFIG_LPC1766STK_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_LPC1766STK_USBHOST_PRIO,
|
||||
CONFIG_LPC1766STK_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -237,9 +238,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -215,9 +216,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_STM32H407_USBHOST_PRIO,
|
||||
CONFIG_STM32H407_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_STM32H407_USBHOST_PRIO,
|
||||
CONFIG_STM32H407_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -219,9 +220,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -236,9 +237,9 @@ int stm32_usbhost_setup(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_OLIMEXP407_USBHOST_PRIO,
|
||||
CONFIG_OLIMEXP407_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_OLIMEXP407_USBHOST_PRIO,
|
||||
CONFIG_OLIMEXP407_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/sdio.h>
|
||||
#include <nuttx/mmcsd.h>
|
||||
@ -343,9 +344,9 @@ static int nsh_usbhostinitialize(void)
|
||||
|
||||
syslog(LOG_INFO, "Start nsh_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/mmcsd.h>
|
||||
@ -309,9 +310,9 @@ static int nsh_usbhostinitialize(void)
|
||||
|
||||
syslog(LOG_INFO, "Start nsh_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/mmcsd.h>
|
||||
@ -320,9 +321,9 @@ static int nsh_usbhostinitialize(void)
|
||||
|
||||
syslog(LOG_INFO, "Start nsh_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
return -ENODEV;
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -357,9 +358,9 @@ int sam_usbhost_initialize(void)
|
||||
|
||||
/* Start a thread to handle device connection. */
|
||||
|
||||
pid = task_create("OHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE,
|
||||
(main_t)ohci_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("OHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE,
|
||||
(main_t)ohci_waiter, (FAR char * const *)NULL);
|
||||
if (pid < 0)
|
||||
{
|
||||
uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret);
|
||||
@ -379,9 +380,9 @@ int sam_usbhost_initialize(void)
|
||||
|
||||
/* Start a thread to handle device connection. */
|
||||
|
||||
pid = task_create("EHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE,
|
||||
(main_t)ehci_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("EHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE,
|
||||
(main_t)ehci_waiter, (FAR char * const *)NULL);
|
||||
if (pid < 0)
|
||||
{
|
||||
uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret);
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -355,9 +356,9 @@ int sam_usbhost_initialize(void)
|
||||
|
||||
/* Start a thread to handle device connection. */
|
||||
|
||||
pid = task_create("OHCI Monitor", CONFIG_SAMA5D3xEK_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE,
|
||||
(main_t)ohci_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("OHCI Monitor", CONFIG_SAMA5D3xEK_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE,
|
||||
(main_t)ohci_waiter, (FAR char * const *)NULL);
|
||||
if (pid < 0)
|
||||
{
|
||||
uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret);
|
||||
@ -377,9 +378,9 @@ int sam_usbhost_initialize(void)
|
||||
|
||||
/* Start a thread to handle device connection. */
|
||||
|
||||
pid = task_create("EHCI Monitor", CONFIG_SAMA5D3xEK_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE,
|
||||
(main_t)ehci_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("EHCI Monitor", CONFIG_SAMA5D3xEK_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE,
|
||||
(main_t)ehci_waiter, (FAR char * const *)NULL);
|
||||
if (pid < 0)
|
||||
{
|
||||
uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret);
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -356,9 +357,9 @@ int sam_usbhost_initialize(void)
|
||||
|
||||
/* Start a thread to handle device connection. */
|
||||
|
||||
pid = task_create("OHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D4EK_USBHOST_STACKSIZE,
|
||||
(main_t)ohci_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("OHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D4EK_USBHOST_STACKSIZE,
|
||||
(main_t)ohci_waiter, (FAR char * const *)NULL);
|
||||
if (pid < 0)
|
||||
{
|
||||
uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret);
|
||||
@ -378,9 +379,9 @@ int sam_usbhost_initialize(void)
|
||||
|
||||
/* Start a thread to handle device connection. */
|
||||
|
||||
pid = task_create("EHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D4EK_USBHOST_STACKSIZE,
|
||||
(main_t)ehci_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("EHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO,
|
||||
CONFIG_SAMA5D4EK_USBHOST_STACKSIZE,
|
||||
(main_t)ehci_waiter, (FAR char * const *)NULL);
|
||||
if (pid < 0)
|
||||
{
|
||||
uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret);
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -208,9 +209,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -208,9 +209,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -208,7 +209,7 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -248,9 +249,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_STM32F411DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F411DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_STM32F411DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F411DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -214,9 +215,9 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_STM32F429IDISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F429IDISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_STM32F429IDISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F429IDISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -248,7 +249,7 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO,
|
||||
pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -240,7 +241,7 @@ int stm32_usbhost_initialize(void)
|
||||
|
||||
uinfo("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_STM32F7F4DISCO_USBHOST_PRIO,
|
||||
pid = kthread_create("usbhost", CONFIG_STM32F7F4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32F7F4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
@ -237,9 +238,9 @@ int stm32l4_usbhost_initialize(void)
|
||||
|
||||
uvdbg("Start usbhost_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_STM32L4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32L4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_STM32L4DISCO_USBHOST_PRIO,
|
||||
CONFIG_STM32L4DISCO_USBHOST_STACKSIZE,
|
||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/mmcsd.h>
|
||||
@ -318,9 +319,9 @@ static int nsh_usbhostinitialize(void)
|
||||
|
||||
syslog(LOG_INFO, "Start nsh_waiter\n");
|
||||
|
||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||
CONFIG_USBHOST_STACKSIZE,
|
||||
(main_t)nsh_waiter, (FAR char * const *)NULL);
|
||||
return pid < 0 ? -ENOEXEC : OK;
|
||||
}
|
||||
return -ENODEV;
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
@ -971,15 +972,15 @@ int slip_initialize(int intf, FAR const char *devname)
|
||||
|
||||
slip_ifdown(&priv->dev);
|
||||
|
||||
/* Start the SLIP receiver task */
|
||||
/* Start the SLIP receiver kernel thread */
|
||||
|
||||
snprintf(buffer, 8, "%d", intf);
|
||||
argv[0] = buffer;
|
||||
argv[1] = NULL;
|
||||
|
||||
priv->rxpid = task_create("rxslip", CONFIG_NET_SLIP_DEFPRIO,
|
||||
CONFIG_NET_SLIP_STACKSIZE, (main_t)slip_rxtask,
|
||||
(FAR char * const *)argv);
|
||||
priv->rxpid = kthread_create("rxslip", CONFIG_NET_SLIP_DEFPRIO,
|
||||
CONFIG_NET_SLIP_STACKSIZE, (main_t)slip_rxtask,
|
||||
(FAR char * const *)argv);
|
||||
if (priv->rxpid < 0)
|
||||
{
|
||||
nerr("ERROR: Failed to start receiver task\n");
|
||||
@ -990,11 +991,11 @@ int slip_initialize(int intf, FAR const char *devname)
|
||||
|
||||
slip_semtake(priv);
|
||||
|
||||
/* Start the SLIP transmitter task */
|
||||
/* Start the SLIP transmitter kernel thread */
|
||||
|
||||
priv->txpid = task_create("txslip", CONFIG_NET_SLIP_DEFPRIO,
|
||||
CONFIG_NET_SLIP_STACKSIZE, (main_t)slip_txtask,
|
||||
(FAR char * const *)argv);
|
||||
priv->txpid = kthread_create("txslip", CONFIG_NET_SLIP_DEFPRIO,
|
||||
CONFIG_NET_SLIP_STACKSIZE, (main_t)slip_txtask,
|
||||
(FAR char * const *)argv);
|
||||
if (priv->txpid < 0)
|
||||
{
|
||||
nerr("ERROR: Failed to start receiver task\n");
|
||||
|
@ -1629,12 +1629,12 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv)
|
||||
CONFIG_HIDKBD_STACKSIZE,
|
||||
(main_t)usbhost_kbdpoll,
|
||||
(FAR char * const *)NULL);
|
||||
if (priv->pollpid == ERROR)
|
||||
if (priv->pollpid < 0)
|
||||
{
|
||||
/* Failed to started the poll thread... probably due to memory resources */
|
||||
|
||||
usbhost_givesem(&g_exclsem);
|
||||
ret = -ENOMEM;
|
||||
ret = (int)priv->pollpid;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
|
@ -1699,12 +1699,12 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv)
|
||||
CONFIG_HIDMOUSE_STACKSIZE,
|
||||
(main_t)usbhost_mouse_poll,
|
||||
(FAR char * const *)NULL);
|
||||
if (priv->pollpid == ERROR)
|
||||
if (priv->pollpid < 0)
|
||||
{
|
||||
/* Failed to started the poll thread... probably due to memory resources */
|
||||
|
||||
usbhost_givesem(&g_exclsem);
|
||||
ret = -ENOMEM;
|
||||
ret = priv->pollpid;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
|
@ -1341,12 +1341,12 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv)
|
||||
CONFIG_XBOXCONTROLLER_STACKSIZE,
|
||||
(main_t)usbhost_xboxcontroller_poll,
|
||||
(FAR char * const *)NULL);
|
||||
if (priv->pollpid == ERROR)
|
||||
if (priv->pollpid < 0)
|
||||
{
|
||||
/* Failed to started the poll thread... probably due to memory resources */
|
||||
|
||||
usbhost_givesem(&g_exclsem);
|
||||
ret = -ENOMEM;
|
||||
ret = priv->pollpid;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
|
@ -231,25 +231,24 @@ int usbmonitor_start(void)
|
||||
(FAR char * const *)NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = get_errno();
|
||||
uerr("ERROR: Failed to start the USB monitor: %d\n",
|
||||
errcode);
|
||||
UNUSED(errcode);
|
||||
ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_usbmonitor.pid = ret;
|
||||
uinfo("Started: %d\n", g_usbmonitor.pid);
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
sched_unlock();
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
sched_unlock();
|
||||
uinfo("%s: %d\n",
|
||||
g_usbmonitor.stop ? "Stopping" : "Running", g_usbmonitor.pid);
|
||||
return 0;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -190,11 +190,8 @@ int nx_start(void)
|
||||
CONFIG_NXSTART_SERVERSTACK, nx_server, NULL);
|
||||
if (server < 0)
|
||||
{
|
||||
int errcode = get_errno();
|
||||
DEBUGASSERT(errcode > 0);
|
||||
|
||||
gerr("ERROR: Failed to create nx_server kernel thread: %d\n", errcode);
|
||||
return -errcode;
|
||||
gerr("ERROR: Failed to create nx_server kernel thread: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
g_nxserver_started = true;
|
||||
|
@ -64,6 +64,49 @@ extern "C"
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtask_create
|
||||
*
|
||||
* Description:
|
||||
* This function creates and activates a new user task with a specified
|
||||
* priority and returns its system-assigned ID.
|
||||
*
|
||||
* The entry address entry is the address of the "main" function of the
|
||||
* task. This function will be called once the C environment has been
|
||||
* set up. The specified function will be called with four arguments.
|
||||
* Should the specified routine return, a call to exit() will
|
||||
* automatically be made.
|
||||
*
|
||||
* Note that four (and only four) arguments must be passed for the spawned
|
||||
* functions.
|
||||
*
|
||||
* nxtask_create() is identical to the function task_create(), differing
|
||||
* only in its return value: This function does not modify the errno
|
||||
* variable. This is a non-standard, internal OS function and is not
|
||||
* intended for use by application logic. Applications should use
|
||||
* task_create().
|
||||
*
|
||||
* Input Parameters:
|
||||
* name - Name of the new task
|
||||
* priority - Priority of the new task
|
||||
* stack_size - size (in bytes) of the stack needed
|
||||
* entry - Entry point of a new task
|
||||
* arg - A pointer to an array of input parameters. Up to
|
||||
* CONFIG_MAX_TASK_ARG parameters may be provided. If fewer
|
||||
* than CONFIG_MAX_TASK_ARG parameters are passed, the list
|
||||
* should be terminated with a NULL argv[] value. If no
|
||||
* parameters are required, argv may be NULL.
|
||||
*
|
||||
* Return Value:
|
||||
* Returns the positive, non-zero process ID of the new task or a negated
|
||||
* errno value to indicate the nature of any failure. If memory is
|
||||
* insufficient or the task cannot be created -ENOMEM will be returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nxtask_create(FAR const char *name, int priority,
|
||||
int stack_size, main_t entry, FAR char * const argv[]);
|
||||
|
||||
/********************************************************************************
|
||||
* Name: kthread_create
|
||||
*
|
||||
@ -73,10 +116,20 @@ extern "C"
|
||||
* newly started thread to run in kernel model.
|
||||
*
|
||||
* Input Parameters:
|
||||
* (same as task_create())
|
||||
* name - Name of the new task
|
||||
* priority - Priority of the new task
|
||||
* stack_size - size (in bytes) of the stack needed
|
||||
* entry - Entry point of a new task
|
||||
* arg - A pointer to an array of input parameters. Up to
|
||||
* CONFIG_MAX_TASK_ARG parameters may be provided. If fewer
|
||||
* than CONFIG_MAX_TASK_ARG parameters are passed, the list
|
||||
* should be terminated with a NULL argv[] value. If no
|
||||
* parameters are required, argv may be NULL.
|
||||
*
|
||||
* Return Value:
|
||||
* (same as task_create())
|
||||
* Returns the positive, non-zero process ID of the new task or a negated
|
||||
* errno value to indicate the nature of any failure. If memory is
|
||||
* insufficient or the task cannot be created -ENOMEM will be returned.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
|
@ -257,16 +257,16 @@ static inline void os_do_appstart(void)
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
DEBUGASSERT(USERSPACE->us_entrypoint != NULL);
|
||||
pid = task_create("init", SCHED_PRIORITY_DEFAULT,
|
||||
CONFIG_USERMAIN_STACKSIZE, USERSPACE->us_entrypoint,
|
||||
(FAR char * const *)NULL);
|
||||
pid = nxtask_create("init", SCHED_PRIORITY_DEFAULT,
|
||||
CONFIG_USERMAIN_STACKSIZE, USERSPACE->us_entrypoint,
|
||||
(FAR char * const *)NULL);
|
||||
#else
|
||||
pid = task_create("init", SCHED_PRIORITY_DEFAULT,
|
||||
CONFIG_USERMAIN_STACKSIZE,
|
||||
(main_t)CONFIG_USER_ENTRYPOINT,
|
||||
(FAR char * const *)NULL);
|
||||
pid = nxtask_create("init", SCHED_PRIORITY_DEFAULT,
|
||||
CONFIG_USERMAIN_STACKSIZE,
|
||||
(main_t)CONFIG_USER_ENTRYPOINT,
|
||||
(FAR char * const *)NULL);
|
||||
#endif
|
||||
ASSERT(pid > 0);
|
||||
DEBUGASSERT(pid > 0);
|
||||
}
|
||||
|
||||
#elif defined(CONFIG_INIT_FILEPATH)
|
||||
@ -357,7 +357,7 @@ static inline void os_start_application(void)
|
||||
pid = kthread_create("AppBringUp", CONFIG_BOARD_INITTHREAD_PRIORITY,
|
||||
CONFIG_BOARD_INITTHREAD_STACKSIZE,
|
||||
(main_t)os_start_task, (FAR char * const *)NULL);
|
||||
ASSERT(pid > 0);
|
||||
DEBUGASSERT(pid > 0);
|
||||
|
||||
#else
|
||||
/* Do the board/application initialization on this thread of execution. */
|
||||
|
@ -1,7 +1,8 @@
|
||||
/****************************************************************************
|
||||
* sched/task/task_create.c
|
||||
*
|
||||
* Copyright (C) 2007-2010, 2013-2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2010, 2013-2014, 2016, 2018 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -78,9 +79,9 @@
|
||||
* parameters are required, argv may be NULL.
|
||||
*
|
||||
* Return Value:
|
||||
* Returns the non-zero process ID of the new task or ERROR if memory is
|
||||
* insufficient or the task cannot be created. The errno will be set to
|
||||
* indicate the nature of the error (always ENOMEM).
|
||||
* Returns the positive, non-zero process ID of the new task or a negated
|
||||
* errno value to indicate the nature of any failure. If memory is
|
||||
* insufficient or the task cannot be created -ENOMEM will be returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -90,7 +91,6 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
{
|
||||
FAR struct task_tcb_s *tcb;
|
||||
pid_t pid;
|
||||
int errcode;
|
||||
int ret;
|
||||
|
||||
/* Allocate a TCB for the new task. */
|
||||
@ -99,7 +99,7 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
if (!tcb)
|
||||
{
|
||||
serr("ERROR: Failed to allocate TCB\n");
|
||||
errcode = ENOMEM;
|
||||
return -ENOMEM;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
@ -111,7 +111,6 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
ret = group_allocate(tcb, ttype);
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
#endif
|
||||
@ -129,7 +128,6 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
ret = group_setuptaskfiles(tcb);
|
||||
if (ret < OK)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
}
|
||||
@ -140,7 +138,6 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
ret = up_create_stack((FAR struct tcb_s *)tcb, stack_size, ttype);
|
||||
if (ret < OK)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
|
||||
@ -149,7 +146,6 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
ret = task_schedsetup(tcb, priority, task_start, entry, ttype);
|
||||
if (ret < OK)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
|
||||
@ -163,7 +159,6 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
ret = group_initialize(tcb);
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
#endif
|
||||
@ -177,7 +172,8 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
ret = task_activate((FAR struct tcb_s *)tcb);
|
||||
if (ret < OK)
|
||||
{
|
||||
errcode = get_errno();
|
||||
ret = -get_errno();
|
||||
DEBUGASSERT(ret < 0);
|
||||
|
||||
/* The TCB was added to the active task list by task_schedsetup() */
|
||||
|
||||
@ -189,16 +185,60 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
|
||||
errout_with_tcb:
|
||||
sched_releasetcb((FAR struct tcb_s *)tcb, ttype);
|
||||
|
||||
errout:
|
||||
set_errno(errcode);
|
||||
return ERROR;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtask_create
|
||||
*
|
||||
* Description:
|
||||
* This function creates and activates a new task with a specified
|
||||
* priority and returns its system-assigned ID.
|
||||
*
|
||||
* The entry address entry is the address of the "main" function of the
|
||||
* task. This function will be called once the C environment has been
|
||||
* set up. The specified function will be called with four arguments.
|
||||
* Should the specified routine return, a call to exit() will
|
||||
* automatically be made.
|
||||
*
|
||||
* Note that four (and only four) arguments must be passed for the spawned
|
||||
* functions.
|
||||
*
|
||||
* nxtask_create() is identical to the function task_create(), differing
|
||||
* only in its return value: This function does not modify the errno
|
||||
* variable. This is a non-standard, internal OS function and is not
|
||||
* intended for use by application logic. Applications should use
|
||||
* task_create().
|
||||
*
|
||||
* Input Parameters:
|
||||
* name - Name of the new task
|
||||
* priority - Priority of the new task
|
||||
* stack_size - size (in bytes) of the stack needed
|
||||
* entry - Entry point of a new task
|
||||
* arg - A pointer to an array of input parameters. Up to
|
||||
* CONFIG_MAX_TASK_ARG parameters may be provided. If fewer
|
||||
* than CONFIG_MAX_TASK_ARG parameters are passed, the list
|
||||
* should be terminated with a NULL argv[] value. If no
|
||||
* parameters are required, argv may be NULL.
|
||||
*
|
||||
* Return Value:
|
||||
* Returns the positive, non-zero process ID of the new task or a negated
|
||||
* errno value to indicate the nature of any failure. If memory is
|
||||
* insufficient or the task cannot be created -ENOMEM will be returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nxtask_create(FAR const char *name, int priority,
|
||||
int stack_size, main_t entry, FAR char * const argv[])
|
||||
{
|
||||
return thread_create(name, TCB_FLAG_TTYPE_TASK, priority, stack_size,
|
||||
entry, argv);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: task_create
|
||||
*
|
||||
@ -228,8 +268,8 @@ errout:
|
||||
*
|
||||
* Return Value:
|
||||
* Returns the non-zero process ID of the new task or ERROR if memory is
|
||||
* insufficient or the task cannot be created. The errno will be set to
|
||||
* indicate the nature of the error (always ENOMEM).
|
||||
* insufficient or the task cannot be created. The errno will be set in
|
||||
* the failure case to indicate the nature of the error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -237,8 +277,14 @@ errout:
|
||||
int task_create(FAR const char *name, int priority,
|
||||
int stack_size, main_t entry, FAR char * const argv[])
|
||||
{
|
||||
return thread_create(name, TCB_FLAG_TTYPE_TASK, priority, stack_size,
|
||||
entry, argv);
|
||||
int ret = nxtask_create(name, priority, stack_size, entry, argv);
|
||||
if (ret < 0)
|
||||
{
|
||||
set_errno(-ret);
|
||||
ret = ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -251,10 +297,20 @@ int task_create(FAR const char *name, int priority,
|
||||
* configures the newly started thread to run in kernel model.
|
||||
*
|
||||
* Input Parameters:
|
||||
* (same as task_create())
|
||||
* name - Name of the new task
|
||||
* priority - Priority of the new task
|
||||
* stack_size - size (in bytes) of the stack needed
|
||||
* entry - Entry point of a new task
|
||||
* arg - A pointer to an array of input parameters. Up to
|
||||
* CONFIG_MAX_TASK_ARG parameters may be provided. If fewer
|
||||
* than CONFIG_MAX_TASK_ARG parameters are passed, the list
|
||||
* should be terminated with a NULL argv[] value. If no
|
||||
* parameters are required, argv may be NULL.
|
||||
*
|
||||
* Return Value:
|
||||
* (same as task_create())
|
||||
* Returns the positive, non-zero process ID of the new task or a negated
|
||||
* errno value to indicate the nature of any failure. If memory is
|
||||
* insufficient or the task cannot be created -ENOMEM will be returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -420,9 +420,8 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path,
|
||||
(FAR char * const *)NULL);
|
||||
if (proxy < 0)
|
||||
{
|
||||
ret = get_errno();
|
||||
ret = -proxy;
|
||||
serr("ERROR: Failed to start posix_spawn_proxy: %d\n", ret);
|
||||
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/kthread.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "group/group.h"
|
||||
@ -138,11 +139,11 @@ static int task_spawn_exec(FAR pid_t *pidp, FAR const char *name,
|
||||
|
||||
/* Start the task */
|
||||
|
||||
pid = task_create(name, priority, stacksize, entry, argv);
|
||||
pid = nxtask_create(name, priority, stacksize, entry, argv);
|
||||
if (pid < 0)
|
||||
{
|
||||
ret = get_errno();
|
||||
serr("ERROR: task_create failed: %d\n", ret);
|
||||
ret = -pid;
|
||||
serr("ERROR: nxtask_create failed: %d\n", ret);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
@ -403,15 +404,14 @@ int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
|
||||
* task.
|
||||
*/
|
||||
|
||||
proxy = task_create("task_spawn_proxy", param.sched_priority,
|
||||
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE,
|
||||
(main_t)task_spawn_proxy,
|
||||
(FAR char * const *)NULL);
|
||||
proxy = nxtask_create("task_spawn_proxy", param.sched_priority,
|
||||
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE,
|
||||
(main_t)task_spawn_proxy,
|
||||
(FAR char * const *)NULL);
|
||||
if (proxy < 0)
|
||||
{
|
||||
ret = get_errno();
|
||||
ret = -proxy;
|
||||
serr("ERROR: Failed to start task_spawn_proxy: %d\n", ret);
|
||||
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
|
@ -162,11 +162,8 @@ int work_hpstart(void)
|
||||
DEBUGASSERT(pid > 0);
|
||||
if (pid < 0)
|
||||
{
|
||||
int errcode = get_errno();
|
||||
DEBUGASSERT(errcode > 0);
|
||||
|
||||
serr("ERROR: kthread_create failed: %d\n", errcode);
|
||||
return -errcode;
|
||||
serr("ERROR: kthread_create failed: %d\n", (int)pid);
|
||||
return (int)pid;
|
||||
}
|
||||
|
||||
g_hpwork.worker[0].pid = pid;
|
||||
|
@ -209,12 +209,9 @@ int work_lpstart(void)
|
||||
DEBUGASSERT(pid > 0);
|
||||
if (pid < 0)
|
||||
{
|
||||
int errcode = get_errno();
|
||||
DEBUGASSERT(errcode > 0);
|
||||
|
||||
serr("ERROR: kthread_create %d failed: %d\n", wndx, errcode);
|
||||
serr("ERROR: kthread_create %d failed: %d\n", wndx, (int)pid);
|
||||
sched_unlock();
|
||||
return -errcode;
|
||||
return (int)pid;
|
||||
}
|
||||
|
||||
g_lpwork.worker[wndx].pid = pid;
|
||||
|
Loading…
x
Reference in New Issue
Block a user