[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Stackless, non-preemptive uSmartX RTOS and lwIP
From: |
Marko Panger |
Subject: |
[lwip-users] Stackless, non-preemptive uSmartX RTOS and lwIP |
Date: |
Thu, 26 Jan 2006 16:59:57 -0000 |
User-agent: |
Mozilla Thunderbird 1.0.7 (Windows/20050923) |
Hello all,
I'm about to start porting the lwIP stack on my uSmartX RTOS. It's a
stack-less, co-operative, priority based, multitasking RTOS with some
preemptive primitives. It supports timed pending o semaphores and
mailboxes although is stack less. For the sake you can drop an eye on
http://usmartx.sourceforge.net/.
I have already passed through the lwIP sources and documentation. If I
understand well it can works in two modes. The so called raw api and
sequential api mode. The raw api mode doesn't require an underlying
RTOS, but the latter does. The raw API mode should be easy and straight
forward to integrate into my os.
The sequential API looks a little bit tricky if the os is
not-preemptive. If you look at the sample code below you can get an idea
of how for example semaphores are used in my rtos. Basically they
require the task to return if the resource is not available. The task
will be than resumed by a semaphore post or a timeout event. Applying
this to lwIP would require modification of the API calls in such a way
that multiple calls of the same API call can be made if the semaphore is
not available at the moment and than calling the same API function with
"semaphore" available parameter...
Now I am kindly referring to you for some comments on this
implementation. I'm also a little bit confused on sequential API calls -
which file contains the available calls ? Is this api_msg.c, sockets or
some other additional file ?
Thanks in advance four you comments !
Regards,
Marko Panger
Sample uSmartX task:
----------------------------------------------------------------------------------
STATUS TSK_SetLed(STATUS ucEvent) {
static TTSK_State TskState = ACQUIRE_SEM;
static uint32 AnchorTicks = 0;
switch( TskState ) {
case ACQUIRE_SEM:
if( ucEvent == SYS_SEM_TOUT ){
/* Handle error here */
return SYS_ERROR;
}
/* Semaphore acquired within timeout */
else if( ucEvent == SYS_SEM ) {
AnchorTicks = TMR_GetTicks();
TskState = DO_JOB; }
else {
if( SEM_Pend(&LED_SEM, 50) == SYS_OK ) {
AnchorTicks = TMR_GetTicks();
TskState = DO_JOB;
}
}
break;
case DO_JOB:
/* Use shared resource for 10 ms*/
if( TMR_GetTicks() - AnchorTicks > 10 ) {
SetLed(0);
SEM_Post(&LED_SEM);
TskState = ACQUIRE_SEM;
}
else {
SetLed(1); }
break;
default:
break;
} return SYS_OK; }
----------------------------------------------------------------------------------
- [lwip-users] Stackless, non-preemptive uSmartX RTOS and lwIP,
Marko Panger <=