Preemption of programs
int x = 0;      // shared variable.

void function(int s) {
    int i=0;   // local to function
    for(i=0;i<s;i++)
        x++;
}
int main() {
    begin
        function(8);
        function(13);
    end
}

increment on x can be assumed to be executed in CPU in three steps (load,increment,store)

What is the minimum possible value of x, after completion of the program ?

Author: vishal3096
Login to Answer
Sort By:
Oldest
|
Newest
|
Vote
|
My Answer