[En-Nut-Discussion] Using NutTcpReceive() and NutTcpSend() in different threads
Harald Kipp
harald.kipp at egnite.de
Wed Feb 5 20:34:12 CET 2003
The only preemptive thing in Nut/OS are interrupts. VERY IMPORTANT:
Timer callbacks are running in Interrupt context. In this
context, the only Nut/OS calls allowed are NutPostAsync and
NutBroadcastAsync.
Yes, start a second thread. This is save and doesn't require
all this locking, mutex and whatever stuff.
Harald
At 11:02 05.02.2003 -0800, you wrote:
> > >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?
> >
> > Should be no problem. The RS232D sample is using this and also
> > some of our commercial applications.
> >
> > Harald
>
>Thanks Harald for this information and the suggestion on the NutEventWait().
>
>I will be using the dual thread method, as it looks like it works well for
>the RS232 demo!
>
>One question, which I am pretty sure I know the answer to, the threads are
>not pre-emptive, correct? It looks like the timer uses a callback, which
>just changes the thread's state, but doesn't call the thread. So it is up to
>the threads to either call yield, or some other OS function that effectively
>yields. I was concerned that there could be a timer interrupt between the
>for loop where "connected" is checked, and where it calls NutTcpSend(). The
>other thread could have run and killed the socket, and when it returned it
>could have called NutTcpSend() with a dead socket. But if it is not
>preemtive, then there is no problem.
>
>Again, thanks for the answers!
>
>Stephen Noftall
>
>_______________________________________________
>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