Changeset 1625


Ignore:
Timestamp:
Nov 8, 2004, 2:06:54 AM (21 years ago)
Author:
bird
Message:

Debugging and writing signals.

Location:
trunk/src/emx/src/lib
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/process/bsd_signal.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1624 r1625  
    7979    SigAct.sa_flags                   = 0;
    8080    __SIGSET_EMPTY(&SigAct.sa_mask);
    81 
     81    if (__SIGSET_ISSET(&__libc_gSignalRestartMask, iSignalNo))
     82        SigAct.sa_flags |= SA_RESTART;
    8283
    8384    /*
    8485     * Change signal action.
    8586     */
    86     if (__SIGSET_ISSET(&__libc_gSignalRestartMask, iSignalNo))
    87         SigAct.sa_flags |= SA_RESTART;
    8887    rc = __libc_Back_signalAction(iSignalNo, &SigAct, &SigActOld);
    8988    if (!rc)
  • trunk/src/emx/src/lib/process/signal.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1624 r1625  
    3636
    3737/**
    38  * Defaul signal() style is BSD.
     38 * Default signal() style is BSD.
    3939 *
    4040 * @returns pointer to previous signal handler.
  • trunk/src/emx/src/lib/process/sigprocmask.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1624 r1625  
    5050 *                      values are SIG_BLOCK, SIG_UNBLOCK or SIG_SETMASK.
    5151 *
    52  *                      SIG_BLOCK means to or the sigset pointed to by pSigSetNew with
     52 *                      SIG_BLOCK means to OR the sigset pointed to by pSigSetNew with
    5353 *                          the signal mask for the current thread.
    54  *                      SIG_UNBLOCK means to and the 0 complement of the sigset pointed
     54 *                      SIG_UNBLOCK means to AND the 0 complement of the sigset pointed
    5555 *                          to by pSigSetNew with the signal mask of the current thread.
    56  *                      SIG_SETMASK means to set the signal mask of the current thread
     56 *                      SIG_SETMASK means to REPLACE the signal mask of the current thread
    5757 *                          to the sigset pointed to by pSigSetNew.
    5858 *
  • trunk/src/emx/src/lib/sys/b_signalSuspend.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1624 r1625  
    6868    pThrd->enmStatus            = enmLIBCThreadStatus_sigsuspend;
    6969
     70    /** @todo The specs say no rescheduling of signals in sigsuspend()... I'm not sure if that's a great idea. */
     71
    7072    /*
    7173     * Perform signal wait and return.
  • trunk/src/emx/src/lib/sys/sharedpm.c

    • Property cvs2svn:cvs-rev changed from 1.16 to 1.17
    r1624 r1625  
    956956             */
    957957            if (    (   gpSPMHdr->cSigActive < gpSPMHdr->cSigMaxActive
    958                      && gpSPMSelf->cSigsSent < __LIBC_SPM_SIGNALS_MAX_SENT)
     958                     && gpSPMSelf->cSigsSent < _POSIX_SIGQUEUE_MAX)
    959959                || pSignal->si_signo == SIGCHLD)
    960960            {
     
    10231023            {
    10241024                LIBCLOG_MSG("Limit reached: cSigActive=%d cSigMaxActive=%d cSigsSent=%d (max %d)\n",
    1025                             gpSPMHdr->cSigActive, gpSPMHdr->cSigMaxActive, pProcess->cSigsSent, __LIBC_SPM_SIGNALS_MAX_SENT);
     1025                            gpSPMHdr->cSigActive, gpSPMHdr->cSigMaxActive, pProcess->cSigsSent, _POSIX_SIGQUEUE_MAX);
    10261026                rc = -EAGAIN;
    10271027            }
  • trunk/src/emx/src/lib/sys/signals.c

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r1624 r1625  
    7878#include <malloc.h>
    7979#include <386/builtin.h>
     80#include <emx/umalloc.h>
    8081#include <InnoTekLIBC/thread.h>
    8182#include <InnoTekLIBC/fork.h>
     
    529530 * All access to this array is protected by the signal semaphore.
    530531 */
    531 static PSIGQUEUED   gpSigQueuedFree = &gpaSigQueuedPreAlloced[0];
     532static PSIGQUEUED           gpSigQueuedFree = &gpaSigQueuedPreAlloced[0];
    532533/** Number of structures in the free queue. */
    533 static unsigned     gcSigQueuedFree = sizeof(gpaSigQueuedPreAlloced) / sizeof(gpaSigQueuedPreAlloced[0]);
     534static volatile unsigned    gcSigQueuedFree = sizeof(gpaSigQueuedPreAlloced) / sizeof(gpaSigQueuedPreAlloced[0]);
    534535
    535536/** Flag indicating that this LIBC instance have installed the signal handler.
     
    781782
    782783/**
    783  * Worker called after __libc_Back_signalRaise() was called with a
    784  * preallocated signal queue entry. This function will make sure
    785  * we're not ending up with too many heap allocated packets in the
    786  * free list.
    787  */
    788 void __libc_Back_signalFreeWorker(void)
    789 {
    790     LIBCLOG_ENTER("\n");
    791     if (gcSigQueuedFree > sizeof(gpaSigQueuedPreAlloced) * 2 / sizeof(gpaSigQueuedPreAlloced[0]))
    792     {
    793         if (!__libc_back_signalSemRequest())
     784 * Reschedule signals.
     785 * Typically called after a block mask have been updated.
     786 *
     787 * @returns On success a flag mask out of the __LIBC_BSRR_* #defines is returned.
     788 * @returns On failure a negative error code (errno.h) is returned.
     789 * @param   pThrd       Current thread.
     790 */
     791int __libc_back_signalReschedule(__LIBC_PTHREAD pThrd)
     792{
     793    LIBC_ASSERT(__libc_back_signalSemIsOwner());
     794    signalScheduleSPM(pThrd);
     795    signalScheduleProcess(pThrd);
     796    return signalDeliver(pThrd, 0, NULL);
     797}
     798
     799
     800/**
     801 * Raises a signal in the current process.
     802 *
     803 * @returns On success a flag mask out of the __LIBC_BSRR_* #defines is returned.
     804 * @returns On failure a negative error code (errno.h) is returned.
     805 * @param   iSignalNo           Signal to raise.
     806 * @param   pSigInfo            Pointer to signal info for this signal.
     807 *                              NULL is allowed.
     808 * @param   pvXcptOrQueued      Exception handler parameter list.
     809 *                              Or if __LIBC_BSRF_QUEUED is set, a pointer to locally malloced
     810 *                              SIGQUEUED node.
     811 * @param   fFlags              Flags of the #defines __LIBC_BSRF_* describing how to
     812 *                              deliver the signal.
     813 *
     814 * @remark  This Backend Signal API does NOT require the caller to own the signal semaphore.
     815 */
     816int __libc_back_signalQueueSelf(int iSignalNo, siginfo_t *pSigInfo)
     817{
     818    LIBCLOG_ENTER("iSignalNo=%d pSigInfo=%p\n", iSignalNo, (void *)pSigInfo);
     819
     820    /*
     821     * Preallocate a queue entry to avoid entering and leaving the semaphore unecessary.
     822     */
     823    PSIGQUEUED pSigToFree = NULL;
     824    PSIGQUEUED pSig = _hmalloc(sizeof(*pSig));
     825
     826    /*
     827     * Take sempahore.
     828     */
     829    int rc = __libc_back_signalSemRequest();
     830    if (!rc)
     831    {
     832        /*
     833         * Release heap memory accumulated in node
     834         */
     835        if (gcSigQueuedFree > sizeof(gpaSigQueuedPreAlloced) * 2 / sizeof(gpaSigQueuedPreAlloced[0]))
    794836        {
    795837            /*
    796              * Free nodes which was allocated from the heap until we're below the water line.
     838             * No need for the preallocated one!
     839             */
     840            if (pSig)
     841                pSig->pNext = NULL;
     842            pSigToFree = pSig;
     843
     844            /*
     845             * Unlink heap allocated nodes until we're below the waterline again
    797846             */
    798847            PSIGQUEUED pSigPrev = NULL;
    799             PSIGQUEUED pSig = gpSigQueuedFree;
     848            pSig = gpSigQueuedFree;
    800849            int cToMany = gcSigQueuedFree - sizeof(gpaSigQueuedPreAlloced) * 2 / sizeof(gpaSigQueuedPreAlloced[0]);
    801850            while (cToMany > 0)
     
    810859                        gpSigQueuedFree = pSigNext;
    811860
    812                     /* free */
    813                     free(pSig);
     861                    /* queue for free */
     862                    pSig->pNext = pSigToFree;
     863                    pSigToFree = pSig;
    814864
    815865                    /* next */
     
    822872                }
    823873            }
    824             __libc_back_signalSemRelease();
    825         }
    826     }
    827     LIBCLOG_RETURN_VOID();
    828 }
    829 
    830 
    831 /**
    832  * Reschedule signals.
    833  * Typically called after a block mask have been updated.
    834  *
    835  * @returns On success a flag mask out of the __LIBC_BSRR_* #defines is returned.
    836  * @returns On failure a negative error code (errno.h) is returned.
    837  * @param   pThrd       Current thread.
    838  */
    839 int __libc_back_signalReschedule(__LIBC_PTHREAD pThrd)
    840 {
    841     LIBC_ASSERT(__libc_back_signalSemIsOwner());
    842     signalScheduleSPM(pThrd);
    843     signalScheduleProcess(pThrd);
    844     return signalDeliver(pThrd, 0, NULL);
     874
     875            pSig = NULL;
     876        }
     877
     878        /*
     879         * Raise the signal the normal way.
     880         */
     881        rc = __libc_Back_signalRaise(iSignalNo, pSigInfo, pSig, __LIBC_BSRF_QUEUED);
     882        __libc_back_signalSemRelease();
     883        if (rc > 0)
     884            rc = 0;
     885    }
     886
     887    /*
     888     * Cleanup and return.
     889     */
     890    while (pSigToFree)
     891    {
     892        void *pvToFree = pSigToFree;
     893        pSigToFree = pSigToFree->pNext;
     894        free(pvToFree);
     895    }
     896    LIBCLOG_RETURN_INT(rc);
    845897}
    846898
  • trunk/src/emx/src/lib/sys/signals.h

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1624 r1625  
    4949void        __libc_back_signalPokeProcess(void);
    5050int         __libc_back_signalReschedule(__LIBC_PTHREAD pThrd);
     51int         __libc_back_signalQueueSelf(int iSignalNo, siginfo_t *pSigInfo);
    5152int         __libc_back_signalSuspend(void);
    5253int         __libc_back_signalAccept(__LIBC_PTHREAD pThrd, int iSignalNo, sigset_t *pSigSet, siginfo_t *pSigInfo);
Note: See TracChangeset for help on using the changeset viewer.