On Tue, 13 Jan 2004 22:58:06 +0200 Suleyman O Turkyilmaz <turkyilma1@itu.edu.tr> wrote: > 1) what are the hints for reentrant code ? > tips or rules to follow In sum, never use global or static variables inside your functions. Never call non-reentrant functions inside your function. If you absolutely need a global variable lock it with a mutex. Never return a pointer to static data. The best way is to make the caller provides the storage for the data you need to return. But you have to modify the interface to your non-reentrant functions. You can also dinamically allocate storage inside your function and the return a pointer to it, but this way the caller has the responsibility to free it, so it may lead to memory leaks if not handled correctly. > 2) what is realy thread safeness ? Thread safety means that a function or a piece of data, even if accessed (used) by multiple threads concurrently, keeps its state consistent. In sum, it works properly ;) > and how can i be sure that a fonction is thread safe ? It must be reentrant. Data which needs to be accessed concurrently should be locked, using mutexes or semaphores or whatever lock technique you have handy. bye Daniele ____________________________________ Email by www.box.it -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/