AMcTools Forum 
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
createThread (Read 7502 times)
szymek
YaBB Newbies
*
Offline

I Love YaBB 2!

Posts: 3

createThread
02/13/11 at 19:11:58
 
Hi All,

Does anyone used this function in component dll ? For me each time i use it VMLab crashes ... Maybe anyone know another way to spawn new thread ?

VMLab version: 3.15
Back to top
 
 
  IP Logged
moderator
YaBB Administrator
*****
Offline

I love forums, don't
you?

Posts: 308
AMcTools (Spain)
Gender: male
Re: createThread
Reply #1 - 02/13/11 at 19:51:19
 
Hi,

VMLAB uses some multi-thread in some points, but all this stuff is handled by the Borland VCL framework; so, there is no direct use of Win32 functions.

Sorry, I cannot give you to much help....
Back to top
 
 
WWW   IP Logged
ThVortex
Global Moderator
*****
Offline



Posts: 160
Austin, TX, USA
Gender: male
Re: createThread
Reply #2 - 02/14/11 at 02:47:21
 
Are you sure that your own code is not crashing in the newly created thread? VMLAB uses structured exception handlers to protect against crashes in components, but only for the defined call back functions. If you create a new thread, VMLAB doesn't know about it and can't protect itself from a crashing component.

For example, if you deference a bad pointer in the new thread then you'll crash the entire application instead of getting the usual friendly error in the Messages window. Have you tried attaching any debuggers to see what module (i.e. DLL) is crashing?
Back to top
 
 
WWW   IP Logged
szymek
YaBB Newbies
*
Offline

I Love YaBB 2!

Posts: 3

Re: createThread
Reply #3 - 02/14/11 at 07:41:09
 
I don't have much experience in Win32 Function but I think no, I have tried to just spawn thread which do nothing in empty extension juts like:

[code]
HANDLE iThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)&tp, 0, 0, &dwThreadId);
[/code]

But it still crashes, screenshot attached.

Generally idea is to serve incoming connections to namedpipe, which should be constantly checked, now I am trying with on_time_step/remind_me in order to do this. Anyway does anyone know of any other way of communication between extensions without using PINS ? (I am working on simulation of wireless devices...).

It has also come to my mind to use standard properties od dll's, namly declare some shared variables outside of VAR section but I fear  of parrarel access problems.
Back to top
 
  IP Logged
ThVortex
Global Moderator
*****
Offline



Posts: 160
Austin, TX, USA
Gender: male
Re: createThread
Reply #4 - 02/14/11 at 17:44:42
 
That looks like an internal assert in VMLAB failing and not the kind of crash I was thinking of. The moderator will have to check what the 75291 error means.
Back to top
 
 
WWW   IP Logged
moderator
YaBB Administrator
*****
Offline

I love forums, don't
you?

Posts: 308
AMcTools (Spain)
Gender: male
Re: createThread
Reply #5 - 02/16/11 at 14:19:02
 
Yes, this is an internal inconsistency.

I do recommend you NOT to use threads in the component development. The reason is this:

VMLAB uses a internal events queue in wich every event hast to be put in the right order at the right time.

A user-defined thread will corrupt this principle, since is Windows who decided when to give yield to the code and not VMLAB.  That's the reason of the crash.

For a continuous check of ports, detecting edges, etc, I recommend you to use the On_xxx( ) functions


Back to top
 
 
WWW   IP Logged
szymek
YaBB Newbies
*
Offline

I Love YaBB 2!

Posts: 3

Re: createThread
Reply #6 - 08/16/11 at 11:45:10
 
as for me I followed previouse advice and moved my code to on_xxx function instead of creating new thread for serving incoming messages.
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print