-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: move nothread support to own file
Do not build threading support when CONFIG_MULTITHREADING=n is set and move needed calls to a new file with the changes needed instead of the ifdef party in sched.c Signed-off-by: Anas Nashif <[email protected]>
- Loading branch information
Showing
5 changed files
with
62 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (C) 2024 Intel Corporation | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <kernel_internal.h> | ||
|
||
/* We are not building thread.c when MULTITHREADING=n, so we | ||
* need to provide a few stubs here. | ||
*/ | ||
bool k_is_in_isr(void) | ||
{ | ||
return arch_is_in_isr(); | ||
} | ||
|
||
/* This is a fallback implementation of k_sleep() for when multi-threading is | ||
* disabled. The main implementation is in sched.c. | ||
*/ | ||
int32_t z_impl_k_sleep(k_timeout_t timeout) | ||
{ | ||
k_ticks_t ticks; | ||
uint32_t expected_wakeup_ticks; | ||
|
||
__ASSERT(!arch_is_in_isr(), ""); | ||
|
||
SYS_PORT_TRACING_FUNC_ENTER(k_thread, sleep, timeout); | ||
|
||
/* in case of K_FOREVER, we suspend */ | ||
if (K_TIMEOUT_EQ(timeout, K_FOREVER)) { | ||
/* In Single Thread, just wait for an interrupt saving power */ | ||
k_cpu_idle(); | ||
SYS_PORT_TRACING_FUNC_EXIT(k_thread, sleep, timeout, (int32_t) K_TICKS_FOREVER); | ||
|
||
return (int32_t) K_TICKS_FOREVER; | ||
} | ||
|
||
ticks = timeout.ticks; | ||
if (Z_TICK_ABS(ticks) <= 0) { | ||
expected_wakeup_ticks = ticks + sys_clock_tick_get_32(); | ||
} else { | ||
expected_wakeup_ticks = Z_TICK_ABS(ticks); | ||
} | ||
/* busy wait to be time coherent since subsystems may depend on it */ | ||
z_impl_k_busy_wait(k_ticks_to_us_ceil32(expected_wakeup_ticks)); | ||
|
||
int32_t ret = k_ticks_to_ms_ceil64(0); | ||
|
||
SYS_PORT_TRACING_FUNC_EXIT(k_thread, sleep, timeout, ret); | ||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters