Re-entrancy

What’s the thread-safeness of the io_net_self_t functions?
Can I be originating a tx_down() packet in one thread while handling a
rx_up() packet (and likely forwarding it via tx_up()) in another thread?

Thanks,
Shaun

Shaun Jackman <sjackman@nospam.vortek.com> wrote:

What’s the thread-safeness of the io_net_self_t functions?
Can I be originating a tx_down() packet in one thread while handling a
rx_up() packet (and likely forwarding it via tx_up()) in another thread?

The calls themselves are thread-safe. However, you have to ensure that
your own code is thread safe. One rule (that may not be mentioned in even
the lastest ddk docs) is that you shouldn’t hold onto your local mutex(es)
when you make a call into io-net. For example, if you have fast-forwarding
enabled you could deadlock the process. Driver A holds onto mutex while
performing a tx_up() and Driver B holds onto mutex while it does a tx_up().
Both of these tx_up()'s turn into tx_down()‘s in the other drivers. So Driver
A’s thread would be waiting for Driver B to give up it’s mutex and Driver B’
s thread would be waiting for Driver A to give up it’s mutex. Deadlock.

chris


Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/

Chris McKillop <cdm@qnx.com> wrote:
: The calls themselves are thread-safe. However, you have to ensure that
: your own code is thread safe. One rule (that may not be mentioned in even
: the lastest ddk docs) is that you shouldn’t hold onto your local mutex(es)
: when you make a call into io-net. For example, if you have fast-forwarding
: enabled you could deadlock the process. Driver A holds onto mutex while
: performing a tx_up() and Driver B holds onto mutex while it does a tx_up().
: Both of these tx_up()'s turn into tx_down()‘s in the other drivers. So Driver
: A’s thread would be waiting for Driver B to give up it’s mutex and Driver B’
: s thread would be waiting for Driver A to give up it’s mutex. Deadlock.

I’ve added this to the list of things to do for the docs. Thanks.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems