Ignore:
Timestamp:
Oct 10, 2004, 1:07:40 PM (21 years ago)
Author:
bird
Message:

Signal changes - enabled by NEW_SIGNALS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/InnoTekLIBC/thread.h

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1573 r1574  
    6767    /** Default regular heap. */
    6868    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];
    6977    /** Old TLS variable. */
    7078    void           *pvThreadStoreVar;
    71     /** New TLS variable array. */
    72     void           *apvTLS[__LIBC_TLS_MAX];
    7379
    7480    /** The nesting depth of the default logger. */
     
    9197    char            szTTYNameBuf[32];
    9298
     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
    93186    /** Data used by the backends. */
    94187    union __libc_backend_data
     
    96189        struct __libc_sys
    97190        {
    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 
    105191            /** Directory find data entry.
    106192             * Used by __findfirst() and __findnext(). */
     
    110196                unsigned long   hdir;
    111197                /** Type of buffer content. FIL_STANDARDL or FIL_STANDARD,
    112                  * i.e. FILEFINDBUF3 or FILEFINDBUF3L. */
     198                 * i.e. FILEFINDBUF4 or FILEFINDBUF4L. */
    113199                unsigned long   fType;
    114200                /** Number of files left in the buffer. */
     
    122208    } b;
    123209
    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
    135211} __LIBC_THREAD;
    136212
     
    187263 * @returns pointer to current thread struct.
    188264
     265 * @remark  No reference counting here, current thread have a permanent
     266 *          reference to it self.
    189267 * @remark  This API is considered to be internal to LIBC and is thus not
    190268 *          exposed in the shared library version of LIBC. Please don't call it.
     
    202280 * @returns pointer to current thread struct.
    203281
     282 * @remark  No reference counting here, current thread have a permanent
     283 *          reference to it self.
    204284 * @remark  This API is considered to be internal to LIBC and is thus not
    205285 *          exposed in the shared library version of LIBC. Please don't call it.
     
    217297 * @returns NULL if not initiated.
    218298 *
     299 * @remark  No reference counting here, current thread have a permanent
     300 *          reference to it self.
    219301 * @remark  This API is considered to be internal to LIBC and is thus not
    220302 *          exposed in the shared library version of LIBC. Please don't call it.
     
    225307
    226308/**
     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 */
     364int         __libc_threadEnum(int (pfnCallback)(__LIBC_PTHREAD pCur, void *pvParam), void *pvParam);
     365
     366
     367/**
    227368 * Allocate and initialize a thread structure for a thread which is yet
    228369 * to be created.
    229370 *
     371 * The returned thread structure will have cRefs set to 1, thus
     372 * use __libc_threadDereference() to free it.
     373 *
    230374 * @returns Pointer to thread structure.
    231375 * @returns NULL on error. errno set.
     
    235379
    236380/**
    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 */
     386void __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 */
     406void __libc_threadDereference(__LIBC_PTHREAD pThrd);
    245407
    246408
Note: See TracChangeset for help on using the changeset viewer.