/* fcntl.h  -- Defines mutexes in terms of read/write locks on files. 
 *             filerwlock, filerwlockCreate, filelockDelete,
 *             filereadlock, filelockUnlock
 */


typedef struct {
    int fd;
    int n;} filerwlock;

/* Create N read/write locks and returns the id of this cluster of locks. */
filerwlock * filerwlockCreate(char *filename, int n);

/* Delete the cluster of read/write locks associated with fl. */
int filerwlockDelete(filerwlock *fl);

/* Given the read/write lock cluster fl, lock its ith element */
int filereadlock(filerwlock *fl, int i);

int filewritelock(filerwlock *fl, int i);

/* Given the lock cluster fl, unlock its ith element */
int filerwunlock(filerwlock *fl, int i);
