[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Re: [lwip] threads, semaphores and raw interface question
From: |
Adam Dunkels |
Subject: |
[lwip-users] Re: [lwip] threads, semaphores and raw interface question |
Date: |
Wed, 08 Jan 2003 22:06:56 -0000 |
Hi Leon!
On Wednesday 05 December 2001 14:22, you wrote:
> in your RFC for v0.5's sys_arch you mention that threads do not
> have to be supported in the underlying (OS) layer.
>
> However, there are semaphore signal and wait actions in the code,
> so I would conclude that the lwIP code assumes the presence of
> more than 1 thread.
>
> In our current standalone application, how would we include the
> lwIP TCP/IP stack? Do we need to use the (new?) callback,
> and do we have to make the semaphore calls empty?
The semaphore calls in the sys_arch can be implemented as empty functions in
the single threaded case. The reason for using them in the code (memp.c and
mem.c) is that the code should work in the multithreaded case as well. The
memory pools and the heap memory are shared resources so they have to be
protected by semaphores. In a single threaded environment, this protection
isn't necessary so the sys_sem_ functions can be left empty.
In a single threaded environment, the sequential API won't work because it
assumes multithreading (one application process working concurrently with the
TCP/IP stack). Therefore, the only choice is to use the callback based API
described in the previous post. (Which isn't really new, it just hadn't been
documented until now.)
So the answers to your questions would be yes, yes.
/adam
--
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]