~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/concurrency_test.c

  • Committer: Monty Taylor
  • Date: 2008-10-27 23:19:48 UTC
  • mto: (520.4.12 merge-innodb-plugin)
  • mto: This revision was merged to the branch mainline in revision 563.
  • Revision ID: monty@inaugust.com-20081027231948-3kl6ss04plbakqcr
Split some more things out of common_includes.h.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
#define DEFAULT_INITIAL_LOAD 10000
30
30
#define DEFAULT_EXECUTE_SECONDS 120
 
31
#define DEFAULT_CONCURRENCY 8
31
32
#define TEST_FILENAME "concurrency_test.az"
32
33
 
33
34
#define HUGE_STRING_LENGTH 8192
46
47
pthread_mutex_t row_lock;
47
48
 
48
49
/* Prototypes */
49
 
void *run_concurrent_task(void *p);
 
50
void *run_task(void *p);
50
51
void *timer_thread(void *p);
51
52
void scheduler(az_method use_aio);
52
53
void create_data_file(azio_stream *write_handler, uint64_t rows);
150
151
    context[x].use_aio= use_aio;
151
152
 
152
153
    /* now you create the thread */
153
 
    if (pthread_create(&mainthread, &attr, run_concurrent_task,
 
154
    if (pthread_create(&mainthread, &attr, run_task,
154
155
                       (void *)context) != 0)
155
156
    {
156
157
      fprintf(stderr,"Could not create thread\n");
166
167
    timer_alarm= true;
167
168
    pthread_mutex_unlock(&timer_alarm_mutex);
168
169
 
169
 
    if (pthread_create(&mainthread, &attr, timer_thread,
 
170
    if (pthread_create(&mainthread, &attr, timer_thread, 
170
171
                       (void *)&opt_timer_length) != 0)
171
172
    {
172
173
      fprintf(stderr,"%s: Could not create timer thread\n", my_progname);
211
212
  time_t *timer_length= (time_t *)p;
212
213
  struct timespec abstime;
213
214
 
214
 
  /*
215
 
    We lock around the initial call in case were we in a loop. This
 
215
  /* 
 
216
    We lock around the initial call in case were we in a loop. This 
216
217
    also keeps the value properly syncronized across call threads.
217
218
  */
218
219
  pthread_mutex_lock(&sleeper_mutex);
235
236
  return 0;
236
237
}
237
238
 
238
 
void *run_concurrent_task(void *p)
 
239
void *run_task(void *p)
239
240
{
240
241
  thread_context_st *context= (thread_context_st *)p;
241
242
  uint64_t count;
254
255
  while (master_wakeup)
255
256
  {
256
257
    pthread_cond_wait(&sleep_threshhold, &sleeper_mutex);
257
 
  }
 
258
  } 
258
259
  pthread_mutex_unlock(&sleeper_mutex);
259
260
 
260
261
  /* Do Stuff */
312
313
  /* Avoid zero length strings */
313
314
  length++;
314
315
 
315
 
  get_random_string(buffer, length);
 
316
  get_random_string(buffer, length); 
316
317
  pthread_mutex_lock(&row_lock);
317
318
  azwrite_row(s, buffer, length);
318
319
  pthread_mutex_unlock(&row_lock);