Using Pthreads: Synchronization with pthread_join() Explained

The post discusses the advantages of using threads over separate processes, specifically in data sharing and communication. It highlights a scenario where a song title in a word processor can easily be accessed by a music player when both run as threads within the same process. The introduction of the pthread library is significant for managing threads in C. It demonstrates the use of pthread_create() to create threads and emphasizes the importance of pthread_join() to ensure proper synchronization, thereby preventing premature termination of threads. The post concludes by mentioning upcoming discussions on synchronization challenges like race conditions.

Difference between re-entrancy and thread-safety

Thread-safety of a function refers to the fact whether a function can be safely called from multiple threads simultaneously. Safety here means that even if multiple threads are executing the function simultaneously the data integrity is intact and is not intermingled. 

What is memory leak in a C program?

Memory leak is a phenomenon where a running C/C++ program or a running process or thread dynamically allocates memory block from the heap but fails to free the memory block when it no more requires the memory. This happens due to programmatic error where the handle to the allocated memory block gets lost. Over a time if the same programmatic entity (a process, or a thread or a function) comes into action repeatedly and leaks memory, all the free memory of the systems goes away and eventually the systems throws the dreaded "Out Of Memory" and crumbles down.