Skip to content

Commit

Permalink
protecting think time of negative
Browse files Browse the repository at this point in the history
  • Loading branch information
biralavor committed Nov 3, 2024
1 parent aeac44a commit 7d32940
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion 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 15:11:52 by umeneses ### ########.fr */
/* Updated: 2024/11/03 15:17:01 by umeneses ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -79,6 +79,8 @@ void let_philo_think_routine(t_philo *philo)
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);
}
Expand Down

0 comments on commit 7d32940

Please sign in to comment.