#include <pthread.h>

void init_mymalloc();
void *mymalloc (int size);
void myfree (void *p);

typedef struct lock {
  pthread_mutex_t mutex[1];
} Lock;

Lock *make_lock ();
void lock_acquire (Lock *lock);
void lock_release (Lock *lock);
pthread_mutex_t get_mutex (Lock *lock);

typedef struct {
  Lock *rlock;
  Lock *wlock;
  int counter;
} Readwrite;

Readwrite *make_readwrite ();
void read_enter (Readwrite *readwrite);
void read_exit (Readwrite *readwrite);
void write_enter (Readwrite *readwrite);
void write_exit (Readwrite *readwrite);


