xref: /onnv-gate/usr/src/cmd/filebench/common/threadflow.h (revision 6084:d5f45b4dae7e)
15184Sek110237 /*
25184Sek110237  * CDDL HEADER START
35184Sek110237  *
45184Sek110237  * The contents of this file are subject to the terms of the
55184Sek110237  * Common Development and Distribution License (the "License").
65184Sek110237  * You may not use this file except in compliance with the License.
75184Sek110237  *
85184Sek110237  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95184Sek110237  * or http://www.opensolaris.org/os/licensing.
105184Sek110237  * See the License for the specific language governing permissions
115184Sek110237  * and limitations under the License.
125184Sek110237  *
135184Sek110237  * When distributing Covered Code, include this CDDL HEADER in each
145184Sek110237  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155184Sek110237  * If applicable, add the following below this CDDL HEADER, with the
165184Sek110237  * fields enclosed by brackets "[]" replaced with your own identifying
175184Sek110237  * information: Portions Copyright [yyyy] [name of copyright owner]
185184Sek110237  *
195184Sek110237  * CDDL HEADER END
205184Sek110237  */
215184Sek110237 /*
22*6084Saw148015  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
235184Sek110237  * Use is subject to license terms.
245184Sek110237  */
255184Sek110237 
265184Sek110237 #ifndef _FB_THREADFLOW_H
275184Sek110237 #define	_FB_THREADFLOW_H
285184Sek110237 
295184Sek110237 #pragma ident	"%Z%%M%	%I%	%E% SMI"
305184Sek110237 
315184Sek110237 #include "config.h"
325184Sek110237 #include <pthread.h>
335184Sek110237 
345184Sek110237 #ifndef HAVE_CADDR_T1
355184Sek110237 /* typedef char	    *caddr_t; */
365184Sek110237 #endif
375184Sek110237 
385184Sek110237 #ifdef LINUX_PORT
395184Sek110237 #include <linux/types.h>  /* for "caddr_t" */
405184Sek110237 #endif
415184Sek110237 
425184Sek110237 
435184Sek110237 #ifdef HAVE_AIO
445184Sek110237 #include <aio.h>
455184Sek110237 #endif
465184Sek110237 #ifdef HAVE_PROCFS
475184Sek110237 #include <procfs.h>
485184Sek110237 #endif
495184Sek110237 #include "vars.h"
505184Sek110237 #include "procflow.h"
515184Sek110237 #include "fileset.h"
525184Sek110237 
535184Sek110237 #ifdef	__cplusplus
545184Sek110237 extern "C" {
555184Sek110237 #endif
565184Sek110237 
575184Sek110237 #define	AL_READ  1
585184Sek110237 #define	AL_WRITE 2
595184Sek110237 
605184Sek110237 
615184Sek110237 #ifdef HAVE_AIO
625184Sek110237 typedef struct aiolist {
635184Sek110237 	int		al_type;
645184Sek110237 	struct aiolist	*al_next;
655184Sek110237 	struct aiolist	*al_worknext;
665184Sek110237 	struct aiocb64	 al_aiocb;
675184Sek110237 } aiolist_t;
685184Sek110237 #endif
695184Sek110237 
705184Sek110237 #define	THREADFLOW_MAXFD 128
715184Sek110237 #define	THREADFLOW_USEISM 0x1
725184Sek110237 
735184Sek110237 typedef struct threadflow {
745184Sek110237 	char		tf_name[128];	/* Name */
755184Sek110237 	int		tf_attrs;	/* Attributes */
765184Sek110237 	int		tf_instance;	/* Instance number */
775184Sek110237 	int		tf_running;	/* Thread running indicator */
785184Sek110237 	int		tf_abort;	/* Shutdown thread */
795184Sek110237 	int		tf_utid;	/* Unique id for thread */
805184Sek110237 	struct procflow	*tf_process;	/* Back pointer to process */
815184Sek110237 	pthread_t	tf_tid;		/* Thread id */
825184Sek110237 	pthread_mutex_t	tf_lock;	/* Mutex around threadflow */
835184Sek110237 	var_integer_t	tf_instances;	/* Number of instances for this flow */
845184Sek110237 	struct threadflow *tf_next;	/* Next on proc list */
855184Sek110237 	struct flowop	*tf_ops;	/* Flowop list */
865184Sek110237 	caddr_t		tf_mem;		/* Private Memory */
875184Sek110237 	var_integer_t	tf_memsize;	/* Private Memory size */
885184Sek110237 	int		tf_fd[THREADFLOW_MAXFD + 1]; /* Thread local fd's */
895184Sek110237 	filesetentry_t	*tf_fse[THREADFLOW_MAXFD + 1]; /* Thread local files */
905184Sek110237 	int		tf_fdrotor;	/* Rotating fd within set */
915184Sek110237 	flowstat_t	tf_stats;	/* Thread statistics */
925184Sek110237 	hrtime_t	tf_stime;	/* Start time of op */
935184Sek110237 #ifdef HAVE_PROCFS
945184Sek110237 	struct prusage	tf_susage;	/* Resource usage snapshot, start */
955184Sek110237 	struct prusage	tf_eusage;	/* Resource usage snapshot, end */
965184Sek110237 #endif
975184Sek110237 	int		tf_lwpusagefd;	/* /proc lwp usage fd */
985184Sek110237 #ifdef HAVE_AIO
995184Sek110237 	aiolist_t	*tf_aiolist;	/* List of async I/Os */
1005184Sek110237 #endif
1015184Sek110237 
1025184Sek110237 } threadflow_t;
1035184Sek110237 
1045184Sek110237 /* Thread attrs */
1055184Sek110237 #define	THREADFLOW_DEFAULTMEM 1024*1024LL;
1065184Sek110237 
1075184Sek110237 threadflow_t *threadflow_define(procflow_t *, char *name, threadflow_t *inherit,
1085184Sek110237     var_integer_t instances);
1095184Sek110237 threadflow_t *threadflow_find(threadflow_t *, char *);
1105184Sek110237 int threadflow_init(procflow_t *);
1115184Sek110237 void flowop_start(threadflow_t *threadflow);
1125184Sek110237 void threadflow_usage(void);
1135184Sek110237 void threadflow_allstarted(pid_t pid, threadflow_t *threadflow);
114*6084Saw148015 void threadflow_delete_all(threadflow_t **threadlist, int wait_cnt);
1155184Sek110237 
1165184Sek110237 #ifdef	__cplusplus
1175184Sek110237 }
1185184Sek110237 #endif
1195184Sek110237 
1205184Sek110237 #endif	/* _FB_THREADFLOW_H */
121