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 * 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. driver for use by NSH. Does not work! Crashes on first SPIFI write.
* configs/lpc4330-xplorer/*/defconfig: Calibrate delay loops (this is * configs/stm3220g-eval/include/board.h and configs/stm3240g-eval/include/board.h:
based on the current "slow" 72MHz M4 clock and will need to be The SDIOCLK frequency in the F2 and F4 derives for PLL48CLK and not HCLK
re-calibrated when this is increased). 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 #ifndef __CONFIGS_STM3220G_EVAL_INCLUDE_BOARD_H
#define __ARCH_BOARD_BOARD_H #define __CONFIGS_STM3220G_EVAL_INCLUDE_BOARD_H
/************************************************************************************ /************************************************************************************
* Included Files * Included Files
************************************************************************************/ ************************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
# include <stdint.h> # include <stdint.h>
#endif #endif
#include "stm32_rcc.h" #include "stm32_rcc.h"
#include "stm32_sdio.h" #include "stm32_sdio.h"
#include "stm32_internal.h" #include "stm32_internal.h"
@ -168,29 +170,29 @@
* to service FIFOs in interrupt driven mode. These values have not been * to service FIFOs in interrupt driven mode. These values have not been
* tuned!!! * 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 ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(1+2)=16 MHz
* DMA OFF: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(3+2)=14.4 MHz * DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)=12 MHz
*/ */
#ifdef CONFIG_SDIO_DMA #ifdef CONFIG_SDIO_DMA
# define SDIO_MMCXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT) # define SDIO_MMCXFR_CLKDIV (1 << SDIO_CLKCR_CLKDIV_SHIFT)
#else #else
# define SDIO_MMCXFR_CLKDIV (3 << SDIO_CLKCR_CLKDIV_SHIFT) # define SDIO_MMCXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT)
#endif #endif
/* DMA ON: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(1+2)=24 MHz /* DMA ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(0+2)= 24 MHz
* DMA OFF: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(3+2)=14.4 MHz * DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)= 12 MHz
*/ */
#ifdef CONFIG_SDIO_DMA #ifdef CONFIG_SDIO_DMA
# define SDIO_SDXFR_CLKDIV (1 << SDIO_CLKCR_CLKDIV_SHIFT) # define SDIO_SDXFR_CLKDIV (0 << SDIO_CLKCR_CLKDIV_SHIFT)
#else #else
# define SDIO_SDXFR_CLKDIV (3 << SDIO_CLKCR_CLKDIV_SHIFT) # define SDIO_SDXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT)
#endif #endif
/* Ethernet *************************************************************************/ /* Ethernet *************************************************************************/
@ -531,4 +533,4 @@ EXTERN void stm3220g_lcdclear(uint16_t color);
#endif #endif
#endif /* __ASSEMBLY__ */ #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_INPUT=n
CONFIG_DEBUG_DMA=n CONFIG_DEBUG_DMA=n
CONFIG_HAVE_CXX=n CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=n CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_MM_REGIONS=1 CONFIG_MM_REGIONS=1
CONFIG_ARCH_LOWPUTC=y CONFIG_ARCH_LOWPUTC=y
CONFIG_RR_INTERVAL=200 CONFIG_RR_INTERVAL=200
@ -813,7 +813,6 @@ CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
CONFIG_MMCSD_MMCSUPPORT=n CONFIG_MMCSD_MMCSUPPORT=n
CONFIG_MMCSD_HAVECARDDETECT=n CONFIG_MMCSD_HAVECARDDETECT=n
# #
# TCP/IP and UDP support via uIP # TCP/IP and UDP support via uIP
# #
@ -1342,8 +1341,8 @@ CONFIG_STM32_ILI9325_DISABLE=n
# #
# Settings for examples/uip # Settings for examples/uip
# #
CONFIG_EXAMPLE_UIP_IPADDR==(192<<24|168<<16|21<<8|15) CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_UIP_DRIPADDR=(192<<24|168<<16|21<<8|10) 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_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_UIP_DHCPC=n CONFIG_EXAMPLE_UIP_DHCPC=n
@ -1352,10 +1351,10 @@ CONFIG_EXAMPLE_UIP_DHCPC=n
CONFIG_EXAMPLE_NETTEST_SERVER=n CONFIG_EXAMPLE_NETTEST_SERVER=n
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
CONFIG_EXAMPLE_NETTEST_NOMAC=y CONFIG_EXAMPLE_NETTEST_NOMAC=y
CONFIG_EXAMPLE_NETTEST_IPADDR==(192<<24|168<<16|21<<8|15) CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_NETTEST_DRIPADDR=(192<<24|168<<16|21<<8|10) 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_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 # Settings for examples/ostest
@ -1410,12 +1409,12 @@ CONFIG_NSH_DISABLEBG=n
CONFIG_NSH_ROMFSETC=n CONFIG_NSH_ROMFSETC=n
CONFIG_NSH_CONSOLE=y CONFIG_NSH_CONSOLE=y
CONFIG_NSH_TELNET=y CONFIG_NSH_TELNET=y
CONFIG_NSH_ARCHINIT=n CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_IOBUFFER_SIZE=512 CONFIG_NSH_IOBUFFER_SIZE=512
CONFIG_NSH_DHCPC=n CONFIG_NSH_DHCPC=n
CONFIG_NSH_NOMAC=y CONFIG_NSH_NOMAC=y
CONFIG_NSH_IPADDR=(192<<24|168<<16|13<<8|161) CONFIG_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_NSH_DRIPADDR=(192<<24|168<<16|13<<8|1) CONFIG_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0) CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_NSH_ROMFSMOUNTPT="/etc" CONFIG_NSH_ROMFSMOUNTPT="/etc"
CONFIG_NSH_INITSCRIPT="init.d/rcS" CONFIG_NSH_INITSCRIPT="init.d/rcS"

View File

