-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatstr.h
47 lines (38 loc) · 824 Bytes
/
datstr.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
#ifndef DATSTR_H
#define DATSTR_H
#include <pthread.h>
#include <semaphore.h>
/*stores the orders so we can print them out at the end*/
struct Order
{
char * bookTitle;
float cost;
float currentCredits;
};
/*used to make generic linked lists*/
struct Node
{
void * data;
struct Node * next;
};
/*stroes data for each user*/
struct User{
char * username;
int uid;
double remainingCredits;
pthread_mutex_t* userMutex;
struct Node * success;
struct Node * fail;
};
/*struct to give to consumer threads when they're created*/
struct ConsumerThreadData{
struct User **users;
char *input;
int usersSize;
sem_t *semaphore;
pthread_mutex_t *condLock;
pthread_cond_t *condition;
};
struct User* createUser(char *username,int uid,double initialCredits);
void freeUsers(struct User **array, int size);
#endif