annotate src/synchronizedQueue/synchronizedQueueContext.h @ 58:4283b87ddbf4

Add stub to synchronizedQueues
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 16 Jun 2015 15:59:48 +0900
parents 83ee9c75115a
children 2a40d697bf4e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
2e7e66ccb3db Add synchronizedQueueForSem Files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 40
diff changeset
1 /* Context definition for synchronized queue 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
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
10 Code4,
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
11 Code5,
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
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
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
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
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
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
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
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
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
32 void* heap_start;
28
5d9f74220506 Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 void* heap;
36
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
34 long dataSize;
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
35 int dataNum;
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
36 union Data* head;
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
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
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
42 struct Queue {
58
4283b87ddbf4 Add stub to synchronizedQueues
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
43 struct Element* first;
4283b87ddbf4 Add stub to synchronizedQueues
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
44 struct Element* last;
38
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;
52
83ee9c75115a Add pthread_cond_wait & pthread_cond_signal to synchronizedQueue.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
47 pthread_cond_t cond;
36
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
48 } queue;
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
49 struct Element {
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
50 int value;
58
4283b87ddbf4 Add stub to synchronizedQueues
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
51 struct Element* next;
36
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
52 } element;
28
5d9f74220506 Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 struct Allocate {
5d9f74220506 Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 long size;
5d9f74220506 Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 enum Code next;
5d9f74220506 Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 enum Code after_put;
36
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
57 enum Code after_get;
48
1b71266af056 Add CAS loop to synchronizedQueueForCas
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
58 enum Code after_fail;
28
5d9f74220506 Add file synchronizedQueueContext
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 } allocate;
36
240c045ebab2 Add normal queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 28
diff changeset
60 };