@ -80,6 +80,10 @@ ifeq ($(CONFIG_WATCHDOG),y)
CONFIGURED_APPS += examples/watchdog CONFIGURED_APPS += examples/watchdog
endif endif
ifeq ($(CONFIG_INPUT_STMPE811),y)
CONFIGURED_APPS += examples/touchscreen
endif
# Uncomment examples/ftpc to include the FTP client example # Uncomment examples/ftpc to include the FTP client example
# Uncomment examples/ftpd to include the FTP daemon 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/ftpc
#CONFIGURED_APPS += examples/ftpd #CONFIGURED_APPS += examples/ftpd
endif 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_RMII=n
CONFIG_STM32_AUTONEG=y CONFIG_STM32_AUTONEG=y
#CONFIG_STM32_ETHFD #CONFIG_STM32_ETHFD
#CONFIG_STM32_ETH100MB #CONFIG_STM32_ETH100MBPS
CONFIG_STM32_PHYSR=16 CONFIG_STM32_PHYSR=16
CONFIG_STM32_PHYSR_SPEED=0x0002 CONFIG_STM32_PHYSR_SPEED=0x0002
CONFIG_STM32_PHYSR_100MBPS=0x0000 CONFIG_STM32_PHYSR_100MBPS=0x0000
@ -517,6 +517,7 @@ CONFIG_DEBUG_PWM=n
CONFIG_DEBUG_CAN=n CONFIG_DEBUG_CAN=n
CONFIG_DEBUG_I2C=n CONFIG_DEBUG_I2C=n
CONFIG_DEBUG_DMA=n CONFIG_DEBUG_DMA=n
CONFIG_HAVE_CXX=y CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_MM_REGIONS=1 CONFIG_MM_REGIONS=1
@ -529,7 +530,7 @@ CONFIG_START_MONTH=12
CONFIG_START_DAY=6 CONFIG_START_DAY=6
CONFIG_GREGORIAN_TIME=n CONFIG_GREGORIAN_TIME=n
CONFIG_JULIAN_TIME=n CONFIG_JULIAN_TIME=n
CONFIG_DEV_CONSOLE=y CONFIG_DEV_CONSOLE=n
CONFIG_DEV_LOWCONSOLE=n CONFIG_DEV_LOWCONSOLE=n
CONFIG_MUTEX_TYPES=n CONFIG_MUTEX_TYPES=n
CONFIG_PRIORITY_INHERITANCE=n CONFIG_PRIORITY_INHERITANCE=n
@ -541,7 +542,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKQUEUE=y
CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPRIORITY=192
CONFIG_SCHED_WORKPERIOD=(50*1000) CONFIG_SCHED_WORKPERIOD=(50*1000)
CONFIG_SCHED_WORKSTACKSIZE=1024 CONFIG_SCHED_WORKSTACKSIZE=2048
CONFIG_SIG_SIGWORK=4 CONFIG_SIG_SIGWORK=4
CONFIG_SCHED_WAITPID=y CONFIG_SCHED_WAITPID=y
CONFIG_SCHED_ATEXIT=n CONFIG_SCHED_ATEXIT=n
@ -935,6 +936,74 @@ CONFIG_RTC_HIRES=n
CONFIG_RTC_FREQUENCY=n CONFIG_RTC_FREQUENCY=n
CONFIG_RTC_ALARM=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 # USB Device Configuration
# #
@ -1082,11 +1151,11 @@ CONFIG_WATCHDOG=n
# CONFIG_NXTK_BORDERWIDTH # CONFIG_NXTK_BORDERWIDTH
# Specifies with with of the border (in pixels) used with # Specifies with with of the border (in pixels) used with
# framed windows. The default is 4. # 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. # Specify the colors of the border used with framed windows.
# CONFIG_NXTK_BORDERCOLOR2 is the shadow side color and so # CONFIG_NXTK_BORDERCOLOR2 is the shadow side color and so is normally darker.
# is normally darker. The default is medium and dark grey, # CONFIG_NXTK_BORDERCOLOR3 is the shiny side color and so is normally brighter.
# respectively # The default is mediumdark grey, and light grey, respectively
# CONFIG_NXTK_AUTORAISE # CONFIG_NXTK_AUTORAISE
# If set, a window will be raised to the top if the mouse position # 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 # 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_MXSERVERMSGS=32
CONFIG_NX_MXCLIENTMSGS=16 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 # Settings for examples/uip
# #
CONFIG_EXAMPLE_UIP_IPADDR==(192<<24|168<<16|21<<8|15) CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_UIP_DRIPADDR=(192<<24|168<<16|21<<8|10) 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_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_UIP_DHCPC=n CONFIG_EXAMPLE_UIP_DHCPC=n
@ -1212,10 +1351,10 @@ CONFIG_EXAMPLE_UIP_DHCPC=n
CONFIG_EXAMPLE_NETTEST_SERVER=n CONFIG_EXAMPLE_NETTEST_SERVER=n
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
CONFIG_EXAMPLE_NETTEST_NOMAC=y CONFIG_EXAMPLE_NETTEST_NOMAC=y
CONFIG_EXAMPLE_NETTEST_IPADDR==(192<<24|168<<16|21<<8|15) CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_NETTEST_DRIPADDR=(192<<24|168<<16|21<<8|10) 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_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 # Settings for examples/ostest
@ -1268,14 +1407,14 @@ CONFIG_NSH_NESTDEPTH=3
CONFIG_NSH_DISABLESCRIPT=n CONFIG_NSH_DISABLESCRIPT=n
CONFIG_NSH_DISABLEBG=n CONFIG_NSH_DISABLEBG=n
CONFIG_NSH_ROMFSETC=n CONFIG_NSH_ROMFSETC=n
CONFIG_NSH_CONSOLE=y CONFIG_NSH_CONSOLE=n
CONFIG_NSH_TELNET=y CONFIG_NSH_TELNET=y
CONFIG_NSH_ARCHINIT=y CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_IOBUFFER_SIZE=512 CONFIG_NSH_IOBUFFER_SIZE=512
CONFIG_NSH_DHCPC=n CONFIG_NSH_DHCPC=n
CONFIG_NSH_NOMAC=y CONFIG_NSH_NOMAC=y
CONFIG_NSH_IPADDR=(192<<24|168<<16|13<<8|161) CONFIG_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_NSH_DRIPADDR=(192<<24|168<<16|13<<8|1) CONFIG_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0) CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_NSH_ROMFSMOUNTPT="/etc" CONFIG_NSH_ROMFSMOUNTPT="/etc"
CONFIG_NSH_INITSCRIPT="init.d/rcS" 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 # built-in, the default is 32. Otherwise messages are sent and received
# indefinitely. # 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 # Settings for examples/pwm
# #

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
* sched/clock_getres.c * sched/clock_getres.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -79,7 +79,7 @@
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: clock_getres * Name: clock_getres
* *
* Description: * Description:
* Clock Functions based on POSIX APIs * 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) if (clock_id != CLOCK_REALTIME)
{ {
sdbg("Returning ERROR\n"); sdbg("Returning ERROR\n");
*get_errno_ptr() = EINVAL; set_errno(EINVAL);
ret = ERROR; ret = ERROR;
} }
else else

