To make it clear I am a student with a question and have read the Posting Guidelines, here is what I have written:
It is contained within a file called synch.cc
Lock::Lock(char * debugName)
{
name = debugName;
lockHolder = NULL; // no thread yet holds lock
Semaphore(name, 1);
}
Lock::~Lock()
{
delete lockHolder;
}
void Lock::Acquire()
{
IntStatus oldLevel = interrupt->SetLevel(IntOf f);
semaphore->P();
(void) interrupt->SetLevel(oldLe vel);
}
void Lock::Release()
{
IntStatus oldLevel = interrupt->SetLevel(IntOf f);
ASSERT(isHeldBy CurrentThread() );
if(isHeldByCurr entThread())
{
semaphore->V();
}
(void) interrupt->SetLevel(IntOf f);
}
bool Lock::isHeldByC urrentThread()
{
IntStatus oldLevel = interrupt->SetLevel(IntOf f);
if(currentThrea d == lockHolder)
return true;
(void) interrupt->SetLevel(oldLe vel);
}
and I added this to the synch.h under the class lock private section
Semaphore *semaphore;
when I run a test on the code it gives me a segmentation error(core dumped) I am stuck and don't know what to do any thoughts?
It is contained within a file called synch.cc
Lock::Lock(char * debugName)
{
name = debugName;
lockHolder = NULL; // no thread yet holds lock
Semaphore(name, 1);
}
Lock::~Lock()
{
delete lockHolder;
}
void Lock::Acquire()
{
IntStatus oldLevel = interrupt->SetLevel(IntOf f);
semaphore->P();
(void) interrupt->SetLevel(oldLe vel);
}
void Lock::Release()
{
IntStatus oldLevel = interrupt->SetLevel(IntOf f);
ASSERT(isHeldBy CurrentThread() );
if(isHeldByCurr entThread())
{
semaphore->V();
}
(void) interrupt->SetLevel(IntOf f);
}
bool Lock::isHeldByC urrentThread()
{
IntStatus oldLevel = interrupt->SetLevel(IntOf f);
if(currentThrea d == lockHolder)
return true;
(void) interrupt->SetLevel(oldLe vel);
}
and I added this to the synch.h under the class lock private section
Semaphore *semaphore;
when I run a test on the code it gives me a segmentation error(core dumped) I am stuck and don't know what to do any thoughts?
Comment