From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <3392e490f654445c44d7a285c14069fb@hamnavoe.com> To: 9fans@9fans.net From: Richard Miller <9fans@hamnavoe.com> Date: Sun, 13 Jun 2010 10:00:26 +0100 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] 9vx, kproc and *double sleep* Topicbox-Message-UUID: 320b4b84-ead6-11e9-9d60-3106f5b1d025 > - splhi -- it's not a true splhi in some sense; is it possible that > some code is sneaking in and running even when you splhi()? Could this > explain it? The error Philippe has found is only indirectly related to splhi(). It's a race between a process in sleep() returning to the scheduler on cpu A, and the same process being readied and rescheduled on cpu B after the wakeup. On native plan 9, A always wins the race because it runs splhi() and the code path from sleep to schedinit (where up->state==Running is checked) is shorter than the code path from runproc to the point in sched where up->state is set to Running. But the fact that this works is timing-dependent: if cpu A for some reason ran slower than cpu B, it could lose the race even without being interrupted. As Philippe explained, in 9vx the cpus are being simulated by threads. Because these threads are being scheduled by the host operating system, the virtual cpus can appear to be running at different speeds or to pause at awkward moments. Even without any "preemption" at the plan 9 level of abstraction, the timing assumption which prevents the sleep - reschedule race is no longer guaranteed.