[squeak-dev] The Trunk: Kernel-ul.515.mcz
leves at elte.hu
Mon Nov 15 19:45:13 UTC 2010
On Mon, 15 Nov 2010, Juan Vuletich wrote:
> Hi Folks,
> Please also restore Semaphore>>critical:ifLocked: It already includes this
> comment: "Note: The following is tricky and depends on the fact that the VM
> will not switch between processes while executing byte codes (process
> switches happen only in real sends). The following test is written carefully
> so that it will result in bytecodes only."
> To be more explicit, in Cuis it also says: "Do not change the following #==
> for #=, as #== is not a real message send, just a bytecode."
It's unnecessary, because #= also has it's own bytecode in the current
VM. So #= won't be a real message send in this case, because both
excessSignals and 0 are SmallIntegers.
Also, this method has a bug. There's no guarantee, that the sender won't
wait for the semaphore. I uploaded a fix to the Inbox for review recently,
though I didn't get any feedback on it:
> Juan Vuletich
>> 2010/11/15 <commits at source.squeak.org>:
>>> Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
>>> ==================== Summary ====================
>>> Name: Kernel-ul.515
>>> Author: ul
>>> Time: 15 November 2010, 10:32:19.849 am
>>> UUID: 2254c085-e86b-ef4e-916c-4e2008a6e9dc
>>> Ancestors: Kernel-ul.513
>>> - use #= for integer comparison instead of #==
>>> (http://bugs.squeak.org/view.php?id=2788 )
>>> =============== Diff against Kernel-ul.513 ===============
>>> Item was changed:
>>> Item was changed:
>>> ----- Method: Semaphore>>critical:ifLocked: (in category 'mutual
>>> exclusion') -----
>>> critical: mutuallyExcludedBlock ifLocked: alternativeBlock
>>> "Evaluate mutuallyExcludedBlock only if the receiver is not
>>> currently in
>>> the process of running the critical: message. If the receiver is,
>>> mutuallyExcludedBlock after the other critical: message is
>>> "Note: The following is tricky and depends on the fact that the VM
>>> will not switch between processes while executing byte codes (process
>>> switches happen only in real sends). The following test is written
>>> carefully so that it will result in bytecodes only."
>>> + excessSignals = 0 ifTrue:[
>>> - excessSignals == 0 ifTrue:[
>>> "If we come here, then the semaphore was locked when the
>>> test executed.
>>> Evaluate the alternative block and answer its result."
>>> ^alternativeBlock value
>>> ^self critical: mutuallyExcludedBlock!
More information about the Squeak-dev