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 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _FB_IPC_H 27 #define _FB_IPC_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #include "config.h" 32 #include <pthread.h> 33 34 #include "procflow.h" 35 #include "threadflow.h" 36 #include "fileset.h" 37 #include "flowop.h" 38 #include "filebench.h" 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 #ifdef USE_PROCESS_MODEL 45 #define FILEBENCH_MEMSIZE 4096 46 #else 47 #define FILEBENCH_MEMSIZE 2048 48 #endif /* USE_PROCESS_MODEL */ 49 50 #define FILEBENCH_NFILESETS FILEBENCH_MEMSIZE 51 #define FILEBENCH_NFILESETENTRIES (1024 * 1024) 52 #define FILEBENCH_NPROCFLOWS FILEBENCH_MEMSIZE 53 #define FILEBENCH_NTHREADFLOWS 64 * FILEBENCH_MEMSIZE 54 #define FILEBENCH_NFLOWOPS 64 * FILEBENCH_MEMSIZE 55 #define FILEBENCH_NVARS FILEBENCH_MEMSIZE 56 #define FILEBENCH_FILESETPATHMEMORY FILEBENCH_NFILESETENTRIES*FSE_MAXPATHLEN 57 #define FILEBENCH_STRINGMEMORY FILEBENCH_NVARS * 128 58 #define FILEBENCH_MAXBITMAP FILEBENCH_NFILESETENTRIES 59 60 #define FILEBENCH_PROCFLOW 0 61 #define FILEBENCH_THREADFLOW 1 62 #define FILEBENCH_FLOWOP 2 63 #define FILEBENCH_INTEGER 3 64 #define FILEBENCH_STRING 4 65 #define FILEBENCH_VARIABLE 5 66 #define FILEBENCH_FILESET 6 67 #define FILEBENCH_FILESETENTRY 7 68 #define FILEBENCH_TYPES 8 69 70 #define FILEBENCH_NSEMS 128 71 72 typedef struct filebench_shm { 73 pthread_mutex_t fileset_lock; 74 pthread_mutex_t procflow_lock; 75 pthread_mutex_t threadflow_lock; 76 pthread_mutex_t flowop_lock; 77 pthread_mutex_t msg_lock; 78 pthread_mutex_t malloc_lock; 79 pthread_mutex_t ism_lock; 80 pthread_rwlock_t run_lock; 81 pthread_rwlock_t flowop_find_lock; 82 83 char *string_ptr; 84 char *path_ptr; 85 fileset_t *filesetlist; 86 flowop_t *flowoplist; 87 procflow_t *proclist; 88 var_t *var_list; 89 var_t *var_dyn_list; 90 int debug_level; 91 hrtime_t epoch; 92 hrtime_t starttime; 93 int bequiet; 94 key_t semkey; 95 int seminit; 96 int semid_seq; 97 int utid; 98 int log_fd; 99 int dump_fd; 100 char dump_filename[MAXPATHLEN]; 101 pthread_mutex_t eventgen_lock; 102 pthread_cond_t eventgen_cv; 103 int eventgen_hz; 104 uint64_t eventgen_q; 105 char fscriptname[1024]; 106 int shm_id; 107 size_t shm_required; 108 size_t shm_allocated; 109 caddr_t shm_addr; 110 char *shm_ptr; 111 int allrunning; 112 int f_abort; 113 114 int marker; 115 116 fileset_t fileset[FILEBENCH_NFILESETS]; 117 filesetentry_t filesetentry[FILEBENCH_NFILESETENTRIES]; 118 char filesetpaths[FILEBENCH_FILESETPATHMEMORY]; 119 procflow_t procflow[FILEBENCH_NPROCFLOWS]; 120 threadflow_t threadflow[FILEBENCH_NTHREADFLOWS]; 121 flowop_t flowop[FILEBENCH_NFLOWOPS]; 122 var_t var[FILEBENCH_NVARS]; 123 vinteger_t integer_ptrs[FILEBENCH_NVARS]; 124 char *string_ptrs[FILEBENCH_NVARS]; 125 char strings[FILEBENCH_STRINGMEMORY]; 126 char semids[FILEBENCH_NSEMS]; 127 int bitmap[FILEBENCH_TYPES][FILEBENCH_MAXBITMAP]; 128 } filebench_shm_t; 129 130 extern char *shmpath; 131 132 void ipc_init(void); 133 void *ipc_malloc(int type); 134 void ipc_free(int type, char *addr); 135 int ipc_attach(caddr_t shmaddr); 136 pthread_mutexattr_t *ipc_mutexattr(void); 137 pthread_condattr_t *ipc_condattr(void); 138 int ipc_semidalloc(void); 139 void ipc_semidfree(int semid); 140 char *ipc_stralloc(char *string); 141 char *ipc_pathalloc(char *string); 142 int ipc_mutex_lock(pthread_mutex_t *mutex); 143 int ipc_mutex_unlock(pthread_mutex_t *mutex); 144 void ipc_seminit(void); 145 char *ipc_ismmalloc(size_t size); 146 int ipc_ismcreate(size_t size); 147 void ipc_ismdelete(void); 148 void ipc_cleanup(void); 149 150 extern filebench_shm_t *filebench_shm; 151 152 #ifdef __cplusplus 153 } 154 #endif 155 156 #endif /* _FB_IPC_H */ 157