Issue #3251 has been updated by kosaki (Motohiro KOSAKI).


?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????mutex??????????
???????????????semaphoe??????????????????????????
----------------------------------------
Feature #3251: allow to unlock mutex locked by another thread
https://bugs.ruby-lang.org/issues/3251#change-27435

Author: mame (Yusuke Endoh)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 2.0.0


=begin
 ???????????
 
 ????? mutex ??? lock ?????????????????????????? unlock ?????????????????
 ?????????許??????????????????????????????????? 2 ??????????????
 
 1) Python ??? condition variable ??? mutex ?????????????????? unlock
    ??????????????????????????????????????似??????
 2) Thread#raise ??? race condition ??????使????????????????? (??????????)
 
 
 1 ?????????Python ??? condition variable ??以????????????????????
 ?????????????????
 
   def wait(m1)
     m2 = Mutex.new
     m2.lock
     @waiters << m2
     m1.unlock
     begin
       m2.lock
     ensure
       m1.lock
     end
   end
 
   def signal
     @waiters.shift.unlock
   end
 
 ????????wait ?????????? mutex ??? lock ???????????????????????????????????
 signal ??? mutex ?????????????????? unlock ?????????????????????????????
 ???????????????????????????
 ???? ConditionVariable ????????大??????????????????????????????????
 Python ????似????????????????????????????????
 
 # 権??主義
 
 
 2 ????????????? Thread#raise ???以??????????? race ???????????????
 
   t1: begin ????????????????
   t2: t1.raise ??????
   t1: rescue/ensure ???????????????????
   t3: t1.raise ??????
   t1: rescue/ensure ?????????????????????度????????????????
 
 # ?????????? race ????????????????????
 
 ????????????Thread#raise ??????? Mutex#lock ???????????????????????????
 race ?????????使?????????????????????????????????????????????????
 
   t1: begin ????????????????
   t2: m.lock; t1.raise ??????
   t1: rescue/ensure ???????????????????
   t3: m.lock ???止??????????? t1.raise ????????
   t1: 次?????????????込??????????????????????? m.unlock ??????
   t3: m.lock ?????????? t1.raise ??????
 
 -- 
 Yusuke Endoh <mame / tsg.ne.jp>
=end



-- 
http://bugs.ruby-lang.org/