lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] FreeRTOS/lwIP Win32 simulator project now hosted


From: Paul Archer
Subject: Re: [lwip-users] FreeRTOS/lwIP Win32 simulator project now hosted
Date: Tue, 26 Jul 2011 16:20:47 +1000

Hi Richard,

> Done - although I think it should be SYS_STATS_INC_USED( mbox ) /*
> without the .used on the mbox. */
You are corerct, it should have been just SYS_STATS_INC_USED( mbox )

> I could not see that there was a SYS_STATS_DEC_USED equivalent.
Also correct, just use the SYS_STATS_DEC as you have.

> I have attached my current file.  It has also been bent into the
> FreeRTOS coding style since I posed it up, as it is FreeRTOS specific file.
This file looks good. And does all that it needs to.

The only comment I have is due to my requirement for DNS lookups.
In my sys_arch.c file I needed to add a way to track tasks. This is due
to performing DNS lookups without needing to lock for each task.

There is a function
struct hostent *sys_thread_hostent(struct hostent *hostent)

My function that I have is
/**
 * Get the thread's hostent structure
 *
 * \param[in] hostent Copy the data from this into the threads hostent
 *
 * \return The threads hostent with the data copied from the argument
 */
struct hostent *
sys_thread_hostent(struct hostent *hostent)
{
    sys_tcb_t *current;

    syslog(LOG_DEBUG, "Got here: '%s'", inet_ntoa(hostent->h_addr));

    /* Find the current thread */
    if ((current = sys_arch_thread_current()) == NULL)
    {
        return NULL;
    }

    /* Check if we need to allocate the memory */
    if (current->hostent == NULL)
    {
        current->hostent = pvPortMalloc(sizeof(*current->hostent));
        if (current->hostent == NULL)
        {
            return NULL;
        }
    }

    /* Copy the data into the return result */
    memcpy(current->hostent, hostent, sizeof(*hostent));

    return current->hostent;
}

What is needed here is a way to get a per tasks hostent structure.
The way that I did this is sub-par, and is just an linked list of task
handles, which is searched when needed.
It works, but its not particularly quick or memory efficient.

If you can find a better solution and include that in the sys_arch
example I am sure that many people would like
thread safe DNS resolving out of the box.

> To demonstrate sockets use, the current plan is to add in a simple
> telnet "like" console (just single connection to keep it really simple),
> and command interpreter (to return the same information that is already
> being returned by the web server).  Then it will just be a case of
> adding in a sockets client side demo.
I think this is a perfect example and is exactly what most people would want.

-- 
----
Regards
Paul Archer
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]