Purchase Solution

Forking and Scheduling: Few programs and problems

Not what you're looking for?

Ask Custom Question

[A] What happens when you run the following piece of code:

main(int argc, char ** argv)
{
for(;;)
fork();
}

[B] 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;
}
}

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

[C] Given the following piece of code

main(int argc, char ** argv)
{
forkthem(5)
}

void forkthem(int n)
{
if(n > 0)
{
fork();
forkthem(n-1);
}
}

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

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

Attachments
Purchase this Solution

Solution Summary

Solution explains the concept of "fork bomb" and effects of "smaller quantum" in fixed-size quantum round-robin scheduling, apart from giving detailed explanations behind the solution in not-so-obvious cases.

Solution Preview

[A] This program creates a "fork bomb" that will keep on creating copies of itself forever. Very soon, the limit on maximum number of user processes for the user is reached (please refer to "ulimit -a" output for this limit) and no further process can be created by the user. Further "fork" attempts will give the error ...

Purchase this Solution


Free BrainMass Quizzes
Javscript Basics

Quiz on basics of javascript programming language.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

C# variables and classes

This quiz contains questions about C# classes and variables.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.