[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] more questions... thanks in advance.
From: |
Ed Sutter |
Subject: |
Re: [lwip-users] more questions... thanks in advance. |
Date: |
Wed, 17 Mar 2004 08:14:15 -0500 |
Eric,
Some thoughts embedded...
Ed
Eric Shufro wrote:
>
> 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 :(
>
I'm not sure what that logic is for. I've been using...
struct sys_timeouts *
sys_arch_timeouts(void)
{
return &timeoutlist[OSPrioCur];
}
So, either you can remove that logic and use the above function or
someone please tell me (also) what that logic is for.
>
> 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
This is very system-specific. The location of tcpip_thread() should
be irrelevant.
>
> 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)
Based on the call from tcpip_init() this makes sense. The second argument is
NULL.
The parameter lists don't match. I haven't downloaded the sys_arch.c recently;
so my version is likely to be hacked a bit. How is your version of
sys_thread_new()
using the "arg" argument? Is it possible that it is being used as the task
priority?
If that's the case, then OSTaskCreate may be failing.
Eric Shufro wrote:
>
> 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 mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/lwip-users