Changeset 26 for trunk/pthreads-pc.c


Ignore:
Timestamp:
Apr 18, 2014, 8:10:14 AM (5 years ago)
Author:
monga
Message:

Programmi 2014

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> */
    22/* $Id$ */
    33#include <pthread.h>
     
    1313  while (1){
    1414    char* o = (char*)malloc(sizeof(char));
    15     printf("Ho prodotto %x\n", o);
     15    printf("Ho prodotto %p\n", o);
    1616    b_insert(o);
    1717  }
     
    2525    b_remove(&o);
    2626    free(o);
    27     printf("Ho consumato %x\n", o);
     27    printf("Ho consumato %p\n", o);
    2828  }
    2929  return NULL;
     
    5656
    5757  while (count == N) pthread_cond_wait(&full, &lock);
     58  printf("Buffer a %d\n", count);
    5859  buffer[count++] = o;
    5960  if (count == 1) pthread_cond_signal(&empty);
     
    6869
    6970  while (count == 0) pthread_cond_wait(&empty, &lock);
     71  printf("Buffer a %d\n", count);
    7072  *result = buffer[--count];
    7173  if (count == N-1) pthread_cond_signal(&full);
Note: See TracChangeset for help on using the changeset viewer.