Bug in communication techniques bench

* prod_idx and cons_idx aren't declared volatile so compiler could
  sur-optimize access to these variable and lead to a deadlock
This commit is contained in:
Thomas Preud'homme 2009-06-12 00:36:31 +02:00 committed by Thomas Preud'homme
parent 471fdef61e
commit 02db9b77f6
4 changed files with 12 additions and 12 deletions

View File

@ -14,8 +14,8 @@ struct communication_assoc
struct communication_assoc *prev;
pthread_t tid;
uintptr_t *shared_space;
int *cons_idx;
int *prod_idx;
volatile int *cons_idx;
volatile int *prod_idx;
};
extern struct communication_assoc assoc_root;
@ -23,8 +23,8 @@ extern struct communication_assoc assoc_root;
__BEGIN_DECLS
extern __thread uintptr_t *shared_space;
extern __thread int prod_idx;
extern __thread int cons_idx;
extern __thread volatile int prod_idx;
extern __thread volatile int cons_idx;
struct communication_assoc *create_comm_assoc(void);
static inline void send(uintptr_t value) {

View File

@ -14,8 +14,8 @@ struct communication_assoc
struct communication_assoc *prev;
pthread_t tid;
uintptr_t *shared_space;
int *cons_idx;
int *prod_idx;
volatile int *cons_idx;
volatile int *prod_idx;
};
extern struct communication_assoc assoc_root;
@ -23,8 +23,8 @@ extern struct communication_assoc assoc_root;
__BEGIN_DECLS
extern __thread uintptr_t *shared_space;
extern __thread int prod_idx;
extern __thread int cons_idx;
extern __thread volatile int prod_idx;
extern __thread volatile int cons_idx;
struct communication_assoc *create_comm_assoc(void);
static inline void send(uintptr_t value) {

View File

@ -9,8 +9,8 @@
__thread uintptr_t *shared_space;
__thread int cons_idx = 0;
__thread int prod_idx = 0;
__thread volatile int cons_idx = 0;
__thread volatile int prod_idx = 0;
struct communication_assoc *create_comm_assoc(void)
{

View File

@ -9,8 +9,8 @@
__thread uintptr_t *shared_space;
__thread int cons_idx = 0;
__thread int prod_idx = 0;
__thread volatile int cons_idx = 0;
__thread volatile int prod_idx = 0;
struct communication_assoc *create_comm_assoc(void)
{