xref: /onnv-gate/usr/src/cmd/filebench/common/threadflow.h (revision 8762:6e3d4153d2d5)
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 /*
228615SAndrew.W.Wilson@sun.com  * Copyright 2009 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 #include "config.h"
308615SAndrew.W.Wilson@sun.com #include "fsplug.h"
315184Sek110237 #include <pthread.h>
325184Sek110237 
335184Sek110237 #ifndef HAVE_CADDR_T1
345184Sek110237 /* typedef char	    *caddr_t; */
355184Sek110237 #endif
365184Sek110237 
375184Sek110237 #ifdef LINUX_PORT
385184Sek110237 #include <linux/types.h>  /* for "caddr_t" */
395184Sek110237 #endif
405184Sek110237 
415184Sek110237 
425184Sek110237 #ifdef HAVE_AIO
435184Sek110237 #include <aio.h>
445184Sek110237 #endif
455184Sek110237 #ifdef HAVE_PROCFS
465184Sek110237 #include <procfs.h>
475184Sek110237 #endif
485184Sek110237 #include "vars.h"
495184Sek110237 #include "procflow.h"
505184Sek110237 #include "fileset.h"
515184Sek110237 
525184Sek110237 #ifdef	__cplusplus
535184Sek110237 extern "C" {
545184Sek110237 #endif
555184Sek110237 
565184Sek110237 #define	AL_READ  1
575184Sek110237 #define	AL_WRITE 2
585184Sek110237 
595184Sek110237 
605184Sek110237 #ifdef HAVE_AIO
615184Sek110237 typedef struct aiolist {
625184Sek110237 	int		al_type;
635184Sek110237 	struct aiolist	*al_next;
645184Sek110237 	struct aiolist	*al_worknext;
655184Sek110237 	struct aiocb64	 al_aiocb;
665184Sek110237 } aiolist_t;
675184Sek110237 #endif
685184Sek110237 
695184Sek110237 #define	THREADFLOW_MAXFD 128
705184Sek110237 #define	THREADFLOW_USEISM 0x1
715184Sek110237 
725184Sek110237 typedef struct threadflow {
735184Sek110237 	char		tf_name[128];	/* Name */
745184Sek110237 	int		tf_attrs;	/* Attributes */
755184Sek110237 	int		tf_instance;	/* Instance number */
765184Sek110237 	int		tf_running;	/* Thread running indicator */
775184Sek110237 	int		tf_abort;	/* Shutdown thread */
785184Sek110237 	int		tf_utid;	/* Unique id for thread */
795184Sek110237 	struct procflow	*tf_process;	/* Back pointer to process */
805184Sek110237 	pthread_t	tf_tid;		/* Thread id */
815184Sek110237 	pthread_mutex_t	tf_lock;	/* Mutex around threadflow */
826212Saw148015 	avd_t		tf_instances;	/* Number of instances for this flow */
835184Sek110237 	struct threadflow *tf_next;	/* Next on proc list */
846550Saw148015 	struct flowop	*tf_thrd_fops;	/* Flowop list */
855184Sek110237 	caddr_t		tf_mem;		/* Private Memory */
866212Saw148015 	avd_t		tf_memsize;	/* Private Memory size attribute */
876212Saw148015 	fbint_t		tf_constmemsize; /* constant copy of memory size */
888615SAndrew.W.Wilson@sun.com 	fb_fdesc_t	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 
1076212Saw148015 threadflow_t *threadflow_define(procflow_t *, char *name,
1086212Saw148015     threadflow_t *inherit, avd_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*8762SAndrew.W.Wilson@sun.com void threadflow_delete_all(threadflow_t **threadlist);
1155184Sek110237 
1165184Sek110237 #ifdef	__cplusplus
1175184Sek110237 }
1185184Sek110237 #endif
1195184Sek110237 
1205184Sek110237 #endif	/* _FB_THREADFLOW_H */
121