View File

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

View File

@ -2,7 +2,7 @@
* sched/clock_gettimeofday.c * sched/clock_gettimeofday.c
* *
* Copyright (C) 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -38,10 +38,11 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/time.h>
#include <sys/time.h>
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include "clock_internal.h" #include "clock_internal.h"
/**************************************************************************** /****************************************************************************
@ -77,7 +78,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: gettimeofday * Name: gettimeofday
* *
* Description: * Description:
* Get the current time * Get the current time
@ -107,5 +108,6 @@ int gettimeofday(struct timeval *tp, void *tzp)
tp->tv_sec = ts.tv_sec; tp->tv_sec = ts.tv_sec;
tp->tv_usec = ts.tv_nsec / NSEC_PER_USEC; tp->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
} }
return ret; return ret;
} }

View File

@ -99,7 +99,7 @@ struct timespec g_basetime;
**************************************************************************/ **************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: clock_basetime * Name: clock_basetime
* *
* Description: * Description:
* Get the initial time value from the best source available. * 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 */ #endif /* CONFIG_RTC */
/**************************************************************************** /****************************************************************************
* Function: clock_inittime * Name: clock_inittime
* *
* Description: * Description:
* Get the initial time value from the best source available. * 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: * Description:
* Perform one-time initialization of the timing facilities. * Perform one-time initialization of the timing facilities.
@ -212,7 +212,7 @@ void clock_initialize(void)
} }
/**************************************************************************** /****************************************************************************
* Function: clock_synchronize * Name: clock_synchronize
* *
* Description: * Description:
* Synchronize the system timer to a hardware RTC. This operation is * Synchronize the system timer to a hardware RTC. This operation is
@ -253,12 +253,12 @@ void clock_synchronize(void)
#endif #endif
/**************************************************************************** /****************************************************************************
* Function: clock_timer * Name: clock_timer
* *
* Description: * Description:
* This function must be called once every time the real * This function must be called once every time the real time clock
* time clock interrupt occurs. The interval of this * interrupt occurs. The interval of this clock interrupt must be
* clock interrupt must be MSEC_PER_TICK * 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. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -33,8 +33,8 @@
* *
********************************************************************************/ ********************************************************************************/
#ifndef __CLOCK_INTERNAL_H #ifndef __SCHED_CLOCK_INTERNAL_H
#define __CLOCK_INTERNAL_H #define __SCHED_CLOCK_INTERNAL_H
/******************************************************************************** /********************************************************************************
* Included Files * Included Files
@ -79,13 +79,13 @@ extern struct timespec g_basetime;
* Public Function Prototypes * Public Function Prototypes
********************************************************************************/ ********************************************************************************/
extern void weak_function clock_initialize(void); void weak_function clock_initialize(void);
extern void weak_function clock_timer(void); void weak_function clock_timer(void);
extern int clock_abstime2ticks(clockid_t clockid, int clock_abstime2ticks(clockid_t clockid,
FAR const struct timespec *abstime, FAR const struct timespec *abstime,
FAR int *ticks); FAR int *ticks);
extern int clock_time2ticks(FAR const struct timespec *reltime, FAR int *ticks); int clock_time2ticks(FAR const struct timespec *reltime, FAR int *ticks);
extern int clock_ticks2time(int ticks, FAR struct timespec *reltime); 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: * Description:
* Clock Functions based on POSIX APIs * Clock Functions based on POSIX APIs

View File

@ -2,7 +2,7 @@
* sched/clock_systimer.c * sched/clock_systimer.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -58,7 +58,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: clock_systimer * Name: clock_systimer
* *
* Description: * Description:
* Return the current value of the 32-bit system timer counter * Return the current value of the 32-bit system timer counter
@ -85,7 +85,7 @@ uint32_t clock_systimer(void)
#endif #endif
/**************************************************************************** /****************************************************************************
* Function: clock_systimer64 * Name: clock_systimer64
* *
* Description: * Description:
* Return the current value of the 64-bit system timer counter * Return the current value of the 64-bit system timer counter

View File

@ -2,7 +2,7 @@
* clock_ticks2time.c * clock_ticks2time.c
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -67,7 +67,7 @@
********************************************************************************/ ********************************************************************************/
/******************************************************************************** /********************************************************************************
* Function: clock_ticks2time * Name: clock_ticks2time
* *
* Description: * Description:
* Convert the system time tick value to a relative time. * Convert the system time tick value to a relative time.

View File

@ -2,7 +2,7 @@
* sched/clock_time2ticks.c * sched/clock_time2ticks.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -69,7 +69,7 @@
********************************************************************************/ ********************************************************************************/
/******************************************************************************** /********************************************************************************
* Function: clock_time2ticks * Name: clock_time2ticks
* *
* Description: * Description:
* Convert a timespec delay to system timer ticks. This function is suitable * Convert a timespec delay to system timer ticks. This function is suitable

View File

@ -2,7 +2,7 @@
* sched/env_clearenv.c * sched/env_clearenv.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -55,7 +55,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: clearenv * Name: clearenv
* *
* Description: * Description:
* The clearenv() function clears the environment of all name-value pairs * The clearenv() function clears the environment of all name-value pairs

View File

@ -2,7 +2,7 @@
* sched/env_dup.c * sched/env_dup.c
* *
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -60,7 +60,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: env_dup * Name: env_dup
* *
* Description: * Description:
* Copy the internal environment structure of a task. This is the action * 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; ptcb->envp = envp;
sched_unlock(); sched_unlock();
} }
return ret; return ret;
} }

View File

@ -2,7 +2,7 @@
* eched/env_dupenv.c * eched/env_dupenv.c
* *
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -57,7 +57,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: dupenv * Name: dupenv
* *
* Description: * Description:
* Copy the internal environment structure of a task. This is the action * Copy the internal environment structure of a task. This is the action

View File

@ -2,7 +2,7 @@
* sched/env_findvar.c * sched/env_findvar.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * 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) 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 true;
} }
return false; return false;
} }
@ -77,7 +78,7 @@ static bool env_cmpname(const char *pszname, const char *peqname)
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: env_findvar * Name: env_findvar
* *
* Description: * Description:
* Search the provided environment structure for the variable of the * 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 */ /* 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 */ /* Check for success */
@ -118,6 +121,7 @@ FAR char *env_findvar(environ_t *envp, const char *pname)
ret = ptr; ret = ptr;
} }
} }
return ret; return ret;
} }

View File

@ -2,7 +2,7 @@
* env_getenv.c * env_getenv.c
* *
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -58,7 +58,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: getenv * Name: getenv
* *
* Description: * Description:
* The getenv() function searches the environment list for a string that * The getenv() function searches the environment list for a string that
@ -91,7 +91,6 @@ FAR char *getenv(const char *name)
goto errout; goto errout;
} }
/* Get a reference to the thread-private environ in the TCB.*/ /* Get a reference to the thread-private environ in the TCB.*/
sched_lock(); sched_lock();
@ -126,7 +125,7 @@ FAR char *getenv(const char *name)
errout_with_lock: errout_with_lock:
sched_unlock(); sched_unlock();
errout: errout:
*get_errno_ptr() = ret; set_errno(ret);
return NULL; return NULL;
} }

View File

@ -2,7 +2,7 @@
* env_getenvironptr.c * env_getenvironptr.c
* *
* Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -56,7 +56,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: get_environ_ptr * Name: get_environ_ptr
* *
* Description: * Description:
* Return a pointer to the thread specific environ variable. * Return a pointer to the thread specific environ variable.
@ -75,9 +75,9 @@ FAR char **get_environ_ptr( void )
{ {
#if 1 #if 1
/* Type of internal representation of environment is incompatible with /* Type of internal representation of environment is incompatible with
* char ** return value. * char ** return value.
*/ */
return NULL; return NULL;

View File

@ -2,7 +2,7 @@
* sched/env_internal.h * sched/env_internal.h
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions

View File

@ -2,7 +2,7 @@
* sched/env_putenv.c * sched/env_putenv.c
* *
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -57,7 +57,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: putenv * Name: putenv
* *
* Description: * Description:
* The putenv() function adds or changes the value of environment variables. * The putenv() function adds or changes the value of environment variables.

View File

@ -2,7 +2,7 @@
* sched/env_clearenv.c * sched/env_clearenv.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -55,12 +55,12 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: env_release * Name: env_release
* *
* Description: * Description:
* The env_release() function clears the environment of all name-value pairs * The env_release() function clears the environment of all name-value
* and sets the value of the external variable environ to NULL. * pairs and sets the value of the external variable environ to NULL.
*
* Parameters: * Parameters:
* ptcb Identifies the TCB containing the environment structure * ptcb Identifies the TCB containing the environment structure
* *
@ -75,6 +75,7 @@
int env_release(FAR _TCB *ptcb) int env_release(FAR _TCB *ptcb)
{ {
int ret = OK; int ret = OK;
if (!ptcb) if (!ptcb)
{ {
ret = -EINVAL; ret = -EINVAL;
@ -111,8 +112,10 @@ int env_release(FAR _TCB *ptcb)
ptcb->envp = NULL; ptcb->envp = NULL;
} }
sched_unlock(); sched_unlock();
} }
return ret; return ret;
} }

View File

@ -2,7 +2,7 @@
* sched/env_removevar.c * sched/env_removevar.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -53,7 +53,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: env_removevar * Name: env_removevar
* *
* Description: * Description:
* Remove the referenced name=value pair from the environment * Remove the referenced name=value pair from the environment
@ -109,6 +109,7 @@ int env_removevar(environ_t *envp, char *pvar)
ret = OK; ret = OK;
} }
} }
return ret; return ret;
} }

View File

@ -2,7 +2,7 @@
* sched/env_setenv.c * sched/env_setenv.c
* *
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -61,7 +61,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: setenv * Name: setenv
* *
* Description: * Description:
* The setenv() function adds the variable name to the environment with the * 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 /* 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; varlen = strlen(name) + strlen(value) + 2;

View File

@ -2,7 +2,7 @@
* sched/env_share.c * sched/env_share.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -43,6 +43,7 @@
#include <sched.h> #include <sched.h>
#include <errno.h> #include <errno.h>
#include "os_internal.h" #include "os_internal.h"
#include "env_internal.h" #include "env_internal.h"
@ -55,7 +56,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: env_share * Name: env_share
* *
* Description: * Description:
* Increment the reference count on the internal environment structure of * Increment the reference count on the internal environment structure of
@ -106,6 +107,7 @@ int env_share(FAR _TCB *ptcb)
ptcb->envp = envp; ptcb->envp = envp;
sched_unlock(); sched_unlock();
} }
return ret; return ret;
} }

View File

@ -2,7 +2,7 @@
* sched/env_unsetenv.c * sched/env_unsetenv.c
* *
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -59,7 +59,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: unsetenv * Name: unsetenv
* *
* Description: * Description:
* The unsetenv() function deletes the variable name from the environment. * The unsetenv() function deletes the variable name from the environment.

View File

@ -2,7 +2,7 @@
* sched/errno_get.c * sched/errno_get.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -58,7 +58,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: get_errno * Name: get_errno
* *
* Description: * Description:
* Return the value of the thread specific errno. This function is only * Return the value of the thread specific errno. This function is only

View File

@ -2,7 +2,7 @@
* sched/errno_getptr.c * sched/errno_getptr.c
* *
* Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * 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: * Description:
* Return a pointer to the thread specific errno. * Return a pointer to the thread specific errno.

View File

@ -2,7 +2,7 @@
* sched/errno_set.c * sched/errno_set.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -58,7 +58,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: set_errno * Name: set_errno
* *
* Description: * Description:
* Set the value of the thread specific errno. This function is only * Set the value of the thread specific errno. This function is only

View File

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

View File

@ -2,7 +2,7 @@
* sched/getpid.c * sched/getpid.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -40,6 +40,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <sched.h> #include <sched.h>
#include "os_internal.h" #include "os_internal.h"
/************************************************************************ /************************************************************************
@ -76,9 +77,9 @@
pid_t getpid(void) pid_t getpid(void)
{ {
/* Return the task ID from the TCB at the head of the /* Return the task ID from the TCB at the head of the
* ready-to-run task list * 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/config.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include "irq_internal.h" #include "irq_internal.h"
/**************************************************************************** /****************************************************************************
@ -69,8 +71,8 @@
* Name: irq_attach * Name: irq_attach
* *
* Description: * Description:
* Configure the IRQ subsystem so that IRQ number 'irq' * Configure the IRQ subsystem so that IRQ number 'irq' is dispatched to
* is dispatched to 'isr' * 'isr'
* *
****************************************************************************/ ****************************************************************************/
@ -123,5 +125,3 @@ int irq_attach(int irq, xcpt_t isr)
return OK; return OK;
#endif #endif
} }

