Hello,
i'm here again, i can confirm that the following code do not work well in my 
environment.

PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s) );

but looking at the assembly code, as suggested by Till, we can see that both 
expressions are evalueted before the jump, so it's not clear why it doesn't work

   217:     PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s) ); 
C:0x4B20    900002   MOV      DPTR,#0x0002
C:0x4B23    E4       CLR      A
C:0x4B24    75F0D9   MOV      B(0xF0),#0xD9
C:0x4B27    122DAA   LCALL    C?ISTOPTR(C:2DAA)
C:0x4B2A    90D635   MOV      DPTR,#psock_send?BYTE(0xD635)
C:0x4B2D    122DE3   LCALL    C?PLDXDATA(C:2DE3)
C:0x4B30    12543C   LCALL    send_data(C:543C)
C:0x4B33    AC07     MOV      R4,0x07
C:0x4B35    90D635   MOV      DPTR,#psock_send?BYTE(0xD635)
C:0x4B38    122DE3   LCALL    C?PLDXDATA(C:2DE3)
C:0x4B3B    12539E   LCALL    data_acked(C:539E)
C:0x4B3E    EF       MOV      A,R7
C:0x4B3F    5C       ANL      A,R4
C:0x4B40    70D7     JNZ      C:4B19
C:0x4B42    FF       MOV      R7,A

 
Anyway, by putting the two functions in one and having them explicitally 
evalueted, and returning the combined result, it works fine.
Simone



----- Original Message ----- 
From: "Olaf Hartmann" <[EMAIL PROTECTED]>
To: <uip-users@sics.se>
Sent: Monday, March 05, 2007 11:04 AM
Subject: Re: [uip-users] Webserver problem


> Quoting Simone <[EMAIL PROTECTED]>:
> 
>> Thanks a lot Peter!!
>> The buffer size seems to be one of the problems!! But the first one 
>> i've figured out is this one: the & operator used in the psock.c 
>> don't work as written in the comments below! There are at least a 
>> couple of points in the code which are affected by this, maybe it's 
>> due to the compiler and/or compiler optimizations i've used (it's the 
>> keil c51).
>>
>> THE ORIGINAL CODE:
>>
>>    /*
>>     * The condition for this PT_WAIT_UNTIL is a little tricky: the
>>     * protothread will wait here until all data has been acknowledged
>>     * (data_acked() returns true) and until all data has been sent
>>     * (send_data() returns true). The two functions data_acked() and
>>     * send_data() must be called in succession to ensure that all
>>     * data is sent. Therefore the & operator is used instead of the
>>     * && operator, which would cause only the data_acked() function
>>     * to be called when it returns false.
>>     */
>>
>>    PT_WAIT_UNTIL(&s->psockpt,  data_acked(s) & send_data(s));
>>
>>
>> It seems that with my setup the evaluation of the expression 
>> data_acked(s) & send_data(s) depends on the order of the operands and 
>> it do not work in any case, so i've adjusted the code in this way, 
>> using a temp variable to store the results and have both function 
>> evaluated:
>>
>> THE CODE MODIFIED BY ME
>>
>> temp = 1;
>> temp &= data_acked(s);
>> temp &= send_data(s);
>>    PT_WAIT_UNTIL(&s->psockpt,  temp );
> 
> Uhm. This patch is no good. =)
> 
> The macro PT_WAIT_UNTIL implements a blocking wait for protothreads and 
> gets translated to:
>  temp = 1;
>  temp &= data_acked(s);
>  temp &= send_data(s);
>  do {
>    LC_SET((&s->psockpt)->lc);
>    if(!(temp)) {
>      return PT_WAITING;
>    }
>  } while(0)
> where LC_SET basically is a label that will be jumped to from the 
> beginning of the function. So temp will not be evaluated every time as 
> it should. If your variable temp isn't static or global it's contents 
> is even random...
> 
> But i agree that this data_acked() & send_data() code is very ugly and 
> even seems to fail for you. I suggest that data_acked() and send_data() 
> should be put into one function, which makes to code much more readable.
> 
> btw: additionally psock_generator_send() has the problem, that it 
> cannot retransmit packets, since the PT_WAIT_UNTIL() macro waits for an 
> ack, but the retransmit is done in a loop around PT_WAIT_UNTIL.
> 
> Greets
> Olaf
> 

Reply via email to