summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-12-20 20:02:25 +0000
committerZeev Suraski <zeev@php.net>1999-12-20 20:02:25 +0000
commit469966917b33f97d0d03e51d409c5f93f48a8969 (patch)
treed9b17912313984a1349d281a823a72ed227d547d /TSRM
parenta2cc070fc2c99174bcf6bb002b03658f9e554504 (diff)
downloadphp-git-469966917b33f97d0d03e51d409c5f93f48a8969.tar.gz
Use Critical Sections under Win32 - shows roughly 40% performance increase under
multithreaded Win32!
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/TSRM.c11
-rw-r--r--TSRM/TSRM.h2
2 files changed, 8 insertions, 5 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
index 8cf563075b..1f7da18d88 100644
--- a/TSRM/TSRM.c
+++ b/TSRM/TSRM.c
@@ -326,7 +326,8 @@ TSRM_API MUTEX_T tsrm_mutex_alloc( void )
MUTEX_T mutexp;
#ifdef WIN32
- mutexp = CreateMutex(NULL,FALSE,NULL);
+ mutexp = malloc(sizeof(CRITICAL_SECTION));
+ InitializeCriticalSection(mutexp);
#elif defined(GNUPTH)
mutexp = (MUTEX_T) malloc(sizeof(*mutexp));
pth_mutex_init(mutexp);
@@ -350,7 +351,7 @@ TSRM_API void tsrm_mutex_free( MUTEX_T mutexp )
{
if (mutexp) {
#ifdef WIN32
- CloseHandle(mutexp);
+ DeleteCriticalSection(mutexp);
#elif defined(GNUPTH)
free(mutexp);
#elif defined(PTHREADS)
@@ -375,7 +376,8 @@ TSRM_API int tsrm_mutex_lock( MUTEX_T mutexp )
tsrm_debug("Mutex locked thread: %ld\n",tsrm_thread_id());
#endif
#ifdef WIN32
- return WaitForSingleObject(mutexp,1000);
+ EnterCriticalSection(mutexp);
+ return 1;
#elif defined(GNUPTH)
return pth_mutex_acquire(mutexp, 0, NULL);
#elif defined(PTHREADS)
@@ -395,7 +397,8 @@ TSRM_API int tsrm_mutex_unlock( MUTEX_T mutexp )
tsrm_debug("Mutex unlocked thread: %ld\n",tsrm_thread_id());
#endif
#ifdef WIN32
- return ReleaseMutex(mutexp);
+ LeaveCriticalSection(mutexp);
+ return 1;
#elif defined(GNUPTH)
return pth_mutex_release(mutexp);
#elif defined(PTHREADS)
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h
index 35eb53676b..7b0ce30753 100644
--- a/TSRM/TSRM.h
+++ b/TSRM/TSRM.h
@@ -49,7 +49,7 @@ typedef int ts_rsrc_id;
/* Define THREAD_T and MUTEX_T */
#if defined(WIN32)
# define THREAD_T DWORD
-# define MUTEX_T void *
+# define MUTEX_T CRITICAL_SECTION *
#elif defined(GNUPTH)
# define THREAD_T pth_attr_t
# define MUTEX_T pth_mutex_t *