1*5184Sek110237 /* 2*5184Sek110237 * CDDL HEADER START 3*5184Sek110237 * 4*5184Sek110237 * The contents of this file are subject to the terms of the 5*5184Sek110237 * Common Development and Distribution License (the "License"). 6*5184Sek110237 * You may not use this file except in compliance with the License. 7*5184Sek110237 * 8*5184Sek110237 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5184Sek110237 * or http://www.opensolaris.org/os/licensing. 10*5184Sek110237 * See the License for the specific language governing permissions 11*5184Sek110237 * and limitations under the License. 12*5184Sek110237 * 13*5184Sek110237 * When distributing Covered Code, include this CDDL HEADER in each 14*5184Sek110237 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5184Sek110237 * If applicable, add the following below this CDDL HEADER, with the 16*5184Sek110237 * fields enclosed by brackets "[]" replaced with your own identifying 17*5184Sek110237 * information: Portions Copyright [yyyy] [name of copyright owner] 18*5184Sek110237 * 19*5184Sek110237 * CDDL HEADER END 20*5184Sek110237 */ 21*5184Sek110237 /* 22*5184Sek110237 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*5184Sek110237 * Use is subject to license terms. 24*5184Sek110237 */ 25*5184Sek110237 26*5184Sek110237 #ifndef _FB_THREADFLOW_H 27*5184Sek110237 #define _FB_THREADFLOW_H 28*5184Sek110237 29*5184Sek110237 #pragma ident "%Z%%M% %I% %E% SMI" 30*5184Sek110237 31*5184Sek110237 #include "config.h" 32*5184Sek110237 #include <pthread.h> 33*5184Sek110237 34*5184Sek110237 #ifndef HAVE_CADDR_T1 35*5184Sek110237 /* typedef char *caddr_t; */ 36*5184Sek110237 #endif 37*5184Sek110237 38*5184Sek110237 #ifdef LINUX_PORT 39*5184Sek110237 #include <linux/types.h> /* for "caddr_t" */ 40*5184Sek110237 #endif 41*5184Sek110237 42*5184Sek110237 43*5184Sek110237 #ifdef HAVE_AIO 44*5184Sek110237 #include <aio.h> 45*5184Sek110237 #endif 46*5184Sek110237 #ifdef HAVE_PROCFS 47*5184Sek110237 #include <procfs.h> 48*5184Sek110237 #endif 49*5184Sek110237 #include "vars.h" 50*5184Sek110237 #include "procflow.h" 51*5184Sek110237 #include "fileset.h" 52*5184Sek110237 53*5184Sek110237 #ifdef __cplusplus 54*5184Sek110237 extern "C" { 55*5184Sek110237 #endif 56*5184Sek110237 57*5184Sek110237 #define AL_READ 1 58*5184Sek110237 #define AL_WRITE 2 59*5184Sek110237 60*5184Sek110237 61*5184Sek110237 #ifdef HAVE_AIO 62*5184Sek110237 typedef struct aiolist { 63*5184Sek110237 int al_type; 64*5184Sek110237 struct aiolist *al_next; 65*5184Sek110237 struct aiolist *al_worknext; 66*5184Sek110237 struct aiocb64 al_aiocb; 67*5184Sek110237 } aiolist_t; 68*5184Sek110237 #endif 69*5184Sek110237 70*5184Sek110237 #define THREADFLOW_MAXFD 128 71*5184Sek110237 #define THREADFLOW_USEISM 0x1 72*5184Sek110237 73*5184Sek110237 typedef struct threadflow { 74*5184Sek110237 char tf_name[128]; /* Name */ 75*5184Sek110237 int tf_attrs; /* Attributes */ 76*5184Sek110237 int tf_instance; /* Instance number */ 77*5184Sek110237 int tf_running; /* Thread running indicator */ 78*5184Sek110237 int tf_abort; /* Shutdown thread */ 79*5184Sek110237 int tf_utid; /* Unique id for thread */ 80*5184Sek110237 struct procflow *tf_process; /* Back pointer to process */ 81*5184Sek110237 pthread_t tf_tid; /* Thread id */ 82*5184Sek110237 pthread_mutex_t tf_lock; /* Mutex around threadflow */ 83*5184Sek110237 var_integer_t tf_instances; /* Number of instances for this flow */ 84*5184Sek110237 struct threadflow *tf_next; /* Next on proc list */ 85*5184Sek110237 struct flowop *tf_ops; /* Flowop list */ 86*5184Sek110237 caddr_t tf_mem; /* Private Memory */ 87*5184Sek110237 var_integer_t tf_memsize; /* Private Memory size */ 88*5184Sek110237 int tf_fd[THREADFLOW_MAXFD + 1]; /* Thread local fd's */ 89*5184Sek110237 filesetentry_t *tf_fse[THREADFLOW_MAXFD + 1]; /* Thread local files */ 90*5184Sek110237 int tf_fdrotor; /* Rotating fd within set */ 91*5184Sek110237 flowstat_t tf_stats; /* Thread statistics */ 92*5184Sek110237 hrtime_t tf_stime; /* Start time of op */ 93*5184Sek110237 #ifdef HAVE_PROCFS 94*5184Sek110237 struct prusage tf_susage; /* Resource usage snapshot, start */ 95*5184Sek110237 struct prusage tf_eusage; /* Resource usage snapshot, end */ 96*5184Sek110237 #endif 97*5184Sek110237 int tf_lwpusagefd; /* /proc lwp usage fd */ 98*5184Sek110237 #ifdef HAVE_AIO 99*5184Sek110237 aiolist_t *tf_aiolist; /* List of async I/Os */ 100*5184Sek110237 #endif 101*5184Sek110237 102*5184Sek110237 } threadflow_t; 103*5184Sek110237 104*5184Sek110237 /* Thread attrs */ 105*5184Sek110237 #define THREADFLOW_DEFAULTMEM 1024*1024LL; 106*5184Sek110237 107*5184Sek110237 threadflow_t *threadflow_define(procflow_t *, char *name, threadflow_t *inherit, 108*5184Sek110237 var_integer_t instances); 109*5184Sek110237 threadflow_t *threadflow_find(threadflow_t *, char *); 110*5184Sek110237 int threadflow_init(procflow_t *); 111*5184Sek110237 void flowop_start(threadflow_t *threadflow); 112*5184Sek110237 void threadflow_usage(void); 113*5184Sek110237 void threadflow_allstarted(pid_t pid, threadflow_t *threadflow); 114*5184Sek110237 void threadflow_delete_all(threadflow_t **threadlist); 115*5184Sek110237 116*5184Sek110237 #ifdef __cplusplus 117*5184Sek110237 } 118*5184Sek110237 #endif 119*5184Sek110237 120*5184Sek110237 #endif /* _FB_THREADFLOW_H */ 121