mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
core: make messaging optional
This commit is contained in:
parent
5f81284270
commit
58a12e5034
@ -1,3 +1,3 @@
|
||||
DEFAULT_MODULE += board cpu core sys
|
||||
DEFAULT_MODULE += board cpu core core_msg sys
|
||||
|
||||
DEFAULT_MODULE += auto_init
|
||||
|
@ -2,6 +2,7 @@ PSEUDOMODULES += conn
|
||||
PSEUDOMODULES += conn_ip
|
||||
PSEUDOMODULES += conn_tcp
|
||||
PSEUDOMODULES += conn_udp
|
||||
PSEUDOMODULES += core_msg
|
||||
PSEUDOMODULES += core_thread_flags
|
||||
PSEUDOMODULES += gnrc_netdev_default
|
||||
PSEUDOMODULES += gnrc_ipv6_default
|
||||
|
@ -375,6 +375,11 @@ int msg_avail(void);
|
||||
*/
|
||||
int msg_init_queue(msg_t *array, int num);
|
||||
|
||||
/**
|
||||
* @brief Prints the message queue of the current thread.
|
||||
*/
|
||||
void msg_queue_print(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -85,11 +85,14 @@ struct _thread {
|
||||
|
||||
clist_node_t rq_entry; /**< run queue entry */
|
||||
|
||||
void *wait_data; /**< holding messages */
|
||||
#if defined(MODULE_CORE_MSG) || defined(MODULE_CORE_THREAD_FLAGS)
|
||||
void *wait_data; /**< used by msg and thread flags */
|
||||
#endif
|
||||
#if defined(MODULE_CORE_MSG)
|
||||
priority_queue_t msg_waiters; /**< threads waiting on message */
|
||||
|
||||
cib_t msg_queue; /**< message queue */
|
||||
msg_t *msg_array; /**< memory holding messages */
|
||||
#endif
|
||||
|
||||
#if defined DEVELHELP || defined(SCHED_TEST_STACK)
|
||||
char *stack_start; /**< thread's stack start address */
|
||||
@ -321,11 +324,6 @@ static inline kernel_pid_t thread_getpid(void)
|
||||
*/
|
||||
char *thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_start, int stack_size);
|
||||
|
||||
/**
|
||||
* @brief Prints the message queue of the current thread.
|
||||
*/
|
||||
void thread_print_msg_queue(void);
|
||||
|
||||
/**
|
||||
* @brief Add thread to list, sorted by priority (internal)
|
||||
*
|
||||
|
28
core/msg.c
28
core/msg.c
@ -34,6 +34,8 @@
|
||||
#include "debug.h"
|
||||
#include "thread.h"
|
||||
|
||||
#ifdef MODULE_CORE_MSG
|
||||
|
||||
static int _msg_receive(msg_t *m, int block);
|
||||
static int _msg_send(msg_t *m, kernel_pid_t target_pid, bool block, unsigned state);
|
||||
|
||||
@ -389,3 +391,29 @@ int msg_init_queue(msg_t *array, int num)
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void msg_queue_print(void)
|
||||
{
|
||||
unsigned state = irq_disable();
|
||||
|
||||
thread_t *thread =(thread_t *)sched_active_thread;
|
||||
cib_t *msg_queue = &thread->msg_queue;
|
||||
msg_t *msg_array = thread->msg_array;
|
||||
unsigned int i = msg_queue->read_count & msg_queue->mask;
|
||||
|
||||
printf("Message queue of thread %" PRIkernel_pid "\n", thread->pid);
|
||||
printf(" size: %u (avail: %d)\n", msg_queue->mask + 1,
|
||||
cib_avail((cib_t *)msg_queue));
|
||||
|
||||
for (; i != (msg_queue->write_count & msg_queue->mask);
|
||||
i = (i + 1) & msg_queue->mask) {
|
||||
msg_t *m = &msg_array[i];
|
||||
printf(" * %u: sender: %" PRIkernel_pid ", type: 0x%04" PRIu16
|
||||
", content: %" PRIu32 " (%p)\n", i, m->sender_pid, m->type,
|
||||
m->content.value, (void *)m->content.ptr);
|
||||
}
|
||||
|
||||
irq_restore(state);
|
||||
}
|
||||
|
||||
#endif /* MODULE_CORE_MSG */
|
||||
|
@ -225,12 +225,12 @@ kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags,
|
||||
|
||||
cb->rq_entry.next = NULL;
|
||||
|
||||
#ifdef MODULE_CORE_MSG
|
||||
cb->wait_data = NULL;
|
||||
|
||||
cb->msg_waiters.first = NULL;
|
||||
|
||||
cib_init(&(cb->msg_queue), 0);
|
||||
cb->msg_array = NULL;
|
||||
#endif
|
||||
|
||||
sched_num_threads++;
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sched.h"
|
||||
#include "thread.h"
|
||||
|
||||
void thread_print_msg_queue(void)
|
||||
{
|
||||
volatile thread_t *thread = sched_active_thread;
|
||||
volatile cib_t *msg_queue = &thread->msg_queue;
|
||||
msg_t *msg_array = thread->msg_array;
|
||||
unsigned int i = msg_queue->read_count & msg_queue->mask;
|
||||
|
||||
printf("Message queue of thread %" PRIkernel_pid "\n", thread->pid);
|
||||
printf(" size: %u (avail: %d)\n", msg_queue->mask + 1,
|
||||
cib_avail((cib_t *)msg_queue));
|
||||
|
||||
for (; i != (msg_queue->write_count & msg_queue->mask);
|
||||
i = (i + 1) & msg_queue->mask) {
|
||||
msg_t *m = &msg_array[i];
|
||||
printf(" * %u: sender: %" PRIkernel_pid ", type: 0x%04" PRIu16
|
||||
", content: %" PRIu32 " (%p)\n", i, m->sender_pid, m->type,
|
||||
m->content.value, (void *)m->content.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
5
dist/Makefile
vendored
5
dist/Makefile
vendored
@ -36,6 +36,11 @@ QUIET ?= 1
|
||||
#USEMODULE += posix
|
||||
#USEMODULE += xtimer
|
||||
|
||||
# If your application is very simple and doesn't use modules that use
|
||||
# messaging, it can be disabled to save some memory:
|
||||
|
||||
#DISABLE_MODULE += core_msg
|
||||
|
||||
#export INCLUDES += -Iapplication_include
|
||||
|
||||
# Specify custom dependencies for your application here ...
|
||||
|
@ -1,7 +1,12 @@
|
||||
APPLICATION = sizeof_tcb
|
||||
include ../Makefile.tests_common
|
||||
|
||||
# optional thread_t modifying modules:
|
||||
# othread_t modifying modules:
|
||||
#
|
||||
# disabled by default:
|
||||
# USEMODULE += core_thread_flags
|
||||
#
|
||||
# enabled by defaule:
|
||||
# DISABLE_MODULE += core_msg
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -39,10 +39,12 @@ int main(void)
|
||||
P(flags);
|
||||
#endif
|
||||
P(rq_entry);
|
||||
#ifdef MODULE_CORE_MSG
|
||||
P(wait_data);
|
||||
P(msg_waiters);
|
||||
P(msg_queue);
|
||||
P(msg_array);
|
||||
#endif
|
||||
#ifdef DEVELHELP
|
||||
P(name);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user