1 #ifndef _THREADNOTIFY_H_
2 #define _THREADNOTIFY_H_
8 #define N_LOADFACTOR 0.75
11 //Structure to notify object of which other objects/threads are waiting on it
12 typedef struct threadlist {
13 unsigned int threadid;
15 struct threadlist *next;
18 //Structure for objects involved in wait-notify call
19 typedef struct notifydata {
20 unsigned int numoid; /* Number of oids on which we are waiting for updated notification */
21 unsigned int threadid; /* The threadid that is waiting for update notification response*/
22 unsigned int *oidarry; /* Pointer to array of oids that this threadid is waiting on*/
23 unsigned short *versionarry;/* Pointer to array of versions of the oids that we are waiting on */
24 pthread_cond_t threadcond; /* Cond variable associated with each threadid that needs to be signaled*/
27 typedef struct notifylistnode {
28 unsigned int threadid;
30 struct notifylistnode *next;
33 typedef struct notifyhashtable {
34 notifylistnode_t *table; //Points to beginning of hash table
36 unsigned int numelements;
38 pthread_mutex_t locktable; //Lock for the hashtable
41 void insNode(threadlist_t *head, unsigned int threadid, unsigned int mid); //Inserts nodes for one object that
42 //needs to send notification to threads waiting on it
43 void display(threadlist_t *head);// Displays linked list of nodes for one object
44 unsigned int notifyhashCreate(unsigned int size, float loadfactor); //returns 1 if hashtable creation is not successful
45 unsigned int notifyhashFunction(unsigned int tid); //returns index in the hash table
46 unsigned int notifyhashInsert(unsigned int tid, notifydata_t *ndata); //returns 1 if insert not successful
47 notifydata_t *notifyhashSearch(unsigned int tid); //returns pointer to notify data, NULL if not found
48 unsigned int notifyhashRemove(unsigned int tid); //returns 1 if not successful
49 unsigned int notifyhashResize(unsigned int newsize);