diff --git a/sys/Makefile.dep b/sys/Makefile.dep index 34373bce9b..9ba2194c79 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -353,7 +353,7 @@ ifneq (,$(filter pthread,$(USEMODULE))) endif ifneq (,$(filter schedstatistics,$(USEMODULE))) - USEMODULE += xtimer + USEMODULE += ztimer_usec USEMODULE += sched_cb endif diff --git a/sys/include/schedstatistics.h b/sys/include/schedstatistics.h index 4e6352bf35..7d10735273 100644 --- a/sys/include/schedstatistics.h +++ b/sys/include/schedstatistics.h @@ -42,7 +42,7 @@ typedef struct { uint32_t laststart; /**< Time stamp of the last time this thread was scheduled to run */ unsigned int schedules; /**< How often the thread was scheduled to run */ - uint64_t runtime_ticks; /**< The total runtime of this thread in ticks */ + uint64_t runtime_us; /**< The total runtime of this thread in microseconds */ } schedstat_t; /** diff --git a/sys/ps/ps.c b/sys/ps/ps.c index 6ebfc0765a..5dbaae1b78 100644 --- a/sys/ps/ps.c +++ b/sys/ps/ps.c @@ -26,7 +26,7 @@ #ifdef MODULE_SCHEDSTATISTICS #include "schedstatistics.h" -#include "xtimer.h" +#include "ztimer.h" #endif #ifdef MODULE_TLSF_MALLOC @@ -77,12 +77,12 @@ void ps(void) #ifdef MODULE_SCHEDSTATISTICS uint64_t rt_sum = 0; if (!IS_ACTIVE(MODULE_CORE_IDLE_THREAD)) { - rt_sum = sched_pidlist[KERNEL_PID_UNDEF].runtime_ticks; + rt_sum = sched_pidlist[KERNEL_PID_UNDEF].runtime_us; } for (kernel_pid_t i = KERNEL_PID_FIRST; i <= KERNEL_PID_LAST; i++) { thread_t *p = thread_get(i); if (p != NULL) { - rt_sum += sched_pidlist[i].runtime_ticks; + rt_sum += sched_pidlist[i].runtime_us; } } #endif /* MODULE_SCHEDSTATISTICS */ @@ -103,10 +103,10 @@ void ps(void) #endif #ifdef MODULE_SCHEDSTATISTICS /* multiply with 100 for percentage and to avoid floats/doubles */ - uint64_t runtime_ticks = sched_pidlist[i].runtime_ticks * 100; - xtimer_ticks32_t xtimer_ticks = {sched_pidlist[i].runtime_ticks}; - unsigned runtime_major = runtime_ticks / rt_sum; - unsigned runtime_minor = ((runtime_ticks % rt_sum) * 1000) / rt_sum; + uint64_t runtime_us = sched_pidlist[i].runtime_us * 100; + uint32_t ztimer_us = {sched_pidlist[i].runtime_us}; + unsigned runtime_major = runtime_us / rt_sum; + unsigned runtime_minor = ((runtime_us % rt_sum) * 1000) / rt_sum; unsigned switches = sched_pidlist[i].schedules; #endif printf("\t%3" PRIkernel_pid @@ -131,7 +131,7 @@ void ps(void) thread_get_stackstart(p), thread_get_sp(p) #endif #ifdef MODULE_SCHEDSTATISTICS - , runtime_major, runtime_minor, switches, xtimer_usec_from_ticks(xtimer_ticks) + , runtime_major, runtime_minor, switches, ztimer_us #endif ); } diff --git a/sys/schedstatistics/Kconfig b/sys/schedstatistics/Kconfig index e991199219..22bf74a0d6 100644 --- a/sys/schedstatistics/Kconfig +++ b/sys/schedstatistics/Kconfig @@ -7,6 +7,6 @@ config MODULE_SCHEDSTATISTICS bool "Scheduler statistics support" - depends on MODULE_XTIMER + select ZTIMER_USEC depends on TEST_KCONFIG select MODULE_SCHED_CB diff --git a/sys/schedstatistics/schedstatistics.c b/sys/schedstatistics/schedstatistics.c index 0d23881bf1..892466f4b1 100644 --- a/sys/schedstatistics/schedstatistics.c +++ b/sys/schedstatistics/schedstatistics.c @@ -24,7 +24,7 @@ #include "sched.h" #include "schedstatistics.h" #include "thread.h" -#include "xtimer.h" +#include "ztimer.h" /** * When core_idle_thread is not active, the KERNEL_PID_UNDEF is used to track @@ -34,12 +34,12 @@ schedstat_t sched_pidlist[KERNEL_PID_LAST + 1]; void sched_statistics_cb(kernel_pid_t active_thread, kernel_pid_t next_thread) { - uint32_t now = xtimer_now().ticks32; + uint32_t now = ztimer_now(ZTIMER_USEC); /* Update active thread stats */ if (!IS_USED(MODULE_CORE_IDLE_THREAD) || active_thread != KERNEL_PID_UNDEF) { schedstat_t *active_stat = &sched_pidlist[active_thread]; - active_stat->runtime_ticks += now - active_stat->laststart; + active_stat->runtime_us += now - active_stat->laststart; } /* Update next_thread stats */ @@ -55,7 +55,7 @@ void init_schedstatistics(void) /* Init laststart for the thread starting schedstatistics since the callback wasn't registered when it was first scheduled */ schedstat_t *active_stat = &sched_pidlist[thread_getpid()]; - active_stat->laststart = xtimer_now().ticks32; + active_stat->laststart = ztimer_now(ZTIMER_USEC); active_stat->schedules = 1; sched_register_cb(sched_statistics_cb); } diff --git a/tests/periph_spi/Makefile b/tests/periph_spi/Makefile index b3b522f839..db32addf76 100644 --- a/tests/periph_spi/Makefile +++ b/tests/periph_spi/Makefile @@ -10,7 +10,8 @@ ifeq (,$(filter $(BOARD),$(LOW_MEMORY_BOARDS))) FEATURES_OPTIONAL += periph_spi_reconfigure endif -USEMODULE += xtimer +USEMODULE += ztimer_usec +USEMODULE += ztimer_sec USEMODULE += shell USEMODULE += shell_commands USEMODULE += schedstatistics diff --git a/tests/periph_spi/Makefile.ci b/tests/periph_spi/Makefile.ci index 966b237618..c9ac296b6c 100644 --- a/tests/periph_spi/Makefile.ci +++ b/tests/periph_spi/Makefile.ci @@ -6,5 +6,6 @@ BOARD_INSUFFICIENT_MEMORY := \ atmega328p \ atmega328p-xplained-mini \ nucleo-l011k4 \ + samd10-xmini \ stm32f030f4-demo \ # diff --git a/tests/periph_spi/app.config.test b/tests/periph_spi/app.config.test index 81f400d92b..c7079a1a8b 100644 --- a/tests/periph_spi/app.config.test +++ b/tests/periph_spi/app.config.test @@ -5,4 +5,6 @@ CONFIG_MODULE_PERIPH_SPI=y CONFIG_MODULE_SHELL=y CONFIG_MODULE_SHELL_COMMANDS=y CONFIG_MODULE_SCHEDSTATISTICS=y -CONFIG_MODULE_XTIMER=y +CONFIG_MODULE_ZTIMER=y +CONFIG_MODULE_ZTIMER_SEC=y +CONFIG_ZTIMER_USEC=y diff --git a/tests/periph_spi/main.c b/tests/periph_spi/main.c index 8ba39202e5..557fef2334 100644 --- a/tests/periph_spi/main.c +++ b/tests/periph_spi/main.c @@ -24,7 +24,7 @@ #include #include -#include "xtimer.h" +#include "ztimer.h" #include "shell.h" #include "periph/spi.h" #include "schedstatistics.h" @@ -85,18 +85,15 @@ static void _sched_statistics_trigger(void) sched_statistics_cb(thread_getpid(), thread_getpid()); } -static xtimer_ticks32_t _sched_ticks(void) +static uint32_t _sched_us(void) { _sched_statistics_trigger(); - xtimer_ticks32_t runtime_ticks = { - .ticks32 = sched_pidlist[thread_getpid()].runtime_ticks - }; - return runtime_ticks; + return sched_pidlist[thread_getpid()].runtime_us; } -static uint32_t _xtimer_diff_usec(xtimer_ticks32_t stop, xtimer_ticks32_t start) +static uint32_t _ztimer_diff_usec(uint32_t stop, uint32_t start) { - return xtimer_usec_from_ticks(xtimer_diff(stop, start)); + return stop - start; } void print_bytes(char* title, uint8_t* data, size_t len) @@ -266,7 +263,7 @@ int cmd_bench(int argc, char **argv) (void)argv; uint32_t start, stop; - xtimer_ticks32_t sched_start, sched_stop; + uint32_t sched_start, sched_stop; uint32_t sched_diff_us; uint32_t sum = 0; uint32_t sched_sum = 0; @@ -288,231 +285,231 @@ int cmd_bench(int argc, char **argv) puts("### Test\t\t\t\tTransfer time\tuser time\n"); /* 1 - write 1000 times 1 byte */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { in = spi_transfer_byte(spiconf.dev, spiconf.cs, false, out); (void)in; } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf(" 1 - write %i times %i byte:", BENCH_REDOS, 1); printf("\t\t\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 2 - write 1000 times 2 byte */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_bytes(spiconf.dev, spiconf.cs, false, bench_wbuf, NULL, BENCH_SMALL); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf(" 2 - write %i times %i byte:", BENCH_REDOS, BENCH_SMALL); printf("\t\t\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 3 - write 1000 times 100 byte */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_bytes(spiconf.dev, spiconf.cs, false, bench_wbuf, NULL, BENCH_LARGE); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf(" 3 - write %i times %i byte:", BENCH_REDOS, BENCH_LARGE); printf("\t\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 4 - write 1000 times 1 byte to register */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { in = spi_transfer_reg(spiconf.dev, spiconf.cs, BENCH_REGADDR, out); (void)in; } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf(" 4 - write %i times %i byte to register:", BENCH_REDOS, 1); printf("\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 5 - write 1000 times 2 byte to register */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_regs(spiconf.dev, spiconf.cs, BENCH_REGADDR, bench_wbuf, NULL, BENCH_SMALL); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf(" 5 - write %i times %i byte to register:", BENCH_REDOS, BENCH_SMALL); printf("\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 6 - write 1000 times 100 byte to register */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_regs(spiconf.dev, spiconf.cs, BENCH_REGADDR, bench_wbuf, NULL, BENCH_LARGE); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf(" 6 - write %i times %i byte to register:", BENCH_REDOS, BENCH_LARGE); printf("\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 7 - read 1000 times 2 byte */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_bytes(spiconf.dev, spiconf.cs, false, NULL, bench_rbuf, BENCH_SMALL); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf(" 7 - read %i times %i byte:", BENCH_REDOS, BENCH_SMALL); printf("\t\t\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 8 - read 1000 times 100 byte */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_bytes(spiconf.dev, spiconf.cs, false, NULL, bench_rbuf, BENCH_LARGE); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf(" 8 - read %i times %i byte:", BENCH_REDOS, BENCH_LARGE); printf("\t\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 9 - read 1000 times 2 byte from register */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_regs(spiconf.dev, spiconf.cs, BENCH_REGADDR, NULL, bench_rbuf, BENCH_SMALL); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf(" 9 - read %i times %i byte from register:", BENCH_REDOS, BENCH_SMALL); printf("\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 10 - read 1000 times 100 byte from register */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_regs(spiconf.dev, spiconf.cs, BENCH_REGADDR, NULL, bench_rbuf, BENCH_LARGE); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf("10 - read %i times %i byte from register:", BENCH_REDOS, BENCH_LARGE); printf("\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 11 - transfer 1000 times 2 byte */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_bytes(spiconf.dev, spiconf.cs, false, bench_wbuf, bench_rbuf, BENCH_SMALL); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf("11 - transfer %i times %i byte:", BENCH_REDOS, BENCH_SMALL); printf("\t\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 12 - transfer 1000 times 100 byte */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_bytes(spiconf.dev, spiconf.cs, false, bench_wbuf, bench_rbuf, BENCH_LARGE); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf("12 - transfer %i times %i byte:", BENCH_REDOS, BENCH_LARGE); printf("\t\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 13 - transfer 1000 times 2 byte from/to register */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_regs(spiconf.dev, spiconf.cs, BENCH_REGADDR, bench_wbuf, bench_rbuf, BENCH_SMALL); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf("13 - transfer %i times %i byte to register:", BENCH_REDOS, BENCH_SMALL); printf("\t%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 14 - transfer 1000 times 100 byte from/to register */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_transfer_regs(spiconf.dev, spiconf.cs, BENCH_REGADDR, bench_wbuf, bench_rbuf, BENCH_LARGE); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf("14 - transfer %i times %i byte to register:", BENCH_REDOS, BENCH_LARGE); printf("%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; /* 15 - release & acquire the bus 1000 times */ - sched_start = _sched_ticks(); - start = xtimer_now_usec(); + sched_start = _sched_us(); + start = ztimer_now(ZTIMER_USEC); for (int i = 0; i < BENCH_REDOS; i++) { spi_release(spiconf.dev); spi_acquire(spiconf.dev, spiconf.cs, spiconf.mode, spiconf.clk); } - stop = xtimer_now_usec(); - sched_stop = _sched_ticks(); - sched_diff_us = _xtimer_diff_usec(sched_stop, sched_start); + stop = ztimer_now(ZTIMER_USEC); + sched_stop = _sched_us(); + sched_diff_us = _ztimer_diff_usec(sched_stop, sched_start); printf("15 - acquire/release %i times:\t\t", BENCH_REDOS); printf("%"PRIu32"\t%"PRIu32"\n", (stop - start), sched_diff_us); sum += (stop - start); sched_sum += sched_diff_us; - xtimer_sleep(1); + ztimer_sleep(ZTIMER_SEC, 1); printf("-- - SUM:\t\t\t\t\t%"PRIu32"\t%"PRIu32"\n", sum, sched_sum); @@ -546,19 +543,19 @@ int cmd_spi_gpio(int argc, char **argv) gpio_init(miso_pin, GPIO_OUT); gpio_init(mosi_pin, GPIO_OUT); - xtimer_sleep(1); + ztimer_sleep(ZTIMER_SEC, 1); printf("Command: gpio_set()\n"); gpio_set(miso_pin); gpio_set(mosi_pin); - xtimer_sleep(1); + ztimer_sleep(ZTIMER_SEC, 1); printf("Command: gpio_clear()\n"); gpio_clear(miso_pin); gpio_clear(mosi_pin); - xtimer_sleep(1); + ztimer_sleep(ZTIMER_SEC, 1); printf("Command: spi_init_pins(%i)\n", dev); spi_init_pins(dev); diff --git a/tests/periph_spi_dma/app.config.test b/tests/periph_spi_dma/app.config.test index 29981de4c5..e00e33a81b 100644 --- a/tests/periph_spi_dma/app.config.test +++ b/tests/periph_spi_dma/app.config.test @@ -6,4 +6,6 @@ CONFIG_MODULE_PERIPH_SPI=y CONFIG_MODULE_SHELL=y CONFIG_MODULE_SHELL_COMMANDS=y CONFIG_MODULE_SCHEDSTATISTICS=y -CONFIG_MODULE_XTIMER=y +CONFIG_MODULE_ZTIMER=y +CONFIG_MODULE_ZTIMER_SEC=y +CONFIG_ZTIMER_USEC=y diff --git a/tests/ps_schedstatistics/Makefile b/tests/ps_schedstatistics/Makefile index 071a344950..6dbf2ff4a7 100644 --- a/tests/ps_schedstatistics/Makefile +++ b/tests/ps_schedstatistics/Makefile @@ -5,6 +5,8 @@ USEMODULE += shell_commands USEMODULE += ps USEMODULE += schedstatistics USEMODULE += printf_float +USEMODULE += ztimer_usec +USEMODULE += ztimer_sec # For this test we don't want to use the shell version of # test_utils_interactive_sync, since we want to synchronize before diff --git a/tests/ps_schedstatistics/main.c b/tests/ps_schedstatistics/main.c index c54b110123..d360da8672 100644 --- a/tests/ps_schedstatistics/main.c +++ b/tests/ps_schedstatistics/main.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include "test_utils/interactive_sync.h" @@ -44,10 +44,11 @@ static void *_thread_fn(void *arg) msg_t m1, m2; msg_receive(&m1); /* generate different loads per thead */ - for (int i = 0; i < (10 * (next + 1)); ++i) { - _xtimer_now64(); + for (int i = 0; i < (100 * (next + 1)); ++i) { + volatile uint32_t now = ztimer_now(ZTIMER_USEC); + (void)now; } - xtimer_usleep(XTIMER_BACKOFF * 10); + ztimer_sleep(ZTIMER_USEC, 100); /* Sleep for a bit */ msg_send(&m2, pids[next]); } @@ -65,7 +66,7 @@ int main(void) _thread_fn, (void *)i, "thread"); } /* sleep for a second, so that `ps` shows some % on idle at the beginning */ - xtimer_sleep(1); + ztimer_sleep(ZTIMER_SEC, 1); msg_t msg; msg_send(&msg, pids[0]);