Find Jobs
Hire Freelancers

modifing some program

$10-30 USD

Zrušeno
Zveřejněno před více než 7 roky

$10-30 USD

Zaplaceno při doručení
you will be given a functioning program, called minor5.c, that simply reads user input keys and echoes them back to the screen using the producerconsumer paradigm. The single producer thread reads user input keys and adds them to the shared buffer while two consumer threads read the added keys from the buffer and echo them back to the screen. To complicate matters, each key is read and echoed by exactly one consumer thread. A shared variable, called shared_count, keeps track of the number of items in the shared buffer. While this program does work (thanks to the mutex locks and unlocks already provided), it is unfortunately very inefficient. To see just how inefficient this program is, compile the original minor5.c program (using the pthread library) and execute the program. You should type in some keys and see them echoed back on the screen in their correct order. To see the inefficiency, though, run the top command from another shell (don’t just run the minor5.c program in the background and then run top, but actually open up another shell/window). Then check out the %CPU column in the top command and you should see your (original) minor5.c program using up a significant percentage of the CPU, which is not good. Your goal for this assignment is to modify this program to use condition variables that will drastically reduce its CPU percentage usage. Here are the details: • You will modify the original minor5.c file to add condition varabiables, but does not change the “spirit” of the program other than necessary changes that are needed for how conditional variables work. • You will add two global pthread condition variables – one to handle when the shared buffer is full (and therefore, nothing else can be added to the until a key is removed from the buffer) and one to handle when the shared buffer is empty (and therefore, nothing can be read/echoed back to the screen until a key is added to the buffer). • In the main function, you will initialize and destroy the both of the condition variables. • You will modify the code in the producer function to wait on and signal the appropriate condition variable(s) based on what is happening with the shared variables (i.e., the shared buffer and shared counter). Note that this will require some small changes in logic to accomplish, but you should not change the lines that work with the prod_index variable. 2 • You will modify the code in the consumer function to wait on and signal the appropriate condition variable(s) based on what is happening with the shared variables (i.e., the shared buffer and shared counter). Note that this will require some small changes in logic to accomplish, but you should not change the lines that work with the cons_index variable. Be sure to run your solution along with the top command to verify that the program is more efficient (i.e., does not use nearly as much percentage of the CPU).
IČ projektu: 11913796

O projektu

4 nabídky
Vzdálený projekt
Aktivní před 8 roky

Chcete si vydělat nějaké peníze?

Výhody podávání nabídek na Freelancer

Stanovte si rozpočet a časový rámec
Získejte za svou práci zaplaceno
Načrtněte svůj návrh
Registrace a podávání nabídek je zdarma
4 freelanceři nabízejí v průměru $44 USD za tuto práci
Avatar uživatele
Hello, Sir Weebside Inc. is a professional freelancer service provided to worthy clients like you. We can provide our best developers to provide you High-Quality Product with 100% Delivery Rate, 100% Satisfaction. Having Experts in Java, C / C++ , C# , VB , .NET , SQL, MySQL, and Python Programming Language and Frameworks made us capable to bid here. We can provide any service of any caliber within Hours. CHAT WITH US TO START RIGHT NOW. BEST DEVELOPERS AROUND. WITH HIGHEST QUALITY DELIVERED WITHIN TIME. WITHIN BUDGET. CLICK CHAT TO START CLICK CHAT TO START CLICK CHAT TO START CLICK CHAT TO START CLICK CHAT TO START
$25 USD v 1 dni
4,5 (23 recenze)
4,5
4,5
Avatar uživatele
Hello, I hope you doing very well! I have gone through the description and would like to provide a quality solution using 5+ years of professional experience in required skills. (.NET/ASP.NET - MVC, EF, SQL, C#). Awaiting for your positive response so we can have final talk and start project immediately :)
$25 USD v 1 dni
5,0 (10 recenze)
3,6
3,6
Avatar uživatele
Hello, How are you. I am a talented developer of China with full experienced knowledge in C/C++, C# programming. I've just read your job posting and I'm very interested. I know how to bring your idea alive and communication well. I never disappoint my clients and I'm able to lead your project to success and troubleshoot problems. Additionally in our team there are many expert software developers, so we can help you in every part of IT continuously. Please contact me if I am a match for you are looking for. Best Regards
$25 USD v 1 dni
0,0 (0 recenze)
0,0
0,0

O klientovi

Pochází z UNITED STATES
denton, United States
5,0
20
Ověřená platební metoda
Členem od říj 23, 2015

Ověření klienta

Díky! Poslali jsme vám e-mailem odkaz pro získání kreditu zdarma.
Při odesílání e-mailu se něco pokazilo. Zkuste to prosím znovu.
Registrovaných uživatelů Zveřejněných projektů
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Načítání náhledu
Bylo uděleno povolení ke geolokaci.
Vaše doba přihlášení vypršela a byli jste odhlášeni. Přihlaste se znovu.