-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibobjdata.h
More file actions
79 lines (63 loc) · 1.58 KB
/
libobjdata.h
File metadata and controls
79 lines (63 loc) · 1.58 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
74
75
76
77
78
79
#ifndef UNTITLED_LIBOBJDATA_H
#define UNTITLED_LIBOBJDATA_H
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <sched.h>
#include <dlfcn.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <bfd.h>
#include <fcntl.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <ctype.h>
#define MAX_DATA_LENGTH 20
typedef enum {bit0=0, bit1=1} bit;
typedef struct
{
char *data; //buffer slot stored data
size_t size; //size of the data
} slot_t;
typedef struct
{
bit latest;
bit reading;
bit slots[2];
int prev;
slot_t buffer[2][2];
int buff_size; //size of buffer
int count; //number of slots in the buffer
int in_marker; //next slot to add data to
int out_marker; //next slot to take data from
pthread_mutex_t mutex; //mutex for shared buffer
pthread_cond_t occupied_slot; //condition when >= 1 full buffer slots
pthread_cond_t empty_slot; //condition when at least 1 empty buffer slot
slot_t slot[]; //array of slots
} buffer_t;
typedef struct
{
int is_sync;
int argn;
buffer_t *buff[];
}thread_arg;
typedef struct
{
char name[MAX_DATA_LENGTH];
char value[MAX_DATA_LENGTH];
}NameValuePair;
#endif
void *get_data (void *arg);
void *observe(void *arg);
void addNameValuePair(int index, NameValuePair *pairs, char *name, char *value);
void *reconstruct(void *arg);
void *tapplot(void *arg);
void produce (buffer_t *b, char *item, size_t size);
char *consume (buffer_t *b);
void slotwrite(buffer_t *b, char *item, size_t size);
char *slotread (buffer_t *b);