9
0
Fork 0

Fix STM32 F2/F4 SDIO clocking; Clean-up files in sched/ directory

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4940 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-07-14 19:30:31 +00:00
parent 1eb675344c
commit 907c8fcd4a
204 changed files with 2197 additions and 1635 deletions

View File

@ -2981,7 +2981,12 @@
* configs/lpc4330-xplorer/up_nsh.c: Add support for a basic SPIFI block
driver for use by NSH. Does not work! Crashes on first SPIFI write.
* configs/lpc4330-xplorer/*/defconfig: Calibrate delay loops (this is
based on the current "slow" 72MHz M4 clock and will need to be
re-calibrated when this is increased).
* configs/stm3220g-eval/include/board.h and configs/stm3240g-eval/include/board.h:
The SDIOCLK frequency in the F2 and F4 derives for PLL48CLK and not HCLK
so that the SDIOCLK input frequency should always be 48MHz.
* sched/os_internal.h, sched_setupidlefiles.c, sched_setuptaskfiles.c, and
sched_setupidlefiles.c: Detangle some conditional compilation. Allow for
a perverse configuration that has socket descriptors and streams but no file
descriptors (sure, why not?).
* sched/: Stylistic clean-up of all files. Some of these files are pretty old
and do not follow current NuttX coding standards in detail.

View File

@ -34,17 +34,19 @@
*
************************************************************************************/
#ifndef __ARCH_BOARD_BOARD_H
#define __ARCH_BOARD_BOARD_H
#ifndef __CONFIGS_STM3220G_EVAL_INCLUDE_BOARD_H
#define __CONFIGS_STM3220G_EVAL_INCLUDE_BOARD_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif
#include "stm32_rcc.h"
#include "stm32_sdio.h"
#include "stm32_internal.h"
@ -168,29 +170,29 @@
* to service FIFOs in interrupt driven mode. These values have not been
* tuned!!!
*
* HCLK=72MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(178+2)=400 KHz
* SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(118+2)=400 KHz
*/
#define SDIO_INIT_CLKDIV (178 << SDIO_CLKCR_CLKDIV_SHIFT)
#define SDIO_INIT_CLKDIV (118 << SDIO_CLKCR_CLKDIV_SHIFT)
/* DMA ON: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(2+2)=18 MHz
* DMA OFF: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(3+2)=14.4 MHz
/* DMA ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(1+2)=16 MHz
* DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)=12 MHz
*/
#ifdef CONFIG_SDIO_DMA
# define SDIO_MMCXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT)
# define SDIO_MMCXFR_CLKDIV (1 << SDIO_CLKCR_CLKDIV_SHIFT)
#else
# define SDIO_MMCXFR_CLKDIV (3 << SDIO_CLKCR_CLKDIV_SHIFT)
# define SDIO_MMCXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT)
#endif
/* DMA ON: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(1+2)=24 MHz
* DMA OFF: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(3+2)=14.4 MHz
/* DMA ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(0+2)= 24 MHz
* DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)= 12 MHz
*/
#ifdef CONFIG_SDIO_DMA
# define SDIO_SDXFR_CLKDIV (1 << SDIO_CLKCR_CLKDIV_SHIFT)
# define SDIO_SDXFR_CLKDIV (0 << SDIO_CLKCR_CLKDIV_SHIFT)
#else
# define SDIO_SDXFR_CLKDIV (3 << SDIO_CLKCR_CLKDIV_SHIFT)
# define SDIO_SDXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT)
#endif
/* Ethernet *************************************************************************/
@ -531,4 +533,4 @@ EXTERN void stm3220g_lcdclear(uint16_t color);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_BOARD_BOARD_H */
#endif /* __CONFIGS_STM3220G_EVAL_INCLUDE_BOARD_H */

View File

@ -518,8 +518,8 @@ CONFIG_DEBUG_I2C=n
CONFIG_DEBUG_INPUT=n
CONFIG_DEBUG_DMA=n
CONFIG_HAVE_CXX=n
CONFIG_HAVE_CXXINITIALIZE=n
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_MM_REGIONS=1
CONFIG_ARCH_LOWPUTC=y
CONFIG_RR_INTERVAL=200
@ -813,7 +813,6 @@ CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
CONFIG_MMCSD_MMCSUPPORT=n
CONFIG_MMCSD_HAVECARDDETECT=n
#
# TCP/IP and UDP support via uIP
#
@ -1342,8 +1341,8 @@ CONFIG_STM32_ILI9325_DISABLE=n
#
# Settings for examples/uip
#
CONFIG_EXAMPLE_UIP_IPADDR==(192<<24|168<<16|21<<8|15)
CONFIG_EXAMPLE_UIP_DRIPADDR=(192<<24|168<<16|21<<8|10)
CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_UIP_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLE_UIP_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_UIP_DHCPC=n
@ -1352,10 +1351,10 @@ CONFIG_EXAMPLE_UIP_DHCPC=n
CONFIG_EXAMPLE_NETTEST_SERVER=n
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
CONFIG_EXAMPLE_NETTEST_NOMAC=y
CONFIG_EXAMPLE_NETTEST_IPADDR==(192<<24|168<<16|21<<8|15)
CONFIG_EXAMPLE_NETTEST_DRIPADDR=(192<<24|168<<16|21<<8|10)
CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_NETTEST_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_NETTEST_CLIENTIP=(192<<24|168<<16|21<<8|10)
CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
#
# Settings for examples/ostest
@ -1410,12 +1409,12 @@ CONFIG_NSH_DISABLEBG=n
CONFIG_NSH_ROMFSETC=n
CONFIG_NSH_CONSOLE=y
CONFIG_NSH_TELNET=y
CONFIG_NSH_ARCHINIT=n
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_IOBUFFER_SIZE=512
CONFIG_NSH_DHCPC=n
CONFIG_NSH_NOMAC=y
CONFIG_NSH_IPADDR=(192<<24|168<<16|13<<8|161)
CONFIG_NSH_DRIPADDR=(192<<24|168<<16|13<<8|1)
CONFIG_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_NSH_ROMFSMOUNTPT="/etc"
CONFIG_NSH_INITSCRIPT="init.d/rcS"

View File

@ -80,6 +80,10 @@ ifeq ($(CONFIG_WATCHDOG),y)
CONFIGURED_APPS += examples/watchdog
endif
ifeq ($(CONFIG_INPUT_STMPE811),y)
CONFIGURED_APPS += examples/touchscreen
endif
# Uncomment examples/ftpc to include the FTP client example
# Uncomment examples/ftpd to include the FTP daemon example
@ -87,3 +91,12 @@ ifeq ($(CONFIG_NET),y)
#CONFIGURED_APPS += examples/ftpc
#CONFIGURED_APPS += examples/ftpd
endif
# Uncomment to select a graphics example
ifeq ($(CONFIG_NX),y)
#CONFIGURED_APPS += examples/nx
#CONFIGURED_APPS += examples/nxhello
#CONFIGURED_APPS += examples/nximage
#CONFIGURED_APPS += examples/nxlines
endif

View File

@ -334,7 +334,7 @@ CONFIG_STM32_MII_MCO2=n
CONFIG_STM32_RMII=n
CONFIG_STM32_AUTONEG=y
#CONFIG_STM32_ETHFD
#CONFIG_STM32_ETH100MB
#CONFIG_STM32_ETH100MBPS
CONFIG_STM32_PHYSR=16
CONFIG_STM32_PHYSR_SPEED=0x0002
CONFIG_STM32_PHYSR_100MBPS=0x0000
@ -517,6 +517,7 @@ CONFIG_DEBUG_PWM=n
CONFIG_DEBUG_CAN=n
CONFIG_DEBUG_I2C=n
CONFIG_DEBUG_DMA=n
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_MM_REGIONS=1
@ -529,7 +530,7 @@ CONFIG_START_MONTH=12
CONFIG_START_DAY=6
CONFIG_GREGORIAN_TIME=n
CONFIG_JULIAN_TIME=n
CONFIG_DEV_CONSOLE=y
CONFIG_DEV_CONSOLE=n
CONFIG_DEV_LOWCONSOLE=n
CONFIG_MUTEX_TYPES=n
CONFIG_PRIORITY_INHERITANCE=n
@ -541,7 +542,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_SCHED_WORKQUEUE=y
CONFIG_SCHED_WORKPRIORITY=192
CONFIG_SCHED_WORKPERIOD=(50*1000)
CONFIG_SCHED_WORKSTACKSIZE=1024
CONFIG_SCHED_WORKSTACKSIZE=2048
CONFIG_SIG_SIGWORK=4
CONFIG_SCHED_WAITPID=y
CONFIG_SCHED_ATEXIT=n
@ -935,6 +936,74 @@ CONFIG_RTC_HIRES=n
CONFIG_RTC_FREQUENCY=n
CONFIG_RTC_ALARM=n
#
# Input device configuration
#
CONFIG_INPUT=n
CONFIG_INPUT_TSC2007=n
#
# STMPE811 input device configuration
#
# Prerequisites: CONFIG_INPUT=y
# Other settings that effect the driver: CONFIG_DISABLE_POLL
#
# CONFIG_INPUT_STMPE811
# Enables support for the STMPE811 driver (Needs CONFIG_INPUT)
# CONFIG_STMPE811_SPI
# Enables support for the SPI interface (not currenly supported)
# CONFIG_STMPE811_I2C
# Enables support for the I2C interface
# CONFIG_STMPE811_MULTIPLE
# Can be defined to support multiple STMPE811 devices on board.
# CONFIG_STMPE811_ACTIVELOW
# Interrupt is generated by an active low signal (or falling edge).
# CONFIG_STMPE811_EDGE
# Interrupt is generated on an edge (vs. on the active level)
# CONFIG_STMPE811_NPOLLWAITERS
# Maximum number of threads that can be waiting on poll() (ignored if
# CONFIG_DISABLE_POLL is set).
# CONFIG_STMPE811_TSC_DISABLE
# Disable driver touchscreen functionality.
# CONFIG_STMPE811_ADC_DISABLE
# Disable driver ADC functionality.
# CONFIG_STMPE811_GPIO_DISABLE
# Disable driver GPIO functionality.
# CONFIG_STMPE811_GPIOINT_DISABLE
# Disable driver GPIO interrupt functionality (ignored if GPIO functionality is
# disabled).
# CONFIG_STMPE811_SWAPXY
# Reverse the meaning of X and Y to handle different LCD orientations.
# For the STM3220G-EVAL, X and Y should be swapped in PORTRAIT modes
# CONFIG_STMPE811_TEMP_DISABLE
# Disable driver temperature sensor functionality.
# CONFIG_STMPE811_REGDBUG
# Enabled very low register-level debug output. Requires CONFIG_DEBUG.
# CONFIG_STMPE811_THRESHX and CONFIG_STMPE811_THRESHY
# STMPE811 touchscreen data comes in a a very high rate. New touch positions
# will only be reported when the X or Y data changes by these thresholds.
# This trades reduces data rate for some loss in dragging accuracy. The
# STMPE811 is configure for 12-bit values so the raw ranges are 0-4095. So
# for example, if your display is 320x240, then THRESHX=13 and THRESHY=17
# would correspond to one pixel. Default: 12
#
CONFIG_INPUT_STMPE811=n
CONFIG_STMPE811_SPI=n
CONFIG_STMPE811_I2C=y
CONFIG_STMPE811_MULTIPLE=y
CONFIG_STMPE811_ACTIVELOW=y
CONFIG_STMPE811_EDGE=y
#CONFIG_STMPE811_NPOLLWAITERS
CONFIG_STMPE811_TSC_DISABLE=n
CONFIG_STMPE811_ADC_DISABLE=y
CONFIG_STMPE811_GPIO_DISABLE=y
CONFIG_STMPE811_GPIOINT_DISABLE=y
CONFIG_STMPE811_SWAPXY=y
CONFIG_STMPE811_TEMP_DISABLE=y
CONFIG_STMPE811_REGDEBUG=n
CONFIG_STMPE811_THRESHX=26
CONFIG_STMPE811_THRESHY=34
#
# USB Device Configuration
#
@ -1082,11 +1151,11 @@ CONFIG_WATCHDOG=n
# CONFIG_NXTK_BORDERWIDTH
# Specifies with with of the border (in pixels) used with
# framed windows. The default is 4.
# CONFIG_NXTK_BORDERCOLOR1 and CONFIG_NXTK_BORDERCOLOR2
# CONFIG_NXTK_BORDERCOLOR1, CONFIG_NXTK_BORDERCOLOR2, CONFIG_NXTK_BORDERCOLOR3
# Specify the colors of the border used with framed windows.
# CONFIG_NXTK_BORDERCOLOR2 is the shadow side color and so
# is normally darker. The default is medium and dark grey,
# respectively
# CONFIG_NXTK_BORDERCOLOR2 is the shadow side color and so is normally darker.
# CONFIG_NXTK_BORDERCOLOR3 is the shiny side color and so is normally brighter.
# The default is mediumdark grey, and light grey, respectively
# CONFIG_NXTK_AUTORAISE
# If set, a window will be raised to the top if the mouse position
# is over a visible portion of the window. Default: A mouse
@ -1199,11 +1268,81 @@ CONFIG_NX_BLOCKING=y
CONFIG_NX_MXSERVERMSGS=32
CONFIG_NX_MXCLIENTMSGS=16
#
# NxConsole Configuration Settings:
#
# CONFIG_NXCONSOLE
# Enables building of the NxConsole driver.
# CONFIG_NXCONSOLE_BPP
# Currently, NxConsole supports only a single pixel depth. This
# configuration setting must be provided to support that single pixel depth.
# Default: The smallest enabled pixel depth. (see CONFIG_NX_DISABLE_*BPP)
# CONFIG_NXCONSOLE_MXCHARS
# NxConsole needs to remember every character written to the console so
# that it can redraw the window. This setting determines the size of some
# internal memory allocations used to hold the character data. Default: 128.
# CONFIG_NXCONSOLE_CACHESIZE
# NxConsole supports caching of rendered fonts. This font caching is required
# for two reasons: (1) First, it improves text performance, but more
# importantly (2) it preserves the font memory. Since the NX server runs on
# a separate server thread, it requires that the rendered font memory persist
# until the server has a chance to render the font. (NOTE: There is still
# inherently a race condition in this!). Unfortunately, the font cache would
# be quite large if all fonts were saved. The CONFIG_NXCONSOLE_CACHESIZE setting
# will control the size of the font cache (in number of glyphs). Only that
# number of the most recently used glyphs will be retained. Default: 16.
# CONFIG_NXCONSOLE_LINESEPARATION
# This the space (in rows) between each row of test. Default: 2
# CONFIG_NXCONSOLE_NOWRAP
# By default, lines will wrap when the test reaches the right hand side
# of the window. This setting can be defining to change this behavior so
# that the text is simply truncated until a new line is encountered.
#
CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=16
CONFIG_NXCONSOLE_MXCHARS=256
CONFIG_NXCONSOLE_CACHESIZE=32
# CONFIG_NXCONSOLE_LINESEPARATION
# CONFIG_NXCONSOLE_NOWRAP
#
# STM3220G-EVAL LCD Hardware Configuration
#
# CONFIG_LCD_NOGETRUN
# NX components need to know if it can read from the LCD or not. If reading
# from the LCD is supported, then NxConsole can do more efficient
# scrolling. Default: Supported
# CONFIG_LCD_LANDSCAPE - Define for 320x240 display "landscape"
# support. Default is this 320x240 "landscape" orientation
# CONFIG_LCD_RLANDSCAPE - Define for 320x240 display "reverse
# landscape" support. Default is this 320x240 "landscape"
# orientation
# CONFIG_LCD_PORTRAIT - Define for 240x320 display "portrait"
# orientation support. In this orientation, the STM3220G-EVAL's
# LCD ribbon cable is at the bottom of the display. Default is
# 320x240 "landscape" orientation.
# CONFIG_LCD_RPORTRAIT - Define for 240x320 display "reverse
# portrait" orientation support. In this orientation, the
# STM3220G-EVAL's LCD ribbon cable is at the top of the display.
# Default is 320x240 "landscape" orientation.
#
CONFIG_LCD_NOGETRUN=y
CONFIG_LCD_LANDSCAPE=n
CONFIG_LCD_RLANDSCAPE=n
CONFIG_LCD_PORTRAIT=n
CONFIG_LCD_RPORTRAIT=y
#
# STM3220G-EVAL specific LCD settings
#
CONFIG_STM32_ILI9320_DISABLE=n
CONFIG_STM32_ILI9325_DISABLE=n
#
# Settings for examples/uip
#
CONFIG_EXAMPLE_UIP_IPADDR==(192<<24|168<<16|21<<8|15)
CONFIG_EXAMPLE_UIP_DRIPADDR=(192<<24|168<<16|21<<8|10)
CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_UIP_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLE_UIP_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_UIP_DHCPC=n
@ -1212,10 +1351,10 @@ CONFIG_EXAMPLE_UIP_DHCPC=n
CONFIG_EXAMPLE_NETTEST_SERVER=n
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
CONFIG_EXAMPLE_NETTEST_NOMAC=y
CONFIG_EXAMPLE_NETTEST_IPADDR==(192<<24|168<<16|21<<8|15)
CONFIG_EXAMPLE_NETTEST_DRIPADDR=(192<<24|168<<16|21<<8|10)
CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_NETTEST_DRIPADDR=((10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_NETTEST_CLIENTIP=(192<<24|168<<16|21<<8|10)
CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
#
# Settings for examples/ostest
@ -1268,14 +1407,14 @@ CONFIG_NSH_NESTDEPTH=3
CONFIG_NSH_DISABLESCRIPT=n
CONFIG_NSH_DISABLEBG=n
CONFIG_NSH_ROMFSETC=n
CONFIG_NSH_CONSOLE=y
CONFIG_NSH_CONSOLE=n
CONFIG_NSH_TELNET=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_IOBUFFER_SIZE=512
CONFIG_NSH_DHCPC=n
CONFIG_NSH_NOMAC=y
CONFIG_NSH_IPADDR=(192<<24|168<<16|13<<8|161)
CONFIG_NSH_DRIPADDR=(192<<24|168<<16|13<<8|1)
CONFIG_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_NSH_ROMFSMOUNTPT="/etc"
CONFIG_NSH_INITSCRIPT="init.d/rcS"
@ -1368,6 +1507,276 @@ CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n
# built-in, the default is 32. Otherwise messages are sent and received
# indefinitely.
#
# Settings for examples/nx
#
# CONFIG_EXAMPLES_NX_BUILTIN -- Build the NX example as a "built-in"
# that can be executed from the NSH command line
# CONFIG_EXAMPLES_NX_VPLANE -- The plane to select from the frame-
# buffer driver for use in the test. Default: 0
# CONFIG_EXAMPLES_NX_DEVNO - The LCD device to select from the LCD
# driver for use in the test: Default: 0
# CONFIG_EXAMPLES_NX_BGCOLOR -- The color of the background. Default depends on
# CONFIG_EXAMPLES_NX_BPP.
# CONFIG_EXAMPLES_NX_COLOR1 -- The color of window 1. Default depends on
# CONFIG_EXAMPLES_NX_BPP.
# CONFIG_EXAMPLES_NX_COLOR2 -- The color of window 2. Default depends on
# CONFIG_EXAMPLES_NX_BPP.
# CONFIG_EXAMPLES_NX_TBCOLOR -- The color of the toolbar. Default depends on
# CONFIG_EXAMPLES_NX_BPP.
# CONFIG_EXAMPLES_NX_FONTID - Selects the font (see font ID numbers in
# include/nuttx/nx/nxfonts.h)
# CONFIG_EXAMPLES_NX_FONTCOLOR -- The color of the toolbar. Default depends on
# CONFIG_EXAMPLES_NX_BPP.
# CONFIG_EXAMPLES_NX_BPP -- Pixels per pixel to use. Valid options
# include 2, 4, 8, 16, 24, and 32. Default is 32.
# CONFIG_EXAMPLES_NX_RAWWINDOWS -- Use raw windows; Default is to
# use pretty, framed NXTK windows with toolbars.
# 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
#
CONFIG_EXAMPLES_NX_BUILTIN=y
CONFIG_EXAMPLES_NX_VPLANE=0
CONFIG_EXAMPLES_NX_DEVNO=0
CONFIG_EXAMPLES_NX_BGCOLOR=0x0011
CONFIG_EXAMPLES_NX_COLOR1=0xaedc
CONFIG_EXAMPLES_NX_COLOR2=0xe7ff
CONFIG_EXAMPLES_NX_TBCOLOR=0xd69a
CONFIG_EXAMPLES_NX_FONTID=0
CONFIG_EXAMPLES_NX_FONTCOLOR=0x0000
CONFIG_EXAMPLES_NX_BPP=16
CONFIG_EXAMPLES_NX_RAWWINDOWS=n
CONFIG_EXAMPLES_NX_STACKSIZE=2048
CONFIG_EXAMPLES_NX_CLIENTPRIO=80
CONFIG_EXAMPLES_NX_SERVERPRIO=120
CONFIG_EXAMPLES_NX_NOTIFYSIGNO=4
CONFIG_EXAMPLES_NX_EXTERNINIT=n
#
# Settings for examples/nxhello
#
# CONFIG_EXAMPLES_NXHELLO_BUILTIN -- Build the NXHELLO example as a "built-in"
# that can be executed from the NSH command line
# CONFIG_EXAMPLES_NXHELLO_VPLANE -- The plane to select from the frame-
# buffer driver for use in the test. Default: 0
# CONFIG_EXAMPLES_NXHELLO_DEVNO - The LCD device to select from the LCD
# driver for use in the test: Default: 0
# CONFIG_EXAMPLES_NXHELLO_BGCOLOR -- The color of the background. Default
# depends on CONFIG_EXAMPLES_NXHELLO_BPP.
# CONFIG_EXAMPLES_NXHELLO_FONTID - Selects the font (see font ID numbers in
# include/nuttx/nx/nxfonts.h)
# CONFIG_EXAMPLES_NXHELLO_FONTCOLOR -- The color of the fonts used in the
# background window. Default depends on CONFIG_EXAMPLES_NXHELLO_BPP.
# CONFIG_EXAMPLES_NXHELLO_BPP -- Pixels per pixel to use. Valid options
# include 2, 4, 8, 16, 24, and 32. Default is 32.
# CONFIG_EXAMPLES_NXHELLO_EXTERNINIT - The driver for the graphics device on
# this platform requires some unusual initialization. This is the
# for, for example, SPI LCD/OLED devices. If this configuration is
# selected, then the platform code must provide an LCD initialization
# function.
#
CONFIG_EXAMPLES_NXHELLO_BUILTIN=y
CONFIG_EXAMPLES_NXHELLO_VPLANE=0
CONFIG_EXAMPLES_NXHELLO_DEVNO=0
CONFIG_EXAMPLES_NXHELLO_BGCOLOR=0x0011
CONFIG_EXAMPLES_NXHELLO_FONTID=6
CONFIG_EXAMPLES_NXHELLO_FONTCOLOR=0xffdf
CONFIG_EXAMPLES_NXHELLO_BPP=16
CONFIG_EXAMPLES_NXHELLO_EXTERNINIT=n
#
# Settings for examples/nximage
#
# CONFIG_EXAMPLES_NXIMAGE_BUILTIN -- Build the NXIMAGE example as a "built-in"
# that can be executed from the NSH command line
# CONFIG_EXAMPLES_NXIMAGE_VPLANE -- The plane to select from the frame-
# buffer driver for use in the test. Default: 0
# CONFIG_EXAMPLES_NXIMAGE_DEVNO - The LCD device to select from the LCD
# driver for use in the test: Default: 0
# CONFIG_EXAMPLES_NXIMAGE_BPP -- Pixels per pixel to use. Valid options
# include 8, 16, and 24. Default is 16.
# CONFIG_EXAMPLES_NXIMAGE_XSCALEp5, CONFIG_EXAMPLES_NXIMAGE_XSCALE1p5,
# CONFIG_EXAMPLES_NXIMAGE_XSCALE2p0 -- The logo image width is 160 columns.
# One of these may be defined to rescale the image horizontally by .5, 1.5,
# or 2.0.
# CONFIG_EXAMPLES_NXIMAGE_YSCALEp5, CONFIG_EXAMPLES_NXIMAGE_YSCALE1p5,
# CONFIG_EXAMPLES_NXIMAGE_YSCALE2p0 -- The logo image height is 160 rows.
# One of these may be defined to rescale the image vertically by .5, 1.5,
# or 2.0.
# CONFIG_EXAMPLES_NXIMAGE_EXTERNINIT - The driver for the graphics device on
# this platform requires some unusual initialization. This is the
# for, for example, SPI LCD/OLED devices. If this configuration is
# selected, then the platform code must provide an LCD initialization
# function.
#
CONFIG_EXAMPLES_NXIMAGE_BUILTIN=y
CONFIG_EXAMPLES_NXIMAGE_VPLANE=0
CONFIG_EXAMPLES_NXIMAGE_DEVNO=0
CONFIG_EXAMPLES_NXIMAGE_BPP=16
CONFIG_EXAMPLES_NXIMAGE_XSCALEp5=n
CONFIG_EXAMPLES_NXIMAGE_XSCALE1p5=y
CONFIG_EXAMPLES_NXIMAGE_XSCALE2p0=n
CONFIG_EXAMPLES_NXIMAGE_YSCALEp5=n
CONFIG_EXAMPLES_NXIMAGE_YSCALE1p5=y
CONFIG_EXAMPLES_NXIMAGE_YSCALE2p0=n
CONFIG_EXAMPLES_NXIMAGE_EXTERNINIT=n
#
# Settings for examples/nxlines
#
# CONFIG_EXAMPLES_NXLINES_BUILTIN -- Build the NXLINES example as a "built-in"
# that can be executed from the NSH command line
# CONFIG_EXAMPLES_NXLINES_VPLANE -- The plane to select from the frame-
# buffer driver for use in the test. Default: 0
# CONFIG_EXAMPLES_NXLINES_DEVNO - The LCD device to select from the LCD
# driver for use in the test: Default: 0
# CONFIG_EXAMPLES_NXLINES_BGCOLOR -- The color of the background. Default
# depends on CONFIG_EXAMPLES_NXLINES_BPP.
# CONFIG_EXAMPLES_NXLINES_LINEWIDTH - Selects the width of the lines in
# pixels (default: 16)
# CONFIG_EXAMPLES_NXLINES_LINECOLOR -- The color of the central lines drawn
# in the background window. Default depends on CONFIG_EXAMPLES_NXLINES_BPP
# (there really is no meaningful default).
# CONFIG_EXAMPLES_NXLINES_BORDERWIDTH -- The width of the circular border
# drawn in the background window. (default: 4).
# CONFIG_EXAMPLES_NXLINES_BORDERCOLOR -- The color of the circular border
# drawn in the background window. Default depends on CONFIG_EXAMPLES_NXLINES_BPP
# (there really is no meaningful default).
# CONFIG_EXAMPLES_NXLINES_CIRCLECOLOR -- The color of the circular region
# filled in the background window. Default depends on CONFIG_EXAMPLES_NXLINES_BPP
# (there really is no meaningful default).
# CONFIG_EXAMPLES_NXLINES_BPP -- Pixels per pixel to use. Valid options
# include 2, 4, 8, 16, 24, and 32. Default is 16.
# CONFIG_EXAMPLES_NXLINES_EXTERNINIT - The driver for the graphics device on
# this platform requires some unusual initialization. This is the
# for, for example, SPI LCD/OLED devices. If this configuration is
# selected, then the platform code must provide an LCD initialization
# function.
#
CONFIG_EXAMPLES_NXLINES_BUILTIN=n
CONFIG_EXAMPLES_NXLINES_VPLANE=0
CONFIG_EXAMPLES_NXLINES_DEVNO=0
CONFIG_EXAMPLES_NXLINES_BGCOLOR=0x0320
CONFIG_EXAMPLES_NXLINES_LINEWIDTH=16
CONFIG_EXAMPLES_NXLINES_LINECOLOR=0xffe0
CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=4
CONFIG_EXAMPLES_NXLINES_BORDERCOLOR=0xffe0
CONFIG_EXAMPLES_NXLINES_CIRCLECOLOR=0xf7bb
CONFIG_EXAMPLES_NXLINES_BPP=16
CONFIG_EXAMPLES_NXLINES_EXTERNINIT=n
#
# Settings for examples/touchscreen
#
# CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN - Build the touchscreen test as
# an NSH built-in function. Default: Built as a standalone problem
# CONFIG_EXAMPLES_TOUCHSCREEN_MINOR - The minor device number. Minor=N
# correspnds to touchscreen device /dev/input0. Note this value must
# with CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH. Default 0.
# CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH - The path to the touchscreen
# device. This must be consistent with CONFIG_EXAMPLES_TOUCHSCREEN_MINOR.
# Default: "/dev/input0"
# CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES - If CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN
# is defined, then the number of samples is provided on the command line
# and this value is ignored. Otherwise, this number of samples is
# collected and the program terminates. Default: Samples are collected
# indefinitely.
#
CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN=y
CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0
CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/input0"
CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES=25
#
# Settings for examples/usbstorage
#
# CONFIG_EXAMPLES_USBMSC_BUILTIN
# This example can be built as two NSH "built-in" commands if this option
# is selection: 'msconn' will connect the USB mass storage device; 'msdis'
# will disconnect the USB storage device.
# CONFIG_EXAMPLES_USBMSC_NLUNS
# Defines the number of logical units (LUNs) exported by the USB storage
# driver. Each LUN corresponds to one exported block driver (or partition
# of a block driver). May be 1, 2, or 3. Default is 1.
# CONFIG_EXAMPLES_USBMSC_DEVMINOR1
# The minor device number of the block driver for the first LUN. For
# example, N in /dev/mmcsdN. Used for registering the block driver. Default
# is zero.
# CONFIG_EXAMPLES_USBMSC_DEVPATH1
# The full path to the registered block driver. Default is "/dev/mmcsd0"
# CONFIG_EXAMPLES_USBMSC_DEVMINOR2 and CONFIG_EXAMPLES_USBMSC_DEVPATH2
# Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBMSC_NLUNS
# is 2 or 3. No defaults.
# CONFIG_EXAMPLES_USBMSC_DEVMINOR3 and CONFIG_EXAMPLES_USBMSC_DEVPATH3
# Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBMSC_NLUNS
# is 3. No defaults.
# CONFIG_EXAMPLES_USBMSC_DEBUGMM
# Enables some debug tests to check for memory usage and memory leaks.
#
# If CONFIG_USBDEV_TRACE is enabled (or CONFIG_DEBUG and CONFIG_DEBUG_USB), then
# the example code will also manage the USB trace output. The amount of trace output
# can be controlled using:
#
# CONFIG_EXAMPLES_USBMSC_TRACEINIT
# Show initialization events
# CONFIG_EXAMPLES_USBMSC_TRACECLASS
# Show class driver events
# CONFIG_EXAMPLES_USBMSC_TRACETRANSFERS
# Show data transfer events
# CONFIG_EXAMPLES_USBMSC_TRACECONTROLLER
# Show controller events
# CONFIG_EXAMPLES_USBMSC_TRACEINTERRUPTS
# Show interrupt-related events.
#
CONFIG_EXAMPLES_USBMSC_BUILTIN=y
CONFIG_EXAMPLES_USBMSC_NLUNS=1
CONFIG_EXAMPLES_USBMSC_DEVMINOR1=0
CONFIG_EXAMPLES_USBMSC_DEVPATH1="/dev/mmcsd0"
CONFIG_EXAMPLES_USBMSC_DEBUGMM=n
CONFIG_EXAMPLES_USBMSC_TRACEINIT=n
CONFIG_EXAMPLES_USBMSC_TRACECLASS=n
CONFIG_EXAMPLES_USBMSC_TRACETRANSFERS=n
CONFIG_EXAMPLES_USBMSC_TRACECONTROLLER=n
CONFIG_EXAMPLES_USBMSC_TRACEINTERRUPTS=n
#
# Settings for examples/watchdog
#
# This test depends on these specific Watchdog/NSH configurations settings (your
# specific watchdog hardware settings might require additional settings).
#
# CONFIG_WATCHDOG- Enables watchdog timer support support.
# CONFIG_NSH_BUILTIN_APPS - Build the watchdog time test as an NSH
# built-in function. Default: Not built! The example can only be used
# as an NSH built-in application
#
# The STM32 also needs one of the following enabled:
#
# CONFIG_STM32_WWDG=y, OR
# CONFIG_STM32_IWDG=y (but not both)
#
# Specific configuration options for this example include:
#
# CONFIG_EXAMPLES_WATCHDOG_DEVPATH - The path to the Watchdog device.
# Default: /dev/watchdog0
# CONFIG_EXAMPLES_WATCHDOG_PINGTIME - Time in milliseconds that the example
# will ping the watchdog before letting the watchdog expire. Default: 5000
# milliseconds
# CONFIG_EXAMPLES_WATCHDOG_PINGDELAY - Time delay between pings in
# milliseconds. Default: 500 milliseconds.
# CONFIG_EXAMPLES_WATCHDOG_TIMEOUT - The watchdog timeout value in
# milliseconds before the watchdog timer expires. Default: 2000
# milliseconds.
#
# CONFIG_EXAMPLES_WATCHDOG_DEVPATH
# CONFIG_EXAMPLES_WATCHDOG_PINGTIME
# CONFIG_EXAMPLES_WATCHDOG_PINGDELAY
# CONFIG_EXAMPLES_WATCHDOG_TIMEOUT
#
# Settings for examples/pwm
#

View File

@ -167,29 +167,29 @@
* to service FIFOs in interrupt driven mode. These values have not been
* tuned!!!
*
* HCLK=72MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(178+2)=400 KHz
* SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(118+2)=400 KHz
*/
#define SDIO_INIT_CLKDIV (178 << SDIO_CLKCR_CLKDIV_SHIFT)
#define SDIO_INIT_CLKDIV (118 << SDIO_CLKCR_CLKDIV_SHIFT)
/* DMA ON: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(2+2)=18 MHz
* DMA OFF: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(3+2)=14.4 MHz
/* DMA ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(1+2)=16 MHz
* DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)=12 MHz
*/
#ifdef CONFIG_SDIO_DMA
# define SDIO_MMCXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT)
# define SDIO_MMCXFR_CLKDIV (1 << SDIO_CLKCR_CLKDIV_SHIFT)
#else
# define SDIO_MMCXFR_CLKDIV (3 << SDIO_CLKCR_CLKDIV_SHIFT)
# define SDIO_MMCXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT)
#endif
/* DMA ON: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(1+2)=24 MHz
* DMA OFF: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(3+2)=14.4 MHz
/* DMA ON: HSDIOCLK=48MHz, SDIO_CK=SDIOCLK/(0+2)=24 MHz
* DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)=12 MHz
*/
#ifdef CONFIG_SDIO_DMA
# define SDIO_SDXFR_CLKDIV (1 << SDIO_CLKCR_CLKDIV_SHIFT)
# define SDIO_SDXFR_CLKDIV (0 << SDIO_CLKCR_CLKDIV_SHIFT)
#else
# define SDIO_SDXFR_CLKDIV (3 << SDIO_CLKCR_CLKDIV_SHIFT)
# define SDIO_SDXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT)
#endif
/* Ethernet *************************************************************************/

View File

@ -541,7 +541,7 @@ CONFIG_START_MONTH=12
CONFIG_START_DAY=6
CONFIG_GREGORIAN_TIME=n
CONFIG_JULIAN_TIME=n
CONFIG_DEV_CONSOLE=y
CONFIG_DEV_CONSOLE=n
CONFIG_DEV_LOWCONSOLE=n
CONFIG_MUTEX_TYPES=n
CONFIG_PRIORITY_INHERITANCE=n
@ -1268,7 +1268,7 @@ CONFIG_NSH_NESTDEPTH=3
CONFIG_NSH_DISABLESCRIPT=n
CONFIG_NSH_DISABLEBG=n
CONFIG_NSH_ROMFSETC=n
CONFIG_NSH_CONSOLE=y
CONFIG_NSH_CONSOLE=n
CONFIG_NSH_TELNET=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_IOBUFFER_SIZE=512

View File

@ -80,7 +80,7 @@
************************************************************************/
/************************************************************************
* Function: atexit
* Name: atexit
*
* Description:
* Registers a function to be called at program exit.

View File

@ -2,7 +2,7 @@
* clock_abstime2ticks.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -69,7 +69,7 @@
********************************************************************************/
/********************************************************************************
* Function: clock_abstime2ticks
* Name: clock_abstime2ticks
*
* Description:
* Convert an absolute timespec delay to system timer ticks.
@ -95,8 +95,8 @@ int clock_abstime2ticks(clockid_t clockid, FAR const struct timespec *abstime,
struct timespec reltime;
int ret;
/* Convert the timespec to clock ticks. NOTE: Here we use
* internal knowledge that CLOCK_REALTIME is defined to be zero!
/* Convert the timespec to clock ticks. NOTE: Here we use internal knowledge
* that CLOCK_REALTIME is defined to be zero!
*/
ret = clock_gettime(clockid, &currtime);
@ -105,15 +105,13 @@ int clock_abstime2ticks(clockid_t clockid, FAR const struct timespec *abstime,
return EINVAL;
}
/* The relative time to wait is the absolute time minus the
* current time.
*/
/* The relative time to wait is the absolute time minus the current time. */
reltime.tv_nsec = (abstime->tv_nsec - currtime.tv_nsec);
reltime.tv_sec = (abstime->tv_sec - currtime.tv_sec);
/* Check if we were supposed to borrow from the seconds to
* borrow from the seconds
/* Check if we were supposed to borrow from the seconds to borrow from the
* seconds
*/
if (reltime.tv_nsec < 0)

View File

@ -2,7 +2,7 @@
* sched/clock_getres.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -79,7 +79,7 @@
************************************************************************/
/************************************************************************
* Function: clock_getres
* Name: clock_getres
*
* Description:
* Clock Functions based on POSIX APIs
@ -98,7 +98,7 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
if (clock_id != CLOCK_REALTIME)
{
sdbg("Returning ERROR\n");
*get_errno_ptr() = EINVAL;
set_errno(EINVAL);
ret = ERROR;
}
else

View File

@ -83,7 +83,7 @@
************************************************************************/
/************************************************************************
* Function: clock_gettime
* Name: clock_gettime
*
* Description:
* Clock Functions based on POSIX APIs

View File

@ -2,7 +2,7 @@
* sched/clock_gettimeofday.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -38,10 +38,11 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/time.h>
#include <sys/time.h>
#include <errno.h>
#include <debug.h>
#include "clock_internal.h"
/****************************************************************************
@ -77,7 +78,7 @@
****************************************************************************/
/****************************************************************************
* Function: gettimeofday
* Name: gettimeofday
*
* Description:
* Get the current time
@ -107,5 +108,6 @@ int gettimeofday(struct timeval *tp, void *tzp)
tp->tv_sec = ts.tv_sec;
tp->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
}
return ret;
}

View File

@ -99,7 +99,7 @@ struct timespec g_basetime;
**************************************************************************/
/****************************************************************************
* Function: clock_basetime
* Name: clock_basetime
*
* Description:
* Get the initial time value from the best source available.
@ -170,7 +170,7 @@ static inline void clock_basetime(FAR struct timespec *tp)
#endif /* CONFIG_RTC */
/****************************************************************************
* Function: clock_inittime
* Name: clock_inittime
*
* Description:
* Get the initial time value from the best source available.
@ -191,7 +191,7 @@ static void clock_inittime(void)
****************************************************************************/
/****************************************************************************
* Function: clock_initialize
* Name: clock_initialize
*
* Description:
* Perform one-time initialization of the timing facilities.
@ -212,7 +212,7 @@ void clock_initialize(void)
}
/****************************************************************************
* Function: clock_synchronize
* Name: clock_synchronize
*
* Description:
* Synchronize the system timer to a hardware RTC. This operation is
@ -253,12 +253,12 @@ void clock_synchronize(void)
#endif
/****************************************************************************
* Function: clock_timer
* Name: clock_timer
*
* Description:
* This function must be called once every time the real
* time clock interrupt occurs. The interval of this
* clock interrupt must be MSEC_PER_TICK
* This function must be called once every time the real time clock
* interrupt occurs. The interval of this clock interrupt must be
* MSEC_PER_TICK
*
****************************************************************************/

View File

@ -1,8 +1,8 @@
/********************************************************************************
* clock_internal.h
* sched/clock_internal.h
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -33,8 +33,8 @@
*
********************************************************************************/
#ifndef __CLOCK_INTERNAL_H
#define __CLOCK_INTERNAL_H
#ifndef __SCHED_CLOCK_INTERNAL_H
#define __SCHED_CLOCK_INTERNAL_H
/********************************************************************************
* Included Files
@ -79,13 +79,13 @@ extern struct timespec g_basetime;
* Public Function Prototypes
********************************************************************************/
extern void weak_function clock_initialize(void);
extern void weak_function clock_timer(void);
void weak_function clock_initialize(void);
void weak_function clock_timer(void);
extern int clock_abstime2ticks(clockid_t clockid,
FAR const struct timespec *abstime,
FAR int *ticks);
extern int clock_time2ticks(FAR const struct timespec *reltime, FAR int *ticks);
extern int clock_ticks2time(int ticks, FAR struct timespec *reltime);
int clock_abstime2ticks(clockid_t clockid,
FAR const struct timespec *abstime,
FAR int *ticks);
int clock_time2ticks(FAR const struct timespec *reltime, FAR int *ticks);
int clock_ticks2time(int ticks, FAR struct timespec *reltime);
#endif /* __CLOCK_INTERNAL_H */
#endif /* __SCHED_CLOCK_INTERNAL_H */

View File

@ -81,7 +81,7 @@
************************************************************************/
/************************************************************************
* Function: clock_settime
* Name: clock_settime
*
* Description:
* Clock Functions based on POSIX APIs

View File

@ -2,7 +2,7 @@
* sched/clock_systimer.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -58,7 +58,7 @@
****************************************************************************/
/****************************************************************************
* Function: clock_systimer
* Name: clock_systimer
*
* Description:
* Return the current value of the 32-bit system timer counter
@ -85,7 +85,7 @@ uint32_t clock_systimer(void)
#endif
/****************************************************************************
* Function: clock_systimer64
* Name: clock_systimer64
*
* Description:
* Return the current value of the 64-bit system timer counter

View File

@ -2,7 +2,7 @@
* clock_ticks2time.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -67,7 +67,7 @@
********************************************************************************/
/********************************************************************************
* Function: clock_ticks2time
* Name: clock_ticks2time
*
* Description:
* Convert the system time tick value to a relative time.

View File

@ -2,7 +2,7 @@
* sched/clock_time2ticks.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -69,7 +69,7 @@
********************************************************************************/
/********************************************************************************
* Function: clock_time2ticks
* Name: clock_time2ticks
*
* Description:
* Convert a timespec delay to system timer ticks. This function is suitable

View File

@ -2,7 +2,7 @@
* sched/env_clearenv.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -55,7 +55,7 @@
****************************************************************************/
/****************************************************************************
* Function: clearenv
* Name: clearenv
*
* Description:
* The clearenv() function clears the environment of all name-value pairs

View File

@ -2,7 +2,7 @@
* sched/env_dup.c
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -60,7 +60,7 @@
****************************************************************************/
/****************************************************************************
* Function: env_dup
* Name: env_dup
*
* Description:
* Copy the internal environment structure of a task. This is the action
@ -122,6 +122,7 @@ int env_dup(FAR _TCB *ptcb)
ptcb->envp = envp;
sched_unlock();
}
return ret;
}

View File

@ -2,7 +2,7 @@
* eched/env_dupenv.c
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -57,7 +57,7 @@
****************************************************************************/
/****************************************************************************
* Function: dupenv
* Name: dupenv
*
* Description:
* Copy the internal environment structure of a task. This is the action

View File

@ -2,7 +2,7 @@
* sched/env_findvar.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -54,7 +54,7 @@
****************************************************************************/
/****************************************************************************
* Function: env_cmpname
* Name: env_cmpname
****************************************************************************/
static bool env_cmpname(const char *pszname, const char *peqname)
@ -69,6 +69,7 @@ static bool env_cmpname(const char *pszname, const char *peqname)
{
return true;
}
return false;
}
@ -77,7 +78,7 @@ static bool env_cmpname(const char *pszname, const char *peqname)
****************************************************************************/
/****************************************************************************
* Function: env_findvar
* Name: env_findvar
*
* Description:
* Search the provided environment structure for the variable of the
@ -109,7 +110,9 @@ FAR char *env_findvar(environ_t *envp, const char *pname)
/* Search for a name=value string with matching name */
for (ptr = envp->ev_env; ptr < end && !env_cmpname( pname, ptr); ptr += (strlen(ptr) + 1));
for (ptr = envp->ev_env;
ptr < end && !env_cmpname( pname, ptr);
ptr += (strlen(ptr) + 1));
/* Check for success */
@ -118,6 +121,7 @@ FAR char *env_findvar(environ_t *envp, const char *pname)
ret = ptr;
}
}
return ret;
}

View File

@ -2,7 +2,7 @@
* env_getenv.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -58,7 +58,7 @@
****************************************************************************/
/****************************************************************************
* Function: getenv
* Name: getenv
*
* Description:
* The getenv() function searches the environment list for a string that
@ -91,7 +91,6 @@ FAR char *getenv(const char *name)
goto errout;
}
/* Get a reference to the thread-private environ in the TCB.*/
sched_lock();
@ -126,7 +125,7 @@ FAR char *getenv(const char *name)
errout_with_lock:
sched_unlock();
errout:
*get_errno_ptr() = ret;
set_errno(ret);
return NULL;
}

View File

@ -2,7 +2,7 @@
* env_getenvironptr.c
*
* Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -56,7 +56,7 @@
****************************************************************************/
/****************************************************************************
* Function: get_environ_ptr
* Name: get_environ_ptr
*
* Description:
* Return a pointer to the thread specific environ variable.
@ -75,9 +75,9 @@ FAR char **get_environ_ptr( void )
{
#if 1
/* Type of internal representation of environment is incompatible with
* char ** return value.
*/
/* Type of internal representation of environment is incompatible with
* char ** return value.
*/
return NULL;

View File

@ -2,7 +2,7 @@
* sched/env_internal.h
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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

View File

@ -2,7 +2,7 @@
* sched/env_putenv.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -57,7 +57,7 @@
****************************************************************************/
/****************************************************************************
* Function: putenv
* Name: putenv
*
* Description:
* The putenv() function adds or changes the value of environment variables.

View File

@ -2,7 +2,7 @@
* sched/env_clearenv.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -55,12 +55,12 @@
****************************************************************************/
/****************************************************************************
* Function: env_release
* Name: env_release
*
* Description:
* The env_release() function clears the environment of all name-value pairs
* and sets the value of the external variable environ to NULL.
* The env_release() function clears the environment of all name-value
* pairs and sets the value of the external variable environ to NULL.
*
* Parameters:
* ptcb Identifies the TCB containing the environment structure
*
@ -75,6 +75,7 @@
int env_release(FAR _TCB *ptcb)
{
int ret = OK;
if (!ptcb)
{
ret = -EINVAL;
@ -111,8 +112,10 @@ int env_release(FAR _TCB *ptcb)
ptcb->envp = NULL;
}
sched_unlock();
}
return ret;
}

View File

@ -2,7 +2,7 @@
* sched/env_removevar.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -53,7 +53,7 @@
****************************************************************************/
/****************************************************************************
* Function: env_removevar
* Name: env_removevar
*
* Description:
* Remove the referenced name=value pair from the environment
@ -109,6 +109,7 @@ int env_removevar(environ_t *envp, char *pvar)
ret = OK;
}
}
return ret;
}

View File

@ -2,7 +2,7 @@
* sched/env_setenv.c
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -61,7 +61,7 @@
****************************************************************************/
/****************************************************************************
* Function: setenv
* Name: setenv
*
* Description:
* The setenv() function adds the variable name to the environment with the
@ -148,8 +148,8 @@ int setenv(const char *name, const char *value, int overwrite)
}
/* Get the size of the new name=value string. The +2 is for the '=' and for
* null terminator
*/
* null terminator
*/
varlen = strlen(name) + strlen(value) + 2;

