void MemUnlock(
MemHandle mh); /* Handle of block to unlock */
This routine decrements the lock count of the indicated block. If the lock count reaches zero, the block becomes unlocked (it can be moved, swapped, or discarded). Do not try to unlock a block that has not been locked.
Include: heap.h
void MemUnlockExcl(
memHandle mh); /* Handle of block to release */
If a thread has gained access to a block with
MemLockExcl()
, it should release the block as soon as it can. Until it does, no other thread can access the block for either shared or exclusive access. It can release the block by calling
MemUnlockExcl()
. This routine unlocks the block and releases the thread's access to it. If there is a queue for this block, the highest-priority thread waiting will be awakened, as described in
MemLockExcl()
.
Include: heap.h
Tips and Tricks: You can find out if the block is being accessed by looking at the HM
_otherInfo
word (with
MemGetInfo()
). If HM
_otherInfo
equals one, the block is not grabbed; if it equals zero, it is grabbed, but no threads are queued; otherwise, it equals the handle of the first thread queued.
Be Sure To: Make sure that all routines accessing the block get access with
MemLockExcl()
or
MemLockShared()
. The routines use the block's HM
_otherInfo
word; you must not alter it. Call this routine while the block is still locked; it will call
MemUnlock()
to unlock the block.
Warnings: If you call this routine on a block which you have not gained access to, it may fatal-error.
See Also: MemLockExcl(),
MemLockShared(),
MemUnlockShared().
void MemUnlockFixedOrMovable(
void * ptr); /* virtual segment */
This routine unlocks a previously locked, movable virtual segment. Do not call this routine with normal locked or fixed blocks; only call it for those blocks locked with
MemLockFixedOrMovable()
.
Include: heap.h
void MemUnlockShared(
MemHandle mh); /* Handle of block to release */
If a thread has gained access to a block with
MemLockShared()
, it should release the block as soon as it can. Until it does, no thread can be awakened from the queue. It can release the block by calling
MemUnlockShared()
. This routine calls
MemUnlock()
, decrementing the block's lock count; it then releases the thread's access to it. If no other thread is accessing the block and there is a queue for this block, the highest-priority thread waiting will be awakened, as described in
MemLockExcl()
.
Include: heap.h
Tips and Tricks: You can find out if the block is being accessed by looking at the HM
_otherInfo
word (with
MemGetInfo()
). If HM
_otherInfo
equals one, the block is not grabbed; if it equals zero, it is grabbed, but no threads are queued; otherwise, it equals the handle of the first thread queued.
Be Sure To: Make sure that all routines accessing the block get access with
MemLockExcl()
or
MemLockShared()
. These routines use the block's HM
_otherInfo
word; you must not alter it. Call this routine while the block is still locked; it will call
MemUnlock()
to unlock the block.
Warnings: If you call this routine on a block which you have not gained access to, it may fatal-error.
See Also: MemLockExcl(),
MemLockShared(),
MemUnlockExcl().
void MemUnlockV(
MemHandle mh); /* Handle of block to release */
This routine unlocks a block with
MemUnlock()
, then releases its semaphore with
HandleV()
. Do not use this routine unless the block's semaphore was grabbed and the block locked (typically with the
MemPLock()
routine).
Include: heap.h
Tips and Tricks: You can find out if the block is being accessed by looking at the HM
_otherInfo
word (with
MemGetInfo()
). If HM
_otherInfo
equals one, the block is not grabbed; if it equals zero, it is grabbed, but no threads are queued; otherwise, it equals the handle of the first thread queued.
Be Sure To: Make sure that all threads accessing the block use
HandleP()
or
MemPLock()
to access the thread. These routines use the
HM
_otherInfo
field of the handle table entry; do not alter this field.
Warnings: Do not use this on a block unless you have grabbed it. The routine does not check to see that you have grabbed the thread; it just clears the semaphore and returns.
Never Use Situations:
Never use this routine to release a fixed block. It will try to unlock the block; fixed blocks cannot be locked or unlocked. Instead, call
HandleV()
directly.
See Also: MemPLock(),
HandleP(),
HandleV().
void * MemUpgradeSharedLock(
MemHandle mh); /* handle of locked block */
This routine upgrades a shared lock on the block to an exclusive lock, as if the caller had used MemLockExcl(). If other threads have access to the block, the caller will sleep in the access queue until it can gain exclusive access.
This routine returns the pointer of the locked block because, if the caller sleeps in the queue, the memory block could move between the call and the granting of access.
Include: heap.h
See Also: MemLockExcl(),
MemLockShared(),
MemDowngradeExclLock().
void MessageSetDestination(
EventHandle event, /* handle of the event to be modified */
optr dest); /* new destination for the event */
This routine sets the destination of an event to the optr passed.
Include: object.h
GEOS SDK TechDocs
|
|
MemThreadGrab() ...
|
ModemAnswerCall() ...