NX server needs to be on a kernel thread for the kernel build

This commit is contained in:
Gregory Nutt 2013-12-30 17:55:19 -06:00
parent 90b269568b
commit 43e47f8e78
6 changed files with 128 additions and 31 deletions

View File

@ -6349,3 +6349,6 @@
which allocator is used in the different configurations. Always uses
the user-space allocator because that one is required in certain
configurations (2013-12-30).
* include/nuttx/kthread.h: Move kernel thread definitions out of
os_internal.h so that the rest of the OS can start kernel threads as
well (2013-12-30).

View File

@ -45,6 +45,7 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/kthread.h>
#include <nuttx/nx/nx.h>
#include "nxfe.h"
@ -72,11 +73,11 @@
****************************************************************************/
/****************************************************************************
* Name: nx_servertask
* Name: nx_server
*
* Description:
* NX server thread. This is the entry point into the server thread that
* serializes the multi-threaded accesses to the display.
* NX server thread. This is the entry point into the server kernel
* thread that serializes the multi-threaded accesses to the display.
*
* Input Parameters:
* Standard task start-up parameters (none of which are used)
@ -87,7 +88,7 @@
*
****************************************************************************/
int nx_servertask(int argc, char *argv[])
int nx_server(int argc, char *argv[])
{
FAR NX_DRIVERTYPE *dev;
int ret;
@ -144,7 +145,7 @@ int nx_servertask(int argc, char *argv[])
#endif /* CONFIG_NX_LCDDRIVER */
/* Then start the server (nx_run does not normally retun) */
/* Then start the server (nx_run does not normally return) */
ret = nx_run(dev);
gvdbg("nx_run returned: %d\n", errno);
@ -184,24 +185,27 @@ int nx_start(void)
{
pid_t server;
/* Start the server task */
/* Start the server kernel thread */
gvdbg("Starting server task\n");
server = TASK_CREATE("NX Server", CONFIG_NXSTART_SERVERPRIO,
CONFIG_NXSTART_SERVERSTACK, nx_servertask,
(FAR char * const *)0);
server = KERNEL_THREAD("NX Server", CONFIG_NXSTART_SERVERPRIO,
CONFIG_NXSTART_SERVERSTACK, nx_server,
(FAR char * const *)0);
if (server < 0)
{
int errcode = errno;
DEBUGASSERT(errcode > 0);
gdbg("ERROR: Failed to create nx_servertask task: %d\n", errcode);
gdbg("ERROR: Failed to create nx_server kernel thread: %d\n", errcode);
return -errcode;
}
/* Wait a bit to let the server get started */
#if 0 /* Can't do this on the IDLE thread */
/* Wait a bit to make sure that the server get started */
usleep(50*1000);
#endif
return OK;
}

108
include/nuttx/kthread.h Normal file
View File

@ -0,0 +1,108 @@
/****************************************************************************
* include/nuttx/kthread.h
* Non-standard, NuttX-specific kernel thread-related declarations.
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_KTHREAD_H
#define __INCLUDE_NUTTX_KTHREAD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sched.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* One processor family supported by NuttX has a single, fixed hardware stack.
* That is the 8051 family. So for that family only, there is a variant form
* of kernel_thread() that does not take a stack size parameter. The following
* helper macro is provided to work around the ugliness of that exception.
*/
#ifndef CONFIG_CUSTOM_STACK
# define KERNEL_THREAD(n,p,s,e,a) kernel_thread(n,p,s,e,a)
#else
# define KERNEL_THREAD(n,p,s,e,a) kernel_thread(n,p,e,a)
#endif
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/********************************************************************************
* Name: kernel_thread
*
* Description:
* This function creates and activates a kernel thread task with kernel-mode
* privileges. It is identical to task_create() except that it configures the
* newly started thread to run in kernel model.
*
* Input Parameters:
* (same as task_create())
*
* Return Value:
* (same as task_create())
*
********************************************************************************/
#ifndef CONFIG_CUSTOM_STACK
int kernel_thread(FAR const char *name, int priority, int stack_size,
main_t entry, FAR char * const argv[]);
#else
int kernel_thread(FAR const char *name, int priority, main_t entry,
FAR char * const argv[]);
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_KTHREAD_H */

View File

@ -50,6 +50,7 @@
#include <nuttx/arch.h>
#include <nuttx/init.h>
#include <nuttx/wqueue.h>
#include <nuttx/kthread.h>
#include <nuttx/userspace.h>
#include "os_internal.h"

View File

@ -69,18 +69,6 @@
#define MAX_TASKS_MASK (CONFIG_MAX_TASKS-1)
#define PIDHASH(pid) ((pid) & MAX_TASKS_MASK)
/* One processor family supported by NuttX has a single, fixed hardware stack.
* That is the 8051 family. So for that family only, there is a variant form
* of kernel_thread() that does not take a stack size parameter. The following
* helper macro is provided to work around the ugliness of that exception.
*/
#ifndef CONFIG_CUSTOM_STACK
# define KERNEL_THREAD(n,p,s,e,a) kernel_thread(n,p,s,e,a)
#else
# define KERNEL_THREAD(n,p,s,e,a) kernel_thread(n,p,e,a)
#endif
/* A more efficient ways to access the errno */
#define SET_ERRNO(e) \
@ -238,14 +226,6 @@ int task_exit(void);
int task_terminate(pid_t pid, bool nonblocking);
void task_exithook(FAR struct tcb_s *tcb, int status, bool nonblocking);
void task_recover(FAR struct tcb_s *tcb);
#ifndef CONFIG_CUSTOM_STACK
int kernel_thread(FAR const char *name, int priority, int stack_size,
main_t entry, FAR char * const argv[]);
#else
int kernel_thread(FAR const char *name, int priority, main_t entry,
FAR char * const argv[]);
#endif
bool sched_addreadytorun(FAR struct tcb_s *rtrtcb);
bool sched_removereadytorun(FAR struct tcb_s *rtrtcb);
bool sched_addprioritized(FAR struct tcb_s *newTcb, DSEG dq_queue_t *list);

View File

@ -46,6 +46,7 @@
#include <nuttx/arch.h>
#include <nuttx/kmalloc.h>
#include <nuttx/kthread.h>
#include "os_internal.h"
#include "group_internal.h"