minix/minix/kernel/mqueue.h
Sanchayan Maity 55d341bc54 Allow users to get and set attributes
Currently we only allow users to get and set number of queues. The
operation is always non blocking. There is no provision for non
blocking operation at the moment.

The queue sizes are set to MAX 256 by default. If a user changes the
attributes and sets the queue size or number of messages in a queue
to less than 256, it is the responsibility of the user to close any
queues which were opened with a descriptor greater than the value
currently set.

For example, by default queue sizes are 256. If 150 queues are opened
and then the user sets the number of queues to 32, all open descriptors
and queues from 32 to 150 must be closed. Note that descriptor number
allocation starts with zero and not one.
2016-03-22 15:57:53 +05:30

74 lines
1.7 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
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 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 clean_message_queue(mqd_t mqdes);
int message_index_with_highprio(mqd_t mqdes, endpoint_t dst);
#endif /* MQUEUE_H */