forked from sysprog21/phonebook-concurrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phonebook_lock.h
58 lines (47 loc) · 1.21 KB
/
phonebook_lock.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
56
57
58
#ifndef _PHONEBOOK_H
#define _PHONEBOOK_H
#include <pthread.h>
#include <time.h>
#include "lock_if.h"
#define MAX_LAST_NAME_SIZE 16
#define LOCKLOCK 1
typedef struct _detail {
char firstName[16];
char email[16];
char phone[10];
char cell[10];
char addr1[16];
char addr2[16];
char city[16];
char state[2];
char zip[5];
} detail;
typedef detail *pdetail;
typedef struct __PHONE_BOOK_ENTRY {
char *lastName;
struct __PHONE_BOOK_ENTRY *pNext;
pdetail dtl;
ptlock_t *lock;
} entry;
typedef struct _thread_argument {
char *data_begin;
char *data_end;
int threadID;
int numOfThread;
entry *lEntryPool_begin; /* The local entry pool */
entry *lEntry_head; /* local entry linked list */
entry *lEntry_tail; /* local entry linked list */
} thread_arg;
/* API */
extern struct __PHONEBOOK_API {
void (*create)();
entry *(*appendByFile)(char *fileName);
entry *(*append)(char *lastName);
entry *(*removeByFile)(char *fileName);
entry *(*remove)(char *lastName);
entry *(*findName)(char *lastName);
void (*size)();
void (*free)();
} Phonebook;
static double diff_in_second(struct timespec t1, struct timespec t2);
#endif