adlep
Diamond Member
Consider the following code C++ code..
int y =3; x = 0;
foo()
{
y=y+1;
x=y;
}
bar()
{
y=y*2;
}
main()
{
Thread t1= createThread(foo);
Thread t2= create Thread(bar);
WaitForAllDone();
cout << x << y << endl;
}
1. My question is what is the maximum number of threads that are ever alive in this program, the teacher didnt really explained anything, and I am still confused on how should I interpert such a code..?
2. What are all possible outputs for the program?
I think this means that it can be diffrient depending which operation thread will get executed first, but I am not sure...Help?
Man this Operating System class I am taking is tougher that I have expected....🙁
int y =3; x = 0;
foo()
{
y=y+1;
x=y;
}
bar()
{
y=y*2;
}
main()
{
Thread t1= createThread(foo);
Thread t2= create Thread(bar);
WaitForAllDone();
cout << x << y << endl;
}
1. My question is what is the maximum number of threads that are ever alive in this program, the teacher didnt really explained anything, and I am still confused on how should I interpert such a code..?
2. What are all possible outputs for the program?
I think this means that it can be diffrient depending which operation thread will get executed first, but I am not sure...Help?
Man this Operating System class I am taking is tougher that I have expected....🙁