• Najnowsze pytania
  • Bez odpowiedzi
  • Zadaj pytanie
  • Kategorie
  • Tagi
  • Zdobyte punkty
  • Ekipa ninja
  • IRC
  • FAQ
  • Regulamin
  • Książki warte uwagi

Zlecenie zadań z przedmiotu: Algorytmy współbieżne i równoległe (po angielsku)

Object Storage Arubacloud
0 głosów
171 wizyt
pytanie zadane 21 marca 2020 w Ogłoszenia, zlecenia przez Dawid Małecki Nowicjusz (120 p.)
edycja 21 marca 2020 przez Dawid Małecki

Hej, z powodu pandemii muszę jak najszybciej wrócić do Polski, a do poniedziałku muszę zrobić kilka zadań na studia, więc szukam kogoś, kto rozwiąże je wszystkie. Zapłacę oczywiście (jeśli można tutaj ogłaszać tego typu zlecenia za pieniądze)

Niżej przykład zadania. Przewidywany czas rozwiązania zadań to ok. 1.5h (po angielsku)

Cena: 50-200PLN (do negocjacji)

Zadanie:

A bakery shop has to provide a stream of muffins for customers. The muffins are made by a baker in the kitchen and placed on a conveyor belt. The conveyor belt carries the muffins to where the customers are waiting to buy them.
This scenario has been simulated using two processes: the baker and customer, and a shared conveyor belt implemented as a circular array called conveyor, where each space in the array can hold one muffin. There are two shared general semaphores, empty and full, and a mutex buffer_mutex. In this scenario, there is only multiple bakers and a single customer.
The pseudo-code for the baker is as follows. The baker makes use of an integer variable in for noting the next available space on the conveyor belt.

1. while(true){
2. muffin = makeMuffin(); // Create a muffin
3. wait(empty);
4. wait(buffer_mutex);
5. conveyor[in] = muffin; // Put the muffin on the conveyor belt
6. in=(in+1)modn;
7. signal(buffer_mutex);
8. signal(full);
9. }

The pseudo-code for the customer is as follows. The customer makes use of an integer variable out for noting the next location on the conveyor belt that contains a muffin.

1. while(true){
2. wait(full);
3. muffin = conveyor[out]; // Get a muffin from the conveyor belt
4. conveyor[out] = null;
5. out=(out+1)modn;
6. signal(empty);
7. eat(muffin); // Eat the muffin
8. }

This code should be familiar to you as it is similar to the example of the Producer-Consumer problem. Only a few sentences are required for each of the questions below.

(a) (20 marks) Explain, in words, the purpose of the mod n statement. Explain what is the purpose of mutex buffer_mutex. What problems solves? You may wish to include simple examples.

(b) (20 marks) Explain what will happen if the order of semaphores in the customer changes. So, we have in line 2 signal(empty) and in line 6 wait(full). Now assume that there is a single baker and a single customer, with an infinite buffer. Explain, in words, what changes should be made and why.

 

Zaloguj lub zarejestruj się, aby odpowiedzieć na to pytanie.

Podobne pytania

0 głosów
0 odpowiedzi 177 wizyt
pytanie zadane 11 grudnia 2021 w Ogłoszenia, zlecenia przez Mocaz Użytkownik (560 p.)
0 głosów
0 odpowiedzi 844 wizyt
pytanie zadane 7 czerwca 2022 w Ogłoszenia, zlecenia przez urbix01 Gaduła (3,290 p.)

92,539 zapytań

141,382 odpowiedzi

319,477 komentarzy

61,928 pasjonatów

Motyw:

Akcja Pajacyk

Pajacyk od wielu lat dożywia dzieci. Pomóż klikając w zielony brzuszek na stronie. Dziękujemy! ♡

Oto polecana książka warta uwagi.
Pełną listę książek znajdziesz tutaj.

Akademia Sekuraka

Kolejna edycja największej imprezy hakerskiej w Polsce, czyli Mega Sekurak Hacking Party odbędzie się już 20 maja 2024r. Z tej okazji mamy dla Was kod: pasjamshp - jeżeli wpiszecie go w koszyku, to wówczas otrzymacie 40% zniżki na bilet w wersji standard!

Więcej informacji na temat imprezy znajdziecie tutaj. Dziękujemy ekipie Sekuraka za taką fajną zniżkę dla wszystkich Pasjonatów!

Akademia Sekuraka

Niedawno wystartował dodruk tej świetnej, rozchwytywanej książki (około 940 stron). Mamy dla Was kod: pasja (wpiszcie go w koszyku), dzięki któremu otrzymujemy 10% zniżki - dziękujemy zaprzyjaźnionej ekipie Sekuraka za taki bonus dla Pasjonatów! Książka to pierwszy tom z serii o ITsec, który łagodnie wprowadzi w świat bezpieczeństwa IT każdą osobę - warto, polecamy!

...