dining philosophers problem
philosopher with threads and mutex
arguments: number_of_philosophers time_to_die time_to_eat
time_to_sleep [number_of_times_each_philosopher_must_eat]
philosopher with processes and semaphore
arguments: number_of_philosophers time_to_die time_to_eat
time_to_sleep [number_of_times_each_philosopher_must_eat]
- pthread_mutex_lock(&N_mutex) ensures that exactly ONE thread is sucessful in locking the mutex variable N_mutex. This particular thread will then be the only thread that will update the variable N, thus ensuring that N is updated sequential (one thread after another)
- So Thread Serialization means to make sure that a certain set of events occurs in a sequence not at the same time (src)
- Reentrancy are Some functions designed to not use global variables, strtok (for tokenizing C character string, retains state between calls) is non reetrant function, Non-reentrant functions are dangerous for multithreaded programs (and also cause issues when called from recursive functions) (src)
- Atomic Operation an operation during which a processor can simultaneously read a location and write it in the same bus operation. This prevents any other processor or I/O device from writing or reading memory until the operation is complete.