J
john smith
If I create an object and pass it by reference to two other functions, and
the other two function have separate threads
must I worry about threadsafety? The two functions could modify the myCar
object in main at the same time couldn't they?
I have trouble understading if this is a problem or not. both functions
reference the myCar object in main and could potentially create a critical
section
path correct?
Thanks.
For example
int main()
{
Car myCar;
fixCar( myCar ); // fixCar() is a process running on its
own thread
fixCarAgain( myCar ); // fixCarAgain() is a process running on its
own thread
return 0;
}
void fixCar( Car& myCar ) // separate thread
{
// if I modify myCar should I do mutual exclusion semaphore here?
}
void fixCarAgain( Car& myCar ) // separate thread
{
// if I modify myCar should I do mutual exclusion semaphore here?
}
the other two function have separate threads
must I worry about threadsafety? The two functions could modify the myCar
object in main at the same time couldn't they?
I have trouble understading if this is a problem or not. both functions
reference the myCar object in main and could potentially create a critical
section
path correct?
Thanks.
For example
int main()
{
Car myCar;
fixCar( myCar ); // fixCar() is a process running on its
own thread
fixCarAgain( myCar ); // fixCarAgain() is a process running on its
own thread
return 0;
}
void fixCar( Car& myCar ) // separate thread
{
// if I modify myCar should I do mutual exclusion semaphore here?
}
void fixCarAgain( Car& myCar ) // separate thread
{
// if I modify myCar should I do mutual exclusion semaphore here?
}