From 0f895f0ed4b2370af37d91c0ecb7649d914ed147 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 1 Dec 2008 22:13:03 +0000 Subject: Fixed for multi-user NX mode git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1386 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/examples/README.txt | 25 +++++++++++++++++++++++++ nuttx/examples/nx/nx_internal.h | 5 ++++- nuttx/examples/nx/nx_main.c | 23 ++++++++++++++++++++++- 3 files changed, 51 insertions(+), 2 deletions(-) (limited to 'nuttx/examples') diff --git a/nuttx/examples/README.txt b/nuttx/examples/README.txt index f2a597800..2fbb54e8f 100644 --- a/nuttx/examples/README.txt +++ b/nuttx/examples/README.txt @@ -54,6 +54,31 @@ examples/nsh someday be a great NuttX application debugger. NSH is described in its own README located at examples/nsh/README.txt +examples/nx +^^^^^^^^^^^ + + This directory contains a simple test of a subset of the NX APIs + defined in include/nuttx/nx.h. The following configuration options + can be selected: + + CONFIG_EXAMPLES_NX_VPLANE -- The plane to select from the frame- + buffer driver for use in the test. Default: 0 + CONFIG_EXAMPLES_NX_BGCOLOR -- The color of the background. Default: ' '. + CONFIG_EXAMPLES_NX_COLOR1 -- The color of window 1. Default: '1' + CONFIG_EXAMPLES_NX_COLOR2 -- The color of window 2. Default: '2' + + This test can be performed with either the single-user version of + NX or with the multiple user version of NX selected with CONFIG_NX_MULTIUSER. + If CONFIG_NX_MULTIUSER is defined, then the following configuration + options also apply: + + CONFIG_EXAMPLES_NX_STACKSIZE -- The stacksize to use when creating + the NX server. Default 2048 + CONFIG_EXAMPLES_NX_CLIENTPRIO -- The client priority. Default: 80 + CONFIG_EXAMPLES_NX_SERVERPRIO -- The server priority. Default: 120 + CONFIG_EXAMPLES_NX_NOTIFYSIGNO -- The signal number to use with + nx_eventnotify(). Default: 4 + examples/null ^^^^^^^^^^^^^ diff --git a/nuttx/examples/nx/nx_internal.h b/nuttx/examples/nx/nx_internal.h index d41bbf89f..60ec466e2 100644 --- a/nuttx/examples/nx/nx_internal.h +++ b/nuttx/examples/nx/nx_internal.h @@ -97,8 +97,11 @@ # ifndef CONFIG_EXAMPLES_NX_STACKSIZE # define CONFIG_EXAMPLES_NX_STACKSIZE 2048 # endif +# ifndef CONFIG_EXAMPLES_NX_CLIENTPRIO +# define CONFIG_EXAMPLES_NX_CLIENTPRIO 80 +# endif # ifndef CONFIG_EXAMPLES_NX_SERVERPRIO -# define CONFIG_EXAMPLES_NX_SERVERPRIO 100 +# define CONFIG_EXAMPLES_NX_SERVERPRIO 120 # endif # ifndef CONFIG_EXAMPLES_NX_NOTIFYSIGNO # define CONFIG_EXAMPLES_NX_NOTIFYSIGNO 4 diff --git a/nuttx/examples/nx/nx_main.c b/nuttx/examples/nx/nx_main.c index 039b1645e..f30fef119 100644 --- a/nuttx/examples/nx/nx_main.c +++ b/nuttx/examples/nx/nx_main.c @@ -485,7 +485,28 @@ static inline int nxeg_muinitialize(void) while (!g_connected) { - (void)sem_wait(&g_semevent); + /* Assuming that the incoming message queue is configured non-blocking, + * we can poll the event handler here. This accounts for the case where + * the server is higher prioirty than the client. In that case, the + * server will have already responded to the connection request BEFORE + * the nx_eventnotify was called. + */ + + ret = nx_eventhandler(g_hnx); + if (ret == 0) + { + /* If a message was received, then we are connected */ + + g_connected = TRUE; + } + + /* Otherwise, we will have to wait for the event handler to wake up up + * when we really are connected. + */ + else + { + (void)sem_wait(&g_semevent); + } } } else -- cgit v1.2.3