courses:high_performance_computing:producer_consumer
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
courses:high_performance_computing:producer_consumer [2024/03/04 01:55] – odoronin | courses:high_performance_computing:producer_consumer [2025/02/23 14:55] (current) – odoronin | ||
---|---|---|---|
Line 17: | Line 17: | ||
* Задача потока-interruptor проста: | * Задача потока-interruptor проста: | ||
* Завершение приложения происходит или при считывании перевода каретки из файла или по посылке сигнала SIGTERM, обработку которого нужно также добавить. В обработчике сигнала можно вызывать только signal-safe функции https:// | * Завершение приложения происходит или при считывании перевода каретки из файла или по посылке сигнала SIGTERM, обработку которого нужно также добавить. В обработчике сигнала можно вызывать только signal-safe функции https:// | ||
+ | * При сигнале в качестве вывода нужно выдавать посчитанную на этот момент сумму | ||
* В нашем producer/ | * В нашем producer/ | ||
- | Функция run_threads должна запускать все потоки, | + | Функция run_threads должна запускать все потоки, |
+ | * При отсутствии входных данных ядра процессора не должны вхолостую есть такты | ||
Для обеспечения межпоточного взаимодействия допускается использование только pthread API. На вход приложения передаётся 2 аргумента при старте именно в такой последовательности: | Для обеспечения межпоточного взаимодействия допускается использование только pthread API. На вход приложения передаётся 2 аргумента при старте именно в такой последовательности: | ||
Line 34: | Line 36: | ||
void* producer_routine(void* arg) { | void* producer_routine(void* arg) { | ||
// Wait for consumer to start. | // Wait for consumer to start. | ||
- | // You can use this waiting only for debugging your code | + | // You should |
- | // For final solution please remove this waiting | + | // For the final solution please remove this waiting |
// Read data, loop through each value and update the value, notify consumer, wait for consumer to process | // Read data, loop through each value and update the value, notify consumer, wait for consumer to process | ||
Line 44: | Line 46: | ||
void* consumer_routine(void* arg) { | void* consumer_routine(void* arg) { | ||
// notify about start | // notify about start | ||
- | // you can use this notification only for debugging your code | + | // you should |
- | // for final solution please remove this notification | + | // for the final solution please remove this notification |
| | ||
| | ||
Line 54: | Line 56: | ||
void* consumer_interruptor_routine(void* arg) { | void* consumer_interruptor_routine(void* arg) { | ||
// wait for consumers to start | // wait for consumers to start | ||
- | // you can use this waiting only for debugging your code | + | // you should |
- | // for final solution please remove this waiting | + | // for the final solution please remove this waiting |
// interrupt random consumer while producer is running | // interrupt random consumer while producer is running |
courses/high_performance_computing/producer_consumer.1709506546.txt.gz · Last modified: 2024/03/04 01:55 by odoronin