Task communication, lwIP.

nobody wrote on Monday, September 11, 2006:

I need to make following thing:
First task is waiting on lwIP socket for commands, and second task is waiting on second lwIP socket.
When I get a "start sending" command on socket 1 (first task), I want to start sending data on socket 2 (second task).
And when I get a "stop sending" command, I want to stop sending data.
The question is:
If I use a global variable which is changed only by task 1, and read by task 2, do I need to use critical section? Changing a variable is probably done in one assembler command, am I right?(portCHAR on 32-bit ARM7)
Also, is there any better way to synchronize these two task? Semaphore doesnt fit well here I think, because I dont want the task 2 to take it, it only needs to read the flag to send or not.

Second question: is there any way not to block task when waiting on packet in lwIP? I want to send data continously and also check for commands from another side.

And third: can two tasks work with one lwip socket connection? For example: one sends and one waits for commands.

Please help ;]

nobody wrote on Monday, September 11, 2006:

Q1 - A critical section is only required is both tasks change the variable.  If only one task writes to the variable and the variable is of the natural width of the machine (32bit for arm7) then you are fine without.  You can also use a semaphore for synchronization having the task 2 take the semaphore but never give it, and task 1 give the semaphore but never take it.  Many people ignore this method of using semaphores, check out the uIP examples for this method.

Q2 - Not too familiar with lwIP but normally with berkley sockets you can setup them up to be either blocking or non blocking before binding.  Check the documentation.

Q3 - Don’t know.