Home | History | Annotate | Download | only in ffsb-6.0-rc2
      1 /*
      2  *   Copyright (c) International Business Machines Corp., 2001-2004
      3  *
      4  *   This program is free software;  you can redistribute it and/or modify
      5  *   it under the terms of the GNU General Public License as published by
      6  *   the Free Software Foundation; either version 2 of the License, or
      7  *   (at your option) any later version.
      8  *
      9  *   This program is distributed in the hope that it will be useful,
     10  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
     11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
     12  *   the GNU General Public License for more details.
     13  *
     14  *   You should have received a copy of the GNU General Public License
     15  *   along with this program;  if not, write to the Free Software
     16  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     17  */
     18 #include <pthread.h>
     19 #include <sys/time.h>
     20 #include <sys/times.h>
     21 #include <unistd.h>
     22 #include <string.h>
     23 #include <stdio.h>
     24 #include <stdlib.h>
     25 #include <pthread.h>
     26 
     27 #include <assert.h>
     28 
     29 #include "config.h"
     30 
     31 #include "ffsb.h"
     32 #include "util.h"
     33 #include "parser.h"
     34 
     35 void init_ffsb_config(ffsb_config_t * fc, unsigned num_fs, unsigned num_tg)
     36 {
     37 	memset(fc, 0, sizeof(ffsb_config_t));
     38 
     39 	fc->num_totalthreads = -1;
     40 	fc->num_threadgroups = num_tg;
     41 	fc->num_filesys = num_fs;
     42 
     43 	fc->groups = ffsb_malloc(sizeof(ffsb_tg_t) * num_tg);
     44 	fc->filesystems = ffsb_malloc(sizeof(ffsb_fs_t) * num_fs);
     45 }
     46 
     47 void init_ffsb_config_1fs(ffsb_config_t * fc, ffsb_fs_t * fs, ffsb_tg_t * tg)
     48 {
     49 	memset(fc, 0, sizeof(*fc));
     50 
     51 	fc->num_totalthreads = tg_get_numthreads(tg);
     52 	fc->num_threadgroups = 1;
     53 	fc->num_filesys = 1;
     54 
     55 	fc->groups = tg;
     56 	fc->filesystems = fs;
     57 }
     58 
     59 void destroy_ffsb_config(ffsb_config_t * fc)
     60 {
     61 	int i;
     62 	for (i = 0; i < fc->num_filesys; i++)
     63 		destroy_ffsb_fs(&fc->filesystems[i]);
     64 
     65 	for (i = 0; i < fc->num_threadgroups; i++)
     66 		destroy_ffsb_tg(&fc->groups[i]);
     67 
     68 	free(fc->groups);
     69 	free(fc->filesystems);
     70 }
     71 
     72 void fc_set_time(ffsb_config_t * fc, unsigned time)
     73 {
     74 	fc->time = time;
     75 }
     76 
     77 unsigned fc_get_num_filesys(ffsb_config_t * fc)
     78 {
     79 	return fc->num_filesys;
     80 }
     81 
     82 struct ffsb_tg *fc_get_tg(ffsb_config_t * fc, unsigned num)
     83 {
     84 	assert(num < fc->num_threadgroups);
     85 	return &fc->groups[num];
     86 }
     87 
     88 struct ffsb_fs *fc_get_fs(ffsb_config_t * fc, unsigned num)
     89 {
     90 	assert(num < fc->num_filesys);
     91 	return &fc->filesystems[num];
     92 }
     93 
     94 void fc_set_num_totalthreads(ffsb_config_t * fc, int num)
     95 {
     96 	assert(num > 0);
     97 	fc->num_totalthreads = num;
     98 }
     99 
    100 void fc_set_callout(ffsb_config_t * fc, char *callout)
    101 {
    102 	free(fc->callout);
    103 	fc->callout = ffsb_strdup(callout);
    104 }
    105 
    106 char *fc_get_callout(ffsb_config_t * fc)
    107 {
    108 	return fc->callout;
    109 }
    110