How many different copies of the variable c


Assignment:

Q1. What happens when you run the following piece of code:

main(int argc, char ** argv)
{
for(;;)
fork();
}
Given the following piece of code:
main(int argc, char ** argv)
{
int child = fork();
int c = 5;
if(child == 0)
{
c += 5;
}
else
{
child = fork();
c += 10;
if(child)
c += 5;
}
}

Q2. How many different copies of the variable c are there? What are their values?

Given the following piece of code
main(int argc, char ** argv)
{
forkthem(5)
}
void forkthem(int n)
{
if(n > 0)
{
fork();
forkthem(n-1);
}
}

Q3. How many processes are created if the above piece of code is run?

Most round-robin schedulers use a fixed size quantum. Give an argument in favor of and against a small quantum.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: How many different copies of the variable c
Reference No:- TGS01936344

Now Priced at $25 (50% Discount)

Recommended (92%)

Rated (4.4/5)