-
Notifications
You must be signed in to change notification settings - Fork 0
/
report_api.h
55 lines (40 loc) · 1.51 KB
/
report_api.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
45
46
47
48
49
50
51
52
53
54
55
/*
* This reporting API was a part of the assignment, and its implementation was included in the task.
* Credits (for the Polish-language version) to the Uni of Warsaw
*
*/
#ifndef RAPORT_API_H_
#define RAPORT_API_H_
#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>
#include <stddef.h>
/*** Functions to be caled by the server ***/
/**
* Reports readiness to serve clients. After this function is called, any request must be accommodated.
*/
void server_ready(pid_t server_pid);
/**
* Reports having received a request for resource_count resource_types from the client.
* Called directly after obtaining a request, before processing that request.
*
*/
void assignment_received(pid_t client_pid, size_t resource_type, size_t resource_count);
/**
* Reports assignment of resources to a pair of clients.
* Server should call this function before notifying clients that the resources have been assigned to them.
*/
void allocated_resources(pthread_t thread, size_t client_1_resources,
size_t client_2_resources, size_t resource_type, pid_t client_1,
pid_t client_2, size_t resources_remaining);
/**
* Reports return of resources.
*/
void resources_available(size_t resource_type, size_t resource_amount);
/*** Function called by the client: ***/
/**
* Reports having acquired resources.
*/
void acquired_resources(size_t resource_type, size_t resource_amount,
size_t work_type, pid_t client, pid_t partner);
#endif /* RAPORT_API_H_ */