/// Nombres de los procesos
enum proc_t { PRODUCTOR, CONSUMIDOR };
-void producir(int pipe)
+void producir(int p)
{
int val = rand();
- TEST(write(pipe, &val, sizeof(int)));
+ TEST(write(p, &val, sizeof(int)));
cout << "Producido " << (int)val << endl;
}
-void consumir(int pipe)
+void consumir(int p)
{
int val;
- TEST(read(pipe, &val, sizeof(int)));
+ TEST(read(p, &val, sizeof(int)));
cout << "Consumido " << val << endl;
}
max_iter = atoi(argv[2]);
int mode = (proc == CONSUMIDOR) ? O_RDONLY : O_WRONLY;
- int pipe = open(PIPE, mode);
- TEST(pipe);
+ int p = open(PIPE, mode);
+ TEST(p);
for (int i = 0; i < max_iter; ++i)
{
if (proc == PRODUCTOR)
- producir(pipe);
+ producir(p);
else
- consumir(pipe);
+ consumir(p);
sched_yield();
}