All pastes #26001 Raw Edit

Unnamed

public text v1 · immutable
#26001 ·published 2005-10-19 21:43 UTC
rendered paste body
// global_Sem_Mutex.h

/******************************************************************************
 *	Programmer: Theresa Nelson
 *	Program: Project 2, Cookies2Code
 *	Environment: Fedora Core 4, g++ compiler
 *	Class: Operating Systems, Capra
 *	Date Last Modified: October 17, 2005
 *
 *
 *	COMMENTS:
 *	This file contains code for global_Sem_Mutex.h. It is holds 
 *	declarations for mutexes that are used in cookies2code.cpp,
 *	Elf.cpp, and Student.cpp
 *
 *
 *	Credit given to:
 *	http://dis.cs.umass.edu/~wagner/threads_html/tutorial.html
 * 	http://greenteapress.com/semaphores/
 *
 *	
 *	Honor Pledge:
 *	I pledge that this assignment has been completed in compliance with 
 *	the Undergraduate Honor Code and that I have neither given nor received
 * 	any unauthorized aid on this assignment.
 *	Signed: Theresa Nelson
 *	
 *
 *****************************************************************************/

#ifndef GLOBAL_SEM_MUTEX_H
#define GLOBAL_SEM_MUTEX_H

// include declarations
#include <semaphore.h>
#include "Semaphore.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <pthread.h>


// set pthread defaults
#define pthread_attr_default NULL
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL


extern pthread_mutex_t grainMutex;		// gain access to grain variable
extern pthread_mutex_t grainAvailableMutex;	// there is grain available
extern pthread_mutex_t eCookiesMutex;		// gain access to elf cookies variable
extern pthread_mutex_t eCookiesAvailableMutex; // there are elf cookies available
extern pthread_mutex_t sCookiesMutex;		// gain access to student cookies variable
extern pthread_mutex_t sCookiesAvailableMutex;	// there are student cookies available
extern pthread_mutex_t codeMutex;		// gain access to code written variable
extern Semaphore tractors;		// keep track of how many tractors are being used
extern Semaphore ovens;		// keep track of how many ovens are being used
extern Semaphore trucks;		// keep track of how many trucks are being used
extern Semaphore computers;		// keep track of how many computers are being used
extern Semaphore threadRendevous;	// keep track of how many threads are done executing

#endif