Thread Synch AOSV 2020
1.2
LKM for exchanging messages between threads
|
Go to the documentation of this file.
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/slab.h>
14 #include <linux/uaccess.h>
15 #include <linux/semaphore.h>
16 #include <linux/proc_fs.h>
17 #include <linux/mutex.h>
18 #include <linux/spinlock.h>
19 #include <linux/atomic.h>
25 #define NO_MSG_PRESENT 0
27 #define USER_COPY_ERR -3
28 #define SEM_INIT_ERR -4
29 #define MSG_INVALID_FORMAT -11
30 #define MSG_SIZE_ERROR -12
31 #define MEMORY_ERROR -13
32 #define STORAGE_SIZE_ERR -14
34 #define CLASS_EXISTS -10
36 #define DEV_CREATION_ERR -12
37 #define CDEV_ALLOC_ERR -13
38 #define EMPTY_LIST -20
39 #define NODE_NOT_FOUND -21
40 #define INVALID_IOCTL_COMMAND -1
41 #define CHDEV_ALLOC_ERR -22
45 #define DEFAULT_GC_RATIO 3
51 msg_manager_t *
createMessageManager(
const u_int _max_storage_size,
const u_int _max_message_size, garbage_collector_t *garbageCollector);
53 int writeMessage(msg_t *message, msg_manager_t *manager);
54 int readMessage(msg_t *dest_buffer, msg_manager_t *manager);
57 int copy_msg_to_user(
const msg_t *kmsg, __user
char *ubuffer,
const ssize_t _size);
62 #ifndef DISABLE_DELAYED_MSG
Defines all structures and global variables needed by the module.
int readMessage(msg_t *dest_buffer, msg_manager_t *manager)
Read a message from the corresponding queue.
Definition: message.c:740
int copy_msg_to_user(const msg_t *kmsg, __user char *ubuffer, const ssize_t _size)
copy a msg_t structure from kernel-space to user-space
Definition: message.c:546
int cancelDelay(msg_manager_t *manager)
Set the delay of messages in the delay queue to zero.
Definition: message.c:206
bool isDelaySet(const msg_manager_t *manager)
Check if the message delay is greater than zero on a group.
Definition: message.c:37
int copy_msg_from_user(msg_t *kmsg, const char *umsg, const ssize_t _size)
copy a msg_t structure from user-space to kernel-space
Definition: message.c:583
msg_manager_t * createMessageManager(const u_int _max_storage_size, const u_int _max_message_size, garbage_collector_t *garbageCollector)
Allocate and initialize all the members of a 'msg_manager_t' struct.
Definition: message.c:624
void delayedMessageCallback(struct timer_list *timer)
Called when a timer for a delayed message expires.
Definition: message.c:54
void queueGarbageCollector(struct work_struct *work)
Remove a message from the queue when it was completely delivered.
Definition: message.c:831
int writeMessage(msg_t *message, msg_manager_t *manager)
write message on a group queue
Definition: message.c:666
int queueDelayedMessage(msg_t *message, msg_manager_t *manager)
Insert a delayed message into the pending queue.
Definition: message.c:109
int revokeDelayedMessage(msg_manager_t *manager)
Remove all the delayed message from the queue.
Definition: message.c:163