Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C which you create 2 thread s and pass 1/2 to the thread as a parameter. In the thread function, print

Write a program in C which you create 2 threads and pass 1/2 to the thread as a parameter. In the threadfunction, print the value of the parameter passed 10 times. Have a global variable initialised to 0. In the thread function, increment this counter and print the value of the tid and counter value 10 times. Check the counter value printed from the threads. Is there any inconsistency in the value or is the output as you expected? Experiment the same by adding a mutex around the critical section of incrementing the counter. Print the values and check if there is any difference in output. Is there inconsistency in values? What is needed if we want to ensure that the value of the counter must be printed in a certain order?

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

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions