Commit f8279e9a authored by Geoff Simmons's avatar Geoff Simmons

trackrdrd: Fixed test_spmcq. Linux evidently requires that the object

to which the second arg of pthread_join points be allocated from outside
the thread, not from within the thread.
parent fd4cd393
...@@ -65,6 +65,7 @@ static char errmsg[BUFSIZ]; ...@@ -65,6 +65,7 @@ static char errmsg[BUFSIZ];
static unsigned xids[1 << MIN_TABLE_SCALE]; static unsigned xids[1 << MIN_TABLE_SCALE];
static prod_con_data_t proddata; static prod_con_data_t proddata;
static prod_con_data_t condata[NCON];
static void static void
*producer(void *arg) *producer(void *arg)
...@@ -100,17 +101,17 @@ static void ...@@ -100,17 +101,17 @@ static void
#define consumer_exit(pcdata, reason) \ #define consumer_exit(pcdata, reason) \
do { \ do { \
(pcdata).fail = (reason); \ (pcdata)->fail = (reason); \
pthread_exit(&(pcdata)); \ pthread_exit((pcdata)); \
} while(0) } while(0)
static void static void
*consumer(void *arg) *consumer(void *arg)
{ {
int id = *((int *) arg), deqs = 0; int id = *((int *) arg), deqs = 0;
prod_con_data_t pcdata; prod_con_data_t *pcdata = &condata[id];
pcdata.sum = 0; pcdata->sum = 0;
pcdata.fail = SUCCESS; pcdata->fail = SUCCESS;
unsigned *xid; unsigned *xid;
while (run) { while (run) {
...@@ -141,16 +142,16 @@ static void ...@@ -141,16 +142,16 @@ static void
/* xid != NULL */ /* xid != NULL */
debug_print("Consumer %d: dequeue %d (xid = %u)\n", id, ++deqs, debug_print("Consumer %d: dequeue %d (xid = %u)\n", id, ++deqs,
*xid); *xid);
pcdata.sum += *xid; pcdata->sum += *xid;
} }
} }
debug_print("Consumer %d: drain queue, run = %d\n", id, run); debug_print("Consumer %d: drain queue, run = %d\n", id, run);
while ((xid = (unsigned *) SPMCQ_Deq()) != NULL) { while ((xid = (unsigned *) SPMCQ_Deq()) != NULL) {
debug_print("Consumer %d: dequeue %d (xid = %u)\n", id, ++deqs, *xid); debug_print("Consumer %d: dequeue %d (xid = %u)\n", id, ++deqs, *xid);
pcdata.sum += *xid; pcdata->sum += *xid;
} }
debug_print("Consumer %d: exit\n", id); debug_print("Consumer %d: exit\n", id);
pthread_exit((void *) &pcdata); pthread_exit((void *) pcdata);
} }
/* N.B.: Always run this test first */ /* N.B.: Always run this test first */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment