Mercurial > hg > GearsTemplate
annotate src/synchronizedQueue/synchronizedQueueContext.h @ 40:46917f503bce
Add thread_join to synchronizedQueue
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 18 May 2015 15:24:46 +0900 |
parents | 754c90e96e3d |
children | 2e7e66ccb3db |
rev | line source |
---|---|
36 | 1 /* Context definition for list example */ |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 |
39
754c90e96e3d
Add synchronizedQueue. it use pthread_mutex_lock, unlock
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
38
diff
changeset
|
3 #include <pthread.h> |
40
46917f503bce
Add thread_join to synchronizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
4 #define ALLOCATE_SIZE 1000 |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 enum Code { |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 Code1, |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 Code2, |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 Code3, |
36 | 10 Code4, |
11 Code5, | |
12 Code6, | |
39
754c90e96e3d
Add synchronizedQueue. it use pthread_mutex_lock, unlock
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
38
diff
changeset
|
13 Code7, |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 Allocator, |
38
ce9fde200f3e
Add code segment sender & receiver to synchronizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
15 Sender, |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 Put, |
38
ce9fde200f3e
Add code segment sender & receiver to synchronizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
17 Receiver, |
36 | 18 Get, |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 Exit, |
40
46917f503bce
Add thread_join to synchronizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
20 ThreadExit, |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 }; |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 enum UniqueData { |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 Allocate, |
36 | 25 Queue, |
39
754c90e96e3d
Add synchronizedQueue. it use pthread_mutex_lock, unlock
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
38
diff
changeset
|
26 Counter, |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 }; |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 struct Context { |
36 | 30 int codeNum; |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 __code (**code) (struct Context *); |
36 | 32 void* heap_start; |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 void* heap; |
36 | 34 long dataSize; |
35 int dataNum; | |
36 union Data* head; | |
37 union Data** data; | |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 }; |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 union Data { |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 long count; |
36 | 42 struct Queue { |
38
ce9fde200f3e
Add code segment sender & receiver to synchronizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
43 union Data* first; |
ce9fde200f3e
Add code segment sender & receiver to synchronizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
44 union Data* last; |
ce9fde200f3e
Add code segment sender & receiver to synchronizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
45 int count; |
39
754c90e96e3d
Add synchronizedQueue. it use pthread_mutex_lock, unlock
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
38
diff
changeset
|
46 pthread_mutex_t mutex; |
36 | 47 } queue; |
48 struct Element { | |
49 int value; | |
50 union Data* next; | |
51 } element; | |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 struct Allocate { |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 long size; |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54 enum Code next; |
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55 enum Code after_put; |
36 | 56 enum Code after_get; |
28
5d9f74220506
Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 } allocate; |
36 | 58 }; |