[Python-bugs-list] [Bug #122986] threading not ok with GNU pth - bis

noreply@sourceforge.net noreply@sourceforge.net
Tue, 21 Nov 2000 10:34:50 -0800


Bug #122986, was updated on 2000-Nov-20 09:12
Here is a current snapshot of the bug.

Project: Python
Category: Modules
Status: Closed
Resolution: Invalid
Bug Group: Not a Bug
Priority: 5
Summary: threading not ok with GNU pth - bis

Details: this program is buggy with GNU pth ...

------
#!/usr/bin/env python

from threading import *


def impr():
..d = 0
..while 1:
....d += 1
....print '|',
....if d % 12 == 0:
......e.set()
......f.clear()
......f.wait()


if __name__ == '__main__':
..T1 = Thread(None, impr, '1')
..e = Event()
..f = Event()
..T1.start()

..c = 0
..while 1:
....c += 1
....print '.',
....if c % 10 == 0 :
......f.set()
......e.clear()
......e.wait()

------

the program gives only :
. . . . . . . . . . | | | | | | | | | | | | . . . . . . . . . 

instead of a eternal serie of 10 dots followed by 12 pipes...

i use pth because i'm on hppa1.1-hp-hpux10.20 and there's no
standard thread mecanism

Follow-Ups:

Date: 2000-Nov-21 09:25
By: Nobody

Comment:
i tried the same code on sparc-sun-solaris2.5.1 without pth
and i got more lines but still the (rather silly) program hangs!
-------------------------------------------------------

Date: 2000-Nov-21 10:34
By: tim_one

Comment:
Changed to Invalid and Not-a-Bug, and Closed.

Deadlock is an expected behavior of this test case.  For example, the main thread (M) can have c%10==0 and the spawned thread (S) d%12==0 "at the same time".  Then this sequence is possible:

M executes f.set(), then loses its timeslice.
S executes e.set() and f.clear() and f.wait().
# Now S is hung, waiting for f to get set again.
M executes e.clear() and e.wait().
# Now M is also hung, waiting for e to get set again.

Deadlock.
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=122986&group_id=5470