multithreaded madness

When rx_down() is called I add the packet to a linked list for later
transmission, and return TX_DOWN_OK. A different thread is then awoken by a
timer tick and calls tx_down() on the packet. Due to the multithreading,
occasionally the return of rx_down() precedes the tx_down() call, sometimes
it follows the tx_down() call. Are both these situations ok for io-net?

Threads
1 io-net thread
2 my filter thread (FIFO scheduling, priority=30)

[Scenario 1]
1 rx_down() adds downward packet to buffer
2 awaken by timer tick, extracts downward packet from buffer, and calls
tx_down()
2 waits on next timer tick
1 returns TX_DOWN_OK

[Scenario 2]
1 rx_down() adds downward packet to buffer
1 returns TX_DOWN_OK
2 awaken by timer tick, extracts downward packet from buffer, and calls
tx_down()
2 waits on next timer tick

Thanks,
Shaun

Don’t see anything wrong with this. You’ll need
a mutex to protect your linked list.

-seanb

Shaun Jackman <sjackman@nospam.vortek.com> wrote:
: When rx_down() is called I add the packet to a linked list for later
: transmission, and return TX_DOWN_OK. A different thread is then awoken by a
: timer tick and calls tx_down() on the packet. Due to the multithreading,
: occasionally the return of rx_down() precedes the tx_down() call, sometimes
: it follows the tx_down() call. Are both these situations ok for io-net?

: Threads
: 1 io-net thread
: 2 my filter thread (FIFO scheduling, priority=30)

: [Scenario 1]
: 1 rx_down() adds downward packet to buffer
: 2 awaken by timer tick, extracts downward packet from buffer, and calls
: tx_down()
: 2 waits on next timer tick
: 1 returns TX_DOWN_OK

: [Scenario 2]
: 1 rx_down() adds downward packet to buffer
: 1 returns TX_DOWN_OK
: 2 awaken by timer tick, extracts downward packet from buffer, and calls
: tx_down()
: 2 waits on next timer tick

: Thanks,
: Shaun