View File

@ -2,7 +2,7 @@
* sched/irq_dispatch.c * sched/irq_dispatch.c
* *
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -73,9 +73,9 @@
* Name: irq_dispatch * Name: irq_dispatch
* *
* Description: * Description:
* This function must be called from the achitecture- * This function must be called from the achitecture-specific logic in
* specific logic in order to dispaly an interrupt to * order to dispatch an interrupt to the appropriate, registered handling
* the appropriate, registered handling logic. * logic.
* *
***************************************************************************/ ***************************************************************************/

View File

@ -2,7 +2,7 @@
* sched/irq_initialize.c * sched/irq_initialize.c
* *
* Copyright (C) 2007-2008, 2010 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -40,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include "irq_internal.h" #include "irq_internal.h"
/**************************************************************************** /****************************************************************************
@ -69,7 +70,7 @@ FAR xcpt_t g_irqvector[NR_IRQS+1];
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: irq_initialize * Name: irq_initialize
* *
* Description: * Description:
* Configure the IRQ subsystem * Configure the IRQ subsystem

View File

@ -2,7 +2,7 @@
* sched/irq_internal.h * sched/irq_internal.h
* *
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -33,8 +33,8 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef __IRQ_INTERNAL_H #ifndef __SCHED_IRQ_INTERNAL_H
#define __IRQ_INTERNAL_H #define __SCHED_IRQ_INTERNAL_H
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
@ -79,5 +79,5 @@ EXTERN int irq_unexpected_isr(int irq, FAR void *context);
} }
#endif #endif
#endif /* __IRQ_INTERNAL_H */ #endif /* __SCHED_IRQ_INTERNAL_H */

View File

@ -2,7 +2,7 @@
* sched/irq_unexpectedisr.c * sched/irq_unexpectedisr.c
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -38,8 +38,11 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/irq.h>
#include <debug.h> #include <debug.h>
#include <nuttx/irq.h>
#include "os_internal.h" #include "os_internal.h"
#include "irq_internal.h" #include "irq_internal.h"
@ -68,11 +71,11 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: irq_unexpected_isr * Name: irq_unexpected_isr
* *
* Description: * Description:
* An interrupt has been received for an IRQ that was * An interrupt has been received for an IRQ that was never registered
* never registered with the system. * with the system.
* *
****************************************************************************/ ****************************************************************************/

View File

@ -2,7 +2,7 @@
* sched/kmm_addregion.c * sched/kmm_addregion.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * 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: * Description:
* This is a simple redirection to the user-space mm_addregion() * This is a simple redirection to the user-space mm_addregion()

View File

@ -2,7 +2,7 @@
* sched/kmm_initialize.c * sched/kmm_initialize.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * 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: * Description:
* This is a simple redirection to the user-space mm_initialize() * This is a simple redirection to the user-space mm_initialize()

View File

@ -2,7 +2,7 @@
* sched/kmm_kfree.c * sched/kmm_kfree.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -84,7 +84,7 @@ typedef void (*kfree_t)(FAR void *);
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: kfree * Name: kfree
* *
* Description: * Description:
* This is a simple redirection to the user-space free() function. * This is a simple redirection to the user-space free() function.

View File

@ -2,7 +2,7 @@
* sched/kmm_kmalloc.c * sched/kmm_kmalloc.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -84,7 +84,7 @@ typedef FAR void *(*kmalloc_t)(size_t);
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: kmalloc * Name: kmalloc
* *
* Description: * Description:
* This is a simple redirection to the user-space malloc() function. * This is a simple redirection to the user-space malloc() function.

View File

@ -2,7 +2,7 @@
* sched/kmm_krealloc.c * sched/kmm_krealloc.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * 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: * Description:
* This is a simple redirection to the user-space realloc() function. * This is a simple redirection to the user-space realloc() function.

View File

@ -2,7 +2,7 @@
* sched/kmm_kzalloc.c * sched/kmm_kzalloc.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -84,7 +84,7 @@ typedef FAR void *(*kzalloc_t)(size_t);
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: kzalloc * Name: kzalloc
* *
* Description: * Description:
* This is a simple redirection to the user-space zalloc() function. * This is a simple redirection to the user-space zalloc() function.

View File

@ -2,7 +2,7 @@
* sched/kmm_semaphore.c * sched/kmm_semaphore.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -86,7 +86,7 @@ typedef void (*kmgivesemaphore_t)(void);
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: kmm_trysemaphore * Name: kmm_trysemaphore
* *
* Description: * Description:
* This is a simple redirection to the user-space mm_trysemaphore() * 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: * Description:
* This is a simple redirection to the user-space mm_givesemaphore() * This is a simple redirection to the user-space mm_givesemaphore()

View File

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

View File

@ -2,7 +2,7 @@
* sched/mq_descreate.c * sched/mq_descreate.c
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -39,19 +39,21 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <stdarg.h> /* va_list */ #include <stdarg.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <mqueue.h> #include <mqueue.h>
#include <sched.h> #include <sched.h>
#include <queue.h>
#include <debug.h> #include <debug.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/kmalloc.h>
#include "os_internal.h" #include "os_internal.h"
#include "sig_internal.h" #include "sig_internal.h"
#include <queue.h>
#include <nuttx/kmalloc.h>
#include "mq_internal.h" #include "mq_internal.h"
/**************************************************************************** /****************************************************************************
@ -75,7 +77,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: mq_desalloc * Name: mq_desalloc
* *
* Description: * Description:
* Allocate a message queue descriptor. * Allocate a message queue descriptor.
@ -117,7 +119,7 @@ static mqd_t mq_desalloc(void)
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: mq_descreate * Name: mq_descreate
* *
* Description: * Description:
* Create a message queue descriptor for the specified TCB * 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 * oflags - access rights for the descriptor
* *
* Return Value: * 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 * sched/mq_findnamed.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -40,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <string.h> #include <string.h>
#include "mq_internal.h" #include "mq_internal.h"
/************************************************************************ /************************************************************************
@ -67,18 +68,18 @@
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: mq_findnamed * Name: mq_findnamed
* *
* Description: * Description:
* This function finds the named message queue with the * This function finds the named message queue with the specified name
* specified name in the list of message queues. * in the list of message queues.
* *
* Inputs: * Inputs:
* mq_name - the name of the message queue to find * mq_name - the name of the message queue to find
* *
* Return Value: * Return Value:
* A reference to the matching named message queue * A reference to the matching named message queue structure (or NULL
* structure (or NULL if none was found). * if none was found).
* *
************************************************************************/ ************************************************************************/

