CNxServer: Remove NX server task. Instead, call nx_start (indirectly via boardctl(BOARDIOC_NX_START) to start the NX server as a kernel thread.

This commit is contained in:
Gregory Nutt 2016-12-01 17:07:25 -06:00
parent c5f8817904
commit 7e7b6a5e4c
6 changed files with 25 additions and 155 deletions

View File

@ -618,4 +618,8 @@
large line spacings built-in. From Petteri Aimonen (2016-09-22).
* libnxwidgets: Allow setting line spacing in NxWidgets::CMultiLineTextBox.
From Petteri Aimonen (2016-09-22).
* CNxServer: Remove NX server task. Now calls nx_start (indirectly through
boardctrl(BOARDIOC_NX_START) to start the NX Server kernel thread
(2016-12-01).

30
Kconfig
View File

@ -39,7 +39,7 @@ config NXWIDGETS_EXTERNINIT
config NXWIDGETS_DEVNO
int "LCD Device Number"
default 0
depends on NXWIDGETS_EXTERNINIT || NX_LCDDRIVER
depends on (NXWIDGETS_EXTERNINIT || NX_LCDDRIVER) && !NX_MULTIUSER
---help---
LCD device number (in case there are more than one LCDs connected).
Default: 0
@ -47,7 +47,7 @@ config NXWIDGETS_DEVNO
config NXWIDGETS_VPLANE
int "Plane Number"
default 0
depends on !NX_LCDDRIVER && !NXWIDGETS_EXTERNINIT
depends on !NX_LCDDRIVER && !NXWIDGETS_EXTERNINIT && !NX_MULTIUSER
---help---
Only a single video plane is supported. Default: 0
@ -65,28 +65,6 @@ config NXWIDGET_SERVERINIT
by other, external logic and will simply attempt to connect to the
server.
if NXWIDGET_SERVERINIT
config NXWIDGETS_SERVERPRIO
int "NX Server priority"
default 110
---help---
Priority of the NX server. This applies only if NX is configured in
multi-user mode (NX_MULTIUSER=y). Default: 110.
NOTE: Of the three priority definitions here, NXWIDGETS_SERVERPRIO
should have the highest priority to avoid data overrun race conditions.
Such errors would most likely appear as duplicated rows of data on the
display.
config NXWIDGETS_SERVERSTACK
int "NX Server Stack Size"
default 2048
---help---
NX server thread stack size (in multi-user mode). Default 2048
endif # NXWIDGET_SERVERINIT
config NXWIDGETS_CLIENTPRIO
int "NX Client Priority"
default 100
@ -673,7 +651,7 @@ config NXWM_STARTWINDOW_PRIO
---help---
Priority of the StartWindow task. Default: 100.
NOTE: This priority should be less than NXWIDGETS_SERVERPRIO or else
NOTE: This priority should be less than NXSTART_SERVERPRIO or else
there may be data overrun errors. Such errors would most likely appear
as duplicated rows of data on the display.
@ -703,7 +681,7 @@ config NXWM_NXTERM_PRIO
---help---
Priority of the NxTerm task. Default: 100.
NOTE: This priority should be less than NXWIDGETS_SERVERPRIO or
NOTE: This priority should be less than NXSTART_SERVERPRIO or
else there may be data overrun errors. Such errors would most likely
appear as duplicated rows of data on the display.

View File

@ -90,15 +90,6 @@ namespace NXWidgets
#endif
static uint8_t m_nServers; /**< The number of NX server instances */
/**
* NX server thread. This is the entry point into the server thread that
* serializes the multi-threaded accesses to the display.
*/
#if defined(CONFIG_NX_MULTIUSER) && defined(CONFIG_NXWIDGET_SERVERINIT)
static int server(int argc, char *argv[]);
#endif
/**
* NX listener thread. This is the entry point of a thread that listeners for and
* dispatches events from the NX server.

View File

@ -66,10 +66,10 @@
* CONFIG_NXWIDGETS_DEVNO - LCD device number (in case there are more than
* one LCDs connected. Default: 0
* CONFIG_NXWIDGETS_VPLANE - Only a single video plane is supported. Default: 0
* CONFIG_NXWIDGETS_SERVERPRIO - Priority of the NX server. This applies
* CONFIG_NXSTART_SERVERPRIO - Priority of the NX server. This applies
* only if NX is configured in multi-user mode (CONFIG_NX_MULTIUSER=y).
* Default: (SCHED_PRIORITY_DEFAULT+10). NOTE: Of the three priority
* definitions here, CONFIG_NXWIDGETS_SERVERPRIO should have the highest
* definitions here, CONFIG_NXSTART_SERVERPRIO should have the highest
* priority to avoid data overrun race conditions. Such errors would most
* likely appear as duplicated rows of data on the display.
* CONFIG_NXWIDGETS_CLIENTPRIO - The thread that calls CNxServer::connect()
@ -81,8 +81,6 @@
* (CONFIG_NX_MULTIUSER=y). Default: SCHED_PRIORITY_DEFAULT
* CONFIG_NXWIDGETS_EXTERNINIT - Define to support external display
* initialization.
* CONFIG_NXWIDGETS_SERVERSTACK - NX server thread stack size (in multi-user
* mode). Default 2048
* CONFIG_NXWIDGETS_LISTENERSTACK - NX listener thread stack size (in multi-user
* mode). Default 2048
* CONFIG_NXWIDGET_EVENTWAIT - Build in support for external window event, modal
@ -213,27 +211,15 @@
* Priority of the NX server (in multi-user mode)
*/
#ifndef CONFIG_NXWIDGETS_SERVERPRIO
# define CONFIG_NXWIDGETS_SERVERPRIO (SCHED_PRIORITY_DEFAULT+10)
#endif
#ifndef CONFIG_NXWIDGETS_CLIENTPRIO
# define CONFIG_NXWIDGETS_CLIENTPRIO SCHED_PRIORITY_DEFAULT
#endif
#if CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWIDGETS_CLIENTPRIO
# warning "CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWIDGETS_CLIENTPRIO"
#if CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_CLIENTPRIO
# warning "CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_CLIENTPRIO"
# warning" -- This can result in data overrun errors"
#endif
/**
* NX server thread stack size (in multi-user mode)
*/
#ifndef CONFIG_NXWIDGETS_SERVERSTACK
# define CONFIG_NXWIDGETS_SERVERSTACK 2048
#endif
/**
* Priority of the NX event listener thread (in multi-user mode)
*/
@ -242,8 +228,8 @@
# define CONFIG_NXWIDGETS_LISTENERPRIO SCHED_PRIORITY_DEFAULT
#endif
#if CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWIDGETS_LISTENERPRIO
# warning "CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWIDGETS_LISTENERPRIO"
#if CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_LISTENERPRIO
# warning "CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_LISTENERPRIO"
# warning" -- This can result in data overrun errors"
#endif

View File

@ -246,24 +246,16 @@ bool CNxServer::connect(void)
}
#ifdef CONFIG_NXWIDGET_SERVERINIT
// Start the server task
// Start the NX server kernel thread
ginfo("CNxServer::connect: Starting server task\n");
pid_t serverId = task_create("NX Server", CONFIG_NXWIDGETS_SERVERPRIO,
CONFIG_NXWIDGETS_SERVERSTACK, server,
(FAR char * const *)0);
if (serverId < 0)
printf("CNxServer::connect: Starting NX server\n");
ret = boardctl(BOARDIOC_NX_START, 0);
if (ret < 0)
{
gerr("ERROR: NxServer::connect: Failed to create nx_servertask task: %d\n", errno);
printf("ERROR: CNxServer::connect: Failed to start the NX server: %d\n", errno);
return false;
}
// Wait a bit to let the server get started
usleep(50*1000);
#endif // CONFIG_NXWIDGET_SERVERINIT
// Connect to the server
m_hNxServer = nx_connect();
@ -388,87 +380,6 @@ void CNxServer::disconnect(void)
}
#endif // CONFIG_NX_MULTIUSER
/**
* NX server thread. This is the entry point into the server thread that
* serializes the multi-threaded accesses to the display.
*/
#if defined(CONFIG_NX_MULTIUSER) && defined(CONFIG_NXWIDGET_SERVERINIT)
int CNxServer::server(int argc, char *argv[])
{
FAR NX_DRIVERTYPE *dev;
int ret;
#if defined(CONFIG_NXWIDGETS_EXTERNINIT)
struct boardioc_graphics_s devinfo;
int ret;
// Use external graphics driver initialization
printf("nxtext_initialize: Initializing external graphics device\n");
devinfo.devno = CONFIG_NXWIDGETS_DEVNO;
devinfo.dev = NULL;
ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo);
if (ret < 0)
{
gerr("ERROR: boardctl failed, devno=%d: %d\n", CONFIG_NXWIDGETS_DEVNO, errno);
return EXIT_FAILURE;
}
dev = devinfo.dev;
#elif defined(CONFIG_NX_LCDDRIVER)
// Initialize the LCD device
ret = board_lcd_initialize();
if (ret < 0)
{
gerr("ERROR: board_lcd_initialize failed: %d\n", -ret);
return EXIT_FAILURE;
}
// Get the device instance
dev = board_lcd_getdev(CONFIG_NXWIDGETS_DEVNO);
if (!dev)
{
gerr("ERROR: board_lcd_getdev failed, devno=%d\n", CONFIG_NXWIDGETS_DEVNO);
return EXIT_FAILURE;
}
// Turn the LCD on at 75% power
(void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
#else // CONFIG_NX_LCDDRIVER
// Initialize the frame buffer device
ret = up_fbinitialize(0);
if (ret < 0)
{
gerr("ERROR: nxterm_server: up_fbinitialize failed: %d\n", -ret);
return EXIT_FAILURE;
}
dev = up_fbgetvplane(0, CONFIG_NXWIDGETS_VPLANE);
if (!dev)
{
gerr("ERROR: up_fbgetvplane failed, vplane=%d\n", CONFIG_NXWIDGETS_VPLANE);
return 2;
}
#endif // CONFIG_NX_LCDDRIVER
// Then start the server
ret = nx_run(dev);
ginfo("nx_run returned: %d\n", errno);
return EXIT_FAILURE;
}
#endif // CONFIG_NX_MULTIUSER && CONFIG_NXWIDGET_SERVERINIT
/**
* This is the entry point of a thread that listeners for and dispatches
* events from the NX server.

View File

@ -307,7 +307,7 @@
* CONFIG_NXWM_STARTWINDOW_MXMPRIO - The message priority. Default: 42.
* CONFIG_NXWM_STARTWINDOW_PRIO - Priority of the StartWindoW task. Default:
* SCHED_PRIORITY_DEFAULT. NOTE: This priority should be less than
* CONFIG_NXWIDGETS_SERVERPRIO or else there may be data overrun errors.
* CONFIG_NXSTART_SERVERPRIO or else there may be data overrun errors.
* Such errors would most likely appear as duplicated rows of data on the
* display.
* CONFIG_NXWM_STARTWINDOW_STACKSIZE - The stack size to use when starting the
@ -354,8 +354,8 @@
# define CONFIG_NXWM_STARTWINDOW_PRIO SCHED_PRIORITY_DEFAULT
#endif
#if CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWM_STARTWINDOW_PRIO
# warning "CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWM_STARTWINDOW_PRIO"
#if CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWM_STARTWINDOW_PRIO
# warning "CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWM_STARTWINDOW_PRIO"
# warning" -- This can result in data overrun errors"
#endif
@ -369,7 +369,7 @@
*
* CONFIG_NXWM_NXTERM_PRIO - Priority of the NxTerm task. Default:
* SCHED_PRIORITY_DEFAULT. NOTE: This priority should be less than
* CONFIG_NXWIDGETS_SERVERPRIO or else there may be data overrun errors.
* CONFIG_NXSTART_SERVERPRIO or else there may be data overrun errors.
* Such errors would most likely appear as duplicated rows of data on the
* display.
* CONFIG_NXWM_NXTERM_STACKSIZE - The stack size to use when starting the
@ -388,8 +388,8 @@
# define CONFIG_NXWM_NXTERM_PRIO SCHED_PRIORITY_DEFAULT
# endif
# if CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWM_NXTERM_PRIO
# warning "CONFIG_NXWIDGETS_SERVERPRIO <= CONFIG_NXWM_NXTERM_PRIO"
# if CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWM_NXTERM_PRIO
# warning "CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWM_NXTERM_PRIO"
# warning" -- This can result in data overrun errors"
# endif