Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Write a program in which two threads works. Thread code should be placed in the function Function parameter is the thread number (Integer number).

C++

Write a program in which two threads works. Thread code should be placed in the function Function parameter is the thread number (Integer number). Thread displays in the loop 10 times the message

"i = number from 0 to 9, number = thread number". After displaying each message thread sleeps for 100 to 500 ms (random value) Synchronize operations on the console (use mutex and lock).

Thread code function

Creating threads, waiting for threads

Passing parameters to a thread

IO synchronization

Speelping thread for a random time

Modify the program from the above exercise so that the program has a group of 10 threads. Modify the text displayed by the thread so that it has the form:

"1 = number from 0 to 9 number thread number id = thread identifier". Use a semaphore instead of a mutex to synchronize operations on the console. Cause (also using the semaphore) that maximum 3 threads at a time could perform their action in for loop

Create a thread group, wait for threads

Passing parameters to threads (function bind()

Additionally display the thread identifier

Using a semaphore to limit the number of concurrent threads

Using a semaphore for IO synchronization

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

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

=+Does it showcase the firm's benefits?

Answered: 1 week ago

Question

What is digital literacy? Why is it necessary?

Answered: 1 week ago