Loading...
Searching...
No Matches
msg.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
174
175#include <stdint.h>
176#include <stdbool.h>
177
178#include "compiler_hints.h"
179#include "sched.h"
180
181#ifdef __cplusplus
182extern "C" {
183#endif
184
193typedef struct {
196 uint16_t type;
197 union {
198 void *ptr;
199 uint32_t value;
200 } content;
201} msg_t;
202
221int msg_send(msg_t *m, kernel_pid_t target_pid);
222
239int msg_try_send(msg_t *m, kernel_pid_t target_pid);
240
255
259#define KERNEL_PID_ISR (KERNEL_PID_LAST + 1)
260
279int msg_send_int(msg_t *m, kernel_pid_t target_pid);
280
288static inline int msg_sent_by_int(const msg_t *m)
289{
290 return (m->sender_pid == KERNEL_PID_ISR);
291}
292
304
317
340int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid);
341
353int msg_reply(msg_t *m, msg_t *reply);
354
367int msg_reply_int(msg_t *m, msg_t *reply);
368
382
391unsigned msg_avail(void);
392
401
415ACCESS(write_only, 1, 2)
416void msg_init_queue(msg_t *array, int num);
417
421#ifndef CONFIG_MSG_QUEUE_PRINT_MAX
422# define CONFIG_MSG_QUEUE_PRINT_MAX 16U
423#endif
424
431
432#ifdef __cplusplus
433}
434#endif
435
Common macros and compiler attributes/pragmas configuration.
#define ACCESS(mode, ptr_idx, size_idx)
Emit an attribute (if supported by the compiler) that declares how a function will access its paramet...
Scheduler API definition.
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:288
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:259
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:134
Describes a message object which can be sent between threads.
Definition msg.h:193
uint16_t type
Type field.
Definition msg.h:196
kernel_pid_t sender_pid
PID of sending thread.
Definition msg.h:194
void * ptr
Pointer content field.
Definition msg.h:198
uint32_t value
Value content field.
Definition msg.h:199