Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

modify this program so that it used clone instead of fork. the output should be This is process(thread) 11501. x+y=1 > This is process(thread) 11502.

modify this program so that it used clone instead of fork.

the output should be

This is process(thread) 11501. x+y=1 > This is process(thread) 11502. x+y=7

//fork makes a second process, running the same executable

//pid_t used to be long, but now just int #include #include #include int main ( void ) { int x=0, y=0; pid_t pid, fpid; fpid = fork (); pid = getpid(); if (fpid > 0){ printf (" This is process(thread) %d. ",pid); y=1; } else if (fpid == 0){ sleep(1); printf (" This is process(thread) %d. ",pid); x=7; } else { printf ("fork failed "); return (1); } printf("x+y=%d ",x+y); }

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 Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions

Question

Discuss the states of accounting

Answered: 1 week ago

Question

define EFFECTIVE PARTICIPATION

Answered: 1 week ago