a1200   NEWS   APPS   DOCS   ABOUT
a1200
----
a1200
----
Autodocs
 Libraries:
 exec.library
  AVL_AddNode
  AVL_FindFirstNode
  AVL_FindLastNode
  AVL_FindNextNodeByAddress
  AVL_FindNextNodeByKey
  AVL_FindNode
  AVL_FindPrevNodeByAddress
  AVL_FindPrevNodeByKey
  AVL_RemNodeByAddress
  AVL_RemNodeByKey
  AbortIO
  AddDevice
  AddHead
  AddIntServer
  AddLibrary
  AddMemHandler
  AddMemList
  AddPort
  AddResource
  AddSemaphore
  AddTail
  AddTask
  Alert
  AllocAbs
  AllocEntry
  AllocMem
  AllocPooled
  AllocSignal
  AllocTrap
  AllocVec
  Allocate
  AttemptSemaphore
  AttemptSemaphoreShared
  AvailMem
  CacheClearE
  CacheClearU
  CacheControl
  CachePostDMA
  CachePreDMA
  Cause
  CheckIO
  CloseDevice
  CloseLibrary
  ColdReboot
  CopyMem
  CopyMemQuick
  CreateIORequest
  CreateMsgPort
  CreatePool
  Deallocate
  Debug
  DeleteIORequest
  DeleteMsgPort
  DeletePool
  Disable
  DoIO
  Enable
  Enqueue
  FindName
  FindPort
  FindResident
  FindSemaphore
  FindTask
  Forbid
  FreeEntry
  FreeMem
  FreePooled
  FreeSignal
  FreeTrap
  FreeVec
  GetCC
  GetMsg
  InitCode
  InitResident
  InitSemaphore
  InitStruct
  Insert
  MakeFunctions
  MakeLibrary
  ObtainQuickVector
  ObtainSemaphore
  ObtainSemaphoreList
  ObtainSemaphoreShared
  OldOpenLibrary
  OpenDevice
  OpenLibrary
  OpenResource
  Permit
  Procure
  PutMsg
  RawDoFmt
  ReleaseSemaphore
  ReleaseSemaphoreList
  RemDevice
  RemHead
  RemIntServer
  RemLibrary
  RemMemHandler
  RemPort
  RemResource
  RemSemaphore
  RemTail
  RemTask
  Remove
  ReplyMsg
  SendIO
  SetExcept
  SetFunction
  SetIntVector
  SetSR
  SetSignal
  SetTaskPri
  Signal
  StackSwap
  SumKickData
  SumLibrary
  SuperState
  Supervisor
  TypeOfMem
  UserState
  Vacate
  Wait
  WaitIO
  WaitPort
Include
GuruMeditation
Docs » Autodocs » exec.library » ObtainSemaphoreShared

NAME

	ObtainSemaphoreShared -- gain shared access to a semaphore (V36)

SYNOPSIS

	ObtainSemaphoreShared(signalSemaphore)
a0
void ObtainSemaphoreShared(struct SignalSemaphore *);

FUNCTION

	A lock on a signal semaphore may either be exclusive, or shared.
Exclusive locks are granted by the ObtainSemaphore() and
AttemptSemaphore() functions. Shared locks are granted by
ObtainSemaphoreShared(). Calls may be nested.
Any number of tasks may simultaneously hold a shared lock on a
semaphore. Only one task may hold an exclusive lock. A typical
application is a list that is often read, but only occasionally
written to.
Any exlusive locker will be held off until all shared lockers
release the semaphore. Likewise, if an exlusive lock is held,
all potential shared lockers will block until the exclusive lock
is released. All shared lockers are restarted at the same time.

EXAMPLE

		ObtainSemaphoreShared(ss);
/* read data */
ReleaseSemaohore(ss);
ObtainSemaphore(ss);
/* modify data */
ReleaseSemaohore(ss);

NOTES

	While this function was added for V36, the feature magically works
with all older semaphore structures.
A task owning a shared lock must not attempt to get an exclusive
lock on the same semaphore.
Starting in V39, if the caller already has an exclusive lock on the
semaphore it will return with another nesting of the lock. Pre-V39
this would cause a deadlock. For pre-V39 use, you can use the
following workaround:
/* Try to get the shared semaphore */
if (!AttemptSemaphoreShared(ss))
{
/* Check if we can get the exclusive version */
if (!AttemptSemaphore(ss))
{
/* Oh well, wait for the shared lock */
ObtainSemaphoreShared(ss));
}
}
:
:
ReleaseSemaphore(ss);

INPUTS

	signalSemaphore -- an initialized signal semaphore structure

NOTES

	This call is guaranteed to preserve all registers, starting with
V37 exec.

RESULT

SEE ALSO

ObtainSemaphore(), InitSemaphore(), ReleaseSemaphore(), AttemptSemaphore(), ObtainSemaphoreList(), Procure(), Vacate()

Comments

Name:
E-mail: Use this if you want a message if you get a response, will not be shown.
Comment:
Select correct short for:

Kefrens

KEF
ATX
TRSI
TBL

Comments:

$VER: d0.se 1.14 Copyright © 2011-2024 Tobias Geijersson support at d0 dot se