Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need a C program that must use two threads and a mutex print function. The program must adhere to the following rules, and it

I need a C program that must use two threads and a mutex print function. The program must adhere to the following rules, and it MUST use the printShare mutex print function. Thank you for your help!
image text in transcribed
This time you need to rewrite a multithreaded Pthread program that works with sleep() or pthread join) in order to print out Fibonacci sequences properly. Create a folder name, WK6 on your class Linux machine when you work. gec assignment3.c-Wall-Werror-pthread You are required to develop your own program using C with the following information . Need to declare a function that receives Fibonacci number and prints Fibonacci sequence upon each Fibonacci number o Fibonacci count numbers with corresponding thread-name would be read using main (int arge, char argv [I) function. 4 Fibonacci numbers are entered on the command line such as: John 9 Doe 13 ESU 7 CPSC 9; Each Fibonacci number is executed by each thread shown bclow; . o The program needs to create separate threads such that: Thread 1 with your first name, followed by the Fib sequence data; Thread 2 with your last name, followed by the Fib sequence data; Thread 3 with "ESU" followed by the Fib sequence data; Thread 4 with "CPSC" followed by the Fib sequence data; o o o The parent thread will print the sequence with the thread name printShare); o void printShare (O o pthread mutex lock(&lock); o write or printf (Each Fib sequence that begins with name); o pthread mutex unlock(&lock); You may implement your program such as: Implement as is without using sleep), pthread join) Implement it after adding those statements

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions