Find Jobs
Hire Freelancers

Producer-Consumer Problem using C/C++ and Pthread API(Thread-safe)

$30-250 USD

Ολοκληρώθηκε
Αναρτήθηκε περίπου 6 χρόνια πριν

$30-250 USD

Πληρωμή κατά την παράδοση
Producer-consumer Problem using C/C++ and Pthread APIs (Thread-safe) Do programming project 3: Producer-Consumer Problem described in pp. 253-255 in Textbook 9-th ed. using Pthread APIs and C (or C++) language on Linux with the following additional requirements: As described in the text, your program should be run in the following way: % ./producer_consumer2 how_long_to_sleep_in_seconds num_of_producers number_of_consumers For example, %./producer_consumer2 180 10 20 Your program will As soon as the program starts, read all the words in [login to view URL] into an array Create 10 producer threads Create 20 consumer threads Each producer/consumer thread should run an infinite loop doing one of the followings: o Each producer thread sleeps for a random period of seconds (between 0 and RAND_MAX), upon awakening, will attempt to insert a word randomly selected from the list of words in [login to view URL] into the buffer. Whenever a randomly selected word is inserted into the buffer, the information should be printed on the screen (i.e., thread_id and the word) o Each consumer thread sleeps for a random period of seconds (between 0 and RAND_MAX), upon awakening, will attempt to remove a word from the buffer. Whenever a word is removed from the buffer, the information should be printed on the screen (i.e., thread_id and the word) Your program will run for 180 seconds. An outline of the producer and consumer threads is shown in Figure 5.26. Requirements:  The name of the executable file should “producer_consumer2”.  RAND_MAX should be 10 (i.e., 10 seconds)  Your program should be use all of the following Pthread APIs correctly! o mutex_lock, mutex_unlock, sem_wait, sem_post o You have to use BOTH MUTEX AND SEMAPHORE.  In your code, you can use sleep(seconds) API to make threads to sleep for seconds.  You need to provide a write-up in plain text format describing your source code (300 words or more).  Each producer/consumer thread should print out a message whenever some value is inserted into the buffer or removed from the buffer along with its own identifier. Use the following message formats: [consumer thread ID: 2] removed an item (word: apple) from the buffer [producer thread ID: 1] inserted an item (word: orange) to the buffer Recommended Testing scenarios:  Only producer threads are running 4 o ./producer_consumer2 180 10 0  All producer threads should be blocked eventually since there is no consumer thread.  Only consumer threads are running o ./producer_consumer2 180 0 10  All consumer threads are blocked at the beginning since there is no data to be read by the consumer threads  Multiple producer threads and multiple consumer threads %./producer_consumer2 180 10 20
Ταυτότητα εργασίας: 16775280

Σχετικά με την εργασία

6 προτάσεις
Απομακρυσμένη Εργασία
Ενεργός/ή 6 χρόνια πριν

Ψάχνεις τρόπο για να κερδίσεις μερικά χρήματα;

Πλεονεκτήματα πλειοδοσίας στο Freelancer

Καθόρισε τον προϋπολογισμό σου και το χρονοδιάγραμμα
Πληρώσου για τη δουλειά σου
Περίγραψε την πρόταση σου
Η εγγραφή και η πλειοδοσία σε εργασίες είναι δωρεάν
Βραβεύτηκε στον/στην:
Avatar Χρήστη
Hello, I am interested in this project and so wanted to discuss more it in details. I have a lot of experience in C programming. I will keep your time. And I will provide you quality work according to your instrument. Thanks
$98 USD σε 3 ημέρες
4,9 (130 αξιολογήσεις)
6,4
6,4
6 freelancers δίνουν μια μέση προσφορά $141 USD για αυτή τη δουλειά
Avatar Χρήστη
A proposal has not yet been provided
$155 USD σε 4 ημέρες
0,0 (0 αξιολογήσεις)
0,0
0,0

Σχετικά με τον πελάτη

Σημαία της UNITED STATES
LINCOLN, United States
5,0
7
Επαληθευμένη μέθοδος πληρωμής
Μέλος από Απρ 25, 2018

Επαλήθευση Πελάτη

Ευχαριστούμε! Σου έχουμε στείλει ένα email με ένα σύνδεσμο για να διεκδικήσεις τη δωρεάν πίστωση σου.
Κάτι πήγε στραβά κατά την προσπάθεια αποστολής του email σου. Παρακαλούμε δοκίμασε ξανά.
Εγγεγραμμένοι Χρήστες Συνολικές Αναρτημένες Δουλειές
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Φόρτωση προεπισκόπησης
Δόθηκε πρόσβαση για Geolocation.
Η σύνδεση σου έχει λήξει και τώρα έχεις αποσυνδεθεί. Παρακαλούμε συνδέσου ξανά.