[etherlab-users] schedule_timeout() code issue

Florian Pose fp at igh-essen.com
Wed Apr 1 17:50:17 CEST 2009


On Mon, Mar 30, 2009 at 09:57:44AM +0200, Andre Puschmann wrote:
> Hi list,

Hi Andre,

> I got a question regarding the schedule_timeout(1) functionality used in 
> master.c in ec_master_idle_thread() and ec_master_operation_thread().
> The code calls schedule_timeout(1) which I interpret as "wait for a 
> message but not longer then 10ms (assuming HZ==100) or 1ms (assuming 
> HZ==1000)".
> I am new to EtherCAT and I am not sure about the desired functionality. 
> Is it "wait for a very small amount of time" (which explains the 1) or 
> is it wait for 10ms or 1ms?
> I think in either way, defining the timeout with respect to HZ should be 
> the better idea.
> On the other hand, if HZ is set to 1000, one jiffie is relatively short. 
> I am afraid if it's worth the extra costs of scheduling (i.e. context 
> switches). In this case, calling a delay function without scheduling 
> might be the better solution.
> What do you think? Maybe I am completely wrong ..

It is meant to be "Wait for frame reception, but don't be too busy...". ;-)

The round-trip-time of a frame is typically about 15 us. That would be
not worth scheduling. But as you can see the schedule_timeout(1) is
only used, if there is nothing to do for the state machine.

In the other case (the state machine has a certain job to do, and this
shall be done as fast as possible), only the schedule() function is
used, to signal the scheduler, that the process is ready to run, but
other processes with the same priority should be scheduled while waiting
for the frame.

I don't think this is the perfect solution. Does someone have a better
idea?

-- 
Best regards,
Florian Pose

http://etherlab.org



More information about the Etherlab-users mailing list