View File

@ -2,7 +2,7 @@
* sched/env_share.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -43,6 +43,7 @@
#include <sched.h>
#include <errno.h>
#include "os_internal.h"
#include "env_internal.h"
@ -55,7 +56,7 @@
****************************************************************************/
/****************************************************************************
* Function: env_share
* Name: env_share
*
* Description:
* Increment the reference count on the internal environment structure of
@ -106,6 +107,7 @@ int env_share(FAR _TCB *ptcb)
ptcb->envp = envp;
sched_unlock();
}
return ret;
}

View File

@ -2,7 +2,7 @@
* sched/env_unsetenv.c
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -59,7 +59,7 @@
****************************************************************************/
/****************************************************************************
* Function: unsetenv
* Name: unsetenv
*
* Description:
* The unsetenv() function deletes the variable name from the environment.

View File

@ -2,7 +2,7 @@
* sched/errno_get.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -58,7 +58,7 @@
****************************************************************************/
/****************************************************************************
* Function: get_errno
* Name: get_errno
*
* Description:
* Return the value of the thread specific errno. This function is only

View File

@ -2,7 +2,7 @@
* sched/errno_getptr.c
*
* Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -61,7 +61,7 @@ static int g_irqerrno;
****************************************************************************/
/****************************************************************************
* Function: get_errno_ptr
* Name: get_errno_ptr
*
* Description:
* Return a pointer to the thread specific errno.

View File

@ -2,7 +2,7 @@
* sched/errno_set.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -58,7 +58,7 @@
****************************************************************************/
/****************************************************************************
* Function: set_errno
* Name: set_errno
*
* Description:
* Set the value of the thread specific errno. This function is only

View File

@ -43,7 +43,9 @@
#include <unistd.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/fs/fs.h>
#include "os_internal.h"
/****************************************************************************
@ -75,7 +77,7 @@
****************************************************************************/
/****************************************************************************
* Function: exit
* Name: exit
*
* Description:
* The exit() function causes normal process termination and the value of

View File

@ -2,7 +2,7 @@
* sched/getpid.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -40,6 +40,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <sched.h>
#include "os_internal.h"
/************************************************************************
@ -76,9 +77,9 @@
pid_t getpid(void)
{
/* Return the task ID from the TCB at the head of the
* ready-to-run task list
*/
/* Return the task ID from the TCB at the head of the
* ready-to-run task list
*/
return ((FAR _TCB*)g_readytorun.head)->pid;
return ((FAR _TCB*)g_readytorun.head)->pid;
}

View File

@ -38,7 +38,9 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include "irq_internal.h"
/****************************************************************************
@ -69,8 +71,8 @@
* Name: irq_attach
*
* Description:
* Configure the IRQ subsystem so that IRQ number 'irq'
* is dispatched to 'isr'
* Configure the IRQ subsystem so that IRQ number 'irq' is dispatched to
* 'isr'
*
****************************************************************************/
@ -123,5 +125,3 @@ int irq_attach(int irq, xcpt_t isr)
return OK;
#endif
}

View File

@ -2,7 +2,7 @@
* sched/irq_dispatch.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -73,9 +73,9 @@
* Name: irq_dispatch
*
* Description:
* This function must be called from the achitecture-
* specific logic in order to dispaly an interrupt to
* the appropriate, registered handling logic.
* This function must be called from the achitecture-specific logic in
* order to dispatch an interrupt to the appropriate, registered handling
* logic.
*
***************************************************************************/

View File

@ -2,7 +2,7 @@
* sched/irq_initialize.c
*
* Copyright (C) 2007-2008, 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include "irq_internal.h"
/****************************************************************************
@ -69,7 +70,7 @@ FAR xcpt_t g_irqvector[NR_IRQS+1];
****************************************************************************/
/****************************************************************************
* Function: irq_initialize
* Name: irq_initialize
*
* Description:
* Configure the IRQ subsystem

View File

@ -2,7 +2,7 @@
* sched/irq_internal.h
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -33,8 +33,8 @@
*
****************************************************************************/
#ifndef __IRQ_INTERNAL_H
#define __IRQ_INTERNAL_H
#ifndef __SCHED_IRQ_INTERNAL_H
#define __SCHED_IRQ_INTERNAL_H
/****************************************************************************
* Included Files
@ -79,5 +79,5 @@ EXTERN int irq_unexpected_isr(int irq, FAR void *context);
}
#endif
#endif /* __IRQ_INTERNAL_H */
#endif /* __SCHED_IRQ_INTERNAL_H */

View File

@ -2,7 +2,7 @@
* sched/irq_unexpectedisr.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -38,8 +38,11 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include <debug.h>
#include <nuttx/irq.h>
#include "os_internal.h"
#include "irq_internal.h"
@ -68,11 +71,11 @@
****************************************************************************/
/****************************************************************************
* Function: irq_unexpected_isr
* Name: irq_unexpected_isr
*
* Description:
* An interrupt has been received for an IRQ that was
* never registered with the system.
* An interrupt has been received for an IRQ that was never registered
* with the system.
*
****************************************************************************/

View File

@ -2,7 +2,7 @@
* sched/kmm_addregion.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -84,7 +84,7 @@ typedef void (*kmaddregion_t)(FAR void*, size_t);
************************************************************************/
/************************************************************************
* Function: kmm_addregion
* Name: kmm_addregion
*
* Description:
* This is a simple redirection to the user-space mm_addregion()

View File

@ -2,7 +2,7 @@
* sched/kmm_initialize.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -84,7 +84,7 @@ typedef void (*kminitialize_t)(FAR void*, size_t);
************************************************************************/
/************************************************************************
* Function: kmm_initialize
* Name: kmm_initialize
*
* Description:
* This is a simple redirection to the user-space mm_initialize()

View File

@ -2,7 +2,7 @@
* sched/kmm_kfree.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -84,7 +84,7 @@ typedef void (*kfree_t)(FAR void *);
************************************************************************/
/************************************************************************
* Function: kfree
* Name: kfree
*
* Description:
* This is a simple redirection to the user-space free() function.

View File

@ -2,7 +2,7 @@
* sched/kmm_kmalloc.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -84,7 +84,7 @@ typedef FAR void *(*kmalloc_t)(size_t);
************************************************************************/
/************************************************************************
* Function: kmalloc
* Name: kmalloc
*
* Description:
* This is a simple redirection to the user-space malloc() function.

View File

@ -2,7 +2,7 @@
* sched/kmm_krealloc.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -84,7 +84,7 @@ typedef FAR void *(*krealloc_t)(FAR void*, size_t);
************************************************************************/
/************************************************************************
* Function: krealloc
* Name: krealloc
*
* Description:
* This is a simple redirection to the user-space realloc() function.

View File

@ -2,7 +2,7 @@
* sched/kmm_kzalloc.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -84,7 +84,7 @@ typedef FAR void *(*kzalloc_t)(size_t);
************************************************************************/
/************************************************************************
* Function: kzalloc
* Name: kzalloc
*
* Description:
* This is a simple redirection to the user-space zalloc() function.

View File

@ -2,7 +2,7 @@
* sched/kmm_semaphore.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -86,7 +86,7 @@ typedef void (*kmgivesemaphore_t)(void);
************************************************************************/
/************************************************************************
* Function: kmm_trysemaphore
* Name: kmm_trysemaphore
*
* Description:
* This is a simple redirection to the user-space mm_trysemaphore()
@ -112,7 +112,7 @@ int kmm_trysemaphore(void)
}
/************************************************************************
* Function: kmm_givesemaphore
* Name: kmm_givesemaphore
*
* Description:
* This is a simple redirection to the user-space mm_givesemaphore()

View File

@ -1,8 +1,8 @@
/************************************************************
/****************************************************************************
* sched/mq_close.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -31,71 +31,69 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************/
****************************************************************************/
/************************************************************
/****************************************************************************
* Included Files
************************************************************/
****************************************************************************/
#include <nuttx/config.h>
#include <mqueue.h>
#include <sched.h>
#include "os_internal.h"
#include "mq_internal.h"
/************************************************************
/****************************************************************************
* Definitions
************************************************************/
****************************************************************************/
/************************************************************
/****************************************************************************
* Private Type Declarations
************************************************************/
****************************************************************************/
/************************************************************
/****************************************************************************
* Global Variables
************************************************************/
****************************************************************************/
/************************************************************
/****************************************************************************
* Private Variables
************************************************************/
****************************************************************************/
/************************************************************
/****************************************************************************
* Private Functions
************************************************************/
****************************************************************************/
/************************************************************
* Function: mq_desfree
/****************************************************************************
* Name: mq_desfree
*
* Description:
* Deallocate a message queue descriptor but returning it
* to the free liest
* Deallocate a message queue descriptor but returning it to the free list
*
* Inputs:
* mqdes - message queue descriptor to free
*
************************************************************/
****************************************************************************/
#define mq_desfree(mqdes) sq_addlast((FAR sq_entry_t*)mqdes, &g_desfree)
/************************************************************
/****************************************************************************
* Public Functions
************************************************************/
****************************************************************************/
/************************************************************
* Function: mq_close
/****************************************************************************
* Name: mq_close
*
* Description:
* This function is used to indicate that the calling task
* is finished with the specified message queued mqdes.
* The mq_close() deallocates any system resources
* allocated by the system for use by this task for its
* message queue.
* This function is used to indicate that the calling task is finished
* with the specified message queued mqdes. The mq_close() deallocates
* any system resources allocated by the system for use by this task for
* its message queue.
*
* If the calling task has attached a notification to the
* message queue via this mqdes, this attachment will be
* removed and the message queue is available for another
* process to attach a notification.
* If the calling task has attached a notification to the message queue
* via this mqdes, this attachment will be removed and the message queue
* is available for another process to attach a notification.
*
* Parameters:
* mqdes - Message queue descriptor.
@ -105,12 +103,12 @@
* otherwise, -1 (ERROR).
*
* Assumptions:
* - The behavior of a task that is blocked on either a mq_send()
* or mq_receive is undefined when mq_close() is called.
* - The results of using this message queue descriptor after a
* a successful return from mq_close() is undefined.
* - The behavior of a task that is blocked on either a mq_send() or
* mq_receive() is undefined when mq_close() is called.
* - The results of using this message queue descriptor after a successful
* return from mq_close() is undefined.
*
************************************************************/
****************************************************************************/
int mq_close(mqd_t mqdes)
{

View File

@ -2,7 +2,7 @@
* sched/mq_descreate.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -39,19 +39,21 @@
#include <nuttx/config.h>
#include <stdarg.h> /* va_list */
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <mqueue.h>
#include <sched.h>
#include <queue.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/kmalloc.h>
#include "os_internal.h"
#include "sig_internal.h"
#include <queue.h>
#include <nuttx/kmalloc.h>
#include "mq_internal.h"
/****************************************************************************
@ -75,7 +77,7 @@
****************************************************************************/
/****************************************************************************
* Function: mq_desalloc
* Name: mq_desalloc
*
* Description:
* Allocate a message queue descriptor.
@ -117,7 +119,7 @@ static mqd_t mq_desalloc(void)
****************************************************************************/
/****************************************************************************
* Function: mq_descreate
* Name: mq_descreate
*
* Description:
* Create a message queue descriptor for the specified TCB
@ -128,7 +130,8 @@ static mqd_t mq_desalloc(void)
* oflags - access rights for the descriptor
*
* Return Value:
*
* On success, the message queue descriptor is returned. NULL is returned
* on a failure to allocate.
*
****************************************************************************/

View File

@ -2,7 +2,7 @@
* sched/mq_findnamed.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <string.h>
#include "mq_internal.h"
/************************************************************************
@ -67,18 +68,18 @@
************************************************************************/
/************************************************************************
* Function: mq_findnamed
* Name: mq_findnamed
*
* Description:
* This function finds the named message queue with the
* specified name in the list of message queues.
* This function finds the named message queue with the specified name
* in the list of message queues.
*
* Inputs:
* mq_name - the name of the message queue to find
*
* Return Value:
* A reference to the matching named message queue
* structure (or NULL if none was found).
* A reference to the matching named message queue structure (or NULL
* if none was found).
*
************************************************************************/

View File

@ -2,7 +2,7 @@
* sched/mq_initialize.c
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -53,9 +53,7 @@
* Private Type Declarations
************************************************************************/
/* This is a container for a list of message queue
* descriptors.
*/
/* This is a container for a list of message queue descriptors. */
struct mq_des_block_s
{
@ -71,22 +69,22 @@ struct mq_des_block_s
sq_queue_t g_msgqueues;
/* The g_msgfree is a list of messages that are available
* for general use. The number of messages in this list is a
* system configuration item.
/* The g_msgfree is a list of messages that are available for general
* use. The number of messages in this list is a system configuration
* item.
*/
sq_queue_t g_msgfree;
/* The g_msgfreeInt is a list of messages that are reserved
* for use by interrupt handlers.
/* The g_msgfreeInt is a list of messages that are reserved for use by
* interrupt handlers.
*/
sq_queue_t g_msgfreeirq;
/* The g_desfree data structure is a list of message
* descriptors available to the operating system for general use.
* The number of messages in the pool is a constant.
/* The g_desfree data structure is a list of message descriptors available
* to the operating system for general use. The number of messages in the
* pool is a constant.
*/
sq_queue_t g_desfree;
@ -95,21 +93,19 @@ sq_queue_t g_desfree;
* Private Variables
************************************************************************/
/* g_msgalloc is a pointer to the start of the allocated
* block of messages.
/* g_msgalloc is a pointer to the start of the allocated block of
* messages.
*/
static mqmsg_t *g_msgalloc;
/* g_msgfreeirqalloc is a pointer to the start of the
* allocated block of messages.
/* g_msgfreeirqalloc is a pointer to the start of the allocated block of
* messages.
*/
static mqmsg_t *g_msgfreeirqalloc;
/* g_desalloc is a list of allocated block of message queue
* descriptors.
*/
/* g_desalloc is a list of allocated block of message queue descriptors. */
static sq_queue_t g_desalloc;
@ -118,15 +114,14 @@ static sq_queue_t g_desalloc;
************************************************************************/
/************************************************************************
* Function: mq_msgblockalloc
* Name: mq_msgblockalloc
*
* Description:
* Allocate a block of messages and place them on the free
* list.
* Allocate a block of messages and place them on the free list.
*
*
* Inputs:
* Inputs Parameters:
* queue
*
************************************************************************/
static mqmsg_t *mq_msgblockalloc(sq_queue_t *queue, uint16_t nmsgs,
@ -159,13 +154,12 @@ static mqmsg_t *mq_msgblockalloc(sq_queue_t *queue, uint16_t nmsgs,
************************************************************************/
/************************************************************************
* Function: mq_initialize
* Name: mq_initialize
*
* Description:
* This function initializes the messasge system. This
* function must be called early in the initialization
* sequence before any of the other message interfaces
* execute.
* This function initializes the messasge system. This function must
* be called early in the initialization sequence before any of the
* other message interfaces execute.
*
* Inputs:
* None
@ -207,7 +201,7 @@ void mq_initialize(void)
}
/************************************************************************
* Function: mq_desblockalloc
* Name: mq_desblockalloc
*
* Description:
* Allocate a block of message descriptors and place them on the free

View File

@ -2,7 +2,7 @@
* sched/mq_internal.h
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -63,14 +63,14 @@
#define MQ_MAX_MSGS 16
#define MQ_PRIO_MAX _POSIX_MQ_PRIO_MAX
/* This defines the number of messages descriptors to allocate
* at each "gulp."
/* This defines the number of messages descriptors to allocate at each
* "gulp."
*/
#define NUM_MSG_DESCRIPTORS 24
/* This defines the number of messages to set aside for
* exclusive use by interrupt handlers
/* This defines the number of messages to set aside for exclusive use by
* interrupt handlers
*/
#define NUM_INTERRUPT_MSGS 8
@ -85,6 +85,7 @@ enum mqalloc_e
MQ_ALLOC_DYN, /* dynamically allocated; free when unused */
MQ_ALLOC_IRQ /* Preallocated, reserved for interrupt handling */
};
typedef enum mqalloc_e mqalloc_t;
/* This structure describes one buffered POSIX message. */
@ -101,6 +102,7 @@ struct mqmsg
#endif
uint8_t mail[MQ_MAX_BYTES]; /* Message data */
};
typedef struct mqmsg mqmsg_t;
/****************************************************************************
@ -111,22 +113,21 @@ typedef struct mqmsg mqmsg_t;
extern sq_queue_t g_msgqueues;
/* The g_msgfree is a list of messages that are available
* for general use. The number of messages in this list is a
* system configuration item.
/* The g_msgfree is a list of messages that are available for general use.
* The number of messages in this list is a system configuration item.
*/
extern sq_queue_t g_msgfree;
/* The g_msgfreeInt is a list of messages that are reserved
* for use by interrupt handlers.
/* The g_msgfreeInt is a list of messages that are reserved for use by
* interrupt handlers.
*/
extern sq_queue_t g_msgfreeirq;
/* The g_desfree data structure is a list of message
* descriptors available to the operating system for general use.
* The number of messages in the pool is a constant.
/* The g_desfree data structure is a list of message descriptors available
* to the operating system for general use. The number of messages in the
* pool is a constant.
*/
extern sq_queue_t g_desfree;

View File

@ -2,7 +2,7 @@
* sched/mq_msgfree.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -69,13 +69,12 @@
************************************************************************/
/************************************************************************
* Function: mq_msgfree
* Name: mq_msgfree
*
* Description:
* The mq_msgfree function will return a message to the
* free pool of messages if it was a pre-allocated message.
* If the message was allocated dynamically it will be
* deallocated.
* The mq_msgfree function will return a message to the free pool of
* messages if it was a pre-allocated message. If the message was
* allocated dynamically it will be deallocated.
*
* Inputs:
* mqmsg - message to free
@ -128,7 +127,6 @@ void mq_msgfree(FAR mqmsg_t *mqmsg)
{
sched_free(mqmsg);
}
else
{
PANIC(OSERR_BADMSGTYPE);

View File

@ -2,7 +2,7 @@
* sched/mq_msgqfree.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -68,7 +68,7 @@
************************************************************************/
/************************************************************************
* Function: mq_msgqfree
* Name: mq_msgqfree
*
* Description:
* This function deallocates an initialized message queue

View File

@ -72,22 +72,21 @@
************************************************************************/
/************************************************************************
* Function: mq_notify
* Name: mq_notify
*
* Description:
* If "notification" is not NULL, this function connects
* the task with the message queue such that the specified
* signal will be sent to the task whenever the message
* changes from empty to non-empty. One one notification
* can be attached to a message queue.
* If "notification" is not NULL, this function connects the task with
* the message queue such that the specified signal will be sent to the
* task whenever the message changes from empty to non-empty. Only one
* notification can be attached to a message queue.
*
* If "notification" is NULL, the attached notification is
* detached (if it was held by the calling task) and the
* queue is available to attach another notification.
* If "notification" is NULL, the attached notification is detached (if
* it was held by the calling task) and the queue is available to attach
* another notification.
*
* When the notification is sent to the registered process,
* its registration will be removed. The message queue
* will then be available for registration.
* When the notification is sent to the registered process, its
* registration will be removed. The message queue will then be
* available for registration.
*
* Parameters:
* mqdes - Message queue descriptor

View File

@ -2,7 +2,7 @@
* sched/mq_open.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -79,21 +79,21 @@
****************************************************************************/
/****************************************************************************
* Function: mq_open
* Name: mq_open
*
* Description:
* This function establish a connection between a named
* message queue and the calling task. After a successful
* call of mq_open(), the task can reference the message
* queue using the address returned by the call. The
* message queue remains usable until it is closed by a
* successful call to mq_close().
* This function establish a connection between a named message queue and
* the calling task. After a successful call of mq_open(), the task can
* reference the message queue using the address returned by the call. The
* message queue remains usable until it is closed by a successful call to
* mq_close().
*
* Parameters:
* mq_name - Name of the queue to open
* oflags - open flags
* Optional parameters. When the O_CREAT flag is
* specified, two optional parameters are expected:
* Optional parameters. When the O_CREAT flag is specified, two optional
* parameters are expected:
*
* 1. mode_t mode (ignored), and
* 2. struct mq_attr *attr. The mq_maxmsg attribute
* is used at the time that the message queue is
@ -221,6 +221,7 @@ mqd_t mq_open(const char *mq_name, int oflags, ...)
}
}
}
sched_unlock();
}

View File

@ -81,9 +81,9 @@
* Name: mq_verifyreceive
*
* Description:
* This is internal, common logic shared by both mq_receive
* and mq_timedreceive. This function verifies the
* input parameters that are common to both functions.
* This is internal, common logic shared by both mq_receive and
* mq_timedreceive. This function verifies the input parameters that are
* common to both functions.
*
* Parameters:
* mqdes - Message Queue Descriptor
@ -91,12 +91,12 @@
* msglen - Size of the buffer in bytes
*
* Return Value:
* One success, 0 (OK) is returned. On failure, -1 (ERROR) is
* returned and the errno is set appropriately:
* One success, 0 (OK) is returned. On failure, -1 (ERROR) is returned and
* the errno is set appropriately:
*
* EPERM Message queue opened not opened for reading.
* EMSGSIZE 'msglen' was less than the maxmsgsize attribute of the
* message queue.
* EMSGSIZE 'msglen' was less than the maxmsgsize attribute of the message
* queue.
* EINVAL Invalid 'msg' or 'mqdes'
*
* Assumptions:
@ -129,30 +129,28 @@ int mq_verifyreceive(mqd_t mqdes, void *msg, size_t msglen)
}
/****************************************************************************
* Function: mq_waitreceive
* Name: mq_waitreceive
*
* Description:
* This is internal, common logic shared by both mq_receive
* and mq_timedreceive. This function waits for a message to
* be received on the specified message queue, removes the
* message from the queue, and returns it.
* This is internal, common logic shared by both mq_receive and
* mq_timedreceive. This function waits for a message to be received on
* the specified message queue, removes the message from the queue, and
* returns it.
*
* Parameters:
* mqdes - Message queue descriptor
*
* Return Value:
* On success, a reference to the received message. If the
* wait was interrupted by a signal or a timeout, then the
* errno will be set appropriately and NULL will be returned.
* On success, a reference to the received message. If the wait was
* interrupted by a signal or a timeout, then the errno will be set
* appropriately and NULL will be returned.
*
* Assumptions:
* - The caller has provided all validity checking of the
* input parameters using mq_verifyreceive.
* - Interrupts should be disabled throughout this call. This
* is necessary because messages can be sent from interrupt
* level processing.
* - For mq_timedreceive, setting of the timer and this wait
* must be atomic.
* - The caller has provided all validity checking of the input parameters
* using mq_verifyreceive.
* - Interrupts should be disabled throughout this call. This is necessary
* because messages can be sent from interrupt level processing.
* - For mq_timedreceive, setting of the timer and this wait must be atomic.
*
****************************************************************************/
@ -215,38 +213,34 @@ FAR mqmsg_t *mq_waitreceive(mqd_t mqdes)
{
msgq->nmsgs--;
}
return rcvmsg;
}
/****************************************************************************
* Function: mq_doreceive
* Name: mq_doreceive
*
* Description:
* This is internal, common logic shared by both mq_receive
* and mq_timedreceive. This function accepts the message
* obtained by mq_waitmsg, provides the message content to
* the user, notifies any threads that were waiting for
* the message queue to become non-full, and disposes of the
* message structure
* This is internal, common logic shared by both mq_receive and
* mq_timedreceive. This function accepts the message obtained by
* mq_waitmsg, provides the message content to the user, notifies any
* threads that were waiting for the message queue to become non-full,
* and disposes of the message structure
*
* Parameters:
* mqdes - Message queue descriptor
* mqmsg - The message obtained by mq_waitmsg()
* ubuffer - The address of the user provided buffer to
* receive the message
* prio - The user-provided location to return the
* message priority.
* ubuffer - The address of the user provided buffer to receive the message
* prio - The user-provided location to return the message priority.
*
* Return Value:
* Returns the length of the received message. This
* function does not fail.
* Returns the length of the received message. This function does not fail.
*
* Assumptions:
* - The caller has provided all validity checking of the
* input parameters using mq_verifyreceive.
* - The user buffer, ubuffer, is known to be large enough
* to accept the largest message that an be sent on this
* message queue
* - The caller has provided all validity checking of the input parameters
* using mq_verifyreceive.
* - The user buffer, ubuffer, is known to be large enough to accept the
* largest message that an be sent on this message queue
* - Pre-emption should be disabled throughout this call.
*
****************************************************************************/
@ -308,6 +302,7 @@ ssize_t mq_doreceive(mqd_t mqdes, mqmsg_t *mqmsg, void *ubuffer, int *prio)
msgq->nwaitnotfull--;
up_unblock_task(btcb);
}
irqrestore(saved_state);
}

View File

@ -2,7 +2,7 @@
* sched/mq_receive.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -73,25 +73,22 @@
************************************************************************/
/************************************************************************
* Function: mq_receive
* Name: mq_receive
*
* Description:
* This function receives the oldest of the highest
* priority messages from the message queue specified by
* "mqdes." If the size of the buffer in bytes (msglen) is
* less than the "mq_msgsize" attribute of the message
* queue, mq_receive will return an error. Otherwise, the
* selected message is removed from the queue and copied to
* "msg."
* This function receives the oldest of the highest priority messages
* from the message queue specified by "mqdes." If the size of the
* buffer in bytes (msglen) is less than the "mq_msgsize" attribute of
* the message queue, mq_receive will return an error. Otherwise, the
* selected message is removed from the queue and copied to "msg."
*
* If the message queue is empty and O_NONBLOCK was not
* set, mq_receive() will block until a message is added
* to the message queue. If more than one task is waiting
* to receive a message, only the task with the highest
* priority that has waited the longest will be unblocked.
* If the message queue is empty and O_NONBLOCK was not set,
* mq_receive() will block until a message is added to the message
* queue. If more than one task is waiting to receive a message, only
* the task with the highest priority that has waited the longest will
* be unblocked.
*
* If the queue is empty and O_NONBLOCK is set, ERROR will
* be returned.
* If the queue is empty and O_NONBLOCK is set, ERROR will be returned.
*
* Parameters:
* mqdes - Message Queue Descriptor
@ -100,9 +97,8 @@
* prio - If not NULL, the location to store message priority.
*
* Return Value:
* One success, the length of the selected message in bytes.is
* returned. On failure, -1 (ERROR) is returned and the errno
* is set appropriately:
* One success, the length of the selected message in bytes is returned.
* On failure, -1 (ERROR) is returned and the errno is set appropriately:
*
* EAGAIN The queue was empty, and the O_NONBLOCK flag was set
* for the message queue description referred to by 'mqdes'.

View File

@ -74,7 +74,7 @@
****************************************************************************/
/****************************************************************************
* Function: mq_send
* Name: mq_send
*
* Description:
* This function adds the specificied message (msg) to the message queue

View File

@ -134,11 +134,12 @@ int mq_verifysend(mqd_t mqdes, const void *msg, size_t msglen, int prio)
}
/****************************************************************************
* Function: mq_msgalloc
* Name: mq_msgalloc
*
* Description:
* The mq_msgalloc function will get a free message for use by the
* operating system. The message will be allocated from the g_msgfree list.
* operating system. The message will be allocated from the g_msgfree
* list.
*
* If the list is empty AND the message is NOT being allocated from the
* interrupt level, then the message will be allocated. If a message
@ -221,7 +222,7 @@ FAR mqmsg_t *mq_msgalloc(void)
}
/****************************************************************************
* Function: mq_waitsend
* Name: mq_waitsend
*
* Description:
* This is internal, common logic shared by both mq_send and mq_timesend.
@ -311,7 +312,7 @@ int mq_waitsend(mqd_t mqdes)
}
/****************************************************************************
* Function: mq_dosend
* Name: mq_dosend
*
* Description:
* This is internal, common logic shared by both mq_send and mq_timesend.

View File

@ -2,7 +2,7 @@
* sched/mq_timedreceive.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -47,6 +47,7 @@
#include <mqueue.h>
#include <wdog.h>
#include <debug.h>
#include <nuttx/arch.h>
#include "os_internal.h"
@ -74,7 +75,7 @@
****************************************************************************/
/****************************************************************************
* Function: mq_rcvtimeout
* Name: mq_rcvtimeout
*
* Description:
* This function is called if the timeout elapses before the message queue
@ -96,15 +97,14 @@ static void mq_rcvtimeout(int argc, uint32_t pid)
FAR _TCB *wtcb;
irqstate_t saved_state;
/* Disable interrupts. This is necessary because an
* interrupt handler may attempt to send a message while we are
* doing this.
/* Disable interrupts. This is necessary because an interrupt handler may
* attempt to send a message while we are doing this.
*/
saved_state = irqsave();
/* Get the TCB associated with this pid. It is possible that
* task may no longer be active when this watchdog goes off.
/* Get the TCB associated with this pid. It is possible that task may no
* longer be active when this watchdog goes off.
*/
wtcb = sched_gettcb((pid_t)pid);
@ -130,35 +130,30 @@ static void mq_rcvtimeout(int argc, uint32_t pid)
****************************************************************************/
/****************************************************************************
* Function: mq_timedreceive
* Name: mq_timedreceive
*
* Description:
* This function receives the oldest of the highest
* priority messages from the message queue specified by
* "mqdes." If the size of the buffer in bytes (msglen) is
* less than the "mq_msgsize" attribute of the message
* queue, mq_timedreceive will return an error. Otherwise, the
* selected message is removed from the queue and copied to
* "msg."
* This function receives the oldest of the highest priority messages from
* the message queue specified by "mqdes." If the size of the buffer in
* bytes (msglen) is less than the "mq_msgsize" attribute of the message
* queue, mq_timedreceive will return an error. Otherwise, the selected
* message is removed from the queue and copied to "msg."
*
* If the message queue is empty and O_NONBLOCK was not
* set, mq_timedreceive() will block until a message is added
* to the message queue (or until a timeout occurs). If more
* than one task is waiting to receive a message, only the
* task with the highest priority that has waited the longest
* will be unblocked.
* If the message queue is empty and O_NONBLOCK was not set,
* mq_timedreceive() will block until a message is added to the message
* queue (or until a timeout occurs). If more than one task is waiting
* to receive a message, only the task with the highest priority that has
* waited the longest will be unblocked.
*
* mq_timedreceive() behaves just like mq_receive(), except
* that if the queue is empty and the O_NONBLOCK flag is not
* enabled for the message queue description, then abstime
* points to a structure which specifies a ceiling on the time
* for which the call will block. This ceiling is an absolute
* timeout in seconds and nanoseconds since the Epoch (midnight
* mq_timedreceive() behaves just like mq_receive(), except that if the
* queue is empty and the O_NONBLOCK flag is not enabled for the message
* queue description, then abstime points to a structure which specifies a
* ceiling on the time for which the call will block. This ceiling is an
* absolute timeout in seconds and nanoseconds since the Epoch (midnight
* on the morning of 1 January 1970).
*
* If no message is available, and the timeout has already
* expired by the time of the call, mq_timedreceive() returns
* immediately.
* If no message is available, and the timeout has already expired by the
* time of the call, mq_timedreceive() returns immediately.
*
* Parameters:
* mqdes - Message Queue Descriptor
@ -168,9 +163,8 @@ static void mq_rcvtimeout(int argc, uint32_t pid)
* abstime - the absolute time to wait until a timeout is declared.
*
* Return Value:
* One success, the length of the selected message in bytes.is
* returned. On failure, -1 (ERROR) is returned and the errno
* is set appropriately:
* One success, the length of the selected message in bytes is returned.
* On failure, -1 (ERROR) is returned and the errno is set appropriately:
*
* EAGAIN The queue was empty, and the O_NONBLOCK flag was set
* for the message queue description referred to by 'mqdes'.

View File

@ -2,7 +2,7 @@
* sched/mq_timedsend.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -74,7 +74,7 @@
****************************************************************************/
/****************************************************************************
* Function: mq_sndtimeout
* Name: mq_sndtimeout
*
* Description:
* This function is called if the timeout elapses before the message queue
@ -96,15 +96,14 @@ static void mq_sndtimeout(int argc, uint32_t pid)
FAR _TCB *wtcb;
irqstate_t saved_state;
/* Disable interrupts. This is necessary because an
* interrupt handler may attempt to send a message while we are
* doing this.
/* Disable interrupts. This is necessary because an interrupt handler may
* attempt to send a message while we are doing this.
*/
saved_state = irqsave();
/* Get the TCB associated with this pid. It is possible that
* task may no longer be active when this watchdog goes off.
/* Get the TCB associated with this pid. It is possible that task may no
* longer be active when this watchdog goes off.
*/
wtcb = sched_gettcb((pid_t)pid);
@ -130,7 +129,7 @@ static void mq_sndtimeout(int argc, uint32_t pid)
****************************************************************************/
/****************************************************************************
* Function: mq_send
* Name: mq_send
*
* Description:
* This function adds the specificied message (msg) to the message queue

View File

@ -2,7 +2,7 @@
* sched.mq_unlink.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -71,14 +71,13 @@
************************************************************************/
/************************************************************************
* Function: mq_unlink
* Name: mq_unlink
*
* Description:
* This function removes the message queue named by
* "mq_name." If one or more tasks have the message queue
* open when mq_unlink() is called, removal of the message
* queue is postponed until all references to the message
* queue have been closed.
* This function removes the message queue named by "mq_name." If one
* or more tasks have the message queue open when mq_unlink() is called,
* removal of the message queue is postponed until all references to the
* message queue have been closed.
*
* Parameters:
* mq_name - Name of the message queue
@ -138,6 +137,7 @@ int mq_unlink(const char *mq_name)
ret = OK;
}
sched_unlock();
}

View File

@ -2,7 +2,7 @@
* sched/mq_waitirq.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -72,7 +72,7 @@
****************************************************************************/
/****************************************************************************
* Function: sem_waitirq
* Name: sem_waitirq
*
* Description:
* This function is called when a signal or a timeout is received by a

View File

@ -80,7 +80,7 @@
************************************************************************/
/************************************************************************
* Function: atexit
* Name: atexit
*
* Description:
* Registers a function to be called at program exit.

View File

@ -33,8 +33,8 @@
*
****************************************************************************/
#ifndef __OS_INTERNAL_H
#define __OS_INTERNAL_H
#ifndef __SCHED_OS_INTERNAL_H
#define __SCHED_OS_INTERNAL_H
/****************************************************************************
* Included Files
@ -46,6 +46,7 @@
#include <stdbool.h>
#include <queue.h>
#include <sched.h>
#include <nuttx/kmalloc.h>
/****************************************************************************
@ -141,6 +142,7 @@ struct pidhash_s
FAR _TCB *tcb;
pid_t pid;
};
typedef struct pidhash_s pidhash_t;
/* This structure defines an element of the g_tasklisttable[].
@ -153,6 +155,7 @@ struct tasklist_s
DSEG volatile dq_queue_t *list; /* Pointer to the task list */
bool prioritized; /* true if the list is prioritized */
};
typedef struct tasklist_s tasklist_t;
/****************************************************************************
@ -161,27 +164,25 @@ typedef struct tasklist_s tasklist_t;
/* Declared in os_start.c ***************************************************/
/* The state of a task is indicated both by the task_state field
* of the TCB and by a series of task lists. All of these
* tasks lists are declared below. Although it is not always
* necessary, most of these lists are prioritized so that common
* list handling logic can be used (only the g_readytorun,
* the g_pendingtasks, and the g_waitingforsemaphore lists need
/* The state of a task is indicated both by the task_state field of the TCB
* and by a series of task lists. All of these tasks lists are declared
* below. Although it is not always necessary, most of these lists are
* prioritized so that common list handling logic can be used (only the
* g_readytorun, the g_pendingtasks, and the g_waitingforsemaphore lists need
* to be prioritized).
*/
/* This is the list of all tasks that are ready to run. The head
* of this list is the currently active task; the tail of this
* list is always the idle task.
/* This is the list of all tasks that are ready to run. The head of this
* list is the currently active task; the tail of this list is always the
* IDLE task.
*/
extern volatile dq_queue_t g_readytorun;
/* This is the list of all tasks that are ready-to-run, but
* cannot be placed in the g_readytorun list because: (1) They
* are higher priority than the currently active task at the head
* of the g_readytorun list, and (2) the currenly active task has
* disabled pre-emption.
/* This is the list of all tasks that are ready-to-run, but cannot be placed
* in the g_readytorun list because: (1) They are higher priority than the
* currently active task at the head of the g_readytorun list, and (2) the
* currently active task has disabled pre-emption.
*/
extern volatile dq_queue_t g_pendingtasks;
@ -238,21 +239,20 @@ extern volatile pid_t g_lastpid;
/* The following hash table is used for two things:
*
* 1. This hash table greatly speeds the determination of
* a new unique process ID for a task, and
* 1. This hash table greatly speeds the determination of a new unique
* process ID for a task, and
* 2. Is used to quickly map a process ID into a TCB.
*
* It has the side effects of using more memory and limiting
* the number of tasks to CONFIG_MAX_TASKS.
* It has the side effects of using more memory and limiting the number
* of tasks to CONFIG_MAX_TASKS.
*/
extern pidhash_t g_pidhash[CONFIG_MAX_TASKS];
/* This is a table of task lists. This table is indexed by
* the task state enumeration type (tstate_t) and provides
* a pointer to the associated static task list (if there
* is one) as well as a boolean indication as to if the list
* is an ordered list or not.
/* This is a table of task lists. This table is indexed by the task state
* enumeration type (tstate_t) and provides a pointer to the associated
* static task list (if there is one) as well as a boolean indication as to
* if the list is an ordered list or not.
*/
extern const tasklist_t g_tasklisttable[NUM_TASK_STATES];
@ -261,47 +261,46 @@ extern const tasklist_t g_tasklisttable[NUM_TASK_STATES];
* Public Function Prototypes
****************************************************************************/
extern int os_bringup(void);
extern void task_start(void);
extern int task_schedsetup(FAR _TCB *tcb, int priority, start_t start,
main_t main);
extern int task_argsetup(FAR _TCB *tcb, const char *name, const char *argv[]);
extern void task_exithook(FAR _TCB *tcb, int status);
extern int task_deletecurrent(void);
int os_bringup(void);
void task_start(void);
int task_schedsetup(FAR _TCB *tcb, int priority, start_t start,
main_t main);
int task_argsetup(FAR _TCB *tcb, FAR const char *name, FAR const char *argv[]);
void task_exithook(FAR _TCB *tcb, int status);
int task_deletecurrent(void);
#ifndef CONFIG_CUSTOM_STACK
extern int kernel_thread(const char *name, int priority,
int stack_size, main_t entry, const char *argv[]);
int kernel_thread(FAR const char *name, int priority, int stack_size,
main_t entry, FAR const char *argv[]);
#else
extern int kernel_thread(const char *name, int priority,
main_t entry, const char *argv[]);
int kernel_thread(FAR const char *name, int priority, main_t entry,
FAR const char *argv[]);
#endif
extern bool sched_addreadytorun(FAR _TCB *rtrtcb);
extern bool sched_removereadytorun(FAR _TCB *rtrtcb);
extern bool sched_addprioritized(FAR _TCB *newTcb, DSEG dq_queue_t *list);
extern bool sched_mergepending(void);
extern void sched_addblocked(FAR _TCB *btcb, tstate_t task_state);
extern void sched_removeblocked(FAR _TCB *btcb);
extern int sched_setpriority(FAR _TCB *tcb, int sched_priority);
bool sched_addreadytorun(FAR _TCB *rtrtcb);
bool sched_removereadytorun(FAR _TCB *rtrtcb);
bool sched_addprioritized(FAR _TCB *newTcb, DSEG dq_queue_t *list);
bool sched_mergepending(void);
void sched_addblocked(FAR _TCB *btcb, tstate_t task_state);
void sched_removeblocked(FAR _TCB *btcb);
int sched_setpriority(FAR _TCB *tcb, int sched_priority);
#ifdef CONFIG_PRIORITY_INHERITANCE
extern int sched_reprioritize(FAR _TCB *tcb, int sched_priority);
int sched_reprioritize(FAR _TCB *tcb, int sched_priority);
#else
# define sched_reprioritize(tcb,sched_priority) sched_setpriority(tcb,sched_priority)
#endif
extern FAR _TCB *sched_gettcb(pid_t pid);
extern bool sched_verifytcb(FAR _TCB *tcb);
FAR _TCB *sched_gettcb(pid_t pid);
bool sched_verifytcb(FAR _TCB *tcb);
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0
extern int sched_setupidlefiles(FAR _TCB *tcb);
extern int sched_setuptaskfiles(FAR _TCB *tcb);
extern int sched_setuppthreadfiles(FAR _TCB *tcb);
#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
extern int sched_setupstreams(FAR _TCB *tcb);
extern int sched_flushfiles(FAR _TCB *tcb);
int sched_setupidlefiles(FAR _TCB *tcb);
int sched_setuptaskfiles(FAR _TCB *tcb);
int sched_setuppthreadfiles(FAR _TCB *tcb);
#if CONFIG_NFILE_STREAMS > 0
int sched_setupstreams(FAR _TCB *tcb);
#endif
extern int sched_releasefiles(FAR _TCB *tcb);
int sched_releasefiles(FAR _TCB *tcb);
#endif
extern int sched_releasetcb(FAR _TCB *tcb);
extern void sched_garbagecollection(void);
int sched_releasetcb(FAR _TCB *tcb);
void sched_garbagecollection(void);
#endif /* __OS_INTERNAL_H */
#endif /* __SCHED_OS_INTERNAL_H */

View File

@ -77,27 +77,25 @@
****************************************************************************/
/* Task Lists ***************************************************************/
/* The state of a task is indicated both by the task_state field
* of the TCB and by a series of task lists. All of these
* tasks lists are declared below. Although it is not always
* necessary, most of these lists are prioritized so that common
* list handling logic can be used (only the g_readytorun,
* the g_pendingtasks, and the g_waitingforsemaphore lists need
/* The state of a task is indicated both by the task_state field of the TCB
* and by a series of task lists. All of these tasks lists are declared
* below. Although it is not always necessary, most of these lists are
* prioritized so that common list handling logic can be used (only the
* g_readytorun, the g_pendingtasks, and the g_waitingforsemaphore lists need
* to be prioritized).
*/
/* This is the list of all tasks that are ready to run. The head
* of this list is the currently active task; the tail of this
* list is always the idle task.
/* This is the list of all tasks that are ready to run. The head of this
* list is the currently active task; the tail of this list is always the
* IDLE task.
*/
volatile dq_queue_t g_readytorun;
/* This is the list of all tasks that are ready-to-run, but
* cannot be placed in the g_readytorun list because: (1) They
* are higher priority than the currently active task at the head
* of the g_readytorun list, and (2) the currenly active task has
* disabled pre-emption.
/* This is the list of all tasks that are ready-to-run, but cannot be placed
* in the g_readytorun list because: (1) They are higher priority than the
* currently active task at the head of the g_readytorun list, and (2) the
* currently active task has disabled pre-emption.
*/
volatile dq_queue_t g_pendingtasks;
@ -197,11 +195,10 @@ const tasklist_t g_tasklisttable[NUM_TASK_STATES] =
/****************************************************************************
* Private Variables
****************************************************************************/
/* This is the task control block for this thread of execution.
* This thread of execution is the idle task. NOTE: the
* system boots into the idle task. The idle task spawns
* the user init task and the user init task is responsible
* for bringing up the rest of the system
/* This is the task control block for this thread of execution. This thread
* of execution is the IDLE task. NOTE: the system boots into the IDLE
* task. The IDLE task spawns the user initialization task (user_start) and
* that user init task is responsible for bringing up the rest of the system
*/
static FAR _TCB g_idletcb;
@ -219,10 +216,12 @@ static FAR const char g_idlename[] = "Idle Task";
****************************************************************************/
/****************************************************************************
* Name: os_start
* Description: This function is called to initialize the
* operating system and to spawn the user init thread of
* execution
* Name: os_start
*
* Description:
* This function is called to initialize the operating system and to spawn
* the user initization thread of execution
*
****************************************************************************/
void os_start(void)

View File

@ -2,7 +2,7 @@
* sched/pg_internal.h
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -119,7 +119,7 @@ extern FAR _TCB *g_pftcb;
*
****************************************************************************/
extern int pg_worker(int argc, char *argv[]);
int pg_worker(int argc, char *argv[]);
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_PAGING */

View File

@ -2,7 +2,7 @@
* sched/pg_miss.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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

View File

@ -3,7 +3,7 @@
* Page fill worker thread implementation.
*
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -81,10 +81,9 @@
pid_t g_pgworker;
/* The page fill worker thread maintains a static variable called
* g_pftcb. If no fill is in progress, g_pftcb will be NULL.
* Otherwise, g_pftcb will point to the TCB of the task which is
* receiving the fill that is in progess.
/* The page fill worker thread maintains a static variable called g_pftcb.
* If no fill is in progress, g_pftcb will be NULL. Otherwise, g_pftcb will
* point to the TCB of the task which is receiving the fill that is in progess.
*
* NOTE: I think that this is the only state in which a TCB does not reside
* in some list. Here is it in limbo, outside of the normally queuing while
@ -178,26 +177,27 @@ static void pg_callback(FAR _TCB *tcb, int result)
priority = htcb->sched_priority;
}
/* If this higher priority is higher than current page fill worker
* thread, then boost worker thread's priority to that level. Thus,
* the page fill worker thread will always run at the priority of
* the highest priority task that is waiting for a fill.
*/
/* If this higher priority is higher than current page fill worker
* thread, then boost worker thread's priority to that level. Thus,
* the page fill worker thread will always run at the priority of
* the highest priority task that is waiting for a fill.
*/
if (priority > wtcb->sched_priority)
{
pgllvdbg("New worker priority. %d->%d\n",
wtcb->sched_priority, priority);
sched_setpriority(wtcb, priority);
}
if (priority > wtcb->sched_priority)
{
pgllvdbg("New worker priority. %d->%d\n",
wtcb->sched_priority, priority);
sched_setpriority(wtcb, priority);
}
/* Save the page fill result (don't permit the value -EBUSY) */
/* Save the page fill result (don't permit the value -EBUSY) */
if (result == -EBUSY)
{
result = -ENOSYS;
}
g_fillresult = result;
if (result == -EBUSY)
{
result = -ENOSYS;
}
g_fillresult = result;
}
/* Signal the page fill worker thread (in any event) */
@ -262,50 +262,50 @@ static inline bool pg_dequeue(void)
if (!up_checkmapping(g_pftcb))
{
/* This page needs to be filled. pg_miss bumps up
* the priority of the page fill worker thread as each
* TCB is added to the g_waitingforfill list. So we
* may need to also drop the priority of the worker
* thread as the next TCB comes off of the list.
*
* If wtcb->sched_priority > CONFIG_PAGING_DEFPRIO,
* then the page fill worker thread is executing at
* an elevated priority that may be reduced.
*
* If wtcb->sched_priority > g_pftcb->sched_priority
* then the page fill worker thread is executing at
* a higher priority than is appropriate for this
* fill (this priority can get re-boosted by pg_miss()
* if a new higher priority fill is required).
*/
/* This page needs to be filled. pg_miss bumps up
* the priority of the page fill worker thread as each
* TCB is added to the g_waitingforfill list. So we
* may need to also drop the priority of the worker
* thread as the next TCB comes off of the list.
*
* If wtcb->sched_priority > CONFIG_PAGING_DEFPRIO,
* then the page fill worker thread is executing at
* an elevated priority that may be reduced.
*
* If wtcb->sched_priority > g_pftcb->sched_priority
* then the page fill worker thread is executing at
* a higher priority than is appropriate for this
* fill (this priority can get re-boosted by pg_miss()
* if a new higher priority fill is required).
*/
FAR _TCB *wtcb = (FAR _TCB *)g_readytorun.head;
if (wtcb->sched_priority > CONFIG_PAGING_DEFPRIO &&
wtcb->sched_priority > g_pftcb->sched_priority)
{
/* Don't reduce the priority of the page fill
* worker thread lower than the configured
* minimum.
*/
FAR _TCB *wtcb = (FAR _TCB *)g_readytorun.head;
if (wtcb->sched_priority > CONFIG_PAGING_DEFPRIO &&
wtcb->sched_priority > g_pftcb->sched_priority)
{
/* Don't reduce the priority of the page fill
* worker thread lower than the configured
* minimum.
*/
int priority = g_pftcb->sched_priority;
if (priority < CONFIG_PAGING_DEFPRIO)
{
priority = CONFIG_PAGING_DEFPRIO;
}
int priority = g_pftcb->sched_priority;
if (priority < CONFIG_PAGING_DEFPRIO)
{
priority = CONFIG_PAGING_DEFPRIO;
}
/* Reduce the priority of the page fill worker thread */
/* Reduce the priority of the page fill worker thread */
pgllvdbg("New worker priority. %d->%d\n",
wtcb->sched_priority, priority);
sched_setpriority(wtcb, priority);
}
pgllvdbg("New worker priority. %d->%d\n",
wtcb->sched_priority, priority);
sched_setpriority(wtcb, priority);
}
/* Return with g_pftcb holding the pointer to
* the TCB associated with task that requires the page fill.
*/
/* Return with g_pftcb holding the pointer to
* the TCB associated with task that requires the page fill.
*/
return true;
return true;
}
/* The page need by this task has already been mapped into the
@ -317,6 +317,7 @@ static inline bool pg_dequeue(void)
}
}
while (g_pftcb != NULL);
return false;
}
@ -421,6 +422,7 @@ static inline bool pg_startfill(void)
* task must still be available to run.
*/
#endif /* CONFIG_PAGING_BLOCKINGFILL */
return true;
}
@ -670,6 +672,7 @@ int pg_worker(int argc, char *argv[])
pg_alldone();
#endif
}
return OK; /* To keep some compilers happy */
}
#endif /* CONFIG_PAGING */

View File

@ -46,6 +46,7 @@
#include <debug.h>
#include <nuttx/sched.h>
#include "os_internal.h"
/************************************************************************

View File

@ -2,7 +2,7 @@
* sched/pthread_barriedestroy.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -69,7 +69,7 @@
********************************************************************************/
/********************************************************************************
* Function: pthread_barrier_destroy
* Name: pthread_barrier_destroy
*
* Description:
* The pthread_barrier_destroy() function destroys the barrier referenced by

View File

@ -2,7 +2,7 @@
* sched/pthread_barrieinit.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -69,7 +69,7 @@
********************************************************************************/
/********************************************************************************
* Function: pthread_barrier_init
* Name: pthread_barrier_init
*
* Description:
* The pthread_barrier_init() function allocates any resources required to use
@ -117,5 +117,6 @@ int pthread_barrier_init(FAR pthread_barrier_t *barrier,
sem_init(&barrier->sem, 0, 0);
barrier->count = count;
}
return ret;
}

View File

@ -2,7 +2,7 @@
* sched/pthread_barrierwait.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -70,7 +70,7 @@
********************************************************************************/
/********************************************************************************
* Function: pthread_barrier_wait
* Name: pthread_barrier_wait
*
* Description:
* The pthread_barrier_wait() function synchronizse participating threads at
@ -159,7 +159,7 @@ int pthread_barrier_wait(FAR pthread_barrier_t *barrier)
{
/* If the thread is awakened by a signal, just continue to wait */
int errornumber = *get_errno_ptr();
int errornumber = get_errno();
if (errornumber != EINTR)
{
/* If it is awakened by some other error, then there is a

View File

@ -2,7 +2,7 @@
* sched/pthread_cancel.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -123,6 +123,7 @@ int pthread_cancel(pthread_t thread)
sched_unlock();
return OK;
}
sched_unlock();
/* Check to see if the ID refers to ourselves.. this would be the

View File

@ -69,12 +69,12 @@
************************************************************************/
/************************************************************************
* Function: pthread_notifywaiters
* Name: pthread_notifywaiters
*
* Description:
* Notify all other threads waiting in phread join for this
* thread's exit data. This must be done by the child
* at child thread destruction time.
* Notify all other threads waiting in phread join for this thread's
* exit data. This must be done by the child at child thread
* destruction time.
*
************************************************************************/
@ -117,6 +117,7 @@ static bool pthread_notifywaiters(FAR join_t *pjoin)
(void)pthread_takesemaphore(&pjoin->data_sem);
return true;
}
return false;
}
@ -125,20 +126,20 @@ static bool pthread_notifywaiters(FAR join_t *pjoin)
************************************************************************/
/************************************************************************
* Function: pthread_completejoin
* Name: pthread_completejoin
*
* Description:
* A thread has been terminated -- either by returning,
* calling pthread_exit(), or through pthread_cancel().
* In any event, we must complete any pending join events.
* A thread has been terminated -- either by returning, calling
* pthread_exit(), or through pthread_cancel(). In any event, we must
* complete any pending join events.
*
* Parameters:
* exit_value
*
* Returned Value:
* OK unless there is no join information associated with
* the pid. This could happen, for example, if a task
* started with task_create() calls pthread_exit().
* OK unless there is no join information associated with the pid.
* This could happen, for example, if a task started with task_create()
* calls pthread_exit().
*
* Assumptions:
*
@ -195,16 +196,15 @@ int pthread_completejoin(pid_t pid, FAR void *exit_value)
}
/************************************************************************
* Function: pthread_destroyjoin
* Name: pthread_destroyjoin
*
* Description:
* This is called from pthread_completejoin if the join
* info was detached or from pthread_join when the last
* waiting thread has received the thread exit info.
* This is called from pthread_completejoin if the join info was
* detached or from pthread_join when the last waiting thread has
* received the thread exit info.
*
* Or it may never be called if the join info was never
* detached or if no thread ever calls pthread_join. In
* case, there is a memory leak!
* Or it may never be called if the join info was never detached or if
* no thread ever calls pthread_join. In case, there is a memory leak!
*
* Assumptions:
* The caller holds g_join_semaphore

View File

@ -2,7 +2,7 @@
* sched/pthread_condbroadcast.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -71,7 +71,7 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_cond_broadcast
* Name: pthread_cond_broadcast
*
* Description:
* A thread broadcast on a condition variable.
@ -99,9 +99,9 @@ int pthread_cond_broadcast(FAR pthread_cond_t *cond)
}
else
{
/* Disable pre-emption until all of the waiting threads have
* been restarted. This is necessary to assure that the sval
* behaves as expected in the following while loop
/* Disable pre-emption until all of the waiting threads have been
* restarted. This is necessary to assure that the sval behaves as
* expected in the following while loop
*/
sched_lock();
@ -109,8 +109,9 @@ int pthread_cond_broadcast(FAR pthread_cond_t *cond)
/* Get the current value of the semaphore */
if (sem_getvalue((sem_t*)&cond->sem, &sval) != OK)
ret = EINVAL;
{
ret = EINVAL;
}
else
{
/* Loop until all of the waiting threads have been restarted. */

View File

@ -2,7 +2,7 @@
* sched/pthread_conddestroy.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -49,7 +49,7 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_cond_destroy
* Name: pthread_cond_destroy
*
* Description:
* A thread can delete condition variables.

View File

@ -2,7 +2,7 @@
* sched/pthread_condinit.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -50,7 +50,7 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_cond_init
* Name: pthread_cond_init
*
* Description:
* A thread can create condition variables.

View File

@ -70,7 +70,7 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_cond_signal
* Name: pthread_cond_signal
*
* Description:
* A thread can signal on a condition variable.

View File

@ -2,7 +2,7 @@
* sched/pthread_condtimedwait.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -74,7 +74,7 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_condtimedout
* Name: pthread_condtimedout
*
* Description:
* This function is called if the timeout elapses before
@ -111,7 +111,7 @@ static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
****************************************************************************/
/****************************************************************************
* Function: pthread_cond_timedwait
* Name: pthread_cond_timedwait
*
* Description:
* A thread can perform a timed wait on a condition variable.
@ -255,7 +255,7 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex,
* signal posted by pthread_condtimedout().
*/
if (*get_errno_ptr() == EINTR)
if (get_errno() == EINTR)
{
sdbg("Timedout!\n");
ret = ETIMEDOUT;

View File

@ -72,11 +72,10 @@
****************************************************************************/
/****************************************************************************
* Function: int pthread_cond_wait
* Name: int pthread_cond_wait
*
* Description:
* A thread can wait for a condition variable to be
* signalled or broadcast.
* A thread can wait for a condition variable to be signalled or broadcast.
*
* Parameters:
* None
@ -107,7 +106,6 @@ int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex)
{
ret = EPERM;
}
else
{
/* Give up the mutex */

View File

@ -2,7 +2,7 @@
* sched/pthread_create.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -89,23 +89,22 @@ static const char g_pthreadname[] = "<pthread>";
* Name: pthread_argsetup
*
* Description:
* This functions sets up parameters in the Task Control
* Block (TCB) in preparation for starting a new thread.
* This functions sets up parameters in the Task Control Block (TCB) in
* preparation for starting a new thread.
*
* pthread_argsetup() is called from task_init() and task_start()
* to create a new task (with arguments cloned via strdup)
* or pthread_create() which has one argument passed by
* value (distinguished by the pthread boolean argument).
* pthread_argsetup() is called from task_init() and task_start() to create
* a new task (with arguments cloned via strdup) or pthread_create() which
* has one argument passed by value (distinguished by the pthread boolean
* argument).
*
* Input Parameters:
* tcb - Address of the new task's TCB
* name - Name of the new task (not used)
* argv - 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.
* argv - 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:
* None
@ -145,7 +144,7 @@ static void pthread_argsetup(FAR _TCB *tcb, pthread_addr_t arg)
}
/****************************************************************************
* Function: pthread_addjoininfo
* Name: pthread_addjoininfo
*
* Description:
* Add a join_t to the local data set.
@ -172,6 +171,7 @@ static void pthread_addjoininfo(FAR join_t *pjoin)
{
g_pthread_tail->next = pjoin;
}
g_pthread_tail = pjoin;
}
@ -226,8 +226,8 @@ static void pthread_start(void)
* Name: pthread_create
*
* Description:
* This function creates and activates a new thread with a
* specified attributes.
* This function creates and activates a new thread with a specified
* attributes.
*
* Input Parameters:
* thread
@ -430,5 +430,6 @@ int pthread_create(FAR pthread_t *thread, FAR pthread_attr_t *attr,
sched_free(pjoin);
return EIO;
}
return OK;
}

View File

@ -2,7 +2,7 @@
* sched/pthread_detach.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -73,11 +73,11 @@
************************************************************************/
/************************************************************************
* Function: pthread_detach
* Name: pthread_detach
*
* Description:
* A thread object may be "detached" to specify that the return
* value and completion status will not be requested.
* A thread object may be "detached" to specify that the return value
* and completion status will not be requested.
*
* Parameters:
* thread
@ -129,6 +129,7 @@ int pthread_detach(pthread_t thread)
ret = OK;
}
(void)pthread_givesemaphore(&g_join_semaphore);
sdbg("Returning %d\n", ret);

View File

@ -76,7 +76,7 @@
************************************************************************/
/************************************************************************
* Function: pthread_exit
* Name: pthread_exit
*
* Description:
* Terminate execution of a thread started with pthread_create.
@ -124,6 +124,7 @@ void pthread_exit(FAR void *exit_value)
{
error_code = EXIT_FAILURE;
}
exit(error_code);
}

View File

@ -2,7 +2,7 @@
* pthread_findjoininfo.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -38,7 +38,9 @@
************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include "pthread_internal.h"
/************************************************************************
@ -66,7 +68,7 @@
************************************************************************/
/************************************************************************
* Function: thread_findjoininfo
* Name: thread_findjoininfo
*
* Description:
* Find a join_t to the local data set.

View File

@ -1,8 +1,8 @@
/********************************************************************************************
/****************************************************************************
* pthread_getschedparam.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
********************************************************************************************/
****************************************************************************/
/********************************************************************************************
/****************************************************************************
* Included Files
********************************************************************************************/
****************************************************************************/
#include <sys/types.h>
#include <pthread.h>
@ -44,46 +44,46 @@
#include <debug.h>
#include "pthread_internal.h"
/********************************************************************************************
/****************************************************************************
* Definitions
********************************************************************************************/
****************************************************************************/
/********************************************************************************************
/****************************************************************************
* Private Type Declarations
********************************************************************************************/
****************************************************************************/
/********************************************************************************************
/****************************************************************************
* Global Variables
********************************************************************************************/
****************************************************************************/
/********************************************************************************************
/****************************************************************************
* Private Variables
********************************************************************************************/
****************************************************************************/
/********************************************************************************************
/****************************************************************************
* Private Functions
********************************************************************************************/
****************************************************************************/
/********************************************************************************************
/****************************************************************************
* Public Functions
*********************************************************************************************/
*****************************************************************************/
/********************************************************************************************
* Function: pthread_getschedparam
/****************************************************************************
* Name: pthread_getschedparam
*
* Description:
* The pthread_getschedparam() functions will get the scheduling policy and
* parameters of threads. For SCHED_FIFO and SCHED_RR, the only required
* member of the sched_param structure is the priority sched_priority.
*
* The pthread_getschedparam() function will retrieve the scheduling policy
* and scheduling parameters for the thread whose thread ID is given by
* 'thread' and will store those values in 'policy' and 'param',
* The pthread_getschedparam() function will retrieve the scheduling
* policy and scheduling parameters for the thread whose thread ID is
* given by 'thread' and will store those values in 'policy' and 'param',
* respectively. The priority value returned from pthread_getschedparam()
* will be the value specified by the most recent pthread_setschedparam(),
* pthread_setschedprio(), or pthread_create() call affecting the target
* thread. It will not reflect any temporary adjustments to its priority (such
* as might result of any priority inheritance, for example).
* thread. It will not reflect any temporary adjustments to its priority
* (such as might result of any priority inheritance, for example).
*
* The policy parameter may have the value SCHED_FIFO, or SCHED_RR
* (SCHED_OTHER and SCHED_SPORADIC, in particular, are not supported).
@ -101,9 +101,10 @@
*
* Assumptions:
*
********************************************************************************************/
****************************************************************************/
int pthread_getschedparam(pthread_t thread, FAR int *policy, FAR struct sched_param *param)
int pthread_getschedparam(pthread_t thread, FAR int *policy,
FAR struct sched_param *param)
{
int ret;
@ -128,7 +129,7 @@ int pthread_getschedparam(pthread_t thread, FAR int *policy, FAR struct sched_pa
*policy = sched_getscheduler((pid_t)thread);
if (*policy == ERROR)
{
ret = *get_errno_ptr();
ret = get_errno();
}
}

View File

@ -2,7 +2,7 @@
* sched/pthread_getspecific.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -71,26 +71,23 @@
************************************************************************/
/************************************************************************
* Function: pthread_getspecific
* Name: pthread_getspecific
*
* Description:
* The pthread_getspecific() function returns the value
* currently bound to the specified key on behalf of the
* calling thread.
* The pthread_getspecific() function returns the value currently
* bound to the specified key on behalf of the calling thread.
*
* The effect of calling pthread_getspecific() with
* with a key value not obtained from pthread_create() or
* after a key has been deleted with pthread_key_delete()
* is undefined.
* The effect of calling pthread_getspecific() with with a key value
* not obtained from pthread_create() or after a key has been deleted
* with pthread_key_delete() is undefined.
*
* Parameters:
* key = The data key to get or set
*
* Return Value:
* The function pthread_getspecific() returns the thread-
* specific data associated with the given key. If no
* thread specific data is associated with the key, then
* the value NULL is returned.
* The function pthread_getspecific() returns the thread-specific data
* associated with the given key. If no thread specific data is
* associated with the key, then the value NULL is returned.
*
* EINVAL - The key value is invalid.
*

View File

@ -2,7 +2,7 @@
* sched/pthread_initialize.c
*
* Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -89,11 +89,10 @@ uint8_t g_pthread_num_keys;
****************************************************************************/
/****************************************************************************
* Function: pthread_initialize
* Name: pthread_initialize
*
* Description:
* This is an internal OS function called only at power-up
* boot time.
* This is an internal OS function called only at power-up boot time.
*
* Parameters:
* None
@ -121,7 +120,7 @@ void pthread_initialize(void)
}
/****************************************************************************
* Function: pthread_takesemaphore and pthread_givesemaphore
* Name: pthread_takesemaphore and pthread_givesemaphore
*
* Description:
* Support managed access to the private data sets.
@ -151,9 +150,9 @@ int pthread_takesemaphore(sem_t *sem)
* awakened by the receipt of a signal.
*/
if (*get_errno_ptr() != EINTR)
if (get_errno() != EINTR)
{
*get_errno_ptr() = EINVAL;
set_errno(EINVAL);
return ERROR;
}
}
@ -163,7 +162,7 @@ int pthread_takesemaphore(sem_t *sem)
{
/* NULL semaphore pointer! */
*get_errno_ptr() = EINVAL;
set_errno(EINVAL);
return ERROR;
}
}
@ -184,7 +183,7 @@ int pthread_givesemaphore(sem_t *sem)
{
/* sem_post() reported an error */
*get_errno_ptr() = EINVAL;
set_errno(EINVAL);
return ERROR;
}
}
@ -192,7 +191,7 @@ int pthread_givesemaphore(sem_t *sem)
{
/* NULL semaphore pointer! */
*get_errno_ptr() = EINVAL;
set_errno(EINVAL);
return ERROR;
}
}

