Question: OPERATING system in C langauge NEXT PART Question #2: Write a multithreaded program which creates two threads: print thread and decrement thread. The program creates

OPERATING system in C langauge

OPERATING system in C langauge NEXT PART Question #2: Write a multithreaded

NEXT PART

program which creates two threads: print thread and decrement thread. The program

Question #2: Write a multithreaded program which creates two threads: print thread and decrement thread. The program creates 100 instances of decrement thread. The decrement thread will decrement the count by 1. When the count has become the print thread will print a message "All 100 threads have decremented the counter. Implement this barrier with the help of POSIX semaphores. Also use POSIX semaphores wherever required. Do not use wait statement. (20) There are exactly 3 threads generating string a, b and c in an arbitrary order. In an absence of any synchronization mechanism there will be no order in generation of a, b and c. In the form of regular expression the string (a | b | c)* {* means many times a character an occur, means or, so different combinations can be aaaaaaa... , bbbbbbbbbbb... , ccccc... }. Write a multithreaded program which synchronizes threads using semaphores in such a way that your printed string will be (cba)* {* means many times cba can occur, so different combinations will be cbacbacbacb...}. Note you are not allowed to add or delete any print statement. I/thread 1 While(1) l/thread 2 l/thread 3 While(1) { While(1) { printf("%c ",a); printf("%c ".b)': printf("%c ",c); } }

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!