-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_queue.h
More file actions
73 lines (52 loc) · 1.72 KB
/
Copy pathcommand_queue.h
File metadata and controls
73 lines (52 loc) · 1.72 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef DISTRIBUTEDMALLOC_COMMAND_QUEUE_H
#define DISTRIBUTEDMALLOC_COMMAND_QUEUE_H
#include <stdlib.h>
#include "message.h"
// OP_MALLOC, // Data => Size
// OP_FREE, // Data => Address
// OP_WRITE, // Data => Address; Data size; Data
// OP_READ, // Data => Address; Data size
// OP_DUMP, // Data => Address
// OP_SNAP,
// OP_DNET,
// OP_KILL, // Data => id
// OP_REVIVE, // Data => id
// OP_NONE
struct command_queue {
enum operation command;
struct command_queue *next;
void *data; // Contain the structure depending of the command
};
struct command_queue *generate_command_queue(enum operation op, void *data);
// Delete first command queue, return head
struct command_queue *pop_command(struct command_queue *head);
// Push command in queue, return head, can have head=NULL for init queue
struct command_queue *push_command(struct command_queue *head, struct command_queue *new_elt);
// Get command queue data, you should known how to cast it
void *peek_command(struct command_queue *head);
// Get user command enum of the first of the queue
enum operation peek_user_command(struct command_queue *head);
struct data_write *generate_data_write(size_t address, size_t size, void *data);
struct data_read *generate_data_read(size_t address, size_t size);
struct data_size *generate_data_size(size_t size);
struct data_id *generate_data_id(unsigned short id);
struct data_address *generate_data_address(size_t address);
struct data_write {
size_t address;
size_t size;
void *data;
};
struct data_read {
size_t address;
size_t size;
};
struct data_id {
unsigned short id;
};
struct data_address {
size_t address;
};
struct data_size {
size_t size;
};
#endif /* !DISTRIBUTEDMALLOC_COMMAND_QUEUE_H */