lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] xTaskCreate() or sys_thread_new()


From: Dany Thiffeault
Subject: [lwip-users] xTaskCreate() or sys_thread_new()
Date: Wed, 16 Sep 2009 10:43:23 -0400

Hi,

I'm programming a AVR32 using FreeRTOS and lwIP 1.3.1. I need to create a server on the AVR32 which will have those tasks:

- Answer to request from a host;
- Stream data to the host in a certain mode;

I want to create 2 tasks with each their own sockets, one for receiving/answering host requests, the other one will be dedicated to data streaming for performance. So, my original idea was to create one main task that would listen on both sockets and once a communication is established, a new thread is created for each socket.

I was using xTaskCreate() so far for task creation in my application (non-ethernet), but I noticed that in the ATMEL Control Panel application, for ethernet they use sys_thread_new() function. Is it really important? (the code is pasted below)

Since I'm not doing a web, ftp or smtp server, in sys_thread_new(), my thread must be "ethernetif_input" if I want it to be created and added into the timeouts list structure. According to the code, only my 1st thread can be something else than "ethernetif_input". But I'm creating more than one thread with function names like "Listener" and "Streamer"... Anyway, you probably noticed that I'm confused :)

Thanks in advance!
Dany


/*
  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.
*/
sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg, int prio)
{
xTaskHandle CreatedTask;
int result = pdFAIL;
static int iCall = 0;

if( thread == ethernetif_input )
{
result = xTaskCreate( thread, ( signed portCHAR * ) "ETHINT", netifINTERFACE_TASK_STACK_SIZE, arg, prio, &CreatedTask );
}
else if( iCall == 0 )
{
/* The first time this is called we are creating the lwIP handler. */
result = xTaskCreate( thread, ( signed portCHAR * ) "lwIP", lwipINTERFACE_STACK_SIZE, arg, prio, &CreatedTask );
iCall++;
}

#if (HTTP_USED == 1)
else if (thread == vBasicWEBServer)
{
result = xTaskCreate( thread, ( signed portCHAR * ) "WEB", lwipBASIC_WEB_SERVER_STACK_SIZE, arg, prio, &CreatedTask );
}
#endif
#if (TFTP_USED == 1)
else if (thread == vBasicTFTPServer)
{
result = xTaskCreate( thread, ( signed portCHAR * ) "TFTP", lwipBASIC_TFTP_SERVER_STACK_SIZE, arg, prio, &CreatedTask );
}
#endif
#if (SMTP_USED == 1)
else if (thread == vBasicSMTPClient)
{
result = xTaskCreate( thread, ( signed portCHAR * ) "SMTP", lwipBASIC_SMTP_CLIENT_STACK_SIZE, arg, prio, &CreatedTask );
}
#endif


// For each task created, store the task handle (pid) in the timers array.
// This scheme doesn't allow for threads to be deleted
timeoutlist[nextthread++].pid = CreatedTask;

if(result == pdPASS)
{
return CreatedTask;
}
else
{
return NULL;
}
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]