Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Multithreading question

Author: Michel Langeveld

Date: 23:43:43 09/08/03

Go up one level in this thread


On September 09, 2003 at 02:14:08, Tony Werten wrote:

>Hi,
>
>maybe a silly question, but one get quite desperate during debugging. Suppose I
>have the followin code:
>
>procedure whatever(param:integer)
>begin
>   do_something_heavy_with_param;
>end;
>
>Say, the heavy stuff takes about 10 seconds.
>
>If during these secs another thread is calling this function, what happens ?
>
>Does every thread gets a "local copy" of the function ?
>
>On a single processor, there is a context switch, stuff is pushed on a stack,
>and everything is safe.
>
>What about a dual ? I get the feeling that param is actually changed by the
>second call.
>
>Tony

The code is in the code segment and is the same for both threads.
The paramter resist on the stack. Each thread will use its own stack so this
will work.

If the do_something_heavy_with_param doesn't use globals, class members,
non-thread-safe functions or other shared memory then it should work ok in my
opinion.

Michel



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.