-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic_threads.h
97 lines (75 loc) · 2.15 KB
/
static_threads.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef Thre
#define Thre
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#include <ctype.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include "byte_array_handler.h"
#include "connectedComponents.h"
#include "listworkload.h"
#include "grail.h"
#define perror2(s,e) fprintf(stderr,"%s: %s\n",s,strerror(e))
#define SEQSIZE 10000
#define RES_SIZE 30000000
// Thread Functions
void *worker(void *);
///QUEUE OF jobscheduler
typedef struct Args{
uint32_t from;
uint32_t to;
}Args;
typedef struct Job{
int (*j)(Args *,int);
Args *args;
}Job;
typedef struct JobScheduler{
int threadsnum; //how many threads we got
Job *q; //the queue of jobs
uint32_t head,tail; //start and end of queue (remember ,insert at end,delete from start)
int q_size; //size of queue.
int *results; // result array
int num_of_res;
pthread_t *tids; // the array of thread ids
//and now mutexes-condition variables for synch
pthread_mutex_t mutex_start ;
pthread_mutex_t mutex_workersfree; //protect variable worker free
uint32_t *start_from_here;
int workers_free;
pthread_cond_t cond_JS;
pthread_cond_t cond_Workers;
}JobScheduler;
typedef struct global_vars{
SCC *scc;
Component **hash;
uint32_t graph_size;
NodeIndex *incoming_index,*outcoming_index;
MetaDataBuffer *b_in,*b_out;
FILE *fd,*fp;
//arrays of arrays because each worker has its one dirty bit arrays
DirtyByteArray **dirty_in;
DirtyByteArray **dirty_out;
neighbors **neighbors_forward;
neighbors **neighbors_backward;
}global_vars;
JobScheduler *initialize_scheduler(int thread_num); //create job scheduler
int destroy_scheduler(void); //destroy job scheduler
int submit_jobs(void);
void execute_all_jobs(void);
void wait_all_task_finish(void); //waits all submitted task to finish
int questionJob(Args * args, int t_id); //execute the job using grail bbfs etc
void workers_exit(void);
void execute_print(void);
void wait_print(void);
void destroyStructs(void);
extern global_vars gv;
extern JobScheduler *js;
#endif