[En-Nut-Discussion] Using NutTcpReceive() and NutTcpSend() in different threads

Stephen Noftall stephenn at lcsaudio.com
Wed Feb 5 04:48:36 CET 2003


Hi Mike & Harald;

I have changed the beginning of NutEventWait to:

 int NutEventWait(volatile HANDLE *qhp, u_long ms)
{
 u08 signaled = 0;

    NutEnterCritical();

    /*
     * Check for posts on a previously empty queue.
     */
    if ((*qhp == SIGNALED) || (ms == 0)) {
        /*
         * Even if already signaled, switch to any other thread, which
         * is ready to run and has the same or higher priority.
         */
        if(*qhp == SIGNALED)
        {
   signaled = 1;
            *qhp = 0;
  }
        NutExitCritical();
        NutThreadYield();
        if (signaled) return 0;
        else return -1;
    }
...

This should cause all socket reads and write to be non-blocking, if the
timeout has been set to 0. It will still do a Yield, but this might be
required in order to handle some of the events, I don't understand the code
well enough to say right now.

Thanks!

Stephen Noftall

----- Original Message -----
From: "Mike Cornelius" <mikec at calldirect.com.au>
To: <en-nut-discussion at egnite.de>
Sent: Tuesday, February 04, 2003 5:28 PM
Subject: RE: [En-Nut-Discussion] Using NutTcpReceive() and NutTcpSend() in
different threads


> Hi Stephen,
>
> Funny you should ask, I'm working on an app the uses a UDP socket in 2
> different threads and have noticed some unexpected behaviour under certain
> circumstances (I get MEMCORR messages, do you?).
>
> Working out why is high on my list of things to do, but I'm going to get
the
> less problematic areas of my app finished first and come back to this
> problem a bit later.
>
> Maybe Harald has some idea why this may not work ...
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Mike Cornelius                      Internet: mikec at calldirect.com.au
> Call Direct Cellular Solutions      Phone:    +61 2 99-65-75-85
> Level 1 8-22 West St North Sydney   FAX:      +61 2 99-65-75-90
> NSW 2060 Australia                  URL:      http://www.calldirect.com.au
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
> -----Original Message-----
> From: en-nut-discussion-admin at egnite.de
> [mailto:en-nut-discussion-admin at egnite.de]On Behalf Of Stephen Noftall
> Sent: Wednesday, February 05, 2003 12:02 PM
> To: en-nut-discussion at egnite.de
> Subject: [En-Nut-Discussion] Using NutTcpReceive() and NutTcpSend() in
> different threads
>
>
> Hi;
>
> Is there any problem in using the TCP read and write routines on the same
> socket in different threads? Has anyone used it this way?
>
> Thanks for any information!
>
> Stephen Noftall
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo/en-nut-discussion
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo/en-nut-discussion




More information about the En-Nut-Discussion mailing list