This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
csce313-mp4pinie64backup/semaphore.h

81 lines
1.7 KiB
C
Raw Normal View History

2015-11-05 18:33:21 -06:00
/*
File: semaphore.H
Author: R. Bettati
Department of Computer Science
Texas A&M University
Date : 08/02/11
*/
#ifndef _semaphore_H_ // include file only once
#define _semaphore_H_
/*--------------------------------------------------------------------------*/
/* DEFINES */
/*--------------------------------------------------------------------------*/
/* -- (none) -- */
/*--------------------------------------------------------------------------*/
/* INCLUDES */
/*--------------------------------------------------------------------------*/
#include <pthread.h>
#include <mutex>
/*--------------------------------------------------------------------------*/
/* DATA STRUCTURES */
/*--------------------------------------------------------------------------*/
/* -- (none) -- */
/*--------------------------------------------------------------------------*/
/* FORWARDS */
/*--------------------------------------------------------------------------*/
/* -- (none) -- */
/*--------------------------------------------------------------------------*/
/* CLASS S e m a p h o r e */
/*--------------------------------------------------------------------------*/
class Semaphore {
private:
/* -- INTERNAL DATA STRUCTURES
You may need to change them to fit your implementation. */
int value;
pthread_mutex_t m;
pthread_cond_t c;
public:
/* -- CONSTRUCTOR/DESTRUCTOR */
Semaphore(int _val){value = _val;}
~Semaphore(){}
/* -- SEMAPHORE OPERATIONS */
int P(){
Lock();
}
//;
int V();
};
/*
class BoundBuffer{
Semaphore full(n);
Semaphore empty(n);
Semaphore mutex(n);
};
*/
#endif