minix/minix/kernel/mqueue.h
Sanchayan Maity 8501cb7ed8 Allow users to request a asynchronous notification
This patch adds functionality to request an asynchronous notification
if some other process has send a message to it. We currently send a
SIGALRM to avoid any changes to core infrastructure of signal handling.
Ideally we should implement a separate signal for this. Currently there
is an obvious disadvantage of not being able to use SIGALRM with alarm,
if we are using this functionality.
2016-03-22 17:51:09 +05:30

79 lines
1.8 KiB
C

#ifndef MQUEUE_H
#define MQUEUE_H
/*
* This header file defines constants and function declarations used for
* MINIX interprocess message queues. These are used primarily in file
* mqueue.c
*/
#include <minix/type.h>
/*
* This provides a maximum limit beyond which we do not allow changing
* number of queues or number of messages in queue.
*/
#define MAX_LIMIT 256
#define MIN_LIMIT 16
#define MAX_RECEIVERS 4
#define MAX_MESSAGES MAX_LIMIT
#define MAX_QUEUES MAX_LIMIT
#define MAX_PAYLOAD 32
#define NAME_SIZE 32
#define DEFAULT_PRIO 0
#define EMPTY -1
#define NOT_EMPTY 1
#define MQ_BLOCKING 0
#define MQ_NON_BLOCKING 1
#define NOTIFY_ON 1
#define NOTIFY_OFF 0
typedef int mqd_t;
typedef struct message_entity {
u64_t timestamp;
char msg[MAX_PAYLOAD];
endpoint_t src;
endpoint_t dst[MAX_RECEIVERS];
unsigned int priority;
} message_entity;
typedef struct messageq {
char name[NAME_SIZE];
int num_msgs;
int num_users;
message_entity msge[MAX_MESSAGES];
int msg_slot_empty[MAX_MESSAGES];
} messageq;
typedef struct message_queue {
int num_queues;
messageq msg[MAX_QUEUES];
int queue_slot_empty[MAX_QUEUES];
} message_queue;
int number_of_messages;
int number_of_queues;
int mq_blocking;
int notify;
int initialize_message_queues(void);
int deinitialize_message_queues(void);
mqd_t mq_open(const char *name, int oflag);
int mq_send(mqd_t mqdes, const char *msg_ptr, unsigned int msg_prio, endpoint_t src, endpoint_t dst[]);
size_t mq_receive(mqd_t mqdes, char *msg_ptr, unsigned int msg_prio, endpoint_t dst);
int mq_get_attributes(int *no_of_msgs, int *no_of_queues, int *blocking);
int mq_set_attributes(int no_of_msgs, int no_of_queues, int blocking);
int mq_close(mqd_t mqdes);
int mq_notify(int notify_on_off);
int clean_message_queue(mqd_t mqdes);
int message_index_with_highprio(mqd_t mqdes, endpoint_t dst);
#endif /* MQUEUE_H */