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