diff --git a/core/msg.c b/core/msg.c index 91919442f3..13d2b4eece 100644 --- a/core/msg.c +++ b/core/msg.c @@ -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; } diff --git a/sys/include/net/gnrc/ipv6.h b/sys/include/net/gnrc/ipv6.h index ecc5f76d9f..7098fc9923 100644 --- a/sys/include/net/gnrc/ipv6.h +++ b/sys/include/net/gnrc/ipv6.h @@ -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 /** diff --git a/sys/include/net/gnrc/pktdump.h b/sys/include/net/gnrc/pktdump.h index bac76cd0e4..5a0498256d 100644 --- a/sys/include/net/gnrc/pktdump.h +++ b/sys/include/net/gnrc/pktdump.h @@ -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 /** diff --git a/sys/include/net/gnrc/sixlowpan/config.h b/sys/include/net/gnrc/sixlowpan/config.h index 6736455278..0588d0b262 100644 --- a/sys/include/net/gnrc/sixlowpan/config.h +++ b/sys/include/net/gnrc/sixlowpan/config.h @@ -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 /** diff --git a/sys/include/net/gnrc/udp.h b/sys/include/net/gnrc/udp.h index b3f59ee8e4..8e2da33a7f 100644 --- a/sys/include/net/gnrc/udp.h +++ b/sys/include/net/gnrc/udp.h @@ -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 /** @} */ diff --git a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c index a70f2e0783..382d2fcc6a 100644 --- a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c +++ b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c @@ -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 diff --git a/sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c b/sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c index 6083f5adf1..29a82cd40a 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c +++ b/sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c @@ -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); diff --git a/sys/net/gnrc/pktdump/gnrc_pktdump.c b/sys/net/gnrc/pktdump/gnrc_pktdump.c index 539af12f5a..40e97d56d3 100644 --- a/sys/net/gnrc/pktdump/gnrc_pktdump.c +++ b/sys/net/gnrc/pktdump/gnrc_pktdump.c @@ -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; diff --git a/sys/net/gnrc/transport_layer/udp/gnrc_udp.c b/sys/net/gnrc/transport_layer/udp/gnrc_udp.c index ddf3423e32..38c77eeec4 100644 --- a/sys/net/gnrc/transport_layer/udp/gnrc_udp.c +++ b/sys/net/gnrc/transport_layer/udp/gnrc_udp.c @@ -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);