Find Jobs
Hire Freelancers

modifing C program

$10-30 USD

Concluído
Publicado há mais de 7 anos

$10-30 USD

Pago na entrega
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).
ID do Projeto: 11914623

Sobre o projeto

3 propostas
Projeto remoto
Ativo há 8 anos

Quer ganhar algum dinheiro?

Benefícios de ofertar no Freelancer

Defina seu orçamento e seu prazo
Seja pago pelo seu trabalho
Descreva sua proposta
É grátis para se inscrever e fazer ofertas em trabalhos
Concedido a:
Avatar do Usuário
Hi, I am expert in the multithreaded programming and can solve this task for you. If you are interested to cooperate with me please leave me a message. Please do not hesitate to contact me here even I am offline - I will try to read your message and respond as soon as possible.
$40 USD em 1 dia
4,9 (35 avaliações)
5,6
5,6
3 freelancers estão ofertando em média $73 USD for esse trabalho
Avatar do Usuário
Hello I am C expert and interested in this project. I have reviewed the details and confident to handle it perfectly. I have a lot of experience in helping in students with assignments, so I will keep codes well documented and simple. Please communicate to discuss further. Regards Anshu
$79 USD em 1 dia
4,8 (190 avaliações)
6,5
6,5
Avatar do Usuário
Hello,We are a team of developers and do all work related to computer science( Software Engineering ),. We have experience in , JAVA,C# ,My SQL , website Design( wordpress ,PHP), Excel, ( vb ,(macro)), Research( biology , chemistry , physics , any ), Data Entry, Graphic Design, Logo Design. We are fresh freelancers. but we are doing this since 6 years, still we are university students . we can handle all your issues and help you in a decent way we work with authorized people. We would like to complete your job in an effective and efficient way. Best regards.
$77 USD em 2 dias
0,0 (0 avaliações)
0,0
0,0
Avatar do Usuário
Hi, I am a new freelancer. But i have many experience on c programming. I have done many c programs and make them on high level. I can complete your work in 1 hour. Thank you.
$30 USD em 1 dia
0,0 (0 avaliações)
0,0
0,0

Sobre o cliente

Bandeira do(a) UNITED STATES
denton, United States
5,0
20
Método de pagamento verificado
Membro desde out. 23, 2015

Verificação do Cliente

Obrigado! Te enviamos um link por e-mail para que você possa reivindicar seu crédito gratuito.
Algo deu errado ao enviar seu e-mail. Por favor, tente novamente.
Usuários Registrados Total de Trabalhos Publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Carregando pré-visualização
Permissão concedida para Geolocalização.
Sua sessão expirou e você foi desconectado. Por favor, faça login novamente.