Home | History | Annotate | Download | only in common
      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 2008 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     30 
     31 #include "config.h"
     32 #include <pthread.h>
     33 
     34 #ifndef HAVE_CADDR_T1
     35 /* typedef char	    *caddr_t; */
     36 #endif
     37 
     38 #ifdef LINUX_PORT
     39 #include <linux/types.h>  /* for "caddr_t" */
     40 #endif
     41 
     42 
     43 #ifdef HAVE_AIO
     44 #include <aio.h>
     45 #endif
     46 #ifdef HAVE_PROCFS
     47 #include <procfs.h>
     48 #endif
     49 #include "vars.h"
     50 #include "procflow.h"
     51 #include "fileset.h"
     52 
     53 #ifdef	__cplusplus
     54 extern "C" {
     55 #endif
     56 
     57 #define	AL_READ  1
     58 #define	AL_WRITE 2
     59 
     60 
     61 #ifdef HAVE_AIO
     62 typedef struct aiolist {
     63 	int		al_type;
     64 	struct aiolist	*al_next;
     65 	struct aiolist	*al_worknext;
     66 	struct aiocb64	 al_aiocb;
     67 } aiolist_t;
     68 #endif
     69 
     70 #define	THREADFLOW_MAXFD 128
     71 #define	THREADFLOW_USEISM 0x1
     72 
     73 typedef struct threadflow {
     74 	char		tf_name[128];	/* Name */
     75 	int		tf_attrs;	/* Attributes */
     76 	int		tf_instance;	/* Instance number */
     77 	int		tf_running;	/* Thread running indicator */
     78 	int		tf_abort;	/* Shutdown thread */
     79 	int		tf_utid;	/* Unique id for thread */
     80 	struct procflow	*tf_process;	/* Back pointer to process */
     81 	pthread_t	tf_tid;		/* Thread id */
     82 	pthread_mutex_t	tf_lock;	/* Mutex around threadflow */
     83 	avd_t		tf_instances;	/* Number of instances for this flow */
     84 	struct threadflow *tf_next;	/* Next on proc list */
     85 	struct flowop	*tf_thrd_fops;	/* Flowop list */
     86 	caddr_t		tf_mem;		/* Private Memory */
     87 	avd_t		tf_memsize;	/* Private Memory size attribute */
     88 	fbint_t		tf_constmemsize; /* constant copy of memory size */
     89 	int		tf_fd[THREADFLOW_MAXFD + 1]; /* Thread local fd's */
     90 	filesetentry_t	*tf_fse[THREADFLOW_MAXFD + 1]; /* Thread local files */
     91 	int		tf_fdrotor;	/* Rotating fd within set */
     92 	flowstat_t	tf_stats;	/* Thread statistics */
     93 	hrtime_t	tf_stime;	/* Start time of op */
     94 #ifdef HAVE_PROCFS
     95 	struct prusage	tf_susage;	/* Resource usage snapshot, start */
     96 	struct prusage	tf_eusage;	/* Resource usage snapshot, end */
     97 #endif
     98 	int		tf_lwpusagefd;	/* /proc lwp usage fd */
     99 #ifdef HAVE_AIO
    100 	aiolist_t	*tf_aiolist;	/* List of async I/Os */
    101 #endif
    102 
    103 } threadflow_t;
    104 
    105 /* Thread attrs */
    106 #define	THREADFLOW_DEFAULTMEM 1024*1024LL;
    107 
    108 threadflow_t *threadflow_define(procflow_t *, char *name,
    109     threadflow_t *inherit, avd_t instances);
    110 threadflow_t *threadflow_find(threadflow_t *, char *);
    111 int threadflow_init(procflow_t *);
    112 void flowop_start(threadflow_t *threadflow);
    113 void threadflow_usage(void);
    114 void threadflow_allstarted(pid_t pid, threadflow_t *threadflow);
    115 void threadflow_delete_all(threadflow_t **threadlist, int wait_cnt);
    116 
    117 #ifdef	__cplusplus
    118 }
    119 #endif
    120 
    121 #endif	/* _FB_THREADFLOW_H */
    122