Question: In this question, you are asked to create three threads and run them simultaneously. A, B and Threads that we will call C have blocks

In this question, you are asked to create three threads and run them simultaneously. A, B and Threads that we will call C have blocks of code that follow each other as follows:
- Thread A has three code blocks: A1, A2, A3 - Thread B has four code blocks: B1, B2, B3, B4 - Thread C has three code blocks: C1, C2, C3
What we call a code block actually consists of this piece of code:

In this question, you are asked to create three threads and run

a. By writing a main program, create 3 threads (A, B, C) in your program. Each thread is created by using the print function you wrote above (the function has its own data consisting of name and code block number  A1, A2, A3, B1, etc.- as a parameter. by sending it) should show which code block it is currently running. Therefore, as can be understood from here, a code block for each thread tag five times in a row (A1A1A1A1A1 etc.). Code blocks are ordered sequentially in threads (A2 before A1 is finished). block will not start, etc.). without applying any synchronization control to your program. When you run it, you can observe that the code blocks of different threads are nested. need (like A1A1C1B1A1B1B1.....A3C2C3...).
b. Using semaphores, threads of the program you wrote above, in such a way sync so that every time you run your program: - Let C1 code block be run AFTER A1 code block. - Let code block A2 be run AFTER code block B1. - Let C2 code block be run AFTER B2 code block. - Let B3 code block be run AFTER A2 code block. - Let A3 code block be run AFTER C2 code block. - Let B4 be the LAST executed code block. It does not matter when and in what order the code blocks not mentioned above will run. there is none. You can program your program using the Linux semaphore library (#include ). You can write. It is up to you to determine which functions from the library you should use. staying.

#include #include #include #include void yazdir(const char *data){ int i = 0; for(i;i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!