1/* 2* Tapetest 3* Copyright (c) International Business Machines Corp., 2001 4* 5* 6* This program is free software; you can redistribute it and/or modify 7* it under the terms of the GNU General Public License as published by 8* the Free Software Foundation; either version 2 of the License, or 9* (at your option) any later version. 10* 11* This program is distributed in the hope that it will be useful, 12* but WITHOUT ANY WARRANTY; without even the implied warranty of 13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14* GNU General Public License for more details. 15* 16* You should have received a copy of the GNU General Public License 17* along with this program; if not, write to the Free Software 18* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19* 20* Please send e-mail to yardleyb@us.ibm.com if you have 21* questions or comments. 22* 23* Project Website: TBD 24* 25* $Id: threading.h,v 1.7 2008/02/14 08:22:24 subrata_modak Exp $ 26* $Log: threading.h,v $ 27* Revision 1.7 2008/02/14 08:22:24 subrata_modak 28* Disktest application update to version 1.4.2, by, Brent Yardley <yardleyb@us.ibm.com> 29* 30* Revision 1.9 2008/02/07 17:37:26 yardleyb 31* "yxu@suse.de" corrected the way by which pthread_exit() handles pointer argument 32* 33* Revision 1.8 2004/11/20 04:43:42 yardleyb 34* Minor code fixes. Checking for alloc errors. 35* 36* Revision 1.7 2004/11/19 21:45:12 yardleyb 37* Fixed issue with code added for -F option. Cased disktest 38* to SEG FAULT when cleaning up threads. 39* 40* Revision 1.6 2004/11/02 20:47:13 yardleyb 41* Added -F functions. 42* lots of minor fixes. see README 43* 44* Revision 1.5 2002/03/30 01:32:14 yardleyb 45* Major Changes: 46* 47* Added Dumping routines for 48* data miscompares, 49* 50* Updated performance output 51* based on command line. Gave 52* one decimal in MB/s output. 53* 54* Rewrote -pL IO routine to show 55* correct stats. Now show pass count 56* when using -C. 57* 58* Minor Changes: 59* 60* Code cleanup to remove the plethera 61* if #ifdef for windows/unix functional 62* differences. 63* 64* Revision 1.4 2002/02/28 04:25:45 yardleyb 65* reworked threading code 66* made locking code a macro. 67* 68* Revision 1.3 2002/02/19 02:46:37 yardleyb 69* Added changes to compile for AIX. 70* Update getvsiz so it returns a -1 71* if the ioctl fails and we handle 72* that fact correctly. Added check 73* to force vsiz to always be greater 74* then stop_lba. 75* 76* Revision 1.2 2002/02/04 20:35:38 yardleyb 77* Changed max. number of threads to 64k. 78* Check for max threads in parsing. 79* Fixed windows getopt to return correctly 80* when a bad option is given. 81* Update time output to be in the format: 82* YEAR/MONTH/DAY-HOUR:MIN:SEC 83* instead of epoch time. 84* 85* Revision 1.1 2001/12/04 18:51:06 yardleyb 86* Checkin of new source files and removal 87* of outdated source 88* 89*/ 90 91#ifndef THREADING_H 92#define THREADING_H 1 93 94#ifdef WINDOWS 95#include <windows.h> 96#else 97#include <pthread.h> 98#include <sys/types.h> 99#include <unistd.h> 100#endif 101 102#include "defs.h" 103#include "main.h" 104 105#define MAX_THREADS 65536 /* max number of threads, reader/writer, per test */ 106 107#ifdef WINDOWS 108#define LOCK(Mutex) WaitForSingleObject((void *) Mutex, INFINITE) 109#define UNLOCK(Mutex) ReleaseMutex((void *) Mutex) 110#define TEXIT(errno) ExitThread(errno); return(errno) 111#define ISTHREADVALID(thread) (thread != NULL) 112#else 113#define LOCK(Mutex) \ 114 pthread_cleanup_push((void *) pthread_mutex_unlock, (void *) &Mutex); \ 115 pthread_mutex_lock(&Mutex) 116#define UNLOCK(Mutex) \ 117 pthread_mutex_unlock(&Mutex); \ 118 pthread_cleanup_pop(0) 119#define TEXIT(errno) pthread_exit((void*)errno) 120#define ISTHREADVALID(thread) (thread != 0) 121#endif 122 123void cleanUpTestChildren(test_ll_t *); 124void CreateTestChild(void *, test_ll_t *); 125hThread_t spawnThread(void *, void *); 126void closeThread(hThread_t); 127void createChild(void *, test_ll_t *); 128void cleanUp(test_ll_t *); 129 130#endif /* THREADING_H */ 131