Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

void fork 1 () int x=1; pid t pid = fork (); if (pid== ) printf(Child has x=8d ,++x); else printf (Parent has x=8d ,x);

image text in transcribedimage text in transcribed

void fork 1 () int x=1; pid t pid = fork (); if (pid== ) printf("Child has x=8d ",++x); else printf ("Parent has x=8d ",x); printf ("Bye from process od with x=%d ", getpid(), x); * Both processes continue/start execution after fork - Child starts at instruction after the call to fork (storing into pid) * Can't predict execution order of parent and child * Both processes start with x=1 - Subsequent changes to x are independent * Shared open files: stdout is the same in both parent and child Code 2: For each of the codes above, model the fork process with a process graph, essentially the tree of processes, capturing the partial ordering of statements in our current program (like what we did in our class demonstrations). Note that: - Each vertex is the execution of a statement - ab means a happens before b - Edges can be labeled with current value of variables - printf vertices can be labeled with output - Each graph begins with a vertex with no inedges Questions for each code: - How many processes have been created during the program execution? - What is the output of the program? - What are the concurrent processes as reflected in the process graph? - What are the sequential processes, if any

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago