Changeset 1574 for trunk/src/emx/include/InnoTekLIBC/thread.h
- Timestamp:
- Oct 10, 2004, 1:07:40 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/InnoTekLIBC/thread.h
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1573 r1574 67 67 /** Default regular heap. */ 68 68 struct _uheap * pRegularHeap; 69 /** Reference count. */ 70 unsigned cRefs; 71 /** Thread Id. */ 72 unsigned tid; 73 /** Pointer to next thread in the list. */ 74 struct __libc_thread *pNext; 75 /** New TLS variable array. */ 76 void *apvTLS[__LIBC_TLS_MAX]; 69 77 /** Old TLS variable. */ 70 78 void *pvThreadStoreVar; 71 /** New TLS variable array. */72 void *apvTLS[__LIBC_TLS_MAX];73 79 74 80 /** The nesting depth of the default logger. */ … … 91 97 char szTTYNameBuf[32]; 92 98 99 /** Pending signals. 100 * Protected by the signal semaphore. */ 101 sigset_t SigSetPending; 102 /** Blocked signals. 103 * Protected by the signal semaphore. */ 104 sigset_t SigSetBlocked; 105 /** Old Blocked signals. Used by sigsuspend(). 106 * sigsuspend() sets this and fSigSetBlockedOld. When a signal is to be 107 * delivered this member will be pushed on the stack for use on an eventual 108 * return. fSigSetBlockOld will be clared. 109 * Protected by the signal semaphore. */ 110 sigset_t SigSetBlockedOld; 111 112 /** Signals queued for delivery on this thread. 113 * Protected by the signal semaphore. */ 114 struct 115 { 116 struct SignalQueued *pHead; 117 struct SignalQueued *pTail; 118 } SigQueue; 119 120 /** Alternate signal stack block address. 121 * Protected by the signal semaphore. */ 122 void *pvSigStack; 123 /** Alternate signal stack block size. 124 * Protected by the signal semaphore. */ 125 size_t cbSigStack; 126 127 /** @defgroup libc_threadstruct_flags Thread Flags 128 * @todo checkup access safety here! 129 * @{ */ 130 /** If set SigSetBlockedOld should be used used to restore SigSetBlocked 131 * when returning from a signal handler. */ 132 unsigned fSigSetBlockedOld : 1; 133 /** If set the stack block pointed to by pvSigStack is in use. */ 134 unsigned fSigStackActive : 1; 135 /** If set the thread is internal. 136 * This means the thread will not receive signals. */ 137 unsigned fInternalThread : 1; 138 /** @} */ 139 140 /** Flags whether or not the thread is being forced to evaluate its 141 * pending signals. 142 * 143 * All updates of this variable must be done atomically and when owning 144 * the signal semaphore. The atomically requirement is because it's being 145 * read without owning the semaphore. 146 */ 147 unsigned fSigBeingPoked; 148 149 150 151 /** Thread status, chiefly used for the u member of the thread structure. */ 152 enum enmLIBCThreadStatus 153 { 154 /** The thread status must be queried from the OS. */ 155 enmLIBCThreadStatus_unknown = 0, 156 /** The thread status must be queried from the OS. */ 157 enmLIBCThreadStatus_startup, 158 /** The thread is in a sigwait(), sigwaitinfo(), or sigtimedwait() call. */ 159 enmLIBCThreadStatus_sigwait, 160 } enmStatus; 161 162 /** Data used in certain thread states. 163 * Use the enmStatus field to determin which way to read the data items here. 164 */ 165 union 166 { 167 /** enmLIBCThreadStatus_startup: Begin Thread Arguments. */ 168 struct __libc_thread_startup 169 { 170 /** Thread argument. */ 171 void *pvArg; 172 /** Thread routine. */ 173 void (*pfnStart)(void *pvArg); 174 } startup; 175 176 /** enmLIBCThreadStatus_sigwait: Thread blocked in sigwait(), sigwaitinfo() or sigtimedwait(). */ 177 struct __libc_thread_sigwait 178 { 179 /** The signals we're waiting for. */ 180 sigset_t SigSetWait; 181 /** The where to return signal info. */ 182 siginfo_t *pSigInfo; 183 } SigWait; 184 } u; 185 93 186 /** Data used by the backends. */ 94 187 union __libc_backend_data … … 96 189 struct __libc_sys 97 190 { 98 /** Blocked signal mask. */99 sigset_t sig_blocked;100 /** Pending signal mask. */101 sigset_t sig_pending;102 /** Signal actions. */103 struct sigaction signals[NSIG];104 105 191 /** Directory find data entry. 106 192 * Used by __findfirst() and __findnext(). */ … … 110 196 unsigned long hdir; 111 197 /** Type of buffer content. FIL_STANDARDL or FIL_STANDARD, 112 * i.e. FILEFINDBUF 3 or FILEFINDBUF3L. */198 * i.e. FILEFINDBUF4 or FILEFINDBUF4L. */ 113 199 unsigned long fType; 114 200 /** Number of files left in the buffer. */ … … 122 208 } b; 123 209 124 /** Data used in special periods of a threads life. */ 125 union 126 { 127 struct __libc_thread_startup 128 { 129 /** Thread argument. */ 130 void *pvArg; 131 /** Thread routine. */ 132 void (*pfnStart)(void *pvArg); 133 } startup; 134 } u; 210 135 211 } __LIBC_THREAD; 136 212 … … 187 263 * @returns pointer to current thread struct. 188 264 265 * @remark No reference counting here, current thread have a permanent 266 * reference to it self. 189 267 * @remark This API is considered to be internal to LIBC and is thus not 190 268 * exposed in the shared library version of LIBC. Please don't call it. … … 202 280 * @returns pointer to current thread struct. 203 281 282 * @remark No reference counting here, current thread have a permanent 283 * reference to it self. 204 284 * @remark This API is considered to be internal to LIBC and is thus not 205 285 * exposed in the shared library version of LIBC. Please don't call it. … … 217 297 * @returns NULL if not initiated. 218 298 * 299 * @remark No reference counting here, current thread have a permanent 300 * reference to it self. 219 301 * @remark This API is considered to be internal to LIBC and is thus not 220 302 * exposed in the shared library version of LIBC. Please don't call it. … … 225 307 226 308 /** 309 * Get the thread structure for the thread specified by it's thread identification. 310 * 311 * Used for instance by signal handling to change the signal properties of another 312 * thread. 313 * 314 * @returns Pointer to threads thread struct. 315 * The caller _must_ call __libc_threadRelease() when it's done using the 316 * thread structure. 317 * @returns NULL if the thread wasn't found. 318 * @param tid The Thread Id of the thread to find. 319 * @remark This API is considered to be internal to LIBC and is thus not 320 * exposed in the shared library version of LIBC. Please don't call it. 321 */ 322 __LIBC_PTHREAD __libc_threadLookup(unsigned tid); 323 324 325 /** 326 * Get the thread structure for a thread selected by a custom callback function. 327 * 328 * @returns Pointer to the selected thread. 329 * The caller _must_ call __libc_threadRelease() when it's done using the 330 * thread structure. 331 * @param pfnCallback Function which will to the thread selection. 332 * 333 * Returns 1 if the current thread should be returned. 334 * Returns 2 if the current thread should be returned immediately. 335 * Returns 0 if the current best thread should remain unchanged. 336 * Returns -1 if the enumeration should fail (immediately). 337 * 338 * pCur The current thread. 339 * pBest The current best thread. 340 * pvParam User parameter. 341 * 342 * @param pvParam User Parameter. 343 */ 344 __LIBC_PTHREAD __libc_threadLookup2(int (pfnCallback)(__LIBC_PTHREAD pCur, __LIBC_PTHREAD pBest, void *pvParam), void *pvParam); 345 346 347 /** 348 * Enumerates all the threads LIBC is aware of subjecting each of them to a 349 * caller specified callback function. 350 * 351 * @returns 0 on success. 352 * @returns -1 if pfnCallback returned -1. 353 * 354 * @param pfnCallback Function which will to the thread selection. 355 * 356 * Returns 0 if the enmeration should continue. 357 * Returns -1 if the enumeration should fail (immediately). 358 * 359 * pCur The current thread. 360 * pvParam User parameter. 361 * 362 * @param pvParam User Parameter. 363 */ 364 int __libc_threadEnum(int (pfnCallback)(__LIBC_PTHREAD pCur, void *pvParam), void *pvParam); 365 366 367 /** 227 368 * Allocate and initialize a thread structure for a thread which is yet 228 369 * to be created. 229 370 * 371 * The returned thread structure will have cRefs set to 1, thus 372 * use __libc_threadDereference() to free it. 373 * 230 374 * @returns Pointer to thread structure. 231 375 * @returns NULL on error. errno set. … … 235 379 236 380 /** 237 * Free a thread structure. 238 * 239 * @param pThrd Pointer to the thread structure to free. 240 * Must be valid. 241 * @remark If pThrd is for the current thread the thread must be 242 * in the very final termination stage. 243 */ 244 void __libc_threadFree(__LIBC_PTHREAD pThrd); 381 * Sets up the current thread to use the thread structure pThrd. 382 * 383 * @param pThrd Pointer to the thread structure this thread 384 * should be using. 385 */ 386 void __libc_threadUse(__LIBC_PTHREAD pThrd); 387 388 389 /** 390 * Dereferences a thread structure referenced by __libc_threadLookup() or 391 * __libc_threadLookup2(), or allocated by __libc_threadAlloc(). 392 * 393 * LIBC maintains reference counting on the thread structure so the thread 394 * structure will not be freed by the thread it represent while someone else 395 * is accessing it. However, the reference counting does not protect any of 396 * the structures members from writes or reads, that's left to the users of 397 * the members to synchronize between them. 398 * 399 * @returns pointer to threads thread struct. 400 * @returns NULL if the thread wasn't found. 401 * @param pThrd Pointer to thread structure returned by __libc_threadLookup(), 402 * __libc_threadLookup2() or __libc_threadAlloc(). 403 * @remark This API is considered to be internal to LIBC and is thus not 404 * exposed in the shared library version of LIBC. Please don't call it. 405 */ 406 void __libc_threadDereference(__LIBC_PTHREAD pThrd); 245 407 246 408 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.