mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 16:23:34 +08:00
Correct round-to-ticks logic in sigtimedwait()
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5457 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+96
-18
@@ -17,15 +17,15 @@ Contents
|
||||
General
|
||||
-------
|
||||
This folder provides various applications found in sub-directories. These
|
||||
applications are not inherently a part of NuttX but are provided you help
|
||||
applications are not inherently a part of NuttX but are provided to help
|
||||
you develop your own applications. The apps/ directory is a "break away"
|
||||
part of the configuration that you may chose to use or not.
|
||||
part of the configuration that you may choose to use or not.
|
||||
|
||||
Directory Location
|
||||
------------------
|
||||
The default application directory used by the NuttX build should be named
|
||||
apps/ (or apps-x.y/ where x.y is the NuttX version number). This apps/
|
||||
directoy should appear in the directory tree at the same level as the
|
||||
directory should appear in the directory tree at the same level as the
|
||||
NuttX directory. Like:
|
||||
|
||||
.
|
||||
@@ -54,7 +54,7 @@ In this case, application entry points with their requirements are gathered
|
||||
together in two files:
|
||||
|
||||
- builtin/builtin_proto.h Entry points, prototype function
|
||||
- builtin/builtin_list.h Application specific information and requirements
|
||||
- builtin/builtin_list.h Application specific information and requirements
|
||||
|
||||
The build occurs in several phases as different build targets are executed:
|
||||
(1) context, (2) depend, and (3) default (all). Application information is
|
||||
@@ -96,11 +96,11 @@ after the NSH command.
|
||||
|
||||
Application Configuration File
|
||||
------------------------------
|
||||
A special configuration file is used to configure which applications
|
||||
are to be included in the build. The source for this file is
|
||||
configs/<board>/<configuration>/appconfig. The existence of the appconfig
|
||||
file in the board configuration directory is sufficient to enable building
|
||||
of applications.
|
||||
The old-style NuttX configuration uses a special configuration file is
|
||||
used to configure which applications are to be included in the build.
|
||||
The source for this file is configs/<board>/<configuration>/appconfig.
|
||||
The existence of the appconfig file in the board configuration directory\
|
||||
is sufficient to enable building of applications.
|
||||
|
||||
The appconfig file is copied into the apps/ directory as .config when
|
||||
NuttX is configured. .config is included in the toplevel apps/Makefile.
|
||||
@@ -109,6 +109,38 @@ CONFIGURED_APPS list like:
|
||||
|
||||
CONFIGURED_APPS += examples/hello system/poweroff
|
||||
|
||||
The new NuttX configuration uses kconfig-frontends tools and only the
|
||||
NuttX .config file. The new configuration is indicated by the existence
|
||||
of the definition CONFIG_NUTTX_NEWCONFIG=y in the NuttX .config file.
|
||||
If CONFIG_NUTTX_NEWCONFIG is defined, then the Makefile will:
|
||||
|
||||
- Assume that there is no apps/.config file and will instead
|
||||
- Include Make.defs files from each of the subdirectories.
|
||||
|
||||
When an application is enabled using the kconfig-frontends tool, then
|
||||
a new definition is added to the NuttX .config file. For example, if
|
||||
you want to enable apps/examples/hello then the old apps/.config would
|
||||
have had:
|
||||
|
||||
CONFIGURED_APPS += examples/hello
|
||||
|
||||
But in the new configuration there will be no apps/.config file and,
|
||||
instead, the NuttX .config will have:
|
||||
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
|
||||
This will select the apps/examples/hello in the following way:
|
||||
|
||||
- The top-level make will include examples/Make.defs
|
||||
- examples/Make.defs will set CONFIGURED_APPS += examples/hello
|
||||
like this:
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_HELLO),y)
|
||||
CONFIGURED_APPS += examples/hello
|
||||
endif
|
||||
|
||||
Thus accomplishing the same thing with no apps/.config file.
|
||||
|
||||
Built-In Start-Up main() function
|
||||
------------------------------
|
||||
A builtin application can even be used as the main, start-up entry point
|
||||
@@ -130,17 +162,63 @@ An example application skeleton can be found under the examples/hello
|
||||
sub-directory. This example shows how a builtin application can be added
|
||||
to the project. One must define:
|
||||
|
||||
1. create sub-directory as: appname
|
||||
2. provide entry point: appname_main()
|
||||
3. set the requirements in the file: Makefile, specially the lines:
|
||||
Old configuration method:
|
||||
|
||||
APPNAME = appname
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 768
|
||||
ASRCS = asm source file list as a.asm b.asm ...
|
||||
CSRCS = C source file list as foo1.c foo2.c ..
|
||||
1. Create sub-directory as: appname
|
||||
|
||||
4. add application in the apps/.config
|
||||
2. In this directory there should be:
|
||||
|
||||
- A Makefile, and
|
||||
- The application source code.
|
||||
|
||||
3. The application source code should provide the entry point:
|
||||
appname_main()
|
||||
|
||||
4. Set the requirements in the file: Makefile, specially the lines:
|
||||
|
||||
APPNAME = appname
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 768
|
||||
ASRCS = asm source file list as a.asm b.asm ...
|
||||
CSRCS = C source file list as foo1.c foo2.c ..
|
||||
|
||||
Look at some of the other Makefiles for examples. Note the
|
||||
special registration logic needed for the context: target
|
||||
|
||||
5. Add the to the application to the CONFIGIURED_APPS in the
|
||||
apps/.config file:
|
||||
|
||||
CONFIGURED_APPS += appname
|
||||
|
||||
New Configuration Method:
|
||||
|
||||
1. Create sub-directory as: appname
|
||||
|
||||
2. In this directory there should be:
|
||||
|
||||
- A Make.defs file that would be included by the apps/Makefile
|
||||
- A Kconfig file that would be used by the configuration tool (see
|
||||
misc/tools/kconfig-language.txt). This Kconfig file should be
|
||||
included by the apps/Kconfig file
|
||||
- A Makefile, and
|
||||
- The application source code.
|
||||
|
||||
3. The application source code should provide the entry point:
|
||||
appname_main()
|
||||
|
||||
4. Set the requirements in the file: Makefile, specially the lines:
|
||||
|
||||
APPNAME = appname
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 768
|
||||
ASRCS = asm source file list as a.asm b.asm ...
|
||||
CSRCS = C source file list as foo1.c foo2.c ..
|
||||
|
||||
4b. The Make.defs file should include a line like:
|
||||
|
||||
ifeq ($(CONFIG_APPNAME),y)
|
||||
CONFIGURED_APPS += appname
|
||||
endif
|
||||
|
||||
Building NuttX with Board-Specific Pieces Outside the Source Tree
|
||||
-----------------------------------------------------------------
|
||||
|
||||
@@ -3812,4 +3812,7 @@
|
||||
* include/pthread.h: In sys/prctl.h because it is needed by
|
||||
pthread_[set|get]name_np()
|
||||
* tools/kconfig.bat: Kludge to run kconfig-frontends from a DOS shell.
|
||||
* sched/sig_timedwait.c: Should always move the time up to the next
|
||||
largest number of system ticks. The logic was rounding. Noted by
|
||||
Petteri Aimonen.
|
||||
|
||||
|
||||
@@ -238,10 +238,25 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
||||
|
||||
if (timeout)
|
||||
{
|
||||
/* Convert the timespec to milliseconds */
|
||||
/* Convert the timespec to system clock ticks, making sure that
|
||||
* the resultint delay is greater than or equal to the requested
|
||||
* time in nanoseconds.
|
||||
*/
|
||||
|
||||
waitticks = MSEC2TICK(timeout->tv_sec * MSEC_PER_SEC
|
||||
+ timeout->tv_nsec / NSEC_PER_MSEC);
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
uint64_t waitticks64 = (timeout->tv_sec * NSEC_PER_SEC +
|
||||
timeout->tv_nsec + NSEC_PER_TICK - 1) /
|
||||
NSEC_PER_TICK;
|
||||
DEBUGASSERT(waitticks64 <= UINT32_MAX);
|
||||
waitticks = (uint32_t)waitticks64;
|
||||
#else
|
||||
uint32_t waitmsec;
|
||||
|
||||
DEBUGASSERT(timeout->tv_sec < UINT32_MAX / MSEC_PER_SEC);
|
||||
waitmsec = timeout->tv_sec * MSEC_PER_SEC +
|
||||
(timeout->tv_nsec + NSEC_PER_MSEC - 1) / NSEC_PER_MSEC;
|
||||
waitticks = (waitmsec + MSEC_PER_TICK - 1) / MSEC_PER_TICK;
|
||||
#endif
|
||||
|
||||
/* Create a watchdog */
|
||||
|
||||
@@ -326,6 +341,7 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
||||
{
|
||||
memcpy(info, &rtcb->sigunbinfo, sizeof(struct siginfo));
|
||||
}
|
||||
|
||||
irqrestore(saved_state);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user