threads
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previa | |||
| threads [2018/06/26 13:57] – [Lectores/escritores] lmateu | threads [2018/07/06 00:04] (actual) – [Productor/consumidor] lmateu | ||
|---|---|---|---|
| Línea 359: | Línea 359: | ||
| } | } | ||
| | | ||
| - | void consumidor(Buffer | + | void *consumidor(void *ptr) { // porque se usa en pthread_create |
| + | Buffer *buf= ptr; | ||
| for (;;) { | for (;;) { | ||
| Cuadro *cuadro= get(buf); | Cuadro *cuadro= get(buf); | ||
| Línea 366: | Línea 367: | ||
| mostrarCuadro(cuadro); | mostrarCuadro(cuadro); | ||
| } | } | ||
| + | return NULL; | ||
| } | } | ||
| | | ||
| void reproducirVideo() { | void reproducirVideo() { | ||
| Buffer *buf= nuevoBuffer(60); | Buffer *buf= nuevoBuffer(60); | ||
| - | | + | |
| - | pthread_create(& | + | pthread_create(& |
| productor(buf); | productor(buf); | ||
| - | pthread_join(pid, NULL); | + | pthread_join(t, NULL); |
| } | } | ||
| </ | </ | ||
threads.1530021465.txt.gz · Última modificación: por lmateu
