|
|
@ -100,7 +100,7 @@ class SHMProcess::Private
|
|
|
|
bool SHMProcess::Private::SetAndWait (uint32_t state)
|
|
|
|
bool SHMProcess::Private::SetAndWait (uint32_t state)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint32_t cnt = 0;
|
|
|
|
uint32_t cnt = 0;
|
|
|
|
if(!locked) return false;
|
|
|
|
if(!attached) return false;
|
|
|
|
SHMCMD = state;
|
|
|
|
SHMCMD = state;
|
|
|
|
while (SHMCMD == state)
|
|
|
|
while (SHMCMD == state)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -471,18 +471,26 @@ bool SHMProcess::suspend()
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: this should be controlled on the server side
|
|
|
|
|
|
|
|
// FIXME: IF server got CORE_RUN in this frame, interpret CORE_SUSPEND as CORE_STEP
|
|
|
|
// did we just resume a moment ago?
|
|
|
|
// did we just resume a moment ago?
|
|
|
|
if(D_SHMCMD == CORE_RUN)
|
|
|
|
if(D_SHMCMD == CORE_RUN)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//fprintf(stderr,"%d invokes step\n",d->attachmentIdx);
|
|
|
|
//fprintf(stderr,"%d invokes step\n",d->attachmentIdx);
|
|
|
|
// wait for the next window
|
|
|
|
// wait for the next window
|
|
|
|
D_SHMCMD = CORE_STEP;
|
|
|
|
if(!d->SetAndWait(CORE_STEP))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Error::SHMLockingError("if(!d->SetAndWait(CORE_STEP))");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//fprintf(stderr,"%d invokes suspend\n",d->attachmentIdx);
|
|
|
|
//fprintf(stderr,"%d invokes suspend\n",d->attachmentIdx);
|
|
|
|
// lock now
|
|
|
|
// lock now
|
|
|
|
D_SHMCMD = CORE_SUSPEND;
|
|
|
|
if(!d->SetAndWait(CORE_SUSPEND))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Error::SHMLockingError("if(!d->SetAndWait(CORE_SUSPEND))");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//fprintf(stderr,"waiting for lock\n");
|
|
|
|
//fprintf(stderr,"waiting for lock\n");
|
|
|
|
// we wait for the server to give up our suspend lock (held by default)
|
|
|
|
// we wait for the server to give up our suspend lock (held by default)
|
|
|
@ -495,6 +503,7 @@ bool SHMProcess::suspend()
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: needs a good think-through
|
|
|
|
bool SHMProcess::asyncSuspend()
|
|
|
|
bool SHMProcess::asyncSuspend()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!d->attached)
|
|
|
|
if(!d->attached)
|
|
|
@ -552,16 +561,18 @@ bool SHMProcess::resume()
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
if(!d->suspended)
|
|
|
|
if(!d->suspended)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
// set core to run
|
|
|
|
|
|
|
|
D_SHMCMD = CORE_RUN;
|
|
|
|
|
|
|
|
d->suspended = false;
|
|
|
|
|
|
|
|
// unlock the suspend lock
|
|
|
|
// unlock the suspend lock
|
|
|
|
if(lockf(d->suspend_lock,F_ULOCK,0) == 0)
|
|
|
|
if(lockf(d->suspend_lock,F_ULOCK,0) == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
d->suspended = false;
|
|
|
|
d->locked = false;
|
|
|
|
d->locked = false;
|
|
|
|
|
|
|
|
if(d->SetAndWait(CORE_RUN)) // we have to make sure the server responds!
|
|
|
|
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw Error::SHMLockingError("bool SHMProcess::resume()");
|
|
|
|
throw Error::SHMLockingError("if(d->SetAndWait(CORE_RUN))");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw Error::SHMLockingError("if(lockf(d->suspend_lock,F_ULOCK,0) == 0)");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|