24 lines
1.0 KiB
Plaintext
24 lines
1.0 KiB
Plaintext
Assignment name: race_detector
|
|
Expected files: race_detector.c
|
|
Allowed functions: memset, printf, malloc, free, write, pthread_create, pthread_detach,
|
|
pthread_join, pthread_mutex_init, pthread_mutex_destroy,
|
|
pthread_mutex_lock, pthread_mutex_unlock, usleep, gettimeofday
|
|
----------------------------------------------------------------------------------------
|
|
|
|
Create a version of the philosophers problem that:
|
|
1. Detects and reports possible data races
|
|
2. Tests different optimization strategies:
|
|
- Strategy A: global mutex for all operations
|
|
- Strategy B: mutex per fork + mutex for printing
|
|
- Strategy C: minimize lock time
|
|
|
|
Include stress test: run 100 iterations with different configurations and report:
|
|
- Number of data races detected
|
|
- Performance (total time)
|
|
- Number of deaths
|
|
|
|
Usage: `./race_detector 4 410 200 200`
|
|
|
|
Hint: Use tools like `valgrind --tool=helgrind` to detect data races.
|
|
In the real project, any data race results in a grade of 0.
|
|
Test with odd and even numbers of philosophers, and with time_to_die very close to time_to_eat. |