SemaphoreError ThreadPSem(
SemaphoreHandle sem); /* semaphore to grab */
This routine attempts to grab the passed semaphore via a "P" operation. If the semaphore has already been grabbed, the thread will block until the semaphore becomes available, even if it was grabbed by the same thread.
ThreadPSem()
returns an error code of type
SemaphoreError
. The error code is intended to indicate abnormal return by the previous thread; if the semaphore never becomes available, the thread will block indefinitely and the routine will not return.
Be Sure To: When the thread no longer needs the semaphore, it should release it with
ThreadVSem()
.
Warnings: This routine provides no deadlock protection. If threads will grab multiple common semaphores, they should always grab/release them in the same order, minimizing the chances for deadlock.
A thread may not try to grab a particular semaphore twice without releasing it in between grabs. The thread will block on itself and will deadlock. If a thread may need to grab the semaphore twice in a row, it should use a thread lock instead (see
ThreadAllocThreadLock()
for more information).
Include: sem.h
See Also: ThreadAllocSem(),
ThreadVSem(),
ThreadFreeSem(),
ThreadPTimedSem().
SemaphoreError ThreadPTimedSem(
SemaphoreHandle sem, /* semaphore to grab */
word timeout); /* ticks before timeout */
This routine attempts to grab the passed semaphore via a "P" operation. If the semaphore has already been grabbed, the thread will block for at most the number of ticks specified in
timeout
.
Often
timeout
is passed as zero to indicate that if the semaphore isn't available right now, the thread will go on with some other action.
Be Sure To: When the thread no longer needs the semaphore, it should release it with
ThreadVSem()
.
Warnings: This routine provides no deadlock protection. If threads will grab multiple common semaphores, they should always grab/release them in the same order, minimizing the chances for deadlock.
A thread may not try to grab a particular semaphore twice without releasing it in between grabs. The thread will block on itself and will deadlock. If a thread may need to grab the semaphore twice in a row, it should use a thread lock instead, though there is no timeout equivalent for thread locks (see
ThreadAllocThreadLock()
for more information).
Include: sem.h
See Also: ThreadAllocSem(),
ThreadPSem(),
ThreadVSem(),
ThreadFreeSem().
void ThreadReleaseThreadLock(
ThreadLockHandle sem); /* threadlock to release */
This routine releases the specified thread lock previously grabbed with
ThreadGrabThreadLock()
. Pass the handle of the thread lock as returned by
ThreadAllocThreadLock()
.
Do not try to release a thread lock that has not previously been grabbed. The results are unpredictable.
Include: sem.h
See Also: ThreadAllocThreadLock(),
ThreadGrabThreadLock().
void ThreadVSem(
SemaphoreHandle sem); /* semaphore to release */
This routine releases a semaphore that was grabbed with
ThreadPSem()
or
ThreadPTimedSem()
. Pass the handle of the semaphore as returned by
ThreadAllocSem()
.
Do not try to release a semaphore that has not previously been grabbed with one of the above routines. The results are unpredictable.
Include: sem.h
See Also: ThreadAllocSem(),
ThreadPSem(),
ThreadFreeSem(),
ThreadPTimedSem().
dword TimerGetCount();
This routine returns the value of the system counter. The returned value is the number of ticks since GEOS started.
Include: timer.h
void TimerGetDateAndTime(
TimerDateAndTime * dateAndTime); /* buffer for returned values */
This routine returns the current time and date. Pass it a pointer to an empty
TimerDateAndTime
structure to be filled in by the routine.
Include: timedate.h
TimerFileDateTime TimerGetFileDateTime();
This routine returns the current time and date in a structure equivalent to a
FileDateAndTime
. As such, it is useful for constructing time stamps for files.
void TimerSetDateAndTime(
word flags, /* which item to set */
const TimerDateAndTime * dateAndTime); /* new values */
This routine sets the current date and/or time of the system. Pass it the following:
flags
dateAndTime
TimerDateAndTime
structure containing the information to be set.Include: timedate.h
GEOS SDK TechDocs
|
|
ThreadGetError() ...
|
TimerSleep() ...