[RPL/2] [Patch] Re: still a bug in multitasking
BERTRAND Joël
joel.bertrand at systella.fr
Lun 16 Juil 21:13:12 CEST 2007
BERTRAND Joël wrote:
> BERTRAND Joël wrote:
>> DEMAINE Benoit-Pierre wrote:
>>> Playing with an old example attached:
>>>
>>> dhp at moon_gen_2:~/documents/programmation/rpl$ rpl -scd example_smp.rpl
>>> +++RPL/2 version 4.00pre8w (Tuesday 07/10/07, 23:57:24 CEST)
>>> +++Copyright (C) 1989 to 2006, 2007 BERTRAND Jol
>>> 99 bottles of beer on the wall,
>>> 99 bottles of beer.
>>> Take one down, pass it around,
>>> 98 bottles of beer on the wall.
>>>
>>> [...]
>>>
>>> 34 bottles of beer on the wall,
>>> 34 bottles of beer.
>>> Take one down, pass it around,
>>> 33 bottles of beer on the wall.
>>>
>>> +++System : Process error
>>>
>>> +++Information : Writing rpl-core file
>>> +++Information : Done
>>>
>>> It may fail and stop at various places: 99, 33, 34, 34, 29, 47, 41 ...
>> Thanks for report. Strange, I never saw this bug before, but I can
>> reproduce it. I think that this bug comes from the new futex management
>> in kernel. I will investigate.
>
> I have found this bug, due to the new implementation of POSIX threads.
> I think this bug didn't occur with old pthreads libs. Child process ends
> before it has flushed its pipes to return value to its father.
Fixed. Please replace src/gestion_processus.c by attached file and test
with :
#!/usr/local/bin/rpl -sc
BOTTLES
<<
// Child process is started.
100 'RECURSIVE' detach
-> PROC
<<
do
// Parent waits for datas sent by child.
do PROC recv until end
-> OBJ
<<
OBJ
list-> drop dup " on the wall," +
disp "." +
disp "Take one down, pass it around," disp
if dup 1 same not then
OBJ list-> drop
else
1 "No more bottles of beer"
end
" on the wall." + disp drop "" disp
>>
until
1 same
end
// Parent waits for Child's death.
PROC wfproc
>>
>>
RECURSIVE
<<
while
dup
repeat
1 - dup dup ->str
if over 1 > then " bottles " else " bottle " end +
"of beer" + 2 ->list
// Child send datas to parent process.
send
// Recursive function is caught.
RECURSIVE
end
>>
JKB
-------------- section suivante --------------
Une pièce jointe non texte a été nettoyée...
Nom: gestion_processus.c
Type: text/x-csrc
Taille: 34269 octets
Desc: non disponible
Url: http://www.systella.fr/pipermail/rpl2/attachments/20070716/170f858d/attachment-0001.c
Plus d'informations sur la liste de diffusion RPL2