-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshm_nonblocking.h
More file actions
29 lines (25 loc) · 878 Bytes
/
Copy pathshm_nonblocking.h
File metadata and controls
29 lines (25 loc) · 878 Bytes
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
#ifndef SHM_NONBLOCKING_H
#define SHM_NONBLOCKING_H
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
#include "benchmark.h"
typedef struct {
pthread_mutex_t mutex;
pthread_cond_t server_cond;
pthread_cond_t client_cond;
size_t read_pos;
size_t write_pos;
size_t size;
bool message_available;
bool response_available;
bool message_processed;
bool ready;
char buffer[0];
} NonBlockingRingBuffer;
NonBlockingRingBuffer* setup_shm_nonblocking(size_t size, bool is_server);
void free_shm_nonblocking_server(NonBlockingRingBuffer* rb);
void free_shm_nonblocking_client(NonBlockingRingBuffer* rb);
void run_shm_nonblocking_server(NonBlockingRingBuffer* rb, int duration_secs, float work_secs);
void run_shm_nonblocking_client(NonBlockingRingBuffer* rb, int duration_secs, BenchmarkStats* stats);
#endif // SHM_NONBLOCKING_H