Closed nwhean closed 1 year ago
It may be a good idea to define a fork data structure that contains just that. https://github.com/zklim/42-Philosophers/blob/a9987e94f711269cbdda5af41e2cb518326db07b/philo/philo.h#L47
Then define functions like fork_take and fork_release that deals with all these mutex. This is an abstraction that allows you to write your code in a much more readable fashion. So your eat function would call those instead.
fork_take
fork_release
eat
It may be a good idea to define a fork data structure that contains just that. https://github.com/zklim/42-Philosophers/blob/a9987e94f711269cbdda5af41e2cb518326db07b/philo/philo.h#L47
Then define functions like
fork_take
andfork_release
that deals with all these mutex. This is an abstraction that allows you to write your code in a much more readable fashion. So youreat
function would call those instead.