-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisastrOS_message_queue.h
44 lines (31 loc) · 1017 Bytes
/
disastrOS_message_queue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "disastrOS_resource.h"
#include "pool_allocator.h"
#define MAX_MESSAGE_LENGTH 64
struct MessageQueue_ptr;
typedef struct MessageQueue{
Resource resource; //MQ extends resource struct
ListHead messages; //list of messages
ListHead waiting_to_read;
ListHead waiting_to_write;
int available; //written messages
}MessageQueue;
typedef struct Message{
ListItem list;
int pid_sender;
int length;
char message[MAX_MESSAGE_LENGTH];
}Message;
//initializes MQ allocator for OS
void MessageQueue_init();
//function to add into resource_alloc_func list
Resource* MessageQueue_alloc();
//function to add into resource_free_func list
int MessageQueue_free(Resource* r);
//gives first message of mq
Message* MessageQueue_getFirstMessage(MessageQueue* mq);
void MessageQueue_print(MessageQueue* mq);
//functions for message
void Message_init();
//this one will be used on write syscall for MQ
Message* Message_alloc(int pid_sender, char* message, int m_length);
int Message_free(Message* m);