From f5ff26b2339da5d9ea6a3e1784ca8ca662cf9cca Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Mon, 14 Mar 2005 20:04:44 +0000 Subject: [PATCH] Added commit() call to inner while loop of linearHashNTAWriteRequests.c --- benchmarks/linearHashNTAWriteRequests.c | 6 ++--- test/lladd/check_multiplexer.c | 34 ++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/benchmarks/linearHashNTAWriteRequests.c b/benchmarks/linearHashNTAWriteRequests.c index aca474e..1ff7567 100644 --- a/benchmarks/linearHashNTAWriteRequests.c +++ b/benchmarks/linearHashNTAWriteRequests.c @@ -49,7 +49,7 @@ static void * go (void * arg_ptr) { int k = *(int*)arg_ptr; int j; - int xid = Tbegin(); + int xid;// = Tbegin(); double sum_x_squared = 0; double sum = 0; @@ -98,7 +98,7 @@ static void * go (void * arg_ptr) { assert(timeout.tv_nsec <= start.tv_nsec || timeout.tv_sec < start.tv_sec); */ - + xid = Tbegin(); ThashInsert(xid, hash, (byte*)&j, sizeof(int), (byte*)&j, sizeof(int)); @@ -202,7 +202,7 @@ int main(int argc, char** argv) { pthread_cond_init(&never, NULL); pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN); - pthread_attr_setschedpolicy(&attr, SCHED_FIFO); + // pthread_attr_setschedpolicy(&attr, SCHED_FIFO); pthread_mutex_lock(&mutex); diff --git a/test/lladd/check_multiplexer.c b/test/lladd/check_multiplexer.c index 37c7294..542c7ef 100644 --- a/test/lladd/check_multiplexer.c +++ b/test/lladd/check_multiplexer.c @@ -64,19 +64,47 @@ terms specified in this license. */ -#define NUM_ENTRIES 10000 + +#define NUM_ENTRIES 10000 +#define NUM_THREADS 100 START_TEST(multiplexTest) { Tinit(); int xid = Tbegin(); recordid hash; lladdIterator_t * it = ThashGenericIterator(xid, hash); - lladdFifoPool_t * fifoPool = fifoPool_ringBufferInit(100, 10000); + lladdFifoPool_t * fifoPool = fifoPool_ringBufferInit(NUM_THREADS, NUM_ENTRIES); lladdMultiplexer_t * mux = lladdMultiplexer_alloc(xid, it, &multiplexHashLogByKey, &fifoPool_getConsumerCRC32, fifoPool); // now, read from fifos, checking to see if everything is well. (Need to spawn one thread per fifo.) - + int i; + + /* threads have static thread sizes. Ughh. */ + pthread_attr_t attr; + pthread_attr_init(&attr); + + pthread_mutex_init(&mutex, NULL); + pthread_cond_init(&never, NULL); + + pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN); + pthread_attr_setschedpolicy(&attr, SCHED_FIFO); + pthread_mutex_lock(&mutex); + + pthread_t * workers = malloc(sizeof(pthread_t) * fifoPool->fifoCount); + + for(i = 0 ; i < fifoPool->fifoCount; i++) { + lladdConsumer_t * consumer = fifoPool->pool[i]->consumer; + + pthread_create(&workers[i], &attr, go, consumer); + + } + + pthread_mutex_unlock(&mutex); + + for(i = 0; i < fifoPool->fifoCount; i++) { + pthread_join(&workers[i], NULL); + } } END_TEST