-
Notifications
You must be signed in to change notification settings - Fork 0
/
sugar.h
53 lines (46 loc) · 1.49 KB
/
sugar.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
///////////////////////////////////////////////////////
// Multicore Systems.
// Project 2 : 3D sugar scape.
// GNU General Public License
// Author: Youngdae Kwon
// kydchonje@gmail.com
///////////////////////////////////////////////////////
#ifndef __LIB_SUGAR_H__
#define __LIB_SUGAR_H__
#define SLEEP_ONE_SECOND 1000000
#define MIN_NUM_THREAD 4
#define DEFAULT_NUM_THREAD 8
#define MAX_NUM_THREAD 96
#define THREAD_CREATE_SUGAR_X_ID 0
#define THREAD_CREATE_SUGAR_Y_ID 1
#define THREAD_CREATE_SUGAR_Z_ID 2
#define THREAD_CREATE_PEOPLE_ID 3
#define THREAD_CREATE_PEOPLE_SIZE_FACTOR 3
#define THREAD_CREATE_SUGAR_SIZE_FACTOR 150
#include "./setup.h"
#include "./lcgrand.h"
#include "./queue.h"
////////////////////////////////////////////////////
/* sequential functions */
void loadMapAndPeople();
void peopleMove();
void peopleMergeAndEat();
void createPeople();
void createSugar();
void printMapSugar();
/* thread functions */
void thread_init();
void thread_free();
void* thread_people_move (void* rank);
void thread_main_people_move (int rank);
void* thread_people_merge_eat (void* rank);
void thread_main_people_merge_eat (int rank);
void* thread_create_people (void* num_create);
void* thread_insert_people (void* rank);
void* thread_create_sugar_x (void* num_create);
void* thread_create_sugar_y (void* num_create);
void* thread_create_sugar_z (void* num_create);
void* thread_insert_sugar (void* rank);
// quick sort compare functions
int cmpfunc_total (const void * a, const void * b);
#endif