1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _FB_THREADFLOW_H 27 #define _FB_THREADFLOW_H 28 29 #include "filebench.h" 30 31 #define AL_READ 1 32 #define AL_WRITE 2 33 34 #ifdef HAVE_AIO 35 typedef struct aiolist { 36 int al_type; 37 struct aiolist *al_next; 38 struct aiolist *al_worknext; 39 struct aiocb64 al_aiocb; 40 } aiolist_t; 41 #endif 42 43 #define THREADFLOW_MAXFD 128 44 #define THREADFLOW_USEISM 0x1 45 46 typedef struct threadflow { 47 char tf_name[128]; /* Name */ 48 int tf_attrs; /* Attributes */ 49 int tf_instance; /* Instance number */ 50 int tf_running; /* Thread running indicator */ 51 int tf_abort; /* Shutdown thread */ 52 int tf_utid; /* Unique id for thread */ 53 struct procflow *tf_process; /* Back pointer to process */ 54 pthread_t tf_tid; /* Thread id */ 55 pthread_mutex_t tf_lock; /* Mutex around threadflow */ 56 avd_t tf_instances; /* Number of instances for this flow */ 57 struct threadflow *tf_next; /* Next on proc list */ 58 struct flowop *tf_thrd_fops; /* Flowop list */ 59 caddr_t tf_mem; /* Private Memory */ 60 avd_t tf_memsize; /* Private Memory size attribute */ 61 fbint_t tf_constmemsize; /* constant copy of memory size */ 62 fb_fdesc_t tf_fd[THREADFLOW_MAXFD + 1]; /* Thread local fd's */ 63 filesetentry_t *tf_fse[THREADFLOW_MAXFD + 1]; /* Thread local files */ 64 int tf_fdrotor; /* Rotating fd within set */ 65 struct flowstats tf_stats; /* Thread statistics */ 66 hrtime_t tf_stime; /* Start time of current flowop: used to measure the latency of the flowop */ 67 #ifdef HAVE_AIO 68 aiolist_t *tf_aiolist; /* List of async I/Os */ 69 #endif 70 avd_t tf_ioprio; /* ioprio attribute */ 71 72 } threadflow_t; 73 74 /* Thread attrs */ 75 #define THREADFLOW_DEFAULTMEM 1024*1024LL; 76 77 threadflow_t *threadflow_define(procflow_t *, char *name, 78 threadflow_t *inherit, avd_t instances); 79 threadflow_t *threadflow_find(threadflow_t *, char *); 80 int threadflow_init(procflow_t *); 81 void flowop_start(threadflow_t *threadflow); 82 void threadflow_allstarted(pid_t pid, threadflow_t *threadflow); 83 void threadflow_delete_all(threadflow_t **threadlist); 84 85 #endif /* _FB_THREADFLOW_H */ 86