This shows you the differences between two versions of the page.
|
app:laboratoare:04 [2025/11/12 04:59] alexandru.bala [Semafor] |
app:laboratoare:04 [2025/11/12 05:03] (current) alexandru.bala [Variabile condiție] |
||
|---|---|---|---|
| Line 194: | Line 194: | ||
| int arguments[NUM_THREADS]; | int arguments[NUM_THREADS]; | ||
| - | // cream mutex-ul | + | // creăm mutex-ul |
| pthread_mutex_init(&mutex, NULL); | pthread_mutex_init(&mutex, NULL); | ||
| Line 261: | Line 261: | ||
| for (i = 0; i < NUM_THREADS; i++) { | for (i = 0; i < NUM_THREADS; i++) { | ||
| pthread_join(threads[i], &status); | pthread_join(threads[i], &status); | ||
| - | } | + | } |
| pthread_barrier_destroy(&barrier); | pthread_barrier_destroy(&barrier); | ||
| + | |||
| return 0; | return 0; | ||
| } | } | ||
| Line 358: | Line 360: | ||
| pthread_mutex_init (&mutex, NULL); | pthread_mutex_init (&mutex, NULL); | ||
| - | |||
| sem_init (&full_sem, 0, 0); | sem_init (&full_sem, 0, 0); | ||
| sem_init (&empty_sem, 0, 3); | sem_init (&empty_sem, 0, 3); | ||
| Line 378: | Line 379: | ||
| sem_destroy (&empty_sem); | sem_destroy (&empty_sem); | ||
| sem_destroy (&full_sem); | sem_destroy (&full_sem); | ||
| - | |||
| pthread_mutex_destroy (&mutex); | pthread_mutex_destroy (&mutex); | ||
| Line 493: | Line 493: | ||
| } | } | ||
| + | pthread_cond_destroy (&empty_cond, NULL); | ||
| + | pthread_cond_destroy (&full_cond, NULL); | ||
| pthread_mutex_destroy(&mutex); | pthread_mutex_destroy(&mutex); | ||