1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-13 08:40:26 +01:00

Merge pull request #19998 from fabian18/gnrc_static_messge_queues

gnrc: make message queues static
This commit is contained in:
Marian Buschsieweke 2023-12-04 11:21:08 +00:00 committed by GitHub
commit d252eb7395
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 13 deletions

View File

@ -46,7 +46,8 @@ static int queue_msg(thread_t *target, const msg_t *m)
int n = cib_put(&(target->msg_queue));
if (n < 0) {
DEBUG("queue_msg(): message queue is full (or there is none)\n");
DEBUG("queue_msg(): message queue of thread %" PRIkernel_pid
" is full (or there is none)\n", target->pid);
return 0;
}

View File

@ -122,9 +122,13 @@ extern "C" {
*/
/**
* @brief Default stack size to use for the IPv6 thread
*
* @note The message queue was previously allocated on the stack.
* The default number of messages is 2³.
* Given sizeof(msg_t) == 8, the stack size is reduced by 64 bytes.
*/
#ifndef GNRC_IPV6_STACK_SIZE
#define GNRC_IPV6_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
#define GNRC_IPV6_STACK_SIZE ((THREAD_STACKSIZE_DEFAULT) - 64)
#endif
/**

View File

@ -62,9 +62,13 @@ extern "C" {
/**
* @brief Stack size used for the pktdump thread
*
* @note The message queue was previously allocated on the stack.
* The default number of messages is 2³.
* Given sizeof(msg_t) == 8, the stack size is reduced by 64 bytes.
*/
#ifndef GNRC_PKTDUMP_STACKSIZE
#define GNRC_PKTDUMP_STACKSIZE (THREAD_STACKSIZE_MAIN)
#define GNRC_PKTDUMP_STACKSIZE ((THREAD_STACKSIZE_MAIN) - 64)
#endif
/**

View File

@ -30,9 +30,13 @@ extern "C" {
/**
* @brief Default stack size to use for the 6LoWPAN thread.
*
* @note The message queue was previously allocated on the stack.
* The default number of messages is 2³.
* Given sizeof(msg_t) == 8, the stack size is reduced by 64 bytes.
*/
#ifndef GNRC_SIXLOWPAN_STACK_SIZE
#define GNRC_SIXLOWPAN_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
#define GNRC_SIXLOWPAN_STACK_SIZE ((THREAD_STACKSIZE_DEFAULT) - 64)
#endif
/**

View File

@ -57,9 +57,13 @@ extern "C" {
/**
* @brief Default stack size to use for the UDP thread
*
* @note The message queue was previously allocated on the stack.
* The default number of messages is 2³.
* Given sizeof(msg_t) == 8, the stack size is reduced by 64 bytes.
*/
#ifndef GNRC_UDP_STACK_SIZE
#define GNRC_UDP_STACK_SIZE (THREAD_STACKSIZE_SMALL)
#define GNRC_UDP_STACK_SIZE ((THREAD_STACKSIZE_SMALL) - 64)
#endif
/** @} */

View File

@ -50,6 +50,7 @@
#define _MAX_L2_ADDR_LEN (8U)
static char _stack[GNRC_IPV6_STACK_SIZE + DEBUG_EXTRA_STACKSIZE];
static msg_t _msg_q[GNRC_IPV6_MSG_QUEUE_SIZE];
#ifdef MODULE_FIB
/**
@ -172,12 +173,12 @@ static void _dispatch_next_header(gnrc_pktsnip_t *pkt, unsigned nh,
static void *_event_loop(void *args)
{
msg_t msg, reply, msg_q[GNRC_IPV6_MSG_QUEUE_SIZE];
msg_t msg, reply;
gnrc_netreg_entry_t me_reg = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL,
thread_getpid());
(void)args;
msg_init_queue(msg_q, GNRC_IPV6_MSG_QUEUE_SIZE);
msg_init_queue(_msg_q, GNRC_IPV6_MSG_QUEUE_SIZE);
/* initialize fragmentation data-structures */
#ifdef MODULE_GNRC_IPV6_EXT_FRAG

View File

@ -36,6 +36,7 @@
static kernel_pid_t _pid = KERNEL_PID_UNDEF;
static char _stack[GNRC_SIXLOWPAN_STACK_SIZE + DEBUG_EXTRA_STACKSIZE];
static msg_t _msg_q[GNRC_SIXLOWPAN_MSG_QUEUE_SIZE];
/* handles GNRC_NETAPI_MSG_TYPE_RCV commands */
static void _receive(gnrc_pktsnip_t *pkt);
@ -385,12 +386,12 @@ static void _continue_fragmenting(gnrc_sixlowpan_frag_fb_t *fbuf)
static void *_event_loop(void *args)
{
msg_t msg, reply, msg_q[GNRC_SIXLOWPAN_MSG_QUEUE_SIZE];
msg_t msg, reply;
gnrc_netreg_entry_t me_reg = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL,
thread_getpid());
(void)args;
msg_init_queue(msg_q, GNRC_SIXLOWPAN_MSG_QUEUE_SIZE);
msg_init_queue(_msg_q, GNRC_SIXLOWPAN_MSG_QUEUE_SIZE);
/* register interest in all 6LoWPAN packets */
gnrc_netreg_register(GNRC_NETTYPE_SIXLOWPAN, &me_reg);

View File

@ -44,6 +44,7 @@ kernel_pid_t gnrc_pktdump_pid = KERNEL_PID_UNDEF;
* @brief Stack for the pktdump thread
*/
static char _stack[GNRC_PKTDUMP_STACKSIZE];
static msg_t _msg_queue[GNRC_PKTDUMP_MSG_QUEUE_SIZE];
static void _dump_snip(gnrc_pktsnip_t *pkt)
{
@ -166,10 +167,9 @@ static void *_eventloop(void *arg)
{
(void)arg;
msg_t msg, reply;
msg_t msg_queue[GNRC_PKTDUMP_MSG_QUEUE_SIZE];
/* setup the message queue */
msg_init_queue(msg_queue, GNRC_PKTDUMP_MSG_QUEUE_SIZE);
msg_init_queue(_msg_queue, GNRC_PKTDUMP_MSG_QUEUE_SIZE);
reply.content.value = (uint32_t)(-ENOTSUP);
reply.type = GNRC_NETAPI_MSG_TYPE_ACK;

View File

@ -43,6 +43,7 @@ static kernel_pid_t _pid = KERNEL_PID_UNDEF;
* @brief Allocate memory for the UDP thread's stack
*/
static char _stack[GNRC_UDP_STACK_SIZE + DEBUG_EXTRA_STACKSIZE];
static msg_t _msg_queue[GNRC_UDP_MSG_QUEUE_SIZE];
/**
* @brief Calculate the UDP checksum dependent on the network protocol
@ -220,14 +221,13 @@ static void *_event_loop(void *arg)
{
(void)arg;
msg_t msg, reply;
msg_t msg_queue[GNRC_UDP_MSG_QUEUE_SIZE];
gnrc_netreg_entry_t netreg = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL,
thread_getpid());
/* preset reply message */
reply.type = GNRC_NETAPI_MSG_TYPE_ACK;
reply.content.value = (uint32_t)-ENOTSUP;
/* initialize message queue */
msg_init_queue(msg_queue, GNRC_UDP_MSG_QUEUE_SIZE);
msg_init_queue(_msg_queue, GNRC_UDP_MSG_QUEUE_SIZE);
/* register UPD at netreg */
gnrc_netreg_register(GNRC_NETTYPE_UDP, &netreg);