Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer this question Use the picture as a example. Write a programed name ch.c which should run five processes altogether. These are the requirements:

Please answer this question

Use the picture as a example.

Write a programed name ch.c which should run five processes altogether.

These are the requirements: a) At most three fork() function calls are allowed to appear in your .c> code. b) No for() loops, no do while loops, etc. c) Compile into an executable file called and run it on your Ubuntu system in VirtualBox. Then use top to show the five processes using a snapshot of your terminal window. gcc -o five five.c d) You have to use sleep() function to give enough time to take a snapshot before some or all of the processes finish and exit quickly.

#include #include #include int mainC pidt pid; /* fork a child process*/ pid = fork(); if (pid < 0)error occurred* fprintf(stderr, "Fork Failed" return 1; else if (pid 0) { /* child process */ execlpC"/bin/ls","ls", NULL); else /* parent process* /* parent will wait for the child to complete* wait CNULL); printfC"Child Complete"; return 0

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

Step: 3

blur-text-image

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 Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago