Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: move scheduler defines #15481

Merged
merged 11 commits into from
Nov 23, 2020
45 changes: 0 additions & 45 deletions core/include/kernel_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,51 +49,6 @@ typedef signed ssize_t;
extern "C" {
#endif

/**
* @def MAXTHREADS
* @brief The maximum number of threads to be scheduled
*/
#ifndef MAXTHREADS
#define MAXTHREADS 32
#endif

/**
* Canonical identifier for an invalid PID.
*/
#define KERNEL_PID_UNDEF 0

/**
* The first valid PID (inclusive).
*/
#define KERNEL_PID_FIRST (KERNEL_PID_UNDEF + 1)

/**
* The last valid PID (inclusive).
*/
#define KERNEL_PID_LAST (KERNEL_PID_FIRST + MAXTHREADS - 1)

/**
* Macro for printing formatter
*/
#define PRIkernel_pid PRIi16

/**
* Unique process identifier
*/
typedef int16_t kernel_pid_t;

/**
* @brief Determine if the given pid is valid
*
* @param[in] pid The pid to check
*
* @return true if the pid is valid, false otherwise
*/
static inline int pid_is_valid(kernel_pid_t pid)
{
return ((KERNEL_PID_FIRST <= pid) && (pid <= KERNEL_PID_LAST));
}

#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion core/include/msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@

#include <stdint.h>
#include <stdbool.h>
#include "kernel_types.h"

#include "sched.h"

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion core/include/rmutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#endif

#include "mutex.h"
#include "kernel_types.h"
#include "sched.h"

#ifdef __cplusplus
extern "C" {
Expand Down
47 changes: 46 additions & 1 deletion core/include/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,60 @@
#define SCHED_H

#include <stddef.h>
#include <inttypes.h>

#include "kernel_defines.h"
#include "kernel_types.h"
#include "native_sched.h"
#include "clist.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @def MAXTHREADS
* @brief The maximum number of threads to be scheduled
*/
#ifndef MAXTHREADS
#define MAXTHREADS 32
#endif

/**
* Canonical identifier for an invalid PID.
*/
#define KERNEL_PID_UNDEF 0

/**
* The first valid PID (inclusive).
*/
#define KERNEL_PID_FIRST (KERNEL_PID_UNDEF + 1)

/**
* The last valid PID (inclusive).
*/
#define KERNEL_PID_LAST (KERNEL_PID_FIRST + MAXTHREADS - 1)

/**
* Macro for printing formatter
*/
#define PRIkernel_pid PRIi16

/**
* Unique process identifier
*/
typedef int16_t kernel_pid_t;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What meaning do negative pids have?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a KERNEL_PID_UNDEF that's -1? Anyhow, this is all copied and otherwise unchanged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just moved KERNEL_PID_UNDEF 😉

It's 0 - so that's why I'm wondering what negative PIDs mean.


/**
* @brief Determine if the given pid is valid
*
* @param[in] pid The pid to check
*
* @return true if the pid is valid, false otherwise
*/
static inline int pid_is_valid(kernel_pid_t pid)
{
return ((KERNEL_PID_FIRST <= pid) && (pid <= KERNEL_PID_LAST));
}
/**
* @brief forward declaration for thread_t, defined in thread.h
*/
Expand Down
2 changes: 2 additions & 0 deletions cpu/esp_common/include/freertos/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#ifndef DOXYGEN

#include <limits.h> /* for INT_MAX */

#include "thread.h"
#include "freertos/FreeRTOS.h"

Expand Down
2 changes: 2 additions & 0 deletions cpu/stm32/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#ifndef PERIPH_CPU_H
#define PERIPH_CPU_H

#include <limits.h>

#include "cpu.h"
#include "macros/units.h"

Expand Down
2 changes: 1 addition & 1 deletion drivers/include/pir.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef PIR_H
#define PIR_H

#include "kernel_types.h"
#include "sched.h"
#include "periph/gpio.h"
#include "stdbool.h"

Expand Down
2 changes: 1 addition & 1 deletion pkg/lwip/include/arch/sys_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <stdint.h>

#include "cib.h"
#include "kernel_types.h"
#include "sched.h"
#include "mbox.h"
#include "mutex.h"
#include "random.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From 51d973f2a0a04a716af8260c62fb5045356a30a5 Mon Sep 17 00:00:00 2001
From: Kaspar Schleiser <[email protected]>
Date: Mon, 23 Nov 2020 12:44:54 +0100
Subject: [PATCH] adapt to moved kernel_pid_t location

---
face-table.h | 2 +-
ndn.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/face-table.h b/face-table.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do a PR to https://github.com/named-data-iot/ndn-riot as a follow-up?
It feels a bit silly to carry downstream patches to a project that targets RIOT exclusively.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably do the same for the other two patches in pkg/ndn-riot/patches, those also stem from previous API changes in RIOT

index 28b44a5c02..fb0c39b083 100644
--- a/face-table.h
+++ b/face-table.h
@@ -20,7 +20,7 @@
#ifndef NDN_FACE_TABLE_H_
#define NDN_FACE_TABLE_H_

-#include <kernel_types.h>
+#include "sched.h"

#ifdef __cplusplus
extern "C" {
diff --git a/ndn.h b/ndn.h
index d8d148c7f7..47d2032301 100644
--- a/ndn.h
+++ b/ndn.h
@@ -20,7 +20,7 @@
#ifndef NDN_H_
#define NDN_H_

-#include <kernel_types.h>
+#include "sched.h"

#ifdef __cplusplus
extern "C" {
--
2.29.2

2 changes: 1 addition & 1 deletion pkg/uwb-core/include/dpl/dpl_tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "dpl_types.h"

#include "kernel_types.h"
#include "sched.h"
#include "thread.h"

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion sys/include/can/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C" {
#endif

#include "can/candev.h"
#include "kernel_types.h"
#include "sched.h"

#ifdef MODULE_CAN_PM
#include "xtimer.h"
Expand Down
2 changes: 1 addition & 1 deletion sys/include/can/raw.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
extern "C" {
#endif

#include "kernel_types.h"
#include "sched.h"
#include "can/can.h"
#include "can/common.h"
#include "can/device.h"
Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/fib.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <stdint.h>

#include "net/fib/table.h"
#include "kernel_types.h"
#include "sched.h"

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/fib/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <stdint.h>

#include "kernel_types.h"
#include "sched.h"
#include "universal_address.h"
#include "mutex.h"

Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/gnrc/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
#ifndef NET_GNRC_IPV6_H
#define NET_GNRC_IPV6_H

#include "kernel_types.h"
#include "sched.h"
#include "net/gnrc.h"
#include "thread.h"

Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/gnrc/netif.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <stdint.h>
#include <stdbool.h>

#include "kernel_types.h"
#include "sched.h"
#include "msg.h"
#ifdef MODULE_GNRC_NETIF_BUS
#include "msg_bus.h"
Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/gnrc/netreg.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <inttypes.h>

#include "kernel_types.h"
#include "sched.h"
#include "net/gnrc/nettype.h"
#include "net/gnrc/pkt.h"

Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/gnrc/pkt.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <inttypes.h>
#include <stdlib.h>

#include "kernel_types.h"
#include "sched.h"
#include "net/gnrc/nettype.h"
#include "list.h"

Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/gnrc/pktdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef NET_GNRC_PKTDUMP_H
#define NET_GNRC_PKTDUMP_H

#include "kernel_types.h"
#include "sched.h"

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/gnrc/sixlowpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@

#include <stdbool.h>

#include "kernel_types.h"
#include "sched.h"

#include "net/gnrc/sixlowpan/config.h"
#include "net/gnrc/sixlowpan/frag.h"
Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/gnrc/sixlowpan/frag/fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ gnrc_sixlowpan_frag_fb_t *gnrc_sixlowpan_frag_fb_get_by_tag(uint16_t tag);
uint16_t gnrc_sixlowpan_frag_fb_next_tag(void);

#if defined(TEST_SUITES) && !defined(DOXYGEN)
#include "kernel_types.h"
#include "sched.h"

/* can't include `net/sixlowpan.h` as this would create a cyclical include */
extern kernel_pid_t gnrc_sixlowpan_get_pid(void);
Expand Down
2 changes: 1 addition & 1 deletion sys/include/usb/usbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "clist.h"
#include "event.h"
#include "kernel_types.h"
#include "sched.h"
#include "kernel_defines.h"
#include "msg.h"
#include "thread.h"
Expand Down
2 changes: 1 addition & 1 deletion sys/include/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#include <sys/types.h> /* for off_t etc. */
#include <sys/statvfs.h> /* for struct statvfs */

#include "kernel_types.h"
#include "sched.h"
#include "clist.h"

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion sys/include/xtimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "msg.h"
#endif /* MODULE_CORE_MSG */
#include "mutex.h"
#include "kernel_types.h"
#include "sched.h"
#include "rmutex.h"

#ifdef MODULE_ZTIMER_XTIMER_COMPAT
Expand Down
2 changes: 1 addition & 1 deletion sys/include/ztimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@

#include <stdint.h>

#include "kernel_types.h"
#include "sched.h"
#include "msg.h"

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion sys/include/ztimer/xtimer_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "msg.h"
#endif /* MODULE_CORE_MSG */
#include "mutex.h"
#include "kernel_types.h"
#include "sched.h"

#include "ztimer.h"

Expand Down
2 changes: 1 addition & 1 deletion sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "byteorder.h"
#include "cpu_conf.h"
#include "kernel_types.h"
#include "sched.h"
#include "net/gnrc.h"
#include "net/gnrc/icmpv6.h"
#include "net/gnrc/sixlowpan/ctx.h"
Expand Down
2 changes: 1 addition & 1 deletion sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "bitfield.h"
#include "evtimer_msg.h"
#include "kernel_types.h"
#include "sched.h"
#include "mutex.h"
#include "net/eui64.h"
#include "net/ipv6/addr.h"
Expand Down
2 changes: 1 addition & 1 deletion sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <assert.h>

#include "kernel_types.h"
#include "sched.h"
#include "net/gnrc.h"
#include "thread.h"
#include "utlist.h"
Expand Down
2 changes: 1 addition & 1 deletion sys/ps/ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "thread.h"
#include "sched.h"
#include "thread.h"
#include "kernel_types.h"
#include "sched.h"

#ifdef MODULE_SCHEDSTATISTICS
#include "schedstatistics.h"
Expand Down
Loading