Find Jobs
Hire Freelancers

Producer-consumer Problem using C/C++ and Pthread APIs

$30-250 USD

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

$30-250 USD

Πληρωμή κατά την παράδοση
1 Producer-consumer Problem using C/C++ and Pthread APIs (NOT Thread-safe) Implement a simple producer/consumer program using POSIX threads. You are to design the threads to run with a preemptive scheduler (note: Each call to pthread_create() will create a kernel thread on Linux and all kernel threads will be run with a preemptive scheduler on Linux) and to communicate through a bounded buffer. Design the buffer to have 10 slots. - DO NOT use mutex or semaphore at all! - Design the shared buffer to have 10 slots: o Use an integer array to hold the contents of the buffer o Use a counter variable to hold the number of occupied cells o Use a variable to keep track of the next location for the producer to insert a value o Use a variable to keep track of the next location for the consumer to remove a value. o Do not forget to initialize the counter and the two variables. - Implement the bounded shared buffer in a way that is NOT thread-safe, not protecting the update of the counter or the two variables. - Only one producer thread and only one consumer thread will be created in addition to the main thread. - The producer thread should send a sequence of integers to the consumer. Specifically, it should send the sequence 1, 2, 3, ..., 1000000, in that order by inserting each value in order to the shared buffer. In case that the buffer is full, it should do busy waiting using a while loop. Once all the values have been inserted, the producer thread should call pthread_exit(); - The consumer thread should receive them and check that it has indeed received exactly that sequence, in that order. If you should expect that something will go wrong. The consumer should discover that the numbers received are not in the correct sequence. As soon as the consumer sees an error, it should report how much of the sequence was received correctly, and what the next (incorrect) number was. - You don’t have to create separate functions for insert_item() and remove_item(). [Sample run] % ./producer_consumer1 ERROR: The consumer received the sequence up to 12000 correctly. The next number (incorrect) number was 12004. Requirements: • Makefile should be provided. • The name of the executable file should be “producer_consumer1”.
Ταυτότητα εργασίας: 16775248

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

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

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

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

Καθόρισε τον προϋπολογισμό σου και το χρονοδιάγραμμα
Πληρώσου για τη δουλειά σου
Περίγραψε την πρόταση σου
Η εγγραφή και η πλειοδοσία σε εργασίες είναι δωρεάν
7 freelancers δίνουν μια μέση προσφορά $131 USD για αυτή τη δουλειά
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 ημέρες
5,0 (99 αξιολογήσεις)
6,1
6,1
Avatar Χρήστη
Hello I did read your project detail carefully(producer-consumer console program) I can develop this program. I am sure that I can send you best result in two days. Please contact me Best regards.
$150 USD σε 3 ημέρες
5,0 (21 αξιολογήσεις)
5,0
5,0
Avatar Χρήστη
Hello.. I can do it.. provide more details
$111 USD σε 1 ημέρα
5,0 (8 αξιολογήσεις)
3,9
3,9

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

Σημαία της 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.
Η σύνδεση σου έχει λήξει και τώρα έχεις αποσυνδεθεί. Παρακαλούμε συνδέσου ξανά.