Up: GEOS SDK TechDocs | Up | Prev: ThreadAttachToQueue() ... | Next: ThreadPSem() ...

ThreadGetError()

word	ThreadGetError(void)

This routine returns the thread's current error value.

ThreadGetInfo()

word	ThreadGetInfo(
        ThreadHandle		th,			/* thread to get information about */
        ThreadGetInfoType 		info);			/* type of information to get */

This routine gets information about the specified thread. The information desired is specified in the info parameter; the subject thread is specified in the th parameter. If the thread handle passed is zero or a null handle, the routine will return information about the calling thread.

The info parameter is one of the following values of ThreadGetInfoType , specifying the type of information to be returned by ThreadGetInfo() :

TGIT_PRIORITY_AND_USAGE
The returned word will contain both the thread's priority and the thread's recent CPU usage. To extract the priority of the thread, use the macro TGI_PRIORITY; to extract the recent CPU usage, use the macro TGI_RECENT_CPU_USAGE.
TGIT_THREAD_HANDLE
Useful only when the th parameter is zero, this will return the thread handle of the subject thread. If th is zero, the handle of the calling thread will be returned.
TGIT_QUEUE_HANDLE
The returned word will contain the queue handle of the event-driven thread specified in th . If the thread specified is not event-driven, a null queue handle will be returned.

Include: thread.h

ThreadGrabThreadLock()

void	ThreadGrabThreadLock(
        ThreadLockHandle sem);				/* thread lock to grab */

This routine attempts to grab the thread lock for the calling thread. If the thread lock is currently held by another thread, the caller will block until the lock becomes available. If the caller already has the thread lock, it will grab the lock again and continue executing.

Be Sure To: Thread locks must be released with ThreadReleaseThreadLock() once for each time they are grabbed.

Warnings: This routine provides no deadlock protection for multiple threads. If multiple threads will be grabbing multiple thread locks, the locks should always be grabbed in the same order to minimize the potential for deadlock.

Include: sem.h

See Also: ThreadAllocThreadLock(), ThreadReleaseThreadLock().

ThreadHandleException()

void	ThreadHandleException(
        ThreadHandle		th,				/* thread to handle the exception */
        ThreadExceptions		exception,				/* exception to handle */
        void	(*handler)	());				/* pointer to handler */

This routine allows a thread to set up a handler for a processor exception. This can be useful for debugging purposes. Pass the following three parameters:

th
The handle of the thread to handle the exception. Pass zero for the current thread.
exception
A ThreadException type (see below).
handler
A pointer to a handler in fixed or locked memory. Pass a null pointer to use the GEOS default exception handler.

Structures: The ThreadException type has the following values:

TE_DIVIDE_BY_ZERO
TE_OVERFLOW
TE_BOUND
TE_FPU_EXCEPTION
TE_SINGLE_STEP
TE_BREAKPOINT

Include: thread.h

ThreadModify()

void	ThreadModify(
        ThreadHandle		th,					/* thread to modify */
        word		newBasePriority,					/* thread's new base priority */
        ThreadModifyFlags		flags);					/* flags (see below) */

This routine modifies the priority of the specified thread. Use it to either set the base priority of the thread or reset the current CPU usage to zero. The parameters should have the following values:

th
The thread handle; pass zero to change the priority of the calling thread.
newBasePriority
The new base priority of the thread. Use one of the standard priorities--see ThreadCreate() --or use a value between zero and 255.
flags
A record of ThreadModifyFlags ; pass TMF_BASE_PRIO to change the thread's base priority or TMF_ZERO_USAGE to reset the thread's recent CPU usage to zero.

Warnings: Unless the thread is timing-critical, you should not set the base priority to zero.

Include: thread.h

ThreadPrivAlloc()

word	ThreadPrivAlloc(
        word		wordsRequested,					/* number of words to allocate */
        GeodeHandle		owner);					/* handle of geode to own data */

This routine allocates a number of contiguous words in the private data of all geodes (loaded and yet-to-be loaded). It is exactly the same as GeodePrivAlloc() ; see the entry for that routine.

Include: thread.h

See Also: GeodePrivAlloc().

ThreadPrivFree()

void	ThreadPrivFree(
        word	range,			/* offset to first word to be freed */
        word	wordsRequested);			/* number of words to free */

This routine frees a number of contiguous private-data words previously allocated with ThreadPrivAlloc() . It is similar to GeodePrivFree() ; see the entry for that routine for full information.

Include: thread.h

See Also: GeodePrivFree().


Up: GEOS SDK TechDocs | Up | Prev: ThreadAttachToQueue() ... | Next: ThreadPSem() ...