非同期割り込みに対する対処案(日本語版)

(2012/06/26 5:05), SASADA Koichi wrote:

$B$J$s$H$J$/!$5v$5$J$$J}$,$$$$$h$&$J5$$,$9$k$s$@$1$I(B

(3)$B$H$"$o$;$F%V%m%C%/I,?$@$HA4%W%m%0%i%`$,0lCJ%M%9%H$,?<$/$J$k$N$G(B
$B$&$l$7$/$J$$$J$"(B

$B!!$3$3$O!$C/$+0N$$?M$K%G%6%$%s$rG$$;$?$$$H$3$m$J$s$G$9$,(B…$B!%(B

$B!!%V%m%C%/I,?$8$c$J$$$H!$ITFO$-$J%i%$%V%i%j$,@_Dj$rJQ$($F$7$^$$!$0U?^$7(B
$B$J$$JQ99$,5/$-$k$N$G!$$^$:$$$s$8$c$J$$$+$H;W$$$O$8$a$^$7$?!%(B

def foo
Thread.interrupt_mask($B3d$j9~$_5v2D(B)
end

Thread.interrupt_mask($B3d$j9~$6X;(B) do
foo()
… # $B3d$j9~$_5v2D$K$J$C$F$7$^$&(B
end

$B!!=i4|>uBV$O!$JL$NJ}K!!JNc$($P!$%3%^%s%I%i%$%*%W%7%g%s$d4D6-JQ?t!K$GEO$9(B
$B$N$,$$$$$h$&$J5$$,$7$F$$$^$9!%$I$&$G$7$g$&$+!%(B

end

$B$G$O!$:.$<$F$$$/>l9g$O(B block $B$G$O(B param1 & param2
$B$,8z$-$^$9$,!$CV$-49$((B
$B$k>l9g$H$O!$$3$l$r(B param2 $B$7$+(B
$B8z$+$J$/$9$k$N$O$I$&$@$m$&!$$H$$$&$3$H(B
$B$G$9!%30B&$O0l@Z8+$J$$!%(B

$B!!$3$l$@$H!$%O%C%7%e$r;H$$2s$9$H$$$&$+!$$h$/$d$k!V(Bakr $B$,A&$a$k$@$$$?$$0B(B
$BA4%;%C%H!W!V(Bkosaki $BG’Dj@dBP0BA4%;%C%H!W$_$?$$$J$N$r:n$C$F$=$l$r;H$&MM$K(B
$B$9$k$H!$Kh2s(B Hash $B$r:n$i$J$/$J$C$F!$$h$/$J$k$+$b!%(B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Bj$J$$$H;W$&$N$G$9$,!"(B
$B2?$+8+Mn$H$7$F$$$k$G$7$g$&$+!#(B

(1) $B$H(B (2) $B$N4V$N3d$j9~$_$rKI$0$?$a$K(B

Thread.mask_interrupt(Exception, :blocking_interruptible) do # (0)
begin
# begin $B!A(B ensure $BFb$G$N3d$j9~$$O$$$D$G$b5v$9(B
Thread.mask_interrupt(Exception, :immediate_interruptible) do
# $B2?$+=hM}(B
end
ensure # (1)
# (0) $B$N$*$+$2$G$3$N4V$K3d$j9~$^$l$k$3$H$O$J$$(B
Thread.mask_interrupt(Exception, :uninterruptible) do (2)
# $B0lEYA4It3d$j9~$6X;$K$7$F(B
Thread.mask_interrupt(SignalException, :blocking_interruptible)
do
# $B%7%0%J%k$@$13d$j9~$
$r5v$7$F(B
# $B%j%=!<%92rJ|=hM}(B
end
end
end
end

2012$BG/(B7$B7n(B2$BF|(B 20:29 SASADA Koichi [email protected]:

$B!!(B(0) $B=q$-$?$/$M!<$h!!!$F$JOC$J$N$+$J$!!$$H$b;W$C$?$N$G$9$,!$$I$&$G$7$g(B
$B$&!%8D?ME
$K$O!$$3$l$GNI$1$l$P$3$l$G9T$-$?$$5$$,$7$^$9!%(B

$B$“$/$^$G(B primitive $B$NOC$J$s$G$9$h$M!)(B
$B<B:]$K=q$-$?$$$+$I$&$+$G$$$&$H!”(Bensure $B$NCf$NFs=E$N(B
mask_interrupt $B$b(B
$B8D?ME*$K$O=q$-$?$/$J$$$G$9!#(B

(2012/07/02 20:14), Yusuke E. wrote:

ensure # (1)

$B!!(B(0)
$B=q$-$?$/$M!<$h!!!$F$JOC$J$N$+$J$!!$$H$b;W$C$?$N$G$9$,!$$I$&$G$7$g(B
$B$&!%8D?ME
$K$O!$$3$l$GNI$1$l$P$3$l$G9T$-$?$$5$$,$7$^$9!%(B

(2012/07/02 20:35), Yusuke E. wrote:

$B<B:]$K=q$-$?$$$+$I$&$+$G$$$&$H!"(Bensure $B$NCf$NFs=E$N(B mask_interrupt
$B$b(B
$B8D?ME*$K$O=q$-$?$/$J$$$G$9!#(B

$B!!=q$-$?$/$J$kMM$J%$%s%?!<%U%’!<%9$NOC$KC&@~$7$^$9$,!$(B

ensure
Thread.mask_interrupt(
Exception => :uninterruptible,
SignalException => :blocking_interruptible) do
# $B2rJ|(B
end
end

$B$J$iNI$$$H$$$&OC!)(B
$B$=$l$H$b>e5-%Q%?!<%s$r9T$&C;$$L>A0$rMQ0U!)(B
$B$=$l$H$b(B ensure $B$K$J$s$+:Y9)$9$k;EAH$_$rJLESMQ0U!)(B

2012/7/2 Tanaka A. [email protected]:

2012$BG/(B6$B7n(B29$BF|(B 19:41 KOSAKI Motohiro [email protected]:

$B;d<+?H$O8=:_$N;EMM$O2u$l$F$$$k$H;W$C$F$*$j!"%G%U%)%k%H$rJQ$($k$N$K$O(B
$BH?BP$8$c$J$$$s$G$9$,$I$&JQ$($k$H$$$&0U?^$G$7$g$&$+!#(B
$B%G%U%)%k%H$,(B :blocking $B$H$$$&0UL#$G$7$g$&$+!)(B

$B%7%0%J%k0J30$K$D$$$F$O%V%m%C%/$7$&$k$H$3$m$GNc30H/@8!“(B
$B%7%0%J%k$K$D$$$F$O$I$3$G$bNc30H/@8!”(B
$B$H$$$&$N$,%G%U%)%k%H$@$H$$$$$s$8$c$J$$$+$J$!!"$H;W$C$F$$$^$9!#(B

$B$J$k$[$I!#(B
$B%5!<%P!<%“%W%j%1!<%7%g%s$@$H(B Ctrl+C
$B$O;H$o$J$$$3$H$,B?$$$N$G!”$I$N%f!<%9%1!<%9$K$b(B
$B$$$$%G%U%)%k%H$J5$$,$7$^$9!#$A$c$s$H9M$($F$$$^$;$s$,!#(B

$B%7%0%J%k$K$D$$$F$O$b$&$9$3$7:Y$+$/J,N`$7$F5sF0$rJQ$($F$b$$$$$+$b$7$l$^$;$s$,!#(B

SIGUSR$B$O(B blocking$B$H$+$=$&$$$&0UL#$G$9$+$M!#(B

  1. ruby repository
    $B$N(Btest$B$G$O(BSIGINT$B$P$+$j;H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