Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

image text in transcribed

NEXT PART

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions