1 #ifndef _THREADNOTIFY_H_
2 #define _THREADNOTIFY_H_
8 #define N_LOADFACTOR 0.5
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*/
25 pthread_mutex_t threadnotify;
28 typedef struct notifylistnode {
29 unsigned int threadid;
31 struct notifylistnode *next;
34 typedef struct notifyhashtable {
35 notifylistnode_t *table; //Points to beginning of hash table
37 unsigned int numelements;
39 pthread_mutex_t locktable; //Lock for the hashtable
42 threadlist_t *insNode(threadlist_t *head, unsigned int threadid, unsigned int mid); //Inserts nodes for one object that
43 //needs to send notification to threads waiting on it
44 void display(threadlist_t *head);// Displays linked list of nodes for one object
45 unsigned int notifyhashCreate(unsigned int size, float loadfactor); //returns 1 if hashtable creation is not successful
46 unsigned int notifyhashFunction(unsigned int tid); //returns index in the hash table
47 unsigned int notifyhashInsert(unsigned int tid, notifydata_t *ndata); //returns 1 if insert not successful
48 notifydata_t *notifyhashSearch(unsigned int tid); //returns pointer to notify data, NULL if not found
49 unsigned int notifyhashRemove(unsigned int tid); //returns 1 if not successful
50 unsigned int notifyhashResize(unsigned int newsize);