A favour... need some code running on Linux!

Everything else that doesn't fall into one of the other PB categories.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

A favour... need some code running on Linux!

Post by srod »

On Windows, if you create a thread (call it thread1), and thread1 creates another thread (thread2), then killing thread1 leaves thread2 still running. Must admit that I expected them both to die but now realise that the observed behaviour makes sense.

I just need to be absolutely sure that Linux behaves in an identical fashion in this regard? I am pretty sure it will do, but would be grateful if someone could run the following on Linux for me just to be absolutely 100% certain! :)

Set the threadsafe switch, let the program run for a moment or two just to be sure that both threads are running. Then close the messagerequester to have the first thread killed. Hopefully, thread2 will continue on its merry way!

Code: Select all

Global gCount

Procedure AlertThread(Parameter)
  gCount + 1
  a = gCount
  If a =1 
    CreateThread(@AlertThread(), 154)
  EndIf
  Repeat
    Debug "Thread " + Str(a)
    Delay(1000)
  ForEver
EndProcedure

thdID = CreateThread(@AlertThread(), 154)

MessageRequester("", "Click to destroy the first thread!", 0) 

KillThread(thdID)

MessageRequester("", "Click to end.", 0) 
Thank you.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: A favour... need some code running on Linux!

Post by ts-soft »

On Linux error on line 19, thread doesn't exist.

Ubuntu 9.04, x64
PB 4.40 beta 5

Greetings
Thomas
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: A favour... need some code running on Linux!

Post by srod »

Really; that must go down as a bug!

Do the two threads run okay before you close the first requester?
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: A favour... need some code running on Linux!

Post by ts-soft »

srod wrote:Do the two threads run okay before you close the first requester?
Yes
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: A favour... need some code running on Linux!

Post by srod »

Strange.

I'd better point Fred towards this then.

Thanks Thomas.

**EDIT : could you alter the code Thomas and prevent the second thread from running. Does KillThread() work okay this time?
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: A favour... need some code running on Linux!

Post by srod »

REMOVED.
Last edited by srod on Wed Oct 21, 2009 4:01 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
freak
PureBasic Team
PureBasic Team
Posts: 5962
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: A favour... need some code running on Linux!

Post by freak »

Its a Linux x64 only issue. It works the same as on Windows on Linux x86. I will have a look.
quidquid Latine dictum sit altum videtur
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: A favour... need some code running on Linux!

Post by srod »

Thanks Freak. :)
I may look like a mule, but I'm not a complete ass.
freak
PureBasic Team
PureBasic Team
Posts: 5962
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: A favour... need some code running on Linux!

Post by freak »

The x64 problem is fixed.

Your code should behave the same on all OS.
quidquid Latine dictum sit altum videtur
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: A favour... need some code running on Linux!

Post by ts-soft »

I'm to slow :mrgreen:
srod wrote: **EDIT : could you alter the code Thomas and prevent the second thread from running. Does KillThread() work okay this time?
Same Problem!

On Ubuntu 9.10 beta x86 it works fine.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: A favour... need some code running on Linux!

Post by srod »

freak wrote:The x64 problem is fixed.

Your code should behave the same on all OS.
Great. 8)

Thanks.
I may look like a mule, but I'm not a complete ass.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: A favour... need some code running on Linux!

Post by DoubleDutch »

SRod: Why Linux? Are you getting your libs to have Linux versions?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: A favour... need some code running on Linux!

Post by srod »

DoubleDutch wrote:SRod: Why Linux? Are you getting your libs to have Linux versions?
No.

Just the tool I am currently working on needs to be fully crossplatform.
I may look like a mule, but I'm not a complete ass.
Post Reply