Update for new sys_thread_new parameters (see task #7252 : "Create sys_thread_new_ex()" ). Some @todo are integrate to do some suggestions to port maintainers.

This commit is contained in:
fbernon 2007-09-05 16:48:11 +00:00
parent 1a658707d2
commit f1f5c7dd80
29 changed files with 45 additions and 39 deletions

View File

@ -51,10 +51,12 @@
#include "lwip/sys.h"
#include "lwip/sockets.h"
#define MAX_SERV 5 /* Maximum number of chargen services. Don't need too many */
#define CHARGEN_PRIORITY 254 /* Really low priority */
#define SEND_SIZE TCP_SNDLOWAT /* If we only send this much, then when select
says we can send, we know we won't block */
#define MAX_SERV 5 /* Maximum number of chargen services. Don't need too many */
#define CHARGEN_THREAD_NAME "chargen"
#define CHARGEN_PRIORITY 254 /* Really low priority */
#define CHARGEN_THREAD_STACKSIZE 0
#define SEND_SIZE TCP_SNDLOWAT /* If we only send this much, then when select
says we can send, we know we won't block */
struct charcb
{
struct charcb *next;
@ -253,7 +255,7 @@ static int do_read(struct charcb *p_charcb)
**************************************************************/
void chargen_init(void)
{
sys_thread_new( "chargen", chargen_thread, 0, 0, CHARGEN_PRIORITY);
sys_thread_new( CHARGEN_THREAD_NAME, chargen_thread, 0, CHARGEN_THREAD_STACKSIZE, CHARGEN_PRIORITY);
}

View File

@ -223,7 +223,7 @@ struct sys_timeouts *sys_arch_timeouts(void)
return 0;
}
sys_thread_t sys_thread_new(void (* function)(void *arg), void *arg, int prio)
sys_thread_t sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksize, int prio)
{
struct threadlist *new_thread;
HANDLE h;

View File

@ -114,7 +114,7 @@ sys_arch_timeouts(void)
}
/*-----------------------------------------------------------------------------------*/
sys_thread_t
sys_thread_new(void (* function)(void *arg), void *arg, int prio)
sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksize, int prio)
{
return 0;
}

View File

@ -724,7 +724,7 @@ etharp_timer_thread(void *arg)
static void
etharp_timer_init(void *arg)
{
sys_thread_new((void *)etharp_timer_thread, arg, DEFAULT_THREAD_PRIO);
sys_thread_new(DEFAULT_THREAD_NAME, (void *)etharp_timer_thread, arg, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}

View File

@ -118,7 +118,7 @@ introduce_thread(NU_TASK *id, void (*function)(void *arg), void *arg)
/* We use Nucleus task as thread. Create one with a standard size stack at a standard
* priority. */
sys_thread_t
sys_thread_new(void (*function)(void *arg), void *arg, int prio)
sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksize, int prio)
{
NU_TASK *p_thread;
u8_t *p_stack;
@ -126,6 +126,8 @@ sys_thread_new(void (*function)(void *arg), void *arg, int prio)
char thread_name[8] = " ";
struct sys_thread *st;
/** @todo Replace SYS_STACK_SIZE by "stacksize" parameter, perhaps use "name" if it is prefered */
p_stack = (u8_t *) malloc(SYS_STACK_SIZE);
if (p_stack)
{

View File

@ -251,7 +251,7 @@ ecosglue_init(void)
{
cyg_semaphore_init(&delivery, 0);
init_hw_drivers();
sys_thread_new(input_thread, (void*)0, CYGPKG_LWIP_ETH_THREAD_PRIORITY);
sys_thread_new("input_thread", input_thread, (void*)0, DEFAULT_THREAD_STACKSIZE, CYGPKG_LWIP_ETH_THREAD_PRIORITY);
etharp_init();
sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler) arp_timer, NULL);
}

View File

@ -242,12 +242,13 @@ void sys_sem_free(sys_sem_t sem)
/*
* Create new thread
*/
sys_thread_t sys_thread_new(void (*function) (void *arg), void *arg,int prio)
sys_thread_t sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksize, int prio)
{
struct lwip_thread * nt;
void * stack;
static int thread_count = 0;
nt = (struct lwip_thread *)cyg_mempool_var_alloc(var_mempool_h, sizeof(struct lwip_thread));
/** @todo name is already used but "stacksize" parameter is unused */
nt->next = threads;
nt->to.next = NULL;
@ -256,7 +257,7 @@ sys_thread_t sys_thread_new(void (*function) (void *arg), void *arg,int prio)
stack = (void *)(memfix+CYGNUM_LWIP_THREAD_STACK_SIZE*thread_count++);
cyg_thread_create(prio, (cyg_thread_entry_t *)function, (cyg_addrword_t)arg,
(char *)arg , stack, CYGNUM_LWIP_THREAD_STACK_SIZE, &(nt->th), &(nt->t) );
name, stack, CYGNUM_LWIP_THREAD_STACK_SIZE, &(nt->th), &(nt->t) );
cyg_thread_resume(nt->th);
return NULL;