View File

@ -2,7 +2,7 @@
* sched/pthread_internal.h
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -57,13 +57,11 @@
* Public Type Declarations
****************************************************************************/
/* The following defines an entry in the pthread logic's
* local data set. Note that this structure is used to
* implemented a singly linked list. This structure
* is used (instead of, say, a binary search tree) because
* the data set will be searched using the pid as
* a key -- a process IDs will always be created in a
* montonically increasing fashion.
/* The following defines an entry in the pthread logic's local data set.
* Note that this structure is used to implemented a singly linked list.
* This structure is used (instead of, say, a binary search tree) because
* the data set will be searched using the pid as a key -- a process IDs will
* always be created in a montonically increasing fashion.
*/
struct join_s
@ -79,28 +77,27 @@ struct join_s
pthread_addr_t exit_value; /* Returned data */
};
typedef struct join_s join_t;
/****************************************************************************
* Public Variables
****************************************************************************/
/* This is the head of a private singly linked list. It
* is used to retain information about the spawned threads.
/* This is the head of a private singly linked list. It is used to retain
* information about the spawned threads.
*/
extern FAR join_t *g_pthread_head;
extern FAR join_t *g_pthread_tail;
/* Mutually exclusive access to this data set is enforced with
* the following (un-named) semaphore.
/* Mutually exclusive access to this data set is enforced with the following
* (un-named) semaphore.
*/
extern sem_t g_join_semaphore;
/* This keys track of the number of global keys that have been
* allocated.
*/
/* This keys track of the number of global keys that have been allocated. */
extern uint8_t g_pthread_num_keys;

View File

@ -42,6 +42,7 @@
#include <pthread.h>
#include <errno.h>
#include <debug.h>
#include "os_internal.h"
#include "pthread_internal.h"
@ -70,11 +71,11 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_join
* Name: pthread_join
*
* Description:
* A thread can await termination of another thread and
* retrieve the return value of the thread.
* A thread can await termination of another thread and retrieve the
* return value of the thread.
*
* Parameters:
* thread
@ -83,12 +84,12 @@
* Return Value:
* 0 if successful. Otherwise, one of the following error codes:
*
* EINVAL The value specified by thread does not refer to a
* joinable thread.
* ESRCH No thread could be found corresponding to that
* specified by the given thread ID.
* EDEADLK A deadlock was detected or the value of thread
* specifies the calling thread.
* EINVAL The value specified by thread does not refer to ajoinable
* thread.
* ESRCH No thread could be found corresponding to thatspecified by the
* given thread ID.
* EDEADLK A deadlock was detected or the value of thread specifies the
* calling thread.
*
* Assumptions:
*
@ -236,8 +237,8 @@ int pthread_join(pthread_t thread, FAR pthread_addr_t *pexit_value)
{
(void)pthread_destroyjoin(pjoin);
}
(void)pthread_givesemaphore(&g_join_semaphore);
(void)pthread_givesemaphore(&g_join_semaphore);
ret = OK;
}

View File

@ -2,7 +2,7 @@
* sched/pthread_keycreate.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -70,45 +70,39 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_key_create
* Name: pthread_key_create
*
* Description:
* This function creates a thread-specific data key visible
* to all threads in the system. Although the same key value
* may be used by different threads, the values bound to
* the key by pthread_setspecific() are maintained on a
* per-thread basis and persist for the life of the calling
* This function creates a thread-specific data key visible to all threads
* in the system. Although the same key value may be used by different
* threads, the values bound to the key by pthread_setspecific() are
* maintained on a per-thread basis and persist for the life of the calling
* thread.
*
* Upon key creation, the value NULL will be associated with
* the new key in all active threads. Upon thread
* creation, the value NULL will be associated with all
* defined keys in the new thread.
* Upon key creation, the value NULL will be associated with the new key
* in all active threads. Upon thread creation, the value NULL will be
* associated with all defined keys in the new thread.
*
* Parameters:
* key = A pointer to the key to create.
* destructor = An optional destructor() function that may
* be associated with each key that is invoked when a
* thread exits. However, this argument is ignored in
* the current implementation.
* destructor = An optional destructor() function that may be associated
* with each key that is invoked when a thread exits. However, this
* argument is ignored in the current implementation.
*
* Return Value:
* If successful, the pthread_key_create() function will
* store the newly created key value at *key and return
* zero (OK). Otherwise, an error number will be
* returned to indicate the error:
* If successful, the pthread_key_create() function will store the newly
* created key value at *key and return zero (OK). Otherwise, an error
* number will bereturned to indicate the error:
*
* EAGAIN - The system lacked sufficient resources
* to create another thread-specific data key, or the
* system-imposed limit on the total number of keys
* pers process {PTHREAD_KEYS_MAX} has been exceeded
* EAGAIN - The system lacked sufficient resources to create another
* thread-specific data key, or the system-imposed limit on the total
* number of keys pers process {PTHREAD_KEYS_MAX} has been exceeded
* ENONMEM - Insufficient memory exists to create the key.
*
* Assumptions:
*
* POSIX Compatibility:
* - The present implementation ignores the destructor
* argument.
* - The present implementation ignores the destructor argument.
*
****************************************************************************/

View File

@ -2,7 +2,7 @@
* sched/pthread_keydelete.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -70,12 +70,12 @@
************************************************************************/
/************************************************************************
* Function: pthread_key_delete
* Name: pthread_key_delete
*
* Description:
* This POSIX function should delete a thread-specific data
* key previously returned by pthread_key_create(). However,
* this function does nothing in the present implementation.
* This POSIX function should delete a thread-specific data key
* previously returned by pthread_key_create(). However, this function
* does nothing in the present implementation.
*
* Parameters:
* key = the key to delete

View File

@ -50,23 +50,22 @@
************************************************************************/
/************************************************************************
* Function: pthread_kill
* Name: pthread_kill
*
* Description:
* The pthread_kill() system call can be used to send any
* signal to a thread. See kill() for further information
* as this is just a simple wrapper around the kill()
* function.
* The pthread_kill() system call can be used to send any signal to a
* thread. See kill() for further information as this is just a simple
* wrapper around the kill() function.
*
* Parameters:
* thread - The id of the thread to receive the signal. Only
* positive, non-zero values of 'thread' are supported.
* signo - The signal number to send. If 'signo' is zero,
* no signal is sent, but all error checking is performed.
* thread - The id of the thread to receive the signal. Only positive,
* non-zero values of 'thread' are supported.
* signo - The signal number to send. If 'signo' is zero, no signal is
* sent, but all error checking is performed.
*
* Return Value:
* On success the signal was send and zero is returned.
* On error one of the following error numbers is returned.
* On success the signal was send and zero is returned. On error one
* of the following error numbers is returned.
*
* EINVAL An invalid signal was specified.
* EPERM The thread does not have permission to send the
@ -89,6 +88,7 @@ int pthread_kill(pthread_t thread, int signo)
{
ret = get_errno();
}
return ret;
}

View File

@ -2,7 +2,7 @@
* sched/pthread_mutexdestroy.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -44,6 +44,7 @@
#include <sched.h>
#include <errno.h>
#include <debug.h>
#include "pthread_internal.h"
/****************************************************************************
@ -71,7 +72,7 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_mutex_destroy
* Name: pthread_mutex_destroy
*
* Description:
* Destroy a mutex.
@ -121,6 +122,7 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex)
ret = EINVAL;
}
}
sched_unlock();
}

View File

@ -2,7 +2,7 @@
* sched/pthread_mutexinit.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -71,7 +71,7 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_mutex_init
* Name: pthread_mutex_init
*
* Description:
* Create a mutex

View File

@ -2,7 +2,7 @@
* sched/pthread_mutexlock.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -72,35 +72,38 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_mutex_lock
* Name: pthread_mutex_lock
*
* Description:
* The mutex object referenced by mutex is locked by calling pthread_mutex_lock().
* If the mutex is already locked, the calling thread blocks until the mutex
* becomes available. This operation returns with the mutex object referenced
* by mutex in the locked state with the calling thread as its owner.
* The mutex object referenced by mutex is locked by calling
* pthread_mutex_lock(). If the mutex is already locked, the calling thread
* blocks until the mutex becomes available. This operation returns with the
* mutex object referenced by mutex in the locked state with the calling
* thread as its owner.
*
* If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection is not provided.
* Attempting to relock the mutex causes deadlock. If a thread attempts to unlock
* a mutex that it has not locked or a mutex which is unlocked, undefined behavior
* results.
* If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection is not
* provided. Attempting to relock the mutex causes deadlock. If a thread
* attempts to unlock a mutex that it has not locked or a mutex which is
* unlocked, undefined behavior results.
*
* If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error checking is provided.
* If a thread attempts to relock a mutex that it has already locked, an error
* will be returned. If a thread attempts to unlock a mutex that it has not
* locked or a mutex which is unlocked, an error will be returned.
* If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error checking is
* provided. If a thread attempts to relock a mutex that it has already
* locked, an error will be returned. If a thread attempts to unlock a
* mutex that it has not locked or a mutex which is unlocked, an error will
* be returned.
*
* If the mutex type is PTHREAD_MUTEX_RECURSIVE, then the mutex maintains the concept
* of a lock count. When a thread successfully acquires a mutex for the first time,
* the lock count is set to one. Every time a thread relocks this mutex, the lock count
* is incremented by one. Each time the thread unlocks the mutex, the lock count is
* decremented by one. When the lock count reaches zero, the mutex becomes available
* for other threads to acquire. If a thread attempts to unlock a mutex that it has
* not locked or a mutex which is unlocked, an error will be returned.
* If the mutex type is PTHREAD_MUTEX_RECURSIVE, then the mutex maintains
* the concept of a lock count. When a thread successfully acquires a mutex
* for the first time, the lock count is set to one. Every time a thread
* relocks this mutex, the lock count is incremented by one. Each time the
* thread unlocks the mutex, the lock count is decremented by one. When the
* lock count reaches zero, the mutex becomes available for other threads to
* acquire. If a thread attempts to unlock a mutex that it has not locked or
* a mutex which is unlocked, an error will be returned.
*
* If a signal is delivered to a thread waiting for a mutex, upon return from
* the signal handler the thread resumes waiting for the mutex as if it was
* not interrupted.
* If a signal is delivered to a thread waiting for a mutex, upon return
* from the signal handler the thread resumes waiting for the mutex as if
* it was not interrupted.
*
* Parameters:
* mutex - A reference to the mutex to be locked.
@ -141,16 +144,16 @@ int pthread_mutex_lock(FAR pthread_mutex_t *mutex)
#ifdef CONFIG_MUTEX_TYPES
if (mutex->type == PTHREAD_MUTEX_RECURSIVE)
{
/* Yes... just increment the number of locks held and return success */
mutex->nlocks++;
/* Yes... just increment the number of locks held and return success */
mutex->nlocks++;
}
else
#endif
{
/* No, then we would deadlock... return an error (default behavior
* is like PTHREAD_MUTEX_ERRORCHECK)
*/
/* No, then we would deadlock... return an error (default behavior
* is like PTHREAD_MUTEX_ERRORCHECK)
*/
sdbg("Returning EDEADLK\n");
ret = EDEADLK;
@ -174,6 +177,7 @@ int pthread_mutex_lock(FAR pthread_mutex_t *mutex)
#endif
}
}
sched_unlock();
}

View File

@ -2,7 +2,7 @@
* sched/pthread_mutextrylock.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -45,6 +45,7 @@
#include <sched.h>
#include <errno.h>
#include <debug.h>
#include "pthread_internal.h"
/****************************************************************************
@ -72,7 +73,7 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_mutex_trylock
* Name: pthread_mutex_trylock
*
* Description:
* The function pthread_mutex_trylock() is identical to pthread_mutex_lock()
@ -126,7 +127,7 @@ int pthread_mutex_trylock(FAR pthread_mutex_t *mutex)
/* Was it not available? */
else if (*get_errno_ptr() == EAGAIN)
else if (get_errno() == EAGAIN)
{
ret = EBUSY;
}

View File

@ -2,7 +2,7 @@
* sched/pthread_mutexunlock.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -72,7 +72,7 @@
****************************************************************************/
/****************************************************************************
* Function: pthread_mutex_unlock
* Name: pthread_mutex_unlock
*
* Description:
* The pthread_mutex_unlock() function releases the mutex object referenced

Some files were not shown because too many files have changed in this diff Show More