← Volver
philo code
- Ensure the code of philo complies with the following requirements and ask for explanations.
- Check there is one thread per philosopher.
- Check there is only one fork per philosopher.
- Check if there is a mutex per fork and that it's used to check the fork value and/or change it.
- Check the outputs are never mixed up.
- Check how the death of a philosopher is verified and if there is a mutex to prevent philosopher from dying and starting eating at the same time.
philo testing
- Do not test with more than 200 philosophers.
- Do not test with time_to_die or time_to_eat or time_to_sleep set to values lower than 60ms.
- Test 1 800 200 200. The philosopher should not eat and should die.
- Test 4 410 200 200. No philosopher should die.
- Test 4 310 200 100. One philosopher should die.
- Test with 2 philosophers and check the different times: a death delayed by more than 10ms is unacceptable.
- Test with any values of your choice to verify all the requirements. Ensure the philosophers die at right time, that they don't steal forks, and so forth.
Invalid input tests
./philo -5 600 200 200
./philo 4 -5 200 200
./philo 4 600 -5 200
./philo 4 600 200 -5
./philo 4 600 200 200 -5
./philo 4a 600 200 200 5
./philo 4 600f 200 200 5
./philo 4 600 200dsd 200 5
./philo 4 600 200 200sfsd 5fs
./philo 4 999999999999999 200 200
./philo 4 abdallah 200 200 3
./philo 4 100 abdallah 200 3
./philo 4 100 800 abdallah 200 3
./philo 4 100 800 200 200 abdallah
./philo -5 600 200 200
./philo 4 -5 200 200
./philo 4 600 -5 200
./philo 4 600 200 -5
./philo 4 600 200 200 -5
./philo 4 999999999999999 200 200
./philo 4 abc 200 200 3
./philo 4 100 abc 200 3
./philo 4 100 800 abc 200 3
./philo 4 100 800 200 200 abc
./philo 4 100 800 200 200 2
./philo 4 300 100 100 abdallah
./philo 9 400 100 100 ""
./philo 9 400 100 "" 5
./philo 9 400 "" 100 5
./philo 9 "" 100 100 5
./philo 18446744073709551626 800 200 200 5
./philo 9 18446744073709552016 100 100 5
./philo 9 400 100 18446744073709551726 5
./philo 9 400 18446744073709551726 100 5
tests where program should end with death or enough eaten
./philo 200 122 60 60 # a philo should die
./philo 4 310 200 100 # a philo should die
./philo 4 200 205 200 # a philo should die
./philo 4 600 400 400 # a philo should die
./philo 5 600 400 400 # a philo should die
./philo 5 800 600 100 # a philo should die
./philo 100 400 300 60 # a philo should die
./philo 3 500 400 60 # a philo should die
./philo 5 800 400 300 2 # a philo should die
./philo 2 600 500 200 # a philo should die
./philo 1 800 200 200 # a philo should die
Testing limited meals input
./philo 4 130 60 60 3 # 12
./philo 4 150 70 70 3 # 12
./philo 4 170 80 80 3 # 12
./philo 4 210 100 100 3 # 12
./philo 4 220 110 100 3 # 12
./philo 4 310 150 150 3 # 12
./philo 5 800 200 200 7 # 35
./philo 4 410 200 200 10 # 40
./philo 5 800 200 200 3 # 15
./philo 4 400 150 150 2 # 8
./philo 10 600 300 100 1 # 10
./philo 6 1000 300 500 2 # 12
Tests where a philosopher should NOT die
./philo 5 800 200 200
./philo 5 600 150 150
./philo 4 410 200 200
./philo 4 408 200 200
./philo 4 406 200 200
./philo 4 405 200 200
./philo 100 410 200 200
./philo 200 410 200 200
./philo 4 130 60 60
./philo 100 130 60 60
./philo 200 130 60 60
./philo 100 800 200 200