Question: find an optimal loop count for your system to force CPU scheduling to kick-in. System call fork() is used to create processes. It takes no

 find an optimal loop count for your system to force CPU

scheduling to kick-in. System call fork() is used to create processes. It

find an optimal loop count for your system to force CPU scheduling to kick-in.

System call fork() is used to create processes. It takes no arguments and returns a process ID. The purpose of fork() is to create a new process, which becomes the child process of the caller. After a new child process is created, both processes will execute the next instruction following the fork() system call.

Experiment with how fork can create a process and how the parent and child will get scheduled to run in modern concurrent and multi-tasking operating system.

Modify each c fork to display your name where it says "My Name".

Then compile them with the following command:

gcc -o fork1 fork1.c

gcc -o fork2 fork2.c

Now run each as follows:

First, by having the output to the console:

./fork1

./fork2

Second, by directing the output to a file:

./fork1 > fork1.out

./fork2 > fork2.out

Examine the outputs of these, and create a Word document and describe your understanding of this assignment as follows:

When fork1.c and fork2.c are run, what happens inside the kernel with respect to how the kernel works with its internal algorithms, and scheduling and switching the tasks to run. The computer speed has something to do with this, so you would need to adjust max count and see how these two source code will behave. Note that, the computer speed is irreverent and it is only a byproduct.

/* /* PROGRAM: fork2.c /* DESCRIPTION /* This program runs two processes, a parent and a child. Both of /* them run the same loop printing some messages. Note that printf() /* is used in this program. */ +/ #include #include #include #define MAX_COUNT 200 /* may need to increase based on your CPU Performance. Why? */ /* child process prototype */ /* parent process prototype */ void childProcess (void); void Parent Process (void); int main() { pid_t pid; pid fork(); if (pid = 0){ ChildProcess(); } else { Parent Process(); } return 0; } void ChildProcess (void) { int i; for (i - 1; i #include #include #include #define MAX COUNT 200 /* may need to increase based on your CPU Performance. Why? */ #define BUF_SIZE 100 int main() { pid_t pid; int i; char buf(BUF_SIZE]; fork(); pid = getpid(); for (i = 1; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!