msg.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 Freie Universit├Ąt Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
176#ifndef MSG_H
177#define MSG_H
178
179#include <stdint.h>
180#include <stdbool.h>
181
182#include "sched.h"
183
184#ifdef __cplusplus
185extern "C" {
186#endif
187
196typedef struct {
199 uint16_t type;
200 union {
201 void *ptr;
202 uint32_t value;
203 } content;
204} msg_t;
205
224int msg_send(msg_t *m, kernel_pid_t target_pid);
225
242int msg_try_send(msg_t *m, kernel_pid_t target_pid);
243
258
262#define KERNEL_PID_ISR (KERNEL_PID_LAST + 1)
263
282int msg_send_int(msg_t *m, kernel_pid_t target_pid);
283
291static inline int msg_sent_by_int(const msg_t *m)
292{
293 return (m->sender_pid == KERNEL_PID_ISR);
294}
295
307
320
343int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid);
344
356int msg_reply(msg_t *m, msg_t *reply);
357
370int msg_reply_int(msg_t *m, msg_t *reply);
371
382
389unsigned msg_avail(void);
390
398
412void msg_init_queue(msg_t *array, int num);
413
418
419#ifdef __cplusplus
420}
421#endif
422
423#endif /* MSG_H */
int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid)
Send a message, block until reply received.
int msg_reply_int(msg_t *m, msg_t *reply)
Replies to a message from interrupt.
int msg_try_receive(msg_t *m)
Try to receive a message.
int msg_send_int(msg_t *m, kernel_pid_t target_pid)
Send message from interrupt.
int msg_reply(msg_t *m, msg_t *reply)
Replies to a message.
void msg_queue_print(void)
Prints the message queue of the current thread.
void msg_init_queue(msg_t *array, int num)
Initialize the current thread's message queue.
unsigned msg_queue_capacity(kernel_pid_t pid)
Get maximum capacity of a thread's queue length.
unsigned msg_avail(void)
Check how many messages are available (waiting) in the message queue.
static int msg_sent_by_int(const msg_t *m)
Test if the message was sent inside an ISR.
Definition: msg.h:291
int msg_send_to_self(msg_t *m)
Send a message to the current thread.
int msg_try_send(msg_t *m, kernel_pid_t target_pid)
Send a message (non-blocking).
int msg_send(msg_t *m, kernel_pid_t target_pid)
Send a message (blocking).
#define KERNEL_PID_ISR
Value of msg_t::sender_pid if the sender was an interrupt service routine.
Definition: msg.h:262
int msg_receive(msg_t *m)
Receive a message.
unsigned msg_avail_thread(kernel_pid_t pid)
Check how many messages are available (waiting) in the message queue of a specific thread.
int16_t kernel_pid_t
Unique process identifier.
Definition: sched.h:139
Scheduler API definition.
Describes a message object which can be sent between threads.
Definition: msg.h:196
uint16_t type
Type field.
Definition: msg.h:199
kernel_pid_t sender_pid
PID of sending thread.
Definition: msg.h:197
void * ptr
Pointer content field.
Definition: msg.h:201
uint32_t value
Value content field.
Definition: msg.h:202