Commit Graph

89 Commits

Author SHA1 Message Date
Xiang Xiao 517974787f Rename clock_systime[r|spec] to clock_systime_[ticks|timespec]
follow up the new naming convention:
https://cwiki.apache.org/confluence/display/NUTTX/Naming+of+OS+Internal+Functions
2020-05-10 14:35:50 -06:00
Xiang Xiao b7d922960f Fix nxstyle issue
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-08 07:20:49 -06:00
Xiang Xiao 20a9a62fdf Make compare_timespec public so timer driver could reuse it 2020-02-15 07:17:07 -06:00
Juha Niskanen 15b78abccf Fix typos in comments 2020-02-14 08:50:45 -06:00
Xiang Xiao 6d69439f58 Call xxx_timer_initialize from clock subsystem
Call xxx_timer_initialize from clock subsystem to make timer ready for use as soon as possiblei and revert the workaround:

commit 0863e771a9
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Apr 26 07:24:57 2019 -0600

    Revert "sched/clock/clock_initialize.c:  clock_inittime() needs to be done with CONFIG_SCHED_TICKLESS and clock_initialize should skip clock_inittime() for external RTC case since the RTC isn't ready yet."

    This reverts commit 2bc709d4b9.

    Commit 2bc709d4b9 was intended to handle the case where up_timer_gettime may not start from zero case.  However, this change has the side-effect of breaking every implementation of tickless mode:  After this change the tickless timer structures are used before they are initialized in clock_inittime().  Initialization happens later when up_initialize is called() when arm_timer_initialize().

    Since the tickless mode timer is very special, one solution might be to

    1. Rename xxx_timer_initialize to up_timer_initialize
    2  Move up_timer_initialize to include/nuttx/arch.h
    3.  Call it from clock subsystem instead up_initialize

    Basically, this change make timer initialization almost same as rtc initialization(up_rtc_initialize).

    For now, however, we just need to revert the change.
2020-02-08 07:40:06 -06:00
Juha Niskanen a762c06ed9 Fix typos and some incorrect comments
Author: Alan Carvalho de Assis <acassis@gmail.com>

    Run nxstyle against .c and .h files and fix it

Author: Juha Niskanen <juha.niskanen@haltian.com>

    Fix typos and some incorrect comments
2020-01-20 09:32:36 -03:00
Gregory Nutt 6309165fe0 tools/nxstyle.c: Add automatic detection of line width based on examining
the width of all block comments. Includes a check to assure that all block
comments use the same line width.

Verified against all .c files under /sched.  There were a few cosmetic changes to the coding style under /sched to account to new, correctly detected problems in the /sched files.
2020-01-12 13:07:54 -03:00
Alin Jerpelea a8d63c0cec various fixes (#49)
* libs: libc: math: Fix tanh() math functions
* drivers: mtd: smart: Fix trivial debug message in smartfs
* binfmt: libelf: Fix fd not closed on error
* binfmt: Fix stack memory leak on error
* fs: romfs: Fix private data not free on error
* sched: group: Fix reference after free memory
* sched: clock: Fix clock sync

Fix clock sync when CONFIG_RTC_HIRES is enabled
2020-01-07 09:06:02 -06:00
Xiang Xiao 6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Gregory Nutt d2af57169b tools/nxstyle.c: Fix a rare false alarm that could occur if a variable or function name begins with the sub-string 'union' or 'struct'. misc fixes under fs/ and sched/ from application of current version of nxstyle. 2019-12-01 13:01:16 -06:00
Gregory Nutt b5111d2c38 tools/nxstyle.c: Add logic to detect if there is a blank line following the final right brace. sched/: Applied the modified nxstyle to all C file as a test. 2019-10-24 11:02:42 -06:00
Jens Gräf 7042ec883e Merged in jgraef-linetco/nuttx/fix-32bit-timer-overflow (pull request #1055)
fix early timespec overflow if using 32 bit system timer

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2019-10-21 12:23:02 +00:00
Gregory Nutt f063d7f386 sched/clock/clock.c: Correct a comment as noted in Issue 175. 2019-10-17 12:24:19 -06:00
Juha Niskanen fd462d5ce2 sched/pthread, Documentation: fix pthread_key_delete, pthread_self and pthread_yield documentation and some comments. 2019-10-17 11:04:17 -06:00
Gregory Nutt b912c6fbff sched/clock/clock_timekeeping.c: fix cases in time conversion that must be >= NSEC_PER_SEC, not >NSEC_PER_SEC. Similar to fix of f9e80c4a1e. 2019-08-27 18:18:10 -06:00
Gregory Nutt 0863e771a9 Revert "sched/clock/clock_initialize.c: clock_inittime() needs to be done with CONFIG_SCHED_TICKLESS and clock_initialize should skip clock_inittime() for external RTC case since the RTC isn't ready yet."
This reverts commit 2bc709d4b9.

Commit 2bc709d4b9 was intended to handle the case where up_timer_gettime may not start from zero case.  However, this change has the side-effect of breaking every implementation of tickless mode:  After this change the tickless timer structures are used before they are initialized in clock_inittime().  Initialization happens later when up_initialize is called() when arm_timer_initialize().

Since the tickless mode timer is very special, one solution might be to

1. Rename xxx_timer_initialize to up_timer_initialize
2  Move up_timer_initialize to include/nuttx/arch.h
3.  Call it from clock subsystem instead up_initialize

Basically, this change make timer initialization almost same as rtc initialization(up_rtc_initialize).

For now, however, we just need to revert the change.
2019-04-26 07:24:57 -06:00
Gregory Nutt f914ec6e2b tools/nxstyle.c: Fix logic that detects if an operator is correctly delimited with spaces. sched/: Various changes because sched/ C files were used as Guinea Pigs to test nstyle.c. 2019-03-01 10:50:02 -06:00
Xiang Xiao f337cc1380 sched/clock/ timekeeping: Use clock_basetime() to initialize g_clock_wall_time to get the best initial RTC value and initialize g_clock_last_counter too since the hardware may not start counting from zero. 2018-11-12 07:00:41 -06:00
Xiang Xiao 2bc709d4b9 sched/clock/clock_initialize.c: clock_inittime() needs to be done with CONFIG_SCHED_TICKLESS and clock_initialize should skip clock_inittime() for external RTC case since the RTC isn't ready yet. 2018-11-12 06:55:53 -06:00
Xiang Xiao f0c5c75042 sched/clock/: Don't call up_timer_gettime in clock_gettime and clock_systimer to ensure the return value from them consistent with clock_systimespec 2018-11-12 06:52:56 -06:00
Xiang Xiao 46bd8798c5 ched/clock/: Remove g_monotonic_basetime and g_clock_monotonic_time since we don't need ensure monotonic time start from zero as state here: http://pubs.opengroup.org/onlinepubs/009696899/functions/clock_getres.html 2018-11-12 06:50:37 -06:00
Xiang Xiao 1ef2602933 sched/clock/clock_getres.c: Support CLOCK_MONOTONIC 2018-11-12 06:42:38 -06:00
Xiang Xiao 71ad1993f2 Move clock_timespec_[add|subtract] to include/nuttx/clock.h 2018-08-27 06:04:04 -06:00
Gregory Nutt 8fca244f36 syscall: clock_systimer() is no longer a system call. It has been replaced with the equivalent, standard interface clock() as the system call.
sched/clock:  Move the implementation of clock() from libs/libc/time to sched/clock.  This is necessary because it calls the (now) internal OS function clock_systimer.  clock() is now accessed only via a system call in certain configuratins.
libs/libc/wqueue:  Replace calls to clock_systimer() with calls to the equivalent clock().
2018-06-16 12:50:28 -06:00
Gregory Nutt 8fdbb1e0a4 Elimate use of the non-standard type systime_t and replace it the equivalent, standard type clock_t
Squashed commit of the following:

    sched:  Rename all use of system_t to clock_t.
    syscall:  Rename all use of system_t to clock_t.
    net:  Rename all use of system_t to clock_t.
    libs:  Rename all use of system_t to clock_t.
    fs:  Rename all use of system_t to clock_t.
    drivers:  Rename all use of system_t to clock_t.
    arch:  Rename all use of system_t to clock_t.
    include:  Remove definition of systime_t; rename all use of system_t to clock_t.
2018-06-16 12:16:13 -06:00
Gregory Nutt 06e7533bb0 Update some comments. 2018-03-14 08:17:50 -06:00
Gregory Nutt b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Gregory Nutt e6e7dae05b sched/clock: Fix a recently introduced name collision 2018-03-12 13:36:06 -06:00
Masayuki Ishikawa 7062ca2c03 Merged in masayuki2009/nuttx.nuttx/lc823450_smp_test (pull request #601)
lc823450 smp test

* sched/clock: Replace critical section APIs with spin lock APIs in clock_gettime.c

    This change will improve performance for SMP systems but nothing
    changes for non-SMP systems. (Pls see include/nuttx/irq.h)

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

* sched/sched: Remove unnecessary DEBUGASSERT in sched_removereadytorun.c

    In SMP mode, rtrtcb is not always at the g_readytorun.head.
    This change removes DEBUGASSERT() to avoid this condition.

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2018-02-15 14:18:25 +00:00
Gregory Nutt 7cf88d7dbd Make sure that labeling is used consistently in all function headers. 2018-02-01 10:00:02 -06:00
Gregory Nutt e238c8b090 sched/clock/clock_systimer.c: Change the way that the 64-bit time is sampled. Previously, we disabled interrupts before sampling the 64-bit timer since the uint64_t access is not atomic on most CPUs. However, disabling (local) interrupts does not work in the SMP case. In that case, the timer interrupt will be running on only one of the CPUs; disabling interrupts on a different CPU will provide no protection from timer rollover. To work around this, logic was added that samples 64-bit timer is sampled twice and if 32-bit rollover was detected between samples, then loops until there is no rollover. 2018-01-15 11:05:45 -06:00
Masayuki Ishikawa 0ecef4dbcb clock_systimer: Replace critical section APIs with spinlock APIs. (64bit only)
If SMP=n or SMP=y && SPINLOCK_IRQ=n, this works in the same way as before.
If SMP=y && SPINLOCK_IRQ=y, performance will be improved.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2018-01-15 15:08:11 +09:00
Juha Niskanen cc7af2b0d0 procfs: Fix uptime being close to maximum 32-bit value in certain config 2017-11-10 09:01:39 -06:00
Arjun Hary b274a97840 Miscellaneous fixes from astyle tool. 2017-08-14 17:19:27 -06:00
Jussi Kivilinna e835803166 yslog: use monotonic clock for timestamp when available 2017-04-26 10:38:15 -06:00
Jussi Kivilinna 33ddaa0b10 clock: add testing for 32-bit overflow of 64-bit system timer 2017-04-21 08:55:07 -06:00
Jussi Kivilinna c57d49f420 clock: Add new type ssystime_t for relative 64-bit ticks, change ticks<->time conversion functions to use ssystime_t 2017-04-21 08:51:31 -06:00
Jussi Kivilinna 325ba1a803 clock: add clock_resynchronize and use subseconds RTC
Add clock_resynchronize for better synchronization of CLOCK_REALTIME and CLOCK_MONOTONIC to match RTC after resume from low-power state.

Add up_rtc_getdatetime_with_subseconds under CONFIG_ARCH_HAVE_RTC_SUBSECONDS to allow initializing (and resynchronizing) system clock with subseconds accuracy RTC.
2017-04-21 08:45:57 -06:00
Rajan Gill 0d8e191d69 sched/clock: Correct calculation for the case of Tickless mode with a 32-bit timer. In that case, the calculation was returning millisecond accuracy. That is not good when the timer accuracy is < 1 msec. 2016-11-19 09:55:21 -06:00
Gregory Nutt 123c520db4 Correct time initialization for the case where time is initialized from settings in the .config file. The correct range for month (tm_mon) internally is 0-11, not 1-12 as it is in the .config file. 2016-10-27 08:36:24 -06:00
Gregory Nutt 3404b3cb4a sched/: Review and correct some stylistic inconsistencies 2016-08-07 08:32:11 -06:00
Gregory Nutt 18ce4ff57b sched/: Review and correct some stylistic inconsistencies 2016-08-07 08:25:30 -06:00
Gregory Nutt 94d34bba47 Fix a typo in a Make.defs file 2016-07-28 09:46:28 -06:00
Gregory Nutt 246773faa7 Rename CONFIG_SCHED_TIMEKEEPING to CONFIG_CLOCK_TIMEKEEPING. That is a better compartmentalized name. 2016-07-11 06:54:02 -06:00
Gregory Nutt f47b69e1f0 Add support for adjtime system call 2016-07-10 16:55:32 -06:00
Gregory Nutt c326b6320a Add description of adjtime() from Linux man page 2016-07-10 16:47:06 -06:00
Max Neklyudov 8db29071da timekeeping: initial implementation 2016-07-10 16:14:25 -06:00
Gregory Nutt 13cac3b592 sched/: Change some *err() message to *info() messages if what was a *dbg() message does not indicate and error condition. 2016-06-11 16:42:42 -06:00
Gregory Nutt a1469a3e95 Add CONFIG_DEBUG_ERROR. Change names of *dbg() * *err() 2016-06-11 15:50:49 -06:00
Gregory Nutt 720343612b Remove some empty file section section header comments 2016-02-17 18:05:03 -06:00