Changeset 26 for trunk/pthreads-pc.c
- Timestamp:
- Apr 18, 2014, 8:10:14 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pthreads-pc.c
r8 r26 1 /* Copyright (C) 2008 by Mattia Monga <mattia.monga@unimi.it> */1 /* Copyright (C) 2008, 2014 by Mattia Monga <mattia.monga@unimi.it> */ 2 2 /* $Id$ */ 3 3 #include <pthread.h> … … 13 13 while (1){ 14 14 char* o = (char*)malloc(sizeof(char)); 15 printf("Ho prodotto % x\n", o);15 printf("Ho prodotto %p\n", o); 16 16 b_insert(o); 17 17 } … … 25 25 b_remove(&o); 26 26 free(o); 27 printf("Ho consumato % x\n", o);27 printf("Ho consumato %p\n", o); 28 28 } 29 29 return NULL; … … 56 56 57 57 while (count == N) pthread_cond_wait(&full, &lock); 58 printf("Buffer a %d\n", count); 58 59 buffer[count++] = o; 59 60 if (count == 1) pthread_cond_signal(&empty); … … 68 69 69 70 while (count == 0) pthread_cond_wait(&empty, &lock); 71 printf("Buffer a %d\n", count); 70 72 *result = buffer[--count]; 71 73 if (count == N-1) pthread_cond_signal(&full);
Note:
See TracChangeset
for help on using the changeset viewer.