minix/minix/kernel/mqueue.h
Sanchayan Maity fe71ea4bc1 First round of assorted bug fixes
Fixed the following bugs:
1. Message priority was not set at all at two places
2. Limits check was not correct while returning error values
3. We are suppose to allow multiple users operate on the same queue
using a named descriptor. However any one user calling close before
the other would result in closing the queue even when other users
might be using it. Track number of users and close only if number of
users is zero. Yet to do functional tests for this, so this is untested,
but introduce it anyway at this juncture.
2016-03-19 11:49:48 +05:30

58 lines
1.3 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>
#define MAX_RECEIVERS 4
#define MAX_MESSAGES 16
#define MAX_QUEUES 16
#define MAX_PAYLOAD 32
#define NAME_SIZE 32
#define DEFAULT_PRIO 0
#define EMPTY -1
#define NOT_EMPTY 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 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_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 */