diff --git a/CHANGELOG b/CHANGELOG index d0723951..58bf30f0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,15 @@ HISTORY ++ New features: + 2007-09-05 Frédéric Bernon, Bill Florac + * opt.h, sys.h, tcpip.c, slipif.c, ppp.c, sys_arch.txt: Change parameters list + for sys_thread_new (see "task #7252 : Create sys_thread_new_ex()"). Two new + parameters have to be provided: a task name, and a task stack size. For this + one, since it's platform dependant, you could define the best one for you in + your lwipopts.h. For port maintainers, you can just add these new parameters + in your sys_arch.c file, and but it's not mandatory, use them in your OS + specific functions. + 2007-09-05 Frédéric Bernon * inet.c, autoip.c, msg_in.c, msg_out.c, init.c: Move some build time checkings inside init.c for task #7142 "Sanity check user-configurable values". diff --git a/doc/sys_arch.txt b/doc/sys_arch.txt index 5cb7778d..77a52424 100644 --- a/doc/sys_arch.txt +++ b/doc/sys_arch.txt @@ -128,12 +128,13 @@ If threads are supported by the underlying operating system and if such functionality is needed in lwIP, the following function will have to be implemented as well: -- sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg, int prio) +- sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio) - Starts a new thread with priority "prio" that will begin its execution in the - function "thread()". The "arg" argument will be passed as an argument to the - thread() function. The id of the new thread is returned. Both the id and - the priority are system dependent. + Starts a new thread named "name" with priority "prio" that will begin its + execution in the function "thread()". The "arg" argument will be passed as an + argument to the thread() function. The stack size to used for this thread is + the "stacksize" parameter. The id of the new thread is returned. Both the id + and the priority are system dependent. - sys_prot_t sys_arch_protect(void) diff --git a/src/api/tcpip.c b/src/api/tcpip.c index c0302a79..476fa7ae 100644 --- a/src/api/tcpip.c +++ b/src/api/tcpip.c @@ -543,7 +543,7 @@ tcpip_init(void (* initfunc)(void *), void *arg) lock_tcpip_core = sys_sem_new(1); #endif /* LWIP_TCPIP_CORE_LOCKING */ - sys_thread_new(tcpip_thread, NULL, TCPIP_THREAD_PRIO); + sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO); } #endif /* !NO_SYS */ diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index 3dc313e8..2d1c964a 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -741,37 +741,101 @@ ---------- Thread options ---------- ------------------------------------ */ +/** + * TCPIP_THREAD_NAME: The name assigned to the main tcpip thread. + */ +#ifndef TCPIP_THREAD_NAME +#define TCPIP_THREAD_NAME "tcpip_thread" +#endif + +/** + * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef TCPIP_THREAD_STACKSIZE +#define TCPIP_THREAD_STACKSIZE 0 +#endif + /** * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread. * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when tcpip_thread is created. + * sys_thread_new() when the thread is created. */ #ifndef TCPIP_THREAD_PRIO #define TCPIP_THREAD_PRIO 1 #endif +/** + * SLIPIF_THREAD_NAME: The name assigned to the slipif_loop thread. + */ +#ifndef SLIPIF_THREAD_NAME +#define SLIPIF_THREAD_NAME "slipif_loop" +#endif + +/** + * SLIP_THREAD_STACKSIZE: The stack size used by the slipif_loop thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef SLIPIF_THREAD_STACKSIZE +#define SLIPIF_THREAD_STACKSIZE 0 +#endif + /** * SLIPIF_THREAD_PRIO: The priority assigned to the slipif_loop thread. * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when slipif_loop is created. + * sys_thread_new() when the thread is created. */ #ifndef SLIPIF_THREAD_PRIO #define SLIPIF_THREAD_PRIO 1 #endif +/** + * PPP_THREAD_NAME: The name assigned to the pppMain thread. + */ +#ifndef PPP_THREAD_NAME +#define PPP_THREAD_NAME "pppMain" +#endif + +/** + * PPP_THREAD_STACKSIZE: The stack size used by the pppMain thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef PPP_THREAD_STACKSIZE +#define PPP_THREAD_STACKSIZE 0 +#endif + /** * PPP_THREAD_PRIO: The priority assigned to the pppMain thread. * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when pppMain is created. + * sys_thread_new() when the thread is created. */ #ifndef PPP_THREAD_PRIO #define PPP_THREAD_PRIO 1 #endif /** - * DEFAULT_THREAD_PRIO: The priority assigned to the pppMain thread. + * DEFAULT_THREAD_NAME: The name assigned to any other lwIP thread. + */ +#ifndef DEFAULT_THREAD_NAME +#define DEFAULT_THREAD_NAME "lwIP" +#endif + +/** + * DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread. + * The stack size value itself is platform-dependent, but is passed to + * sys_thread_new() when the thread is created. + */ +#ifndef DEFAULT_THREAD_STACKSIZE +#define DEFAULT_THREAD_STACKSIZE 0 +#endif + +/** + * DEFAULT_THREAD_PRIO: The priority assigned to any other lwIP thread. * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when pppMain is created. + * sys_thread_new() when the thread is created. */ #ifndef DEFAULT_THREAD_PRIO #define DEFAULT_THREAD_PRIO 1 diff --git a/src/include/lwip/sys.h b/src/include/lwip/sys.h index 0a2d3fc4..3cde32f0 100644 --- a/src/include/lwip/sys.h +++ b/src/include/lwip/sys.h @@ -62,7 +62,7 @@ struct sys_timeo {u8_t dummy;}; #define sys_mbox_post(m,d) #define sys_mbox_free(m) -#define sys_thread_new(t,a,p) +#define sys_thread_new(n,t,a,s,p) #else /* NO_SYS */ @@ -134,7 +134,7 @@ void sys_mbox_free(sys_mbox_t mbox); void sys_mbox_fetch(sys_mbox_t mbox, void **msg); /* Thread functions. */ -sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg, int prio); +sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio); /* The following functions are used only in Unix code, and can be omitted when porting the stack. */ diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 6c032912..b5aac3c9 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -532,7 +532,7 @@ int pppOverSerialOpen(sio_fd_t fd, void (*linkStatusCB)(void *ctx, int errCode, pc->linkStatusCB = linkStatusCB; pc->linkStatusCtx = linkStatusCtx; - sys_thread_new(pppMain, (void*)pd, PPP_THREAD_PRIO); + sys_thread_new(PPP_THREAD_NAME, pppMain, (void*)pd, PPP_THREAD_STACKSIZE, PPP_THREAD_PRIO); if(!linkStatusCB) { while(pd >= 0 && !pc->if_up) { sys_msleep(500); diff --git a/src/netif/slipif.c b/src/netif/slipif.c index eadb3c31..162d6a8a 100644 --- a/src/netif/slipif.c +++ b/src/netif/slipif.c @@ -267,6 +267,6 @@ slipif_init(struct netif *netif) NETIF_INIT_SNMP(netif, snmp_ifType_slip, 0); /* Create a thread to poll the serial line. */ - sys_thread_new(slipif_loop, netif, SLIPIF_THREAD_PRIO); + sys_thread_new(SLIPIF_THREAD_NAME, slipif_loop, netif, SLIPIF_THREAD_STACKSIZE, SLIPIF_THREAD_PRIO); return ERR_OK; }