Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

Why did both unemployment and inflation decline after 1982?

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago