comparison prqueue.h @ 20:f3cb11baf791

Fully working longjmp, get_sched based. Also OS Portability work included. Related library_proto-runtime commit: 45dc6d5afb2d
author Philipe Louchtch
date Fri, 09 May 2014 11:19:53 +0200
parents c3829f630c2f
children
comparison
equal deleted inserted replaced
2:ee9e9d0a1359 3:c8260d160e14
7 7
8 #ifndef _PRQUEUE_H 8 #ifndef _PRQUEUE_H
9 #define _PRQUEUE_H 9 #define _PRQUEUE_H
10 10
11 #include <PR__include/PR__primitive_data_types.h> 11 #include <PR__include/PR__primitive_data_types.h>
12 #include <pthread.h> 12 //#include <pthreads/implement.h> //Part of pthreads-win32, needed for type definitions
13 #include <PR__include/osportability.h>
13 14
14 #define TRUE 1 15 #define TRUE 1
15 #define FALSE 0 16 #define FALSE 0
16 17
17 //================== Private Queue stuff =================== 18 //================== Private Queue stuff ===================
18 /* It is the data that is shared so only need one mutex. */ 19 /* It is the data that is shared so only need one mutex. */
19 typedef struct 20 typedef struct _PrivQueueStruc
20 { void **insertPos; 21 { void **insertPos;
21 void **extractPos; 22 void **extractPos;
22 void **startOfData; //data is pointers 23 void **startOfData; //data is pointers
23 void **endOfData; //set when alloc data 24 void **endOfData; //set when alloc data
24 } 25 }
41 //====================== Parallel Queue Stuff ==================== 42 //====================== Parallel Queue Stuff ====================
42 43
43 //========== pThreads based queue ========== 44 //========== pThreads based queue ==========
44 /* It is the data that is shared so only need one mutex. */ 45 /* It is the data that is shared so only need one mutex. */
45 typedef 46 typedef
46 struct 47 struct _PThdQueueStruc
47 { pthread_mutex_t mutex_t; 48 {
49 pthread_mutex_t mutex_t;
48 pthread_cond_t cond_w_t; 50 pthread_cond_t cond_w_t;
49 pthread_cond_t cond_r_t; 51 pthread_cond_t cond_r_t;
50 int32 count; 52 int32 count;
51 int32 readPos; 53 int32 readPos;
52 int32 writePos; 54 int32 writePos;
61 void writePThdQ( void *in, PThdQueueStruc *Q ); 63 void writePThdQ( void *in, PThdQueueStruc *Q );
62 64
63 65
64 //========== CAS based queue ========== 66 //========== CAS based queue ==========
65 typedef 67 typedef
66 struct 68 struct _CASQueueStruc
67 { volatile int32 insertLock; 69 { volatile int32 insertLock;
68 volatile int32 extractLock; 70 volatile int32 extractLock;
69 volatile void* *insertPos; 71 volatile void* *insertPos;
70 volatile void* *extractPos; 72 volatile void* *extractPos;
71 void* startOfData[1024]; //data is pointers 73 void* startOfData[1024]; //data is pointers
78 void writeCASQ( void *in, CASQueueStruc *Q ); 80 void writeCASQ( void *in, CASQueueStruc *Q );
79 81
80 82
81 //========= non-atomic instr based queue =========== 83 //========= non-atomic instr based queue ===========
82 typedef 84 typedef
83 struct 85 struct _SRSWQueueStruc
84 { void* *insertPos; 86 { void* *insertPos;
85 void* *extractPos; 87 void* *extractPos;
86 void* startOfData[1024]; //data is pointers 88 void* startOfData[1024]; //data is pointers
87 void* *endOfData; //set when make queue 89 void* *endOfData; //set when make queue
88 } 90 }
94 void writeSRSWQ( void *in, SRSWQueueStruc *Q ); 96 void writeSRSWQ( void *in, SRSWQueueStruc *Q );
95 97
96 98
97 //========= non-atomic instr S R M W queue =========== 99 //========= non-atomic instr S R M W queue ===========
98 typedef 100 typedef
99 struct 101 struct _SRMWQueueStruc
100 { int32 lastQReadFrom; 102 { int32 lastQReadFrom;
101 int32 numInternalQs; 103 int32 numInternalQs;
102 int32 internalQsSz; 104 int32 internalQsSz;
103 SRSWQueueStruc* *internalQs; 105 SRSWQueueStruc* *internalQs;
104 } 106 }