[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Re: [lwip] Patch for PaulOS + crash fixes
From: |
Adam Dunkels |
Subject: |
[lwip-users] Re: [lwip] Patch for PaulOS + crash fixes |
Date: |
Wed, 08 Jan 2003 22:48:40 -0000 |
Hi Paul!
On Monday 25 February 2002 15.21, you wrote:
> i do think its important to support configurations that
> want to work *without* threads in the *way* that PaulOS
> does.
>
> so whether you call it __PAULOS__ or __NO_OS__ is
> irrelevant. There should be a way to use a TCP stack
> without having to have a complex backbone infrustructure.
>
> that is:
> *- compiling of the http web server and pages should be
> a compile time option.
>
> *- your api_msg and api_lib files should also be a compile
> time option: i don't use them, because i made my own
> socket layer that interfaces with paulos' file
> descriptors.
>
> *- use of messages and semaphores should also be a compile
> time option. i.e. the network driver should be able
> to insert packets without having to pass messages
>
> *- lwIP should be able to run non-blocking - the way i have
> done it, you can call a main function occasionally to
> do any pending TCP work. When there is nothing to do,
> it returns immediately.
All of the above already is true for lwIP (this has been discussed a few
times the last months), but perhaps I have been bad at pointing this out.
Anyway, this is basically how it works:
* To get a simple TCP/IP stack without any thread support, etc., only compile
the files in the core/ directory.
* To get a multithreaded TCP/IP stack with a sequential API, also include the
files in api/ in your project.
* When running in a single-threaded environment, the sys_arch implementation
is really simple - look at src/arch/6502/sys_c64.c for an example of this.
* In a single threaded environment, the functions ip_input(), tcp_fasttmr()
and tcp_slowtmr() is the interface to lwIP. ip_input() should be called when
incoming packets arrive, and tcp_fasttmr() and tcp_slowtmr() should be called
periodically. The periodical TCP timers are taken care of in the api/tcpip.c
file (for multithreaded systems).
Also, the sample project in proj/unixsim/ should not be taken as the
definitive model for how to use lwIP; it is mostly meant as one specific
example of how to build lwIP.
Of course, this does not mean that there is room for improvement: The TCP
timer interface should be made simpler. I just added a new TCP function,
tcp_tmr(), which should be called every 100 ms. This function takes care of
dispatching the actual TCP fast and slow timers. The old tcp_slowtmr() and
tcp_fasttmr() are also avaliable, since people may depend on them.
Also, your comment about being able to turn of the sys.c layer is very
relevant. Single threaded environments does not need the sys.c code, so the
sys_ declarations could be replaced with null #defines and sys.c would not be
compiled into the project.
I've also cleaned up the makefile stuff for the unixsim example project.
Perhaps a new example project, a non-os project, should be added as well?
> *- you should be able to plug in your own malloc module
> so that you can use GNU malloc.c if you have it, or
> whatever malloc implementation your OS supports.
> the patch i sent you has #ifdef's around all the
> memory allocation stuff.
This was something I was thinking about in the early stages of lwIP
development, before the memp stuff was included. This should be implemented
by #defining macros for mem_malloc() et al. in mem.h instead of using lots of
#ifdefs in the code. I've added this to my todo list.
/adam
--
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]
- [lwip-users] Re: [lwip] Patch for PaulOS + crash fixes, psheer, 2003/01/08
- [lwip-users] RE: [lwip] Patch for PaulOS + crash fixes, liandong, 2003/01/08
- [lwip-users] Re: [lwip] Patch for PaulOS + crash fixes,
Adam Dunkels <=
- [lwip-users] Re: [lwip] Patch for PaulOS + crash fixes, psheer, 2003/01/08
- [lwip-users] Re: [lwip] Patch for PaulOS + crash fixes, psheer, 2003/01/08
- [lwip-users] Re: [lwip] Patch for PaulOS + crash fixes, Adam Dunkels, 2003/01/08
- [lwip-users] Re: [lwip] Patch for PaulOS + crash fixes, Adam Dunkels, 2003/01/09