FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2012 Threads] lwip tcp_recieve speed down with FreeRTOSPosted 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 FreeRTOSPosted 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 FreeRTOSPosted 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
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|