Only if commonfunc() is not reentrant (it depends on global or static state, or performs certain types of I/O).
For example, this function should be locked:
1 2 3 4
void f(){
staticint i=0;
return i++;
}
Some I/O is safe. For example, writing concurrently to different files is generally safe (if the OS supports threading, it almost certainly has a thread-safe file system); doing it to the same file is not, specially when appending content to the end, and doubly specially if you're writing to a single file object and jumping around in the file.