kernel: timer: Adding support to CONFIG_MULTITHREADING=n
Updated timer to not touch thread/scheduler code when multithreading is off. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
7dcff6ecfe
commit
dd0715c770
1 changed files with 37 additions and 5 deletions
|
@ -66,6 +66,10 @@ void z_timer_expiration_handler(struct _timeout *t)
|
|||
timer->expiry_fn(timer);
|
||||
}
|
||||
|
||||
if (!IS_ENABLED(CONFIG_MULTITHREADING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
thread = z_waitq_head(&timer->wait_q);
|
||||
|
||||
if (thread == NULL) {
|
||||
|
@ -96,7 +100,10 @@ void k_timer_init(struct k_timer *timer,
|
|||
timer->stop_fn = stop_fn;
|
||||
timer->status = 0U;
|
||||
|
||||
z_waitq_init(&timer->wait_q);
|
||||
if (IS_ENABLED(CONFIG_MULTITHREADING)) {
|
||||
z_waitq_init(&timer->wait_q);
|
||||
}
|
||||
|
||||
z_init_timeout(&timer->timeout);
|
||||
SYS_TRACING_OBJ_INIT(k_timer, timer);
|
||||
|
||||
|
@ -165,11 +172,13 @@ void z_impl_k_timer_stop(struct k_timer *timer)
|
|||
timer->stop_fn(timer);
|
||||
}
|
||||
|
||||
struct k_thread *pending_thread = z_unpend1_no_timeout(&timer->wait_q);
|
||||
if (IS_ENABLED(CONFIG_MULTITHREADING)) {
|
||||
struct k_thread *pending_thread = z_unpend1_no_timeout(&timer->wait_q);
|
||||
|
||||
if (pending_thread != NULL) {
|
||||
z_ready_thread(pending_thread);
|
||||
z_reschedule_unlocked();
|
||||
if (pending_thread != NULL) {
|
||||
z_ready_thread(pending_thread);
|
||||
z_reschedule_unlocked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,6 +215,29 @@ uint32_t z_impl_k_timer_status_sync(struct k_timer *timer)
|
|||
{
|
||||
__ASSERT(!arch_is_in_isr(), "");
|
||||
|
||||
if (!IS_ENABLED(CONFIG_MULTITHREADING)) {
|
||||
uint32_t result;
|
||||
|
||||
do {
|
||||
k_spinlock_key_t key = k_spin_lock(&lock);
|
||||
|
||||
if (!z_is_inactive_timeout(&timer->timeout)) {
|
||||
result = *(volatile uint32_t *)&timer->status;
|
||||
timer->status = 0U;
|
||||
k_spin_unlock(&lock, key);
|
||||
if (result > 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
result = timer->status;
|
||||
k_spin_unlock(&lock, key);
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
k_spinlock_key_t key = k_spin_lock(&lock);
|
||||
uint32_t result = timer->status;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue