Open Source & Linux Lab

It's better when it's simple

User Tools

Site Tools


courses:high_performance_computing:producer_consumer

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
courses:high_performance_computing:producer_consumer [2021/10/02 23:49] kelcourses:high_performance_computing:producer_consumer [2022/09/15 11:36] odoronin
Line 2: Line 2:
 Ваша задача - реализовать классический паттерн producer-consumer с небольшими дополнительными условиями. Ваша задача - реализовать классический паттерн producer-consumer с небольшими дополнительными условиями.
 Программа должна состоять из 3+N потоков:  Программа должна состоять из 3+N потоков: 
-  - главный+  - Главный
   - producer   - producer
   - interruptor   - interruptor
Line 26: Line 26:
  
 <file cpp> <file cpp>
 +#include <iostream>
 +#include <fstream>
 #include <pthread.h> #include <pthread.h>
- 
-void read_values() { 
-  FILE* file = fopen("in.txt"); 
-  ... read(); 
-} 
  
 void* producer_routine(void* arg) { void* producer_routine(void* arg) {
Line 37: Line 34:
  
   // 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
 +  std::ifstream ifs("in.txt");
 +  // ...
 } }
  
courses/high_performance_computing/producer_consumer.txt · Last modified: 2024/03/04 02:19 by odoronin