~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/concurrency_test.c

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
void *run_task(void *p);
51
51
void *timer_thread(void *p);
52
52
void scheduler(az_method use_aio);
53
 
void create_data_file(azio_stream *write_handler, unsigned long long rows);
 
53
void create_data_file(azio_stream *write_handler, uint64_t rows);
54
54
unsigned int write_row(azio_stream *s);
55
55
 
56
56
typedef struct thread_context_st thread_context_st;
57
57
struct thread_context_st {
58
58
  unsigned int how_often_to_write;
59
 
  unsigned long long counter;
 
59
  uint64_t counter;
60
60
  az_method use_aio;
61
61
  azio_stream *writer;
62
62
};
93
93
  pthread_cond_init(&count_threshhold, NULL);
94
94
  pthread_mutex_init(&sleeper_mutex, NULL);
95
95
  pthread_cond_init(&sleep_threshhold, NULL);
96
 
  VOID(pthread_mutex_init(&timer_alarm_mutex, NULL));
97
 
  VOID(pthread_cond_init(&timer_alarm_threshold, NULL));
98
 
  VOID(pthread_mutex_init(&row_lock, NULL));
 
96
  pthread_mutex_init(&timer_alarm_mutex, NULL);
 
97
  pthread_cond_init(&timer_alarm_threshold, NULL);
 
98
  pthread_mutex_init(&row_lock, NULL);
99
99
 
100
100
  for (method= AZ_METHOD_BLOCK; method < AZ_METHOD_MAX; method++)
101
101
    scheduler(method);
104
104
  (void)pthread_cond_destroy(&count_threshhold);
105
105
  (void)pthread_mutex_destroy(&sleeper_mutex);
106
106
  (void)pthread_cond_destroy(&sleep_threshhold);
107
 
  VOID(pthread_mutex_destroy(&timer_alarm_mutex));
108
 
  VOID(pthread_cond_destroy(&timer_alarm_threshold));
109
 
  VOID(pthread_mutex_destroy(&row_lock));
 
107
  pthread_mutex_destroy(&timer_alarm_mutex);
 
108
  pthread_cond_destroy(&timer_alarm_threshold);
 
109
  pthread_mutex_destroy(&row_lock);
110
110
 
111
111
  return 0;
112
112
}
114
114
void scheduler(az_method use_aio)
115
115
{
116
116
  unsigned int x;
117
 
  unsigned long long total;
 
117
  uint64_t total;
118
118
  azio_stream writer_handle;
119
119
  thread_context_st *context;
120
120
  pthread_t mainthread;            /* Thread descriptor */
204
204
  free(context);
205
205
  azclose(&writer_handle);
206
206
 
207
 
  printf("Read %llu rows\n", total);
 
207
  printf("Read %"PRIu64" rows\n", total);
208
208
}
209
209
 
210
210
void *timer_thread(void *p)
239
239
void *run_task(void *p)
240
240
{
241
241
  thread_context_st *context= (thread_context_st *)p;
242
 
  unsigned long long count;
 
242
  uint64_t count;
243
243
  int ret;
244
244
  int error;
245
245
  azio_stream reader_handle;
246
246
 
247
 
  if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY|O_BINARY,
 
247
  if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY,
248
248
                    context->use_aio)))
249
249
  {
250
250
    printf("Could not open test file\n");
285
285
  return NULL;
286
286
}
287
287
 
288
 
void create_data_file(azio_stream *write_handler, unsigned long long rows)
 
288
void create_data_file(azio_stream *write_handler, uint64_t rows)
289
289
{
290
290
  int ret;
291
 
  unsigned long long x;
 
291
  uint64_t x;
292
292
 
293
 
  if (!(ret= azopen(write_handler, TEST_FILENAME, O_CREAT|O_RDWR|O_TRUNC|O_BINARY,
 
293
  if (!(ret= azopen(write_handler, TEST_FILENAME, O_CREAT|O_RDWR|O_TRUNC,
294
294
                    AZ_METHOD_BLOCK)))
295
295
  {
296
296
    printf("Could not create test file\n");