summaryrefslogtreecommitdiff
path: root/TSRM/TSRM.c
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/TSRM.c
parenta2cc070fc2c99174bcf6bb002b03658f9e554504 (diff)
downloadphp-git-469966917b33f97d0d03e51d409c5f93f48a8969.tar.gz
Use Critical Sections under Win32 - shows roughly 40% performance increase under
multithreaded Win32!
Diffstat (limited to 'TSRM/TSRM.c')
-rw-r--r--TSRM/TSRM.c11
1 files changed, 7 insertions, 4 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)