View File

@ -279,7 +279,7 @@ void
tmain(cyg_addrword_t p)
{
lwip_init();
sys_thread_new(httpd_init, (void*)"httpd",7);
sys_thread_new("httpd", httpd_init, (void*)"httpd", DEFAULT_THREAD_STACKSIZE, 7);
}
#define STACK_SIZE 0x1000

View File

@ -742,7 +742,7 @@ void
tmain(cyg_addrword_t p)
{
lwip_init();
sys_thread_new(net_test, 0, MAIN_THREAD_PRIORITY);
sys_thread_new("net_test", net_test, 0, DEFAULT_THREAD_STACKSIZE, MAIN_THREAD_PRIORITY);
}
static char stack[STACK_SIZE];

View File

@ -64,7 +64,7 @@ void
tmain(cyg_addrword_t p)
{
lwip_init();
sys_thread_new(socket_thread, (void*)"socket",7);
sys_thread_new("socket", socket_thread, (void*)"socket", DEFAULT_THREAD_STACKSIZE, 7);
}
#define STACK_SIZE 0x1000

View File

@ -69,7 +69,7 @@ void
tmain(cyg_addrword_t p)
{
lwip_init();
sys_thread_new(timeout_thread, (void*)"timeout",7);
sys_thread_new("timeout", timeout_thread, (void*)"timeout", DEFAULT_THREAD_STACKSIZE, 7);
}
#define STACK_SIZE 0x1000

View File

@ -111,7 +111,7 @@ void
tmain(cyg_addrword_t p)
{
lwip_init();
sys_thread_new(tcpecho_thread, (void*)"tcpecho",7);
sys_thread_new("tcpecho", tcpecho_thread, (void*)"tcpecho", DEFAULT_THREAD_STACKSIZE, 7);
}
#define STACK_SIZE 0x1000

View File

@ -94,7 +94,7 @@ udpecho_thread(void *arg)
void tmain(cyg_addrword_t p)
{
lwip_init();
sys_thread_new(udpecho_thread, (void*)"udpecho",7);
sys_thread_new("udp_echo", udpecho_thread, (void*)"udpecho", DEFAULT_THREAD_STACKSIZE, 7);
}
#define STACK_SIZE 0x1000

View File

@ -164,7 +164,7 @@ sioslipif_init(struct netif *netif)
netif->output = sioslipif_output;
netif_pass = netif;
sys_thread_new((void *)sioslipif_loop, NULL, DEFAULT_THREAD_PRIO);
sys_thread_new("sioslipif_loop", (void *)sioslipif_loop, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
/* Do some magic to make it possible to receive data from the serial I/O device. */
}
/*-----------------------------------------------------------------------------------*/

View File

@ -242,11 +242,12 @@ sys_thread(void)
}
/*-----------------------------------------------------------------------------------*/
sys_thread_t
sys_thread_new(void (* function)(void *arg), void *arg, int prio)
sys_thread_new(char *name, void (* function)(void *arg), void *arg, int istacksize, int prio)
{
TASK newtask;
PRIORITY pri = prio; /* This may have to be changed. */
char *stack;
/** @todo Replace this local constant by the "istacksize" parameter */
int stacksize = 512; /* This may have to be changed. */
struct sys_thread_arg threadarg;

View File

@ -101,7 +101,7 @@ void Task_lwip_init(void * pParam)
//------------------------------------------------------------
//All thread(task) of lwIP must have their PRI between 10 and 14.
// sys_thread_new(httpd_init, (void*)"httpd",10);
// sys_thread_new("httpd_init", httpd_init, (void*)"httpd", DEFAULT_THREAD_STACKSIZE, 10);
//------------------------------------------------------------
httpd_init();//sample_http

View File

@ -198,9 +198,9 @@ sys_timeouts * sys_arch_timeouts(void)
/*------------------------------------------------------------------------*/
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)
{
/** @todo Replace LWIP_TASK_STK by the use of "stacksize" parameter */
if(prio == TCPIP_THREAD_PRIO){
OSTaskCreate(thread, (void *)0x1111, &LWIP_TASK_STK[LWIP_TASK_MAX][LWIP_STK_SIZE-1], prio);
return prio;

View File

@ -314,7 +314,7 @@ delif_init_thread(struct netif *netif)
del->netif->netmask = netif->netmask;
del->input = netif->input;
del->netif->input = delif_input;
sys_thread_new(delif_thread, netif, DEFAULT_THREAD_PRIO);
sys_thread_new("delif_thread", delif_thread, netif, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
return ERR_OK;
}

View File

@ -211,7 +211,7 @@ pcapif_init(struct netif *netif)
p->p = NULL;
p->lasttime = 0;
sys_thread_new(pcapif_thread, netif, DEFAULT_THREAD_PRIO);
sys_thread_new("pcapif_thread", pcapif_thread, netif, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/

View File

@ -135,7 +135,7 @@ low_level_init(struct netif *netif)
LWIP_DEBUGF(TAPIF_DEBUG, ("tapif_init: system(\"%s\");\n", buf));
system(buf);
sys_thread_new(tapif_thread, netif, DEFAULT_THREAD_PRIO);
sys_thread_new("tapif_thread", tapif_thread, netif, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}
/*-----------------------------------------------------------------------------------*/

View File

@ -97,7 +97,7 @@ low_level_init(struct netif *netif)
LWIP_DEBUGF(TUNIF_DEBUG, ("tunif_init: system(\"%s\");\n", buf));
system(buf);
sys_thread_new(tunif_thread, netif, DEFAULT_THREAD_PRIO);
sys_thread_new("tunif_thread", tunif_thread, netif, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}
/*-----------------------------------------------------------------------------------*/

View File

@ -453,8 +453,8 @@ unixif_init_server(struct netif *netif)
unixif->fd = fd2;
unixif->sem = sys_sem_new(0);
sys_thread_new(unixif_thread, netif, DEFAULT_THREAD_PRIO);
sys_thread_new(unixif_thread2, netif, DEFAULT_THREAD_PRIO);
sys_thread_new("unixif_thread", unixif_thread, netif, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
sys_thread_new("unixif_thread2", unixif_thread2, netif, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
@ -477,8 +477,8 @@ unixif_init_client(struct netif *netif)
}
unixif->q = list_new(UNIXIF_QUEUELEN);
unixif->sem = sys_sem_new(0);
sys_thread_new(unixif_thread, netif, DEFAULT_THREAD_PRIO);
sys_thread_new(unixif_thread2, netif, DEFAULT_THREAD_PRIO);
sys_thread_new("unixif_thread", unixif_thread, netif, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
sys_thread_new("unixif_thread2", unixif_thread2, netif, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/

View File

@ -1393,7 +1393,7 @@ shell_thread(void *arg)
void
shell_init(void)
{
sys_thread_new(shell_thread, NULL, DEFAULT_THREAD_PRIO);
sys_thread_new("shell_thread", shell_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}

View File

@ -83,7 +83,7 @@ tcpecho_thread(void *arg)
void
tcpecho_init(void)
{
sys_thread_new(tcpecho_thread, NULL, DEFAULT_THREAD_PRIO);
sys_thread_new("tcpecho_thread", tcpecho_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}
/*-----------------------------------------------------------------------------------*/

View File

@ -62,5 +62,5 @@ udpecho_thread(void *arg)
void
udpecho_init(void)
{
sys_thread_new(udpecho_thread, NULL, DEFAULT_THREAD_PRIO);
sys_thread_new("udpecho_thread", udpecho_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}

View File

@ -387,7 +387,7 @@ main_thread(void *arg)
#if LWIP_RAW
/** @todo remove dependency on RAW PCB support */
if(ping_flag) {
sys_thread_new(ping_thread, NULL, DEFAULT_THREAD_PRIO);
sys_thread_new("ping_thread", ping_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}
#endif
@ -484,7 +484,7 @@ main(int argc, char **argv)
printf("System initialized.\n");
sys_thread_new(main_thread, NULL, DEFAULT_THREAD_PRIO);
sys_thread_new("main_thread", main_thread, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
pause();
return 0;
}

View File

@ -141,7 +141,7 @@ main(int argc, char **argv)
printf("System initialized.\n");
sys_thread_new((void *)(main_thread), NULL, DEFAULT_THREAD_PRIO);
sys_thread_new("main_thread", (void *)(main_thread), NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
pause();
return 0;
}

View File

@ -152,7 +152,7 @@ main(int argc, char **argv)
printf("System initialized.\n");
sys_thread_new((void *)(main_thread), NULL, DEFAULT_THREAD_PRIO);
sys_thread_new("main_thread", (void *)(main_thread), NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
pause();
return 0;
}

View File

@ -151,7 +151,7 @@ current_thread(void)
}
/*-----------------------------------------------------------------------------------*/
sys_thread_t
sys_thread_new(void (*function)(void *arg), void *arg, int prio)
sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksize, int prio)
{
int code;
pthread_t tmp;