1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660
|
/*
% Copyright (C) 2003-2012 GraphicsMagick Group
% Copyright (C) 2002 ImageMagick Studio
%
% This program is covered by multiple licenses, which are described in
% Copyright.txt. You should have received a copy of Copyright.txt with this
% package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% SSSSS EEEEE M M AAA PPPP H H OOO RRRR EEEEE %
% SS E MM MM A A P P H H O O R R E %
% SSS EEE M M M AAAAA PPPP HHHHH O O RRRR EEE %
% SS E M M A A P H H O O R R E %
% SSSSS EEEEE M M A A P H H OOO R R EEEEE %
% %
% %
% GraphicsMagick Semaphore Methods %
% %
% %
% Software Design %
% William Radcliffe %
% John Cristy %
% June 2000 %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%
*/
/*
Include declarations.
*/
#include "magick/studio.h"
#include "magick/utility.h"
#if defined(HAVE_PTHREAD)
# define USE_PTHREAD_LOCKS 1
#elif defined(MSWINDOWS)
# define USE_WIN32_LOCKS 1
#elif defined(HAVE_OPENMP)
# define USE_OPENMP_LOCKS 1
#endif
#if defined(_ARCH_PPC64)
# pragma GCC push_options
# pragma GCC optimize("O0")
#endif
#if defined(USE_PTHREAD_LOCKS)
# include <pthread.h>
# define PTHREAD_MUTEX_DESTROY(semaphore_mutex) \
{ \
int \
err_status; \
\
if ((err_status = pthread_mutex_destroy(semaphore_mutex)) != 0) \
{ \
errno=err_status; \
MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
UnableToDestroySemaphore); \
} \
}
# define PTHREAD_MUTEXATTR_DESTROY(mutexattr) \
{ \
int \
err_status; \
\
if ((err_status = pthread_mutexattr_destroy(mutexattr)) != 0) \
{ \
errno=err_status; \
MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
UnableToDestroySemaphore); \
} \
}
# define PTHREAD_MUTEXATTR_INIT(mutexattr) \
{ \
int \
err_status; \
\
if ((err_status = pthread_mutexattr_init(mutexattr)) != 0) \
{ \
errno=err_status; \
MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
UnableToInitializeSemaphore); \
} \
}
# define PTHREAD_MUTEXATTR_SETTYPE(mutexattr,mutexattrtype) \
{ \
int \
err_status; \
\
if ((err_status = pthread_mutexattr_settype(mutexattr,mutexattrtype)) != 0) \
{ \
errno=err_status; \
MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
UnableToInitializeSemaphore); \
} \
}
# define PTHREAD_MUTEX_INIT(semaphore_mutex,mutexattr) \
{ \
int \
err_status; \
\
if ((err_status = pthread_mutex_init(semaphore_mutex,mutexattr)) != 0) \
{ \
errno=err_status; \
MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
UnableToInitializeSemaphore); \
} \
}
# define PTHREAD_MUTEX_LOCK(semaphore_mutex) \
{ \
int \
err_status; \
\
if ((err_status = pthread_mutex_lock(semaphore_mutex)) != 0) \
{ \
errno=err_status; \
MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
UnableToLockSemaphore); \
} \
}
# define PTHREAD_MUTEX_UNLOCK(semaphore_mutex) \
{ \
int \
err_status; \
\
if ((err_status = pthread_mutex_unlock(semaphore_mutex)) != 0) \
{ \
errno=err_status; \
MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
UnableToUnlockSemaphore); \
} \
}
#endif
#if defined(USE_WIN32_LOCKS)
# include <windows.h>
# define USE_SPINLOCKS
# define SPINLOCK_DELAY_MILLI_SECS 10
#endif
#include "magick/semaphore.h"
/*
Struct declaractions.
*/
struct _SemaphoreInfo
{
#if defined(USE_OPENMP_LOCKS)
omp_lock_t
mutex; /* OpenMP lock */
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
pthread_mutex_t
mutex; /* POSIX thread mutex */
#endif /* if defined(USE_PTHREAD_LOCKS) */
#if defined(USE_WIN32_LOCKS)
CRITICAL_SECTION
mutex; /* Windows critical section */
#endif /* defined(USE_WIN32_LOCKS) */
unsigned long
signature; /* Used to validate structure */
};
/*
Static declaractions.
*/
#if defined(USE_OPENMP_LOCKS)
static omp_lock_t
semaphore_mutex;
static unsigned int
active_semaphore = MagickFalse;
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
static pthread_mutex_t
semaphore_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif /* defined(USE_PTHREAD_LOCKS) */
#if defined(USE_WIN32_LOCKS)
#if !defined(USE_SPINLOCKS)
static CRITICAL_SECTION
semaphore_mutex;
static unsigned int
active_semaphore = MagickFalse;
#else
static LONG
semaphore_mutex = 0;
/* Wait for spin lock */
static void spinlock_wait (LONG volatile *sl)
{
/*
InterlockedCompareExchange performs an atomic comparison of the
specified 32-bit values and exchanges them, based on the outcome of
the comparison. Requires Windows XP, Windows 2000 Professional,
Windows NT Workstation 4.0, Windows Me, or Windows 98.
*/
while (InterlockedCompareExchange (sl, 1L, 0L) != 0)
{
/* slight delay - just in case OS does not giveup CPU */
Sleep (SPINLOCK_DELAY_MILLI_SECS);
}
}
/* Release spin lock */
static void spinlock_release (LONG volatile *sl)
{
/*
InterlockedExchange atomically exchanges a pair of 32-bit
values. Requires Windows XP, Windows 2000 Professional, Windows NT
Workstation 3.5 and later, Windows Me, Windows 98, or Windows 95.
*/
InterlockedExchange (sl, 0L);
}
#endif
#endif
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% A c q u i r e S e m a p h o r e I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% AcquireSemaphoreInfo() locks a semaphore, initializing it first if
% necessary.
%
% This function is deprecated, should not be used for new code, and should
% be removed when possible from existing code.
%
% The format of the AcquireSemaphoreInfo method is:
%
% void AcquireSemaphoreInfo(SemaphoreInfo **semaphore_info)
%
% A description of each parameter follows:
%
% o semaphore_info: Specifies a pointer to an SemaphoreInfo structure.
%
%
*/
MagickExport void AcquireSemaphoreInfo(SemaphoreInfo **semaphore_info)
{
assert(semaphore_info != (SemaphoreInfo **) NULL);
#if defined(USE_OPENMP_LOCKS)
if (!active_semaphore)
{
omp_init_lock(&semaphore_mutex);
active_semaphore=MagickTrue;
}
omp_set_lock(&semaphore_mutex);
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
PTHREAD_MUTEX_LOCK(&semaphore_mutex);
#endif /* defined(USE_PTHREAD_LOCKS) */
#if defined(USE_WIN32_LOCKS)
# if !defined(USE_SPINLOCKS)
if (!active_semaphore)
{
InitializeCriticalSection(&semaphore_mutex);
active_semaphore=MagickTrue;
}
EnterCriticalSection(&semaphore_mutex);
# else
spinlock_wait(&semaphore_mutex);
# endif
#endif /* defined(USE_WIN32_LOCKS) */
if (*semaphore_info == (SemaphoreInfo *) NULL)
*semaphore_info=AllocateSemaphoreInfo();
#if defined(USE_OPENMP_LOCKS)
omp_unset_lock(&semaphore_mutex);
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
PTHREAD_MUTEX_UNLOCK(&semaphore_mutex);
#endif /* defined(USE_PTHREAD_LOCKS) */
#if defined(USE_WIN32_LOCKS)
#if !defined(USE_SPINLOCKS)
LeaveCriticalSection(&semaphore_mutex);
#else
spinlock_release(&semaphore_mutex);
#endif
#endif
(void) LockSemaphoreInfo(*semaphore_info);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% A l l o c a t e S e m a p h o r e I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method AllocateSemaphoreInfo initializes the SemaphoreInfo structure.
%
% The format of the AllocateSemaphoreInfo method is:
%
% SemaphoreInfo *AllocateSemaphoreInfo(void)
%
% A description of each parameter follows:
%
% o semaphore_info: Method AllocateSemaphoreInfo returns a pointer to an
% initialized SemaphoreInfo structure.
%
%
*/
MagickExport SemaphoreInfo *AllocateSemaphoreInfo(void)
{
SemaphoreInfo
*semaphore_info;
/*
Allocate semaphore.
*/
semaphore_info=MagickAllocateAlignedMemory(SemaphoreInfo *,
MAGICK_CACHE_LINE_SIZE,
sizeof(SemaphoreInfo));
if (semaphore_info == (SemaphoreInfo *) NULL)
MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
UnableToAllocateSemaphoreInfo);
(void) memset(semaphore_info,0,sizeof(SemaphoreInfo));
/*
Initialize the semaphore.
*/
#if defined(USE_OPENMP_LOCKS)
omp_init_lock(&semaphore_info->mutex);
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
{
pthread_mutexattr_t
mutexattr;
PTHREAD_MUTEXATTR_INIT(&mutexattr);
/*
If MAGICK_DEBUG is defined then enable pthread mutex error
checks.
*/
#if MAGICK_DEBUG
#if defined(PTHREAD_MUTEX_ERRORCHECK)
PTHREAD_MUTEXATTR_SETTYPE(&mutexattr, PTHREAD_MUTEX_ERRORCHECK);
#endif /* PTHREAD_MUTEX_ERRORCHECK */
#endif /* MAGICK_DEBUG */
PTHREAD_MUTEX_INIT(&semaphore_info->mutex,&mutexattr);
PTHREAD_MUTEXATTR_DESTROY(&mutexattr);
}
#endif
#if defined(USE_WIN32_LOCKS)
InitializeCriticalSection(&semaphore_info->mutex);
#endif
semaphore_info->signature=MagickSignature;
return(semaphore_info);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% D e s t r o y S e m a p h o r e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DestroySemaphore() destroys the semaphore environment.
%
% The format of the DestroySemaphore method is:
%
% void DestroySemaphore(void)
%
%
*/
MagickExport void DestroySemaphore(void)
{
#if defined(USE_OPENMP_LOCKS)
if (active_semaphore)
{
omp_destroy_lock(&semaphore_mutex);
active_semaphore=MagickFalse;
}
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
/*
We use static pthread mutex initialization with
PTHREAD_MUTEX_INITIALIZER so semaphore mutex should not be
destroyed.
*/
/* PTHREAD_MUTEX_DESTROY(&semaphore_mutex); */
#endif
#if defined(USE_WIN32_LOCKS)
#if !defined(USE_SPINLOCKS)
if (active_semaphore)
{
DeleteCriticalSection(&semaphore_mutex);
active_semaphore=MagickFalse;
}
#endif
#endif
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% D e s t r o y S e m a p h o r e I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method DestroySemaphoreInfo destroys a semaphore.
%
% The format of the DestroySemaphoreInfo method is:
%
% void DestroySemaphoreInfo(SemaphoreInfo **semaphore_info)
%
% A description of each parameter follows:
%
% o semaphore_info: Specifies a pointer to an SemaphoreInfo structure.
%
%
*/
MagickExport void DestroySemaphoreInfo(SemaphoreInfo **semaphore_info)
{
assert(semaphore_info != (SemaphoreInfo **) NULL);
if (*semaphore_info == (SemaphoreInfo *) NULL)
return;
assert((*semaphore_info)->signature == MagickSignature);
#if defined(USE_OPENMP_LOCKS)
if (!active_semaphore)
{
omp_init_lock(&semaphore_mutex);
active_semaphore=MagickTrue;
}
omp_set_lock(&semaphore_mutex);
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
PTHREAD_MUTEX_LOCK(&semaphore_mutex);
#endif
#if defined(USE_WIN32_LOCKS)
#if !defined(USE_SPINLOCKS)
if (!active_semaphore)
{
InitializeCriticalSection(&semaphore_mutex);
active_semaphore=MagickTrue;
}
EnterCriticalSection(&semaphore_mutex);
#else
spinlock_wait(&semaphore_mutex);
#endif
#endif
#if defined(USE_OPENMP_LOCKS)
omp_destroy_lock(&(*semaphore_info)->mutex);
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
PTHREAD_MUTEX_DESTROY(&(*semaphore_info)->mutex);
#endif
#if defined(USE_WIN32_LOCKS)
DeleteCriticalSection(&(*semaphore_info)->mutex);
#endif
(void) memset((void *) *semaphore_info,0xbf,sizeof(SemaphoreInfo));
MagickFreeAlignedMemory((*semaphore_info));
#if defined(USE_OPENMP_LOCKS)
omp_unset_lock(&semaphore_mutex);
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
PTHREAD_MUTEX_UNLOCK(&semaphore_mutex);
#endif
#if defined(USE_WIN32_LOCKS)
#if !defined(USE_SPINLOCKS)
LeaveCriticalSection(&semaphore_mutex);
#else
spinlock_release(&semaphore_mutex);
#endif
#endif
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% I n i t i a l i z e S e m a p h o r e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method InitializeSemaphore initializes the semaphore environment.
%
% The format of the InitializeSemaphore method is:
%
% void InitializeSemaphore(void)
%
%
*/
MagickExport void InitializeSemaphore(void)
{
#if defined(USE_OPENMP_LOCKS)
if (!active_semaphore)
{
omp_init_lock(&semaphore_mutex);
active_semaphore=MagickTrue;
}
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
/*
We use static pthread mutex initialization with
PTHREAD_MUTEX_INITIALIZER so explicit runtime initialization is
not required.
*/
/* (void) pthread_mutex_init(&semaphore_mutex, */
/* (const pthread_mutexattr_t *) NULL); */
#endif
#if defined(USE_WIN32_LOCKS)
#if !defined(USE_SPINLOCKS)
if (!active_semaphore)
{
InitializeCriticalSection(&semaphore_mutex);
active_semaphore=MagickTrue;
}
#endif
#endif
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% L i b e r a t e S e m a p h o r e I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method LiberateSemaphoreInfo unlocks the semaphore if it has been allocated.
%
% This function is deprecated, should not be used for new code, and should
% be removed when possible from existing code.
%
% The format of the LiberateSemaphoreInfo method is:
%
% void LiberateSemaphoreInfo(SemaphoreInfo **semaphore_info)
%
% A description of each parameter follows:
%
% o semaphore_info: Specifies a pointer to an SemaphoreInfo structure.
%
%
*/
MagickExport void LiberateSemaphoreInfo(SemaphoreInfo **semaphore_info)
{
assert(semaphore_info != (SemaphoreInfo **) NULL);
if (*semaphore_info != (SemaphoreInfo *) NULL)
{
assert((*semaphore_info)->signature == MagickSignature);
(void) UnlockSemaphoreInfo(*semaphore_info);
}
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% L o c k S e m a p h o r e I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method LockSemaphoreInfo locks a semaphore.
%
% The format of the LockSemaphoreInfo method is:
%
% void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
%
% A description of each parameter follows:
%
% o semaphore_info: Specifies a pointer to an SemaphoreInfo structure.
%
%
*/
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
{
assert(semaphore_info != (SemaphoreInfo *) NULL);
assert(semaphore_info->signature == MagickSignature);
#if defined(USE_OPENMP_LOCKS)
omp_set_lock(&semaphore_info->mutex);
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
PTHREAD_MUTEX_LOCK(&semaphore_info->mutex);
#endif /* defined(USE_PTHREAD_LOCKS) */
#if defined(USE_WIN32_LOCKS)
EnterCriticalSection(&semaphore_info->mutex);
#endif /* defined(USE_WIN32_LOCKS) */
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% U n l o c k S e m a p h o r e I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method UnlockSemaphoreInfo unlocks a semaphore.
%
% The format of the LockSemaphoreInfo method is:
%
% void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
%
% A description of each parameter follows:
%
% o semaphore_info: Specifies a pointer to an SemaphoreInfo structure.
%
%
*/
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
{
assert(semaphore_info != (SemaphoreInfo *) NULL);
assert(semaphore_info->signature == MagickSignature);
#if defined(USE_OPENMP_LOCKS)
omp_unset_lock(&semaphore_info->mutex);
#endif /* defined(USE_OPENMP_LOCKS) */
#if defined(USE_PTHREAD_LOCKS)
PTHREAD_MUTEX_UNLOCK(&semaphore_info->mutex);
#endif /* defined(USE_PTHREAD_LOCKS) */
#if defined(USE_WIN32_LOCKS)
LeaveCriticalSection(&semaphore_info->mutex);
#endif /* defined(USE_WIN32_LOCKS) */
}
#if defined(_ARCH_PPC64)
# pragma GCC pop_options
#endif
|