Re: Question about threads which share a function



"Joe" <Joe@xxxxxxxxxxxxxx> writes:

I have a function defined as void foo(int* pIn, int* pOut). The
function gets some data via pointer pIn and calculates some output
data which is written to the array pointed to by pOut. In the
calculation of the output, some local variables defined in foo are
used.

If I have two or more threads executing and these threads use foo, are
there any risks that something might go wrong; like the output being
screwed up and deviating from what is expected?

Most definitely. For example, if two concurrent calls to foo in
different threads have output arrays that overlap (or an input array
overlapping an output array).

You might find comp.programming.threads to be more suitable as your
design gets more detailed.

--
Ben.
.



Relevant Pages

  • Re: Serialization with XmlSerializer: how to set the XML root node to something different from <
    ... Methods can return instances of Foo. ... If your method returns an array, then the attributes that apply are those on ... You are asking specifically about xml serialization, ...
    (microsoft.public.dotnet.xml)
  • Re: undefine @array
    ... no strict "refs"; ... use vars qw/@foo/; ... the fact that *foo has been replaced with a glob which has no ARRAY ...
    (comp.lang.perl.misc)
  • Re: classes and __init__ question
    ... have a dog class. ... parameters) behind the scenes to create the class Foo itself, ... thinking of, for example, a game board array where each member of the ... ends up using too much memory *and* memory profiling shows the board ...
    (comp.lang.python)
  • Re: Static _Bool initialization
    ... The "&" operator will never yield a null pointer if its operand is ... If foo is an array of more than 42 elements, ... If the compiler (which can ...
    (comp.std.c)
  • Re: pointer usage in c
    ... > char *foo; ... I think my teacher wrong. ... Your array b is local to the function foo. ...
    (comp.lang.c)