Skip to content

Commit

Permalink
Merge pull request #77 from biralavor/76-fixing-think-routine-for-odd…
Browse files Browse the repository at this point in the history
…-total-philos

fixing thinking routine if total philos is odd
  • Loading branch information
biralavor authored Nov 3, 2024
2 parents e8208c7 + 7d32940 commit 7cc4a12
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions philo/src/12.dinner_routines.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: umeneses <umeneses@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/30 16:19:23 by umeneses #+# #+# */
/* Updated: 2024/11/03 12:58:42 by umeneses ### ########.fr */
/* Updated: 2024/11/03 15:17:01 by umeneses ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -75,11 +75,14 @@ void let_philo_think_routine(t_philo *philo)
{
long think_time;

think_time = philo->table->set.time_to_eat * 2 - philo->table->set.time_to_sleep;
think_time = 0;
if (philo->table->set.total_meals % 2 != 0)
think_time = philo->table->set.time_to_eat
* 2 - philo->table->set.time_to_sleep;
if (think_time < 0)
think_time = 0;
printer_with_mutex(THINKING, philo, DEBUG_MODE);
precise_usleep(think_time, philo->table);
// safe_mutex_handler(philo->philo_mtx, LOCK);
// safe_mutex_handler(philo->philo_mtx, UNLOCK);
}

void let_philo_sleep_routine(t_philo *philo)
Expand Down

0 comments on commit 7cc4a12

Please sign in to comment.