[En-Nut-Discussion] Multithreading

Ole Reinhardt ole.reinhardt at embedded-it.de
Mon Mar 29 18:07:50 CEST 2010


Hello,

> I would like to know what happen in a multithread program executing
> the same routins. What happen if in the middle of the execution of the
> routing another thread get the CPU and strar executing the same

Sorry, I don't understand your ascii drawings, but in your example you
won't run into problems. In your example every thread creates it's own
socket file descriptor. The stdio functions are thread safe.

You might also want to read http://www.ethernut.de/pdf/entet100.pdf

In case you want to access the same ressources (like a filedescriptor)
from different threads you need to use a lock to make shure not to
interleave the ressource access.

Regards,

Ole Reinhardt

-- 

Thermotemp GmbH, Embedded-IT

Embedded Hard-/ Software and Open Source Development, 
Integration and Consulting

http://www.embedded-it.de

Geschäftsstelle Siegen - Steinstraße 67 - D-57072 Siegen - 
tel +49 (0)271 5513597, +49 (0)271-73681 - fax +49 (0)271 736 97

Hauptsitz - Hademarscher Weg 7 - 13503 Berlin
Tel +49 (0)30 4315205 - Fax +49 (0)30 43665002
Geschäftsführer: Jörg Friedrichs, Ole Reinhardt
Handelsregister Berlin Charlottenburg HRB 45978 UstID DE 156329280 




More information about the En-Nut-Discussion mailing list