lwip-members
[Top][All Lists]
Advanced

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

Re: [lwip-members] Seems Error to me!!


From: Kieran Mansley
Subject: Re: [lwip-members] Seems Error to me!!
Date: Thu, 26 Jun 2003 08:49:36 +0100 (BST)

On Wed, 25 Jun 2003, Jack Carlson wrote:

> Hi Kieran,
>       I think we are singing two different songs.

Yep!

> Look what my doubt
> is:- that no body is decrementing the count of last so after posting
> more than SYS_MBOX_SIZE no. of messages the task which is posting the
> message will block each time it wants to post a message(irrespective of
> whether the TCPIP thread has read all the messages). Plz see the
> following code and kindly check if it matches ur code:-

It does match, but I think you're wrong about the blocking.  See comments
below.

>
> void
> sys_mbox_post(struct sys_mbox *mbox, void *msg)
> {
>   u8_t first;
>
>   sys_sem_wait(mbox->mutex);
>
>   DEBUGF(SYS_DEBUG, ("sys_mbox_post: mbox %p msg %p\n", (void *)mbox, (void 
> *)msg));
>
>   while ((mbox->last + 1) >= (mbox->first + SYS_MBOX_SIZE)) {

This is the line that would cause it to block.  Even if you have posted
more than SYS_MBOX_SIZE messages it won't block if the TCPIP thread has
read all the messages.  This is because mbox->first will be equal to
mbox->last (if all the messages have been read, then the number of
messages posted and fetched is equal, so the variables are equal).  As a
result (mbox->last + 1) is < (mbox->first + SYS_MBOX_SIZE) and it doesn't
block.  Try putting some numbers in - if mbox->last and mbox->first are
the same the above inequality can never be true!  It doesn't matter what
value you give them.

If we ever decremented mbox->first (but we don't!) we would also need to
decrement mbox->last like you suggest.

The only time I can envisage a problem is if the variables wrapped (and
maybe we should code for this) causing mbox->last to be less than
mbox->first.

> In the while loop the message posting thread blocks each time after it
> exceeds the length. irrespective of if the TCPIP thread has already read
> the messages.(this is bcoz no one is decrementing the count). I really
> could understant the posting of message and fetching of the message. but
> this blocking seems a problem to me. Regards Jack

Are you actually seeing a problem when you run the code, or is it just
something you spotted while reading it through?  If you do have a
real problem, then maybe I am wrong.

Can anyone else on the lwip-members list think of a better way of
explaining this (or point out what I'm missing) - I'm not having much
success!

Thanks

Kieran





reply via email to

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