From: Thomas Veerman Date: Fri, 9 Dec 2011 10:43:13 +0000 (+0000) Subject: Discard process' pending request upon incoming PM request X-Git-Tag: v3.2.0~178 X-Git-Url: http://zhaoyanbai.com/repos/man.isc-hmac-fixup.html?a=commitdiff_plain;h=94da86cbeec0c6673400e63b759faf025b6b24e4;p=minix.git Discard process' pending request upon incoming PM request When a process wants something done from VFS, but VFS has no worker threads available, the request is stored and executed later. However, when PM also sends a request for that process at the same time, discard the pending request from the process and give priority to PM. The request PM sends is either an EXIT or a DUMPCORE request, so we're not interested in executing the pending request anyway. --- diff --git a/servers/avfs/main.c b/servers/avfs/main.c index eccfc82a5..02deb4ce9 100644 --- a/servers/avfs/main.c +++ b/servers/avfs/main.c @@ -881,9 +881,15 @@ PRIVATE void service_pm() okendpt(m_in.PM_PROC, &slot); fp = &fproc[slot]; - assert(!(fp->fp_flags & FP_PENDING)); - fp->fp_job.j_m_in = m_in; - fp->fp_flags |= FP_PM_PENDING; + if (fp->fp_flags & FP_PENDING) { + /* This process has a request pending, but PM wants it gone. + * Forget about the pending request and satisfy PM's request + * instead. Note that a pending request AND an EXEC request + * are mutually exclusive. Also, PM should send only one + * request/process at a time. + */ + assert(fp->fp_job.j_m_in.m_source != PM_PROC_NR); + } /* PM requests on behalf of a proc are handled after the system call * that might be in progress for that proc has finished. If the proc @@ -891,9 +897,11 @@ PRIVATE void service_pm() if (!(fp->fp_flags & FP_PENDING) && mutex_trylock(&fp->fp_lock) == 0) { mutex_unlock(&fp->fp_lock); worker_start(do_dummy); - yield(); } + fp->fp_job.j_m_in = m_in; + fp->fp_flags |= FP_PM_PENDING; + return; case PM_FORK: