Re: Compiler vs. machine issue
- From: "Brent S." <brentatatmosoftdotcom>
- Date: Fri, 2 Sep 2005 09:41:03 -0600
"Francesco Savastano" <francosavastano@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
wrote in message news:431869e7$1@xxxxxxxxxxxxxxxxxxxxxxxxx
> I had same kind of problem yesterday: I usually work on my laptop (Win XP
> home P4 3GHZ) and compile there my exe. Yesterday when i tried to run such
> exe on my home computer (same O.S. but Athlon 1.5 GHZ cpu) a thread that I
> use in the program didn't work correctly. I suspected something with cpu
as
> it is the only difference betwen computers. So I tried to compile the same
> program (with same compile settings) on my home computer and magically it
> worked. Now I definitely solved the problem changing some parameters in
the
> thread that make it faster or slower etc..
>
I would be very uncomfortable with this program. Timing issues should not
effect properly written multithreaded programs. Threads in multithreaded
programs will not lock up and will always work properly if access to objects
and memory are performed correctly. Various threads must not have access to
the same objects unless said objects are built to be used by multiple
threads, i.e. thread safe. Objects or memory which are not thread safe must
be guarded by critical sections. There are other Secondary threads must
never be allowed access to visual components, this is what synchronize is
for which, imho, shouldn't be touched. If the GUI must be updated when a
thread operation is complete then a message can be posted to the main thread
where the update can take place safely. Intra-thread communication is best
done using windows messages and perhaps message objects which hold data
associated with the message. The object is created in one thread, the
reference(pointer) to the object is passed in LParam or WParam, the
receiving thread typecasts the reference, and after use frees the object.
You can also use an objectlist, stack or queue to hold objects, and protect
all accesses to it with a critical section. If you must wait for a thread
to finish then you can use TThread.Waitfor. There are many methods and
objects you can use to help write thread safe programs beyond these. If
timing issues continue to prevent your code from doing what is intended,
then the code is not finished.
Brent S.
.
- Follow-Ups:
- Re: Compiler vs. machine issue
- From: Francesco Savastano
- Re: Compiler vs. machine issue
- References:
- Compiler vs. machine issue
- From: Hoby Smith
- Re: Compiler vs. machine issue
- From: Francesco Savastano
- Compiler vs. machine issue
- Prev by Date: Delphi 2005 Key Location
- Next by Date: Re: Well here's something I never thought I would see....
- Previous by thread: Re: Compiler vs. machine issue
- Next by thread: Re: Compiler vs. machine issue
- Index(es):
Relevant Pages
|
|