View File

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

View File

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

View File

@ -2,7 +2,7 @@
* sched/mq_msgfree.c * sched/mq_msgfree.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -69,13 +69,12 @@
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: mq_msgfree * Name: mq_msgfree
* *
* Description: * Description:
* The mq_msgfree function will return a message to the * The mq_msgfree function will return a message to the free pool of
* free pool of messages if it was a pre-allocated message. * messages if it was a pre-allocated message. If the message was
* If the message was allocated dynamically it will be * allocated dynamically it will be deallocated.
* deallocated.
* *
* Inputs: * Inputs:
* mqmsg - message to free * mqmsg - message to free
@ -128,7 +127,6 @@ void mq_msgfree(FAR mqmsg_t *mqmsg)
{ {
sched_free(mqmsg); sched_free(mqmsg);
} }
else else
{ {
PANIC(OSERR_BADMSGTYPE); PANIC(OSERR_BADMSGTYPE);

View File

@ -2,7 +2,7 @@
* sched/mq_msgqfree.c * sched/mq_msgqfree.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -68,7 +68,7 @@
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: mq_msgqfree * Name: mq_msgqfree
* *
* Description: * Description:
* This function deallocates an initialized message queue * This function deallocates an initialized message queue

View File

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

View File

@ -2,7 +2,7 @@
* sched/mq_open.c * sched/mq_open.c
* *
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -79,21 +79,21 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: mq_open * Name: mq_open
* *
* Description: * Description:
* This function establish a connection between a named * This function establish a connection between a named message queue and
* message queue and the calling task. After a successful * the calling task. After a successful call of mq_open(), the task can
* call of mq_open(), the task can reference the message * reference the message queue using the address returned by the call. The
* queue using the address returned by the call. The * message queue remains usable until it is closed by a successful call to
* message queue remains usable until it is closed by a * mq_close().
* successful call to mq_close().
* *
* Parameters: * Parameters:
* mq_name - Name of the queue to open * mq_name - Name of the queue to open
* oflags - open flags * oflags - open flags
* Optional parameters. When the O_CREAT flag is * Optional parameters. When the O_CREAT flag is specified, two optional
* specified, two optional parameters are expected: * parameters are expected:
*
* 1. mode_t mode (ignored), and * 1. mode_t mode (ignored), and
* 2. struct mq_attr *attr. The mq_maxmsg attribute * 2. struct mq_attr *attr. The mq_maxmsg attribute
* is used at the time that the message queue is * 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(); sched_unlock();
} }

View File

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

View File

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

View File

@ -74,7 +74,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: mq_send * Name: mq_send
* *
* Description: * Description:
* This function adds the specificied message (msg) to the message queue * 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: * Description:
* The mq_msgalloc function will get a free message for use by the * 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 * 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 * 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: * Description:
* This is internal, common logic shared by both mq_send and mq_timesend. * 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: * Description:
* This is internal, common logic shared by both mq_send and mq_timesend. * This is internal, common logic shared by both mq_send and mq_timesend.

View File

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

View File

@ -2,7 +2,7 @@
* sched/mq_timedsend.c * sched/mq_timedsend.c
* *
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -74,7 +74,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: mq_sndtimeout * Name: mq_sndtimeout
* *
* Description: * Description:
* This function is called if the timeout elapses before the message queue * 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; FAR _TCB *wtcb;
irqstate_t saved_state; irqstate_t saved_state;
/* Disable interrupts. This is necessary because an /* Disable interrupts. This is necessary because an interrupt handler may
* interrupt handler may attempt to send a message while we are * attempt to send a message while we are doing this.
* doing this.
*/ */
saved_state = irqsave(); saved_state = irqsave();
/* Get the TCB associated with this pid. It is possible that /* Get the TCB associated with this pid. It is possible that task may no
* task may no longer be active when this watchdog goes off. * longer be active when this watchdog goes off.
*/ */
wtcb = sched_gettcb((pid_t)pid); 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: * Description:
* This function adds the specificied message (msg) to the message queue * This function adds the specificied message (msg) to the message queue

View File

@ -2,7 +2,7 @@
* sched.mq_unlink.c * sched.mq_unlink.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -71,14 +71,13 @@
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: mq_unlink * Name: mq_unlink
* *
* Description: * Description:
* This function removes the message queue named by * This function removes the message queue named by "mq_name." If one
* "mq_name." If one or more tasks have the message queue * or more tasks have the message queue open when mq_unlink() is called,
* open when mq_unlink() is called, removal of the message * removal of the message queue is postponed until all references to the
* queue is postponed until all references to the message * message queue have been closed.
* queue have been closed.
* *
* Parameters: * Parameters:
* mq_name - Name of the message queue * mq_name - Name of the message queue
@ -138,6 +137,7 @@ int mq_unlink(const char *mq_name)
ret = OK; ret = OK;
} }
sched_unlock(); sched_unlock();
} }

View File

@ -2,7 +2,7 @@
* sched/mq_waitirq.c * sched/mq_waitirq.c
* *
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -72,7 +72,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: sem_waitirq * Name: sem_waitirq
* *
* Description: * Description:
* This function is called when a signal or a timeout is received by a * 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: * Description:
* Registers a function to be called at program exit. * Registers a function to be called at program exit.

View File

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

View File

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

View File

@ -2,7 +2,7 @@
* sched/pg_internal.h * sched/pg_internal.h
* *
* Copyright (C) 2010 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * 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 /* __ASSEMBLY__ */
#endif /* CONFIG_PAGING */ #endif /* CONFIG_PAGING */

View File

@ -2,7 +2,7 @@
* sched/pg_miss.c * sched/pg_miss.c
* *
* Copyright (C) 2010 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions

View File

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

View File

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

View File

@ -2,7 +2,7 @@
* sched/pthread_barriedestroy.c * sched/pthread_barriedestroy.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -69,7 +69,7 @@
********************************************************************************/ ********************************************************************************/
/******************************************************************************** /********************************************************************************
* Function: pthread_barrier_destroy * Name: pthread_barrier_destroy
* *
* Description: * Description:
* The pthread_barrier_destroy() function destroys the barrier referenced by * The pthread_barrier_destroy() function destroys the barrier referenced by

View File

@ -2,7 +2,7 @@
* sched/pthread_barrieinit.c * sched/pthread_barrieinit.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -69,7 +69,7 @@
********************************************************************************/ ********************************************************************************/
/******************************************************************************** /********************************************************************************
* Function: pthread_barrier_init * Name: pthread_barrier_init
* *
* Description: * Description:
* The pthread_barrier_init() function allocates any resources required to use * 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); sem_init(&barrier->sem, 0, 0);
barrier->count = count; barrier->count = count;
} }
return ret; return ret;
} }

View File

@ -2,7 +2,7 @@
* sched/pthread_barrierwait.c * sched/pthread_barrierwait.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -70,7 +70,7 @@
********************************************************************************/ ********************************************************************************/
/******************************************************************************** /********************************************************************************
* Function: pthread_barrier_wait * Name: pthread_barrier_wait
* *
* Description: * Description:
* The pthread_barrier_wait() function synchronizse participating threads at * 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 */ /* 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 (errornumber != EINTR)
{ {
/* If it is awakened by some other error, then there is a /* If it is awakened by some other error, then there is a

View File

@ -2,7 +2,7 @@
* sched/pthread_cancel.c * sched/pthread_cancel.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -123,6 +123,7 @@ int pthread_cancel(pthread_t thread)
sched_unlock(); sched_unlock();
return OK; return OK;
} }
sched_unlock(); sched_unlock();
/* Check to see if the ID refers to ourselves.. this would be the /* 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: * Description:
* Notify all other threads waiting in phread join for this * Notify all other threads waiting in phread join for this thread's
* thread's exit data. This must be done by the child * exit data. This must be done by the child at child thread
* at child thread destruction time. * destruction time.
* *
************************************************************************/ ************************************************************************/
@ -117,6 +117,7 @@ static bool pthread_notifywaiters(FAR join_t *pjoin)
(void)pthread_takesemaphore(&pjoin->data_sem); (void)pthread_takesemaphore(&pjoin->data_sem);
return true; return true;
} }
return false; return false;
} }
@ -125,20 +126,20 @@ static bool pthread_notifywaiters(FAR join_t *pjoin)
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: pthread_completejoin * Name: pthread_completejoin
* *
* Description: * Description:
* A thread has been terminated -- either by returning, * A thread has been terminated -- either by returning, calling
* calling pthread_exit(), or through pthread_cancel(). * pthread_exit(), or through pthread_cancel(). In any event, we must
* In any event, we must complete any pending join events. * complete any pending join events.
* *
* Parameters: * Parameters:
* exit_value * exit_value
* *
* Returned Value: * Returned Value:
* OK unless there is no join information associated with * OK unless there is no join information associated with the pid.
* the pid. This could happen, for example, if a task * This could happen, for example, if a task started with task_create()
* started with task_create() calls pthread_exit(). * calls pthread_exit().
* *
* Assumptions: * Assumptions:
* *
@ -195,16 +196,15 @@ int pthread_completejoin(pid_t pid, FAR void *exit_value)
} }
/************************************************************************ /************************************************************************
* Function: pthread_destroyjoin * Name: pthread_destroyjoin
* *
* Description: * Description:
* This is called from pthread_completejoin if the join * This is called from pthread_completejoin if the join info was
* info was detached or from pthread_join when the last * detached or from pthread_join when the last waiting thread has
* waiting thread has received the thread exit info. * received the thread exit info.
* *
* Or it may never be called if the join info was never * Or it may never be called if the join info was never detached or if
* detached or if no thread ever calls pthread_join. In * no thread ever calls pthread_join. In case, there is a memory leak!
* case, there is a memory leak!
* *
* Assumptions: * Assumptions:
* The caller holds g_join_semaphore * The caller holds g_join_semaphore

View File

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

View File

@ -2,7 +2,7 @@
* sched/pthread_conddestroy.c * sched/pthread_conddestroy.c
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -49,7 +49,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: pthread_cond_destroy * Name: pthread_cond_destroy
* *
* Description: * Description:
* A thread can delete condition variables. * A thread can delete condition variables.

View File

@ -2,7 +2,7 @@
* sched/pthread_condinit.c * sched/pthread_condinit.c
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -50,7 +50,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: pthread_cond_init * Name: pthread_cond_init
* *
* Description: * Description:
* A thread can create condition variables. * A thread can create condition variables.

View File

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

View File

@ -2,7 +2,7 @@
* sched/pthread_condtimedwait.c * sched/pthread_condtimedwait.c
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -74,7 +74,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: pthread_condtimedout * Name: pthread_condtimedout
* *
* Description: * Description:
* This function is called if the timeout elapses before * 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: * Description:
* A thread can perform a timed wait on a condition variable. * 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(). * signal posted by pthread_condtimedout().
*/ */
if (*get_errno_ptr() == EINTR) if (get_errno() == EINTR)
{ {
sdbg("Timedout!\n"); sdbg("Timedout!\n");
ret = ETIMEDOUT; ret = ETIMEDOUT;

View File

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

View File

@ -2,7 +2,7 @@
* sched/pthread_create.c * sched/pthread_create.c
* *
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -89,23 +89,22 @@ static const char g_pthreadname[] = "<pthread>";
* Name: pthread_argsetup * Name: pthread_argsetup
* *
* Description: * Description:
* This functions sets up parameters in the Task Control * This functions sets up parameters in the Task Control Block (TCB) in
* Block (TCB) in preparation for starting a new thread. * preparation for starting a new thread.
* *
* pthread_argsetup() is called from task_init() and task_start() * pthread_argsetup() is called from task_init() and task_start() to create
* to create a new task (with arguments cloned via strdup) * a new task (with arguments cloned via strdup) or pthread_create() which
* or pthread_create() which has one argument passed by * has one argument passed by value (distinguished by the pthread boolean
* value (distinguished by the pthread boolean argument). * argument).
* *
* Input Parameters: * Input Parameters:
* tcb - Address of the new task's TCB * tcb - Address of the new task's TCB
* name - Name of the new task (not used) * name - Name of the new task (not used)
* argv - A pointer to an array of input parameters. * argv - A pointer to an array of input parameters. Up to
* Up to CONFIG_MAX_TASK_ARG parameters may be * CONFIG_MAX_TASK_ARG parameters may be provided. If fewer
* provided. If fewer than CONFIG_MAX_TASK_ARG * than CONFIG_MAX_TASK_ARG parameters are passed, the list
* parameters are passed, the list should be * should be terminated with a NULL argv[] value. If no
* terminated with a NULL argv[] value. * parameters are required, argv may be NULL.
* If no parameters are required, argv may be NULL.
* *
* Return Value: * Return Value:
* None * None
@ -145,7 +144,7 @@ static void pthread_argsetup(FAR _TCB *tcb, pthread_addr_t arg)
} }
/**************************************************************************** /****************************************************************************
* Function: pthread_addjoininfo * Name: pthread_addjoininfo
* *
* Description: * Description:
* Add a join_t to the local data set. * 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->next = pjoin;
} }
g_pthread_tail = pjoin; g_pthread_tail = pjoin;
} }
@ -226,8 +226,8 @@ static void pthread_start(void)
* Name: pthread_create * Name: pthread_create
* *
* Description: * Description:
* This function creates and activates a new thread with a * This function creates and activates a new thread with a specified
* specified attributes. * attributes.
* *
* Input Parameters: * Input Parameters:
* thread * thread
@ -430,5 +430,6 @@ int pthread_create(FAR pthread_t *thread, FAR pthread_attr_t *attr,
sched_free(pjoin); sched_free(pjoin);
return EIO; return EIO;
} }
return OK; return OK;
} }

View File

@ -2,7 +2,7 @@
* sched/pthread_detach.c * sched/pthread_detach.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -73,11 +73,11 @@
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: pthread_detach * Name: pthread_detach
* *
* Description: * Description:
* A thread object may be "detached" to specify that the return * A thread object may be "detached" to specify that the return value
* value and completion status will not be requested. * and completion status will not be requested.
* *
* Parameters: * Parameters:
* thread * thread
@ -129,6 +129,7 @@ int pthread_detach(pthread_t thread)
ret = OK; ret = OK;
} }
(void)pthread_givesemaphore(&g_join_semaphore); (void)pthread_givesemaphore(&g_join_semaphore);
sdbg("Returning %d\n", ret); sdbg("Returning %d\n", ret);

View File

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

View File

@ -2,7 +2,7 @@
* pthread_findjoininfo.c * pthread_findjoininfo.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -38,7 +38,9 @@
************************************************************************/ ************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include "pthread_internal.h" #include "pthread_internal.h"
/************************************************************************ /************************************************************************
@ -66,7 +68,7 @@
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: thread_findjoininfo * Name: thread_findjoininfo
* *
* Description: * Description:
* Find a join_t to the local data set. * Find a join_t to the local data set.

View File

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

View File

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

View File

@ -2,7 +2,7 @@
* sched/pthread_initialize.c * sched/pthread_initialize.c
* *
* Copyright (C) 2007-2010 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * 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: * Description:
* This is an internal OS function called only at power-up * This is an internal OS function called only at power-up boot time.
* boot time.
* *
* Parameters: * Parameters:
* None * None
@ -121,7 +120,7 @@ void pthread_initialize(void)
} }
/**************************************************************************** /****************************************************************************
* Function: pthread_takesemaphore and pthread_givesemaphore * Name: pthread_takesemaphore and pthread_givesemaphore
* *
* Description: * Description:
* Support managed access to the private data sets. * 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. * 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; return ERROR;
} }
} }
@ -163,7 +162,7 @@ int pthread_takesemaphore(sem_t *sem)
{ {
/* NULL semaphore pointer! */ /* NULL semaphore pointer! */
*get_errno_ptr() = EINVAL; set_errno(EINVAL);
return ERROR; return ERROR;
} }
} }
@ -184,7 +183,7 @@ int pthread_givesemaphore(sem_t *sem)
{ {
/* sem_post() reported an error */ /* sem_post() reported an error */
*get_errno_ptr() = EINVAL; set_errno(EINVAL);
return ERROR; return ERROR;
} }
} }
@ -192,7 +191,7 @@ int pthread_givesemaphore(sem_t *sem)
{ {
/* NULL semaphore pointer! */ /* NULL semaphore pointer! */
*get_errno_ptr() = EINVAL; set_errno(EINVAL);
return ERROR; return ERROR;
} }
} }

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
* sched/pthread_keydelete.c * sched/pthread_keydelete.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -70,12 +70,12 @@
************************************************************************/ ************************************************************************/
/************************************************************************ /************************************************************************
* Function: pthread_key_delete * Name: pthread_key_delete
* *
* Description: * Description:
* This POSIX function should delete a thread-specific data * This POSIX function should delete a thread-specific data key
* key previously returned by pthread_key_create(). However, * previously returned by pthread_key_create(). However, this function
* this function does nothing in the present implementation. * does nothing in the present implementation.
* *
* Parameters: * Parameters:
* key = the key to delete * key = the key to delete

View File

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

View File

@ -2,7 +2,7 @@
* sched/pthread_mutexdestroy.c * sched/pthread_mutexdestroy.c
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -44,6 +44,7 @@
#include <sched.h> #include <sched.h>
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include "pthread_internal.h" #include "pthread_internal.h"
/**************************************************************************** /****************************************************************************
@ -71,7 +72,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: pthread_mutex_destroy * Name: pthread_mutex_destroy
* *
* Description: * Description:
* Destroy a mutex. * Destroy a mutex.
@ -121,6 +122,7 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex)
ret = EINVAL; ret = EINVAL;
} }
} }
sched_unlock(); sched_unlock();
} }

View File

@ -2,7 +2,7 @@
* sched/pthread_mutexinit.c * sched/pthread_mutexinit.c
* *
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -71,7 +71,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: pthread_mutex_init * Name: pthread_mutex_init
* *
* Description: * Description:
* Create a mutex * Create a mutex

View File

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

View File

@ -2,7 +2,7 @@
* sched/pthread_mutextrylock.c * sched/pthread_mutextrylock.c
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -45,6 +45,7 @@
#include <sched.h> #include <sched.h>
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include "pthread_internal.h" #include "pthread_internal.h"
/**************************************************************************** /****************************************************************************
@ -72,7 +73,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: pthread_mutex_trylock * Name: pthread_mutex_trylock
* *
* Description: * Description:
* The function pthread_mutex_trylock() is identical to pthread_mutex_lock() * 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? */ /* Was it not available? */
else if (*get_errno_ptr() == EAGAIN) else if (get_errno() == EAGAIN)
{ {
ret = EBUSY; ret = EBUSY;
} }

View File

@ -2,7 +2,7 @@
* sched/pthread_mutexunlock.c * sched/pthread_mutexunlock.c
* *
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -72,7 +72,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: pthread_mutex_unlock * Name: pthread_mutex_unlock
* *
* Description: * Description:
* The pthread_mutex_unlock() function releases the mutex object referenced * 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