/**
*
* Esta clase simula las funciones de Locks
*
* Autor: Sistemas Operativos (Francisco Arroyo)
*
* Fecha: 2023/Abr/23
*
**/
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "Lock.h"
/**
* Creates a lock, using a semaphore
**/
Lock::Lock() {
lock = new Semaphore( 1, 1 );
}
/**
* Destroys the lock
**/
Lock::~Lock() {
delete this->lock;
}
/**
* Acquires the lock
*
**/
void Lock::Acquire() {
this->lock->Wait();
}
/**
* Release the lock
*
**/
void Lock::Release() {
this->lock->Signal();
}