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