Logtalk 2.29.2 files.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1773 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura
2007-01-10 12:46:10 +00:00
parent c837589385
commit e75e406f84
232 changed files with 629 additions and 731 deletions

View File

@@ -1,13 +1,15 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================
This folder contains some examples of multi-threading programming.
Multi-threading programming is only supported on some Prolog compilers.
Currently this includes SWI-Prolog and YAP. Moreover, multi-threading
may be turned off by default. In order to run the examples, you may need
to first turn on multi-threading support on the Prolog config files.
Currently this includes SWI-Prolog and YAP (make sure that you use the
multi-threading versions of these Prolog compilers!). Moreover,
multi-threading may be turned off by default. In order to run the
examples, you may need to first turn on multi-threading support on the
Prolog config files.

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -2,9 +2,9 @@
:- category(chopstick).
:- info([
version is 1.1,
version is 1.2,
author is 'Paulo Moura',
date is 2006/12/2,
date is 2006/12/31,
comment is 'Dining philosophers problem: chopstick representation.']).
:- public(pick_up/0).
@@ -91,9 +91,9 @@
:- category(philosopher).
:- info([
version is 1.0,
version is 1.1,
author is 'Paulo Moura',
date is 2006/12/2,
date is 2007/1/3,
comment is 'Dining philosophers problem: philosopher representation.']).
:- public(left_chopstick/1).
@@ -121,12 +121,7 @@
comment is 'Writes all the terms on a list as an atomic operation.',
argnames is ['Atoms']]).
:- private(random/2).
:- synchronized(random/2).
:- mode(random(+integer, -integer), one).
:- info(random/2, [
comment is 'Ensures synchronized access to the random number generator.',
argnames is ['Limit', 'Random']]).
:- uses(random, [random/3]).
run(0, _) :-
this(Philosopher),
@@ -142,32 +137,27 @@
think(MaxTime):-
this(Philosopher),
random(MaxTime, ThinkTime),
random(1, MaxTime, ThinkTime),
message(['Philosopher ', Philosopher, ' thinking for ', ThinkTime, ' seconds.']),
sleep(ThinkTime).
thread_sleep(ThinkTime).
% deadlock while a philosopher is trying to eat is prevented by putting
% down the first chopstick when picking up the second one fails:
eat(MaxTime):-
this(Philosopher),
random(MaxTime, EatTime),
random(1, MaxTime, EatTime),
::left_chopstick(LeftStick),
::right_chopstick(RightStick),
LeftStick::pick_up,
( RightStick::pick_up ->
message(['Philosopher ', Philosopher, ' eating for ', EatTime, ' seconds with chopsticks ', LeftStick, ' and ', RightStick, '.']),
sleep(EatTime),
thread_sleep(EatTime),
::LeftStick::put_down,
::RightStick::put_down
; ::LeftStick::put_down,
fail
).
% as the "random" library object is not multi-threading aware, we must use a
% synchronized wrap up predicate (random/2) to call the random number generator:
random(Limit, Value) :-
random::random(1, Limit, Value).
% writing a message needs to be synchronized as it's accomplished
% using a combination of individual write/1 (and nl/0) calls:
message([]) :-

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,8 +1,8 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.1
Release 2.29.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================