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: Improve core IPC #1270

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b2f90b1
ringbuffer: add ringbuffer_remove and ringbuffer_get_free
kaspar030 May 23, 2014
cd0c049
core: make messaging more flexible by allowing arbitraryly sized msgs
kaspar030 May 23, 2014
a48066b
sys: add new optional msg_queue module
kaspar030 May 23, 2014
8b4994a
core: add support for new msg_queues to threading
kaspar030 May 23, 2014
e04b7a6
core: msg: make _msg_send_int use queue if available
kaspar030 May 23, 2014
422b10e
sys: chardev_thread: change to new msg api
kaspar030 May 23, 2014
2a30b1c
make: sys: include msg_queue module directory
kaspar030 May 23, 2014
ae56345
sys: vtimer: update to new msg api
kaspar030 May 23, 2014
92a7bc8
examples: ipc_pingpong: update to new msg api
kaspar030 May 23, 2014
f7d9a33
test_thread_msg: update to new msg api
kaspar030 May 23, 2014
2b564e3
test: test_thread_msg_block_w_queue: update to new msg api
kaspar030 May 23, 2014
0ce1c26
tests: test_queue_fairness: update to new msg api
kaspar030 May 23, 2014
379e475
sys: msg_queue: add define for space required by one queued pulse
kaspar030 May 23, 2014
bf61121
sys: transceiver: adapt to new msg api
kaspar030 May 23, 2014
9dddef6
native: update to new msg api
kaspar030 May 23, 2014
fa7a902
tests: test_vtimer_msg: update to new msg_api
kaspar030 May 23, 2014
9f68371
tests: test_nativenet: update to new msg api
kaspar030 May 23, 2014
660c1b4
sys: msg_queue: add convenience functions
kaspar030 May 23, 2014
1448d64
core: msg: fix active_thread->sched_active_thread rebase
kaspar030 May 23, 2014
281ba8b
test_vtimer_msg: switch to simplified msg_queue initialization
kaspar030 Jun 3, 2014
dcb66e5
msg_queue: use anonymous type instead of typedef'd msg_hdr_t
kaspar030 Jun 3, 2014
358fc06
core: make send functions use message nodes
kaspar030 Jun 3, 2014
f3347b2
core: msg: expose msg_send_receive and msg_reply
kaspar030 Jun 3, 2014
cf9f27b
examples: add example for non-pulse messages
kaspar030 Jun 3, 2014
ded909f
examples: add example for raw messages using msg_send_receive/msg_reply
kaspar030 Jun 3, 2014
85b75cc
sys: ringbuffer: fix ringbuffer_remove signature typo
kaspar030 Aug 21, 2014
ffe9d18
core: msg: switch to use priority queue
kaspar030 Aug 21, 2014
22bec15
make: fix rebase error
kaspar030 Aug 21, 2014
959bb3a
examples: ipc_pingpong: fix compiler warning
kaspar030 Aug 21, 2014
37901b0
examples: ipc_raw_pingpong: adapt to thread_create with args
kaspar030 Aug 21, 2014
0c6b2bb
Revert "sys: vtimer: update to new msg api"
kaspar030 Aug 21, 2014
081c57d
sys: ringbuffer: add ringbuffer_get_free
kaspar030 Aug 21, 2014
82bde2a
examples: ipc_raw_pingpong_sync: adapt to changed thread_create
kaspar030 Aug 21, 2014
d2ce261
sys: msg_queue: adapt to changed thread_pid
kaspar030 Aug 21, 2014
0c929eb
tests: nativenet: use new msg_queue api
kaspar030 Aug 21, 2014
97bf91b
sys: vtimer: adapt to newmsg IPC changes
kaspar030 Aug 21, 2014
4a63d45
sys: uart0: adapt to new IPC api
kaspar030 Aug 21, 2014
5c6b674
sys: posix_io: adapt to new IPC API
kaspar030 Aug 21, 2014
e5f22b9
tests: thread_msg_block_w_queue: msg_queues are now a module
kaspar030 Aug 21, 2014
272e61b
adapt to new IPC API
kaspar030 Aug 21, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/include/flags.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Freie Universität Berlin
* Copyright (C) 2014 Kaspar Schleiser
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
Expand Down Expand Up @@ -28,6 +29,7 @@
#define CREATE_WOUT_YIELD (4) /**< do not automatically call thread_yield() after creation */
#define CREATE_STACKTEST (8) /**< write markers into the thread's stack to measure stack
usage (for debugging) */
#define CREATE_NOMSG (16) /**< Create thread without messaging capabilities */
/** @} */

#endif /* _FLAGS_H */
Expand Down
328 changes: 228 additions & 100 deletions core/include/msg.h

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions core/include/tcb.h
Expand Up @@ -23,7 +23,6 @@
#include <stdint.h>
#include "priority_queue.h"
#include "clist.h"
#include "cib.h"
#include "msg.h"

/**
Expand Down Expand Up @@ -55,7 +54,7 @@
/**
* @brief @c tcb_t holds thread's context data.
*/
typedef struct tcb_t {
typedef struct tcb {
char *sp; /**< thread's stack pointer */
uint16_t status; /**< thread's status */

Expand All @@ -64,11 +63,7 @@ typedef struct tcb_t {

clist_node_t rq_entry; /**< run queue entry */

void *wait_data; /**< holding messages */
priority_queue_t msg_waiters; /**< threads waiting on message */

cib_t msg_queue; /**< message queue */
msg_t *msg_array; /**< memory holding messages */
msg_node_t *msg_node; /**< optional ptr to message node */

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought you meant to have a thread have multiple message queues? Or is this feature unrelated to this line? (Sorry, I'm scrolling through your PR while I'm half asleep already.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very tired here, too...
The idea is: message nodes contain queues. They're independent of threads, e.g., I want to make it possible to just create multiple msg_node objects and start receiving on / sending to them. But to keep most of the old behaviour (and get an initial communication reference for a thread), every thread is by default created with one (main) message node.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, understood. 👍

const char *name; /**< thread's name */
char *stack_start; /**< thread's stack start address */
Expand Down
18 changes: 18 additions & 0 deletions core/include/thread.h
Expand Up @@ -153,5 +153,23 @@ kernel_pid_t thread_getpid(void);
int thread_measure_stack_free(char *stack);
#endif

#ifdef MODULE_MSG_QUEUE
/**
* @brief Sets / changes a thread's message queue.
*
* The msg_queue object must have been initialized before
* using msg_queue_init().
*
* @param[in] pid the PID of the thread to change
*
* @return `1` on success
* @return `STATUS_NOT_FOUND` if pid is unknown or not sleeping
*/
#include "msg_queue.h"
int thread_set_msg_queue(int pid, msg_queue_t* msg_queue);
#endif

msg_node_t *thread_get_msg_node(int pid);

/* @} */
#endif /* __THREAD_H */