Function using in multi threaded environment

Nov 12, 2014 at 5:41am
Hi,

I have a doubt about function usage in multi threaded environment. Think, we have a small c file call "functiontest.c". This file contains a small function call "process".

1
2
3
4
5
6
7
8
9
10
11
12

// content of functiontest.c file

int process(int a,int b)
{
    int c = (a+b) * 2;

    c += 10;

    return c;
}


If we try to access this "process" function in multi threaded environment will it gives correct answers to each thread?? Can you please explain this?

Thank you.
Nov 12, 2014 at 10:10am
Yes it should be no problems here because no data is shared between the threads. Each call to process will have its own copy of a, b and c.
Last edited on Nov 12, 2014 at 10:11am
Nov 12, 2014 at 11:39am
Hi,

I understood. :)

Thank you
Topic archived. No new replies allowed.