[Simh] race conditions in ethernet code?

Peter Lund firefly at vax64.dk
Thu Aug 30 14:50:07 EDT 2007


Is it me or are there race conditions and just in general bad threading
code in sim_ether.c?

sim_ether uses libpcap to read and write raw ethernet packets.  If
USE_READER_THREAD is defined, it uses the pthread interface to run an
extra thread that receives packets from libpcap, presumably to avoid the
risk of losing them if the simulator blocks for too long.

sim_ether has some queue routines, which all have names beginning with
'ethq_'.  These routines do not do any locking.

There is apparently a queue per opened ethernet device, which has a
pthread mutex in it.  The reader thread and the function eth_read() lock
the mutex around ethq_ calls but they are the only ones to do so.

-Peter, rather confused by this code





More information about the Simh mailing list