Socket calls from timer functions (server based)
paulw at omnitronics.com.au
Wed Apr 13 02:58:17 UTC 2005
Ian Caddy wrote:
> Hi Gene,
> As far as I am aware, the TSRs run in the context of the timer interrupt
> service routine, which means you can only perform operations that are
> safe in interrupts.
> Network functions are generally not safe to call from interrupts, as
> most network functions are blocking functions.
> You will probably need to find another way to implement this, such as
> sending an event or message to a thread that can perform the setsockopt.
From the OP's email he is using server based timers
(not present in rtems 4.5).
In this case the timers run in the context of the timer server task.
As noted in OP: In the time server Thread dispatching is
The previous advice is probably still the best idea, don't
call network functions from the context of a TSR. Generate
an event or message and call the network function from a
My reasoning for this is:
TSR's are still "special" functions, they are run
at the highest task priority and should be very "quick"
and never block.
All timers are processed from the one loop and delays as a result of
processing on TSR will effect all the other timers.
Any function with the possibility of blocking should not
be called from a TSR. Network calls can block (even
setting socket options as they need to access mutex's) so
therefore should not be called from a TSR.
Hope that make sense.
More information about the users