Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

lwip tcp_recieve speed down with FreeRTOS

Posted by vincent on May 8, 2012
Hi:

I found a problem with FreeRTOS. I create a tiny server with LWIP to receive data from TCP tool, the receive speed is stable if running LWIP standalone, but the receive speed goes to down once running LWIP with FreeRTOS., it seems task switch cause this . anyone meet this problem ?

vincent

RE: lwip tcp_recieve speed down with FreeRTOS

Posted by Richard on May 9, 2012
It does not sound like a problem with FreeRTOS to me. Maybe a problem with the integration. Or maybe just the fact that it is running more code and passing messages between tasks when it is running on top of FreeRTOS. I do recall there was a long discussion on the lwIP mailing list about something similar about 4 to 6 months back.

Regards.

RE: lwip tcp_recieve speed down with FreeRTOS

Posted by vincent on May 10, 2012
Hi Richard:

thank you for your reply !

frankly, I think you are right ! because LWIP and FreeRTOS are mature very much . and I also found that the problem disapparent with LWIP standalone. FreeRTOS also is good enough . I don't know if the discussion in LWIP mail list is the following http://groups.google.com/group/osdeve_mirror_tcpip_lwip/browse_thread/thread/ca5738144b1f382d.

for FreeRTOS and LWIP integrity, the only porting file is sys_arch.c . i write mbox, semophare, mutex as following

err_t sys_mbox_new(sys_mbox_t *mbox, int size)
{
*mbox = xQueueCreate( archMESG_QUEUE_LENGTH, sizeof( void * ) );

if (*mbox == NULL)
{
return ERR_MEM;
}

return ERR_OK;
}

void sys_mbox_free(sys_mbox_t *mbox)
{
if (*mbox != NULL)
{
vQueueDelete( *mbox );
}
}

void sys_mbox_post(sys_mbox_t *mbox, void *msg)
{
if (*mbox != NULL)
{
while ( xQueueSendToBack(*mbox, &msg, portMAX_DELAY ) != pdTRUE );
}
}

err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
{
if ( xQueueSend( *mbox, &msg, 0 ) == pdPASS )
{
return ERR_OK;
}

return ERR_MEM;
}

u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
{
void *dummyptr = NULL;
portTickType StartTime, EndTime, Elapsed;

StartTime = xTaskGetTickCount();

if ( msg == NULL )
{
msg = &dummyptr;
}
if (*mbox == NULL)
{
return SYS_MBOX_EMPTY;
}

if ( timeout != 0 )
{
if ( pdTRUE == xQueueReceive( *mbox, &(*msg), timeout / portTICK_RATE_MS ) )
{
EndTime = xTaskGetTickCount();
Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;
return ( Elapsed );
}
else
{
*msg = NULL;
return SYS_ARCH_TIMEOUT;
}
}
else
{
while( pdTRUE != xQueueReceive( *mbox, &(*msg), portMAX_DELAY ));

EndTime = xTaskGetTickCount();
Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;
if (Elapsed == 0)
{
Elapsed = 1;
}
return ( Elapsed );
}
}

u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
{
void *dummyptr = NULL;

if ( msg == NULL )
{
msg = &dummyptr;
}

if (*mbox == NULL)
{
return SYS_MBOX_EMPTY;
}

if ( xQueueReceive( *mbox, &(*msg), 0 ) == pdPASS )
{
return ERR_OK;
}

return SYS_MBOX_EMPTY;
}

int sys_mbox_valid(sys_mbox_t *mbox)
{
return (*mbox != NULL);
}

void sys_mbox_set_invalid(sys_mbox_t *mbox)
{
*mbox = SYS_SEM_NULL;
}

err_t sys_sem_new(sys_sem_t *sem, u8_t count)
{
vSemaphoreCreateBinary( *sem );
if( sem == NULL )
{
return ERR_MEM;
}

if(count == 0)
{
xSemaphoreTake(*sem, 1);
}

return ERR_OK;
}

u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
{
portTickType StartTime, EndTime, Elapsed;

StartTime = xTaskGetTickCount();

if(timeout != 0)
{
if( xSemaphoreTake( *sem, timeout / portTICK_RATE_MS ) == pdTRUE )
{
EndTime = xTaskGetTickCount();
Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;

return (Elapsed);
}
else
{
return SYS_ARCH_TIMEOUT;
}
}
else
{
while( xSemaphoreTake( *sem, portMAX_DELAY ) != pdTRUE ){}
EndTime = xTaskGetTickCount();
Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;
if (Elapsed == 0)
{
Elapsed = 1;
}
return ( Elapsed );
}
}

void sys_sem_signal(sys_sem_t *sem)
{
if (*sem != NULL)
{
xSemaphoreGive( *sem );
}
}

void sys_sem_free(sys_sem_t *sem)
{
if (sem != NULL)
{
vQueueDelete( *sem );
}
}

int sys_sem_valid(sys_sem_t *sem)
{
return (*sem != NULL);
}

void sys_sem_set_invalid(sys_sem_t *sem)
{
*sem = SYS_SEM_NULL;
}

err_t sys_mutex_new( sys_mutex_t *pxMutex )
{
err_t xReturn = ERR_MEM;

*pxMutex = xSemaphoreCreateMutex();

if( *pxMutex != NULL )
{
xReturn = ERR_OK;
}

return xReturn;
}

void sys_mutex_lock( sys_mutex_t *pxMutex )
{
while( xSemaphoreTake( *pxMutex, portMAX_DELAY ) != pdPASS );
}

void sys_mutex_unlock(sys_mutex_t *pxMutex )
{
xSemaphoreGive( *pxMutex );
}


void sys_mutex_free( sys_mutex_t *pxMutex )
{
vQueueDelete( *pxMutex );
}

would you have a look for this ?

thank you very much


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists