003 Linux System ProgrammingIssues, queries and suggestions related to Linux, Linux Programming, IPC, Interprocess Communication, Synchronization, Semaphore, System Programming, Linux Software Development.
Thread synchronization is another half of a project related to linux IPC systems. I feel this is something driven by art. Very detailed touch is required to synchronize data using sempahores & mutex as gatekeepers for critical section code.
in semaphore II arg in sem_init is 0 for intra process while 1 for inter process.
in mutex we need to initialise the mutex along with its attribute. The mutex along with its attribute needs to be either of pthread_process_private or pthread_process_shared. By default it is pthread_process_private.
semaphores & mutexes need to initialised, used & destroyed in a sequential flow.
sem_init, sem_wait n sem_post, sem_destroy.
mutex_init, pthread_mutex_lock n pthread_mutex_unlock, mutex_destroy.
when used these need not remain & be destroyed because the values retained during process must be freed from kernel until the kernel is restarted.