This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/examples/threads/philosophers/SCRIPT.txt
pmoura b697f3d34e Logtalk 2.29.3 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1781 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2007-01-24 11:01:56 +00:00

115 lines
4.6 KiB
Plaintext

=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.3
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================
% start by loading the necessary library support files:
| ?- logtalk_load(library(random_loader)).
...
% now you are ready for loading the example:
| ?- logtalk_load(philosophers(loader)).
...
% five meals for each philosopher, each one spending a maximum of five seconds of continuous thinking or eating:
| ?- threaded_ignore(p1::run(5, 5)), threaded_ignore(p2::run(5, 5)), threaded_ignore(p3::run(5, 5)), threaded_ignore(p4::run(5, 5)), threaded_ignore(p5::run(5, 5)).
Yes
Philosopher p3 thinking for 1 seconds.
Philosopher p1 thinking for 2 seconds.
Philosopher p2 thinking for 3 seconds.
Philosopher p4 thinking for 4 seconds.
Philosopher p5 thinking for 3 seconds.
Philosopher p3 eating for 2 seconds with chopsticks cs3 and cs2.
Philosopher p1 eating for 3 seconds with chopsticks cs5 and cs1.
Philosopher p2 thinking for 3 seconds.
Philosopher p3 thinking for 2 seconds.
Philosopher p5 thinking for 1 seconds.
Philosopher p4 eating for 1 seconds with chopsticks cs4 and cs3.
Philosopher p5 thinking for 1 seconds.
Philosopher p1 thinking for 3 seconds.
Philosopher p4 thinking for 1 seconds.
Philosopher p3 eating for 2 seconds with chopsticks cs3 and cs2.
Philosopher p5 eating for 2 seconds with chopsticks cs5 and cs4.
Philosopher p2 thinking for 3 seconds.
Philosopher p4 thinking for 2 seconds.
Philosopher p3 thinking for 2 seconds.
Philosopher p5 thinking for 1 seconds.
Philosopher p1 eating for 3 seconds with chopsticks cs5 and cs1.
Philosopher p4 eating for 4 seconds with chopsticks cs4 and cs3.
Philosopher p5 thinking for 1 seconds.
Philosopher p2 thinking for 1 seconds.
Philosopher p3 thinking for 4 seconds.
Philosopher p5 thinking for 2 seconds.
Philosopher p2 thinking for 4 seconds.
Philosopher p1 thinking for 1 seconds.
Philosopher p5 thinking for 1 seconds.
Philosopher p4 thinking for 4 seconds.
Philosopher p1 eating for 1 seconds with chopsticks cs5 and cs1.
Philosopher p5 thinking for 3 seconds.
Philosopher p3 eating for 2 seconds with chopsticks cs3 and cs2.
Philosopher p1 thinking for 3 seconds.
Philosopher p2 thinking for 4 seconds.
Philosopher p3 thinking for 3 seconds.
Philosopher p5 eating for 4 seconds with chopsticks cs5 and cs4.
Philosopher p4 thinking for 3 seconds.
Philosopher p1 thinking for 4 seconds.
Philosopher p2 eating for 1 seconds with chopsticks cs1 and cs2.
Philosopher p3 thinking for 3 seconds.
Philosopher p4 thinking for 3 seconds.
Philosopher p2 thinking for 1 seconds.
Philosopher p5 thinking for 2 seconds.
Philosopher p2 eating for 3 seconds with chopsticks cs1 and cs2.
Philosopher p1 thinking for 4 seconds.
Philosopher p3 thinking for 3 seconds.
Philosopher p5 eating for 2 seconds with chopsticks cs5 and cs4.
Philosopher p4 thinking for 1 seconds.
Philosopher p4 thinking for 4 seconds.
Philosopher p2 thinking for 1 seconds.
Philosopher p5 thinking for 4 seconds.
Philosopher p1 eating for 4 seconds with chopsticks cs5 and cs1.
Philosopher p2 thinking for 2 seconds.
Philosopher p3 eating for 2 seconds with chopsticks cs3 and cs2.
Philosopher p2 thinking for 3 seconds.
Philosopher p3 thinking for 1 seconds.
Philosopher p4 eating for 1 seconds with chopsticks cs4 and cs3.
Philosopher p5 thinking for 1 seconds.
Philosopher p3 thinking for 4 seconds.
Philosopher p4 thinking for 4 seconds.
Philosopher p1 thinking for 2 seconds.
Philosopher p5 eating for 2 seconds with chopsticks cs5 and cs4.
Philosopher p2 eating for 2 seconds with chopsticks cs1 and cs2.
Philosopher p1 thinking for 3 seconds.
Philosopher p5 thinking for 4 seconds.
Philosopher p2 thinking for 2 seconds.
Philosopher p3 eating for 4 seconds with chopsticks cs3 and cs2.
Philosopher p4 thinking for 2 seconds.
Philosopher p1 eating for 3 seconds with chopsticks cs5 and cs1.
Philosopher p2 thinking for 1 seconds.
Philosopher p4 thinking for 3 seconds.
Philosopher p2 thinking for 1 seconds.
Philosopher p5 thinking for 3 seconds.
p3 terminated.
Philosopher p2 thinking for 3 seconds.
p1 terminated.
Philosopher p4 eating for 3 seconds with chopsticks cs4 and cs3.
Philosopher p5 thinking for 4 seconds.
Philosopher p2 eating for 4 seconds with chopsticks cs1 and cs2.
Philosopher p4 thinking for 4 seconds.
Philosopher p5 eating for 1 seconds with chopsticks cs5 and cs4.
Philosopher p2 thinking for 1 seconds.
p5 terminated.
Philosopher p2 eating for 4 seconds with chopsticks cs1 and cs2.
Philosopher p4 eating for 3 seconds with chopsticks cs4 and cs3.
p4 terminated.
p2 terminated.