zephyr/kernel
Andy Ross 3e729b2b1c kernel/timer: Correctly clamp period argument
The period argument of a k_timer needs an offset of one tick from the
value computed in user code (because periods get reset from within the
ISR, see the comment above this code for an explanation).  When the
computed tick value was 1, it would become 0.  This is actually
perfectly correct as a k_timeout_t to be passed to z_add_timeout().

BUT: to k_timer's API, K_NO_WAIT means "never" (i.e. the same as
K_FOREVER) and not "as soon as possible", so the period timer would
not be reset.  This is sort of a wart, but it's the way the API has
been specified forever.

The upshot is that for the case of calling k_timer_start() with a
minimal period argument (i.e. one that produces "one tick"), the
period would be ignored and the timer would act like a one shot.  Fix
the clamp so it can't produce K_NO_WAIT.

This also adds a filter for absolute timeouts, which (while that's
sort of a pathological usage) were getting that one tick offset when
it wasn't appropriate.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-04-24 16:38:33 +02:00
..
include kernel: reduce scope of z_new_thread_init() 2020-04-21 18:45:45 -04:00
atomic_c.c kernel: Add k_heap synchronized memory allocator 2020-04-14 10:05:55 -07:00
CMakeLists.txt kernel: Add k_mem_pool compatibility layer on top of k_heap 2020-04-14 10:05:55 -07:00
compiler_stack_protect.c
device.c
errno.c
fatal.c
futex.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
idle.c
init.c drivers: entropy: replace CONFIG_ENTROPY_NAME with DT macro 2020-04-13 09:14:21 -05:00
Kconfig kernel: Make the k_heap backend default for k_mem_pool 2020-04-14 10:05:55 -07:00
Kconfig.power_mgmt
kheap.c kernel: Add k_mem_pool compatibility layer on top of k_heap 2020-04-14 10:05:55 -07:00
mailbox.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
mem_domain.c
mem_slab.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
mempool_sys.c kernel: Refactor k_mem_pool APIs into a base and derived level 2020-04-14 10:05:55 -07:00
mempool.c kernel: Refactor k_mem_pool APIs into a base and derived level 2020-04-14 10:05:55 -07:00
msg_q.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
mutex.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
pipes.c kernel: fix runtime initialization of k_pipe object 2020-04-21 11:19:29 +02:00
poll.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
queue.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
sched.c kernel/timeout: Enable 64 bit timeout precision 2020-03-31 19:40:47 -04:00
sem.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
smp.c
stack.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
system_work_q.c
thread_abort.c
thread.c kernel: add Z_STACK_PTR_ALIGN ARCH_STACK_PTR_ALIGN 2020-04-21 18:45:45 -04:00
timeout.c kernel/timeout: Check for K_FOREVER in z_add_timeout() 2020-04-22 11:10:17 -07:00
timer.c kernel/timer: Correctly clamp period argument 2020-04-24 16:38:33 +02:00
userspace_handler.c
userspace.c
version.c
work_q.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00