[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] more questions... thanks in advance.
From: |
Eric Shufro |
Subject: |
[lwip-users] more questions... thanks in advance. |
Date: |
Mon, 15 Mar 2004 22:46:54 -0500 |
I get stuck in a few places during the tcp/ip initialization process. I have
traced through much of the code, but the logic in a few spots where errors
occurs confuses me. Ill do my best to explain where I am confused.
I am using the uCOS-II port available online.
In sys_arch.c:
//-------------------------------------
struct sys_timeouts *
sys_arch_timeouts(void)
{
INT8S currPrio;
currPrio = (OSPrioCur-LWIP_START_PRIO);
if((currPrio < 0) || (currPrio >= LWIP_MAX_TASKS))
{
/* Error! */
printf("sys_arch_timeouts: Prio not found\n");
while(1);
}
return &timeoutlist[currPrio];
}
//-------------------------------------
OSPrioCur moves around as the scheduler switches tasks, and LWIP_START_PRIO
is #define'd as 7.
When tcp/ip init is called, this code runs for the first time, a thread is
created and then this function gets called. However, currPrio = -2 !!
Which always makes the IF statement true! - this is very bad!
***
1) What is the point of this function? (other than what it says in the
sys_arch.txt -> (a non programmers explanation would be great)
2) What is the logic / reason for calculating currPrio and why is it done
like that? Any idea why I could be falling into that IF statement everytime?
OsPrioCur = 5. so currPrio = 5-7 = -2 :(
***
As for a separate issue, I was wondering about the syntax where lwip
attempts to create a new thread for itself using the sys_arch.
In tcpip.c in tcpip_init there is a call to
sys_thread_new(tcpip_thread, NULL, TCPIP_THREAD_PRIO);
tcpip_thread seems to have an absolute address of 6a3b or something like
that which I believe is meant to be the address of the function
tcpip_thread() also found in tcpip.c
In sys_arch.c the sys_thread_new() function is defined as follows:
sys_thread_new(void (* function)(void *arg), void *arg)
However, after sys_thread_new() is called, the parameter function appears
NULL! And the OS uses this to create a new task when OSTaskCreate is called
(OS level function)
I cant tell if the OS actually made the task or not (yet) but it doesn't
crash which is what I would expect it to do if it actually tried to schedule
a task whos address was NULL.
So somewhere in the process from tcpip_init to sys_thread_new in sys_arch.c
I might be loosing the address of the tcpip_thread which needs to be
created. Not sure.
I did read something where based on the syntax shown, the function is
actually run first, then its return value is passed into the function being
called. - Im not sure about that either, so I put a break point in
tcpip_thread and it never did execute.
Sorry if this is a bit drawn out. Thank you for the help,
Have a great day,
--eric shufro
- [lwip-users] more questions... thanks in advance.,
Eric Shufro <=