• 沒有找到結果。

分散式共享記憶體的容錯及執行緒同步機制之研究

N/A
N/A
Protected

Academic year: 2021

Share "分散式共享記憶體的容錯及執行緒同步機制之研究"

Copied!
4
0
0

加載中.... (立即查看全文)

全文

(1)

1

  (I)

 NSC88 - 2213 - E009 - 087

  87 /08 /01 -- 88 /07 /31

   

       Java  deadlock monitor  !"#$%& '()!* +,-./0123! * 456789:91;!<=> ?"@A$BC789:97!DEF G.89:9 HIJK%&'(DEFL6M NOPQ!RSTUDE/0V1%&! FWOXYZZ=[\!W]^O_S 1=!`!abcd'(* +efg h i j \  k l ^ K m n opqNrK st9suvwx NrK y9wt7wvzs{|{vz !DE}3 * .~`€$ 89:9 GK'‚ƒ„!… n†;‡* +e\…ˆ!opDE}3 * L6V‰Š!‹#Œ6ŽX. vz{|vy 6‘$DEFG}3\’!“ ”89:9 HI!DEF•6–3'‚—˜™ šL6›d6(œ! žvz{|vy1;3Ÿ  \¡¢!N£¤¥$¦§¨©eª«* …-¬3Ÿ N…ˆ.—­¥®¯r°±² 89:9 $DE}3* G‹#;³Vf!`€ !ƒ„…´b¯µ¶·¸31op! žvz{|vy $* 45¹ºGBC 89:9 !DE F;³»¡·¸31%&!¼ ½¾€¿ ÀÁ ÃÄ* +eopDE}3* ‰Å¯r¾Vf!ƒ„…´Rƅ-!Ç È.7 7

 (Keywords: distributed shared mem-ory, multi-thread, concurrency control, Java, deadlock, monitor)

There are many synchronized mechanisms an-nounced now, and different platforms or pro-gramming languages have their own suitable solutions. But there are no proper solutions for Java. Java has its own synchronized mechanism, but it is not truly concurrent, it supports a lim-ited form of currency. A programmer must take care of many details when developing concurrent applications. Even there are some solutions are designed for Java, and also let a programmer can develop concurrent applications more conven-iently, but the poor performance is the common problem. Monitor is a technique used in concur-rency control for a long time, Java synchroniza-tion mechanism also take advantages of this

concept a little, but is not enough. This paper will declare the disadvantage of other solutions and will also introduce an approach for enhanc-ing this mechanism in programmenhanc-ing level bye use of our monitors. We will provide libraries and a preprocessor that are helping for concur-rency control. Finally, we will compare our so-lution with others in performance and the com-plexity of coding style.

 

7 7 $ Java GVHI!DEF$ÉÊGË KÌ(ÍÊ'6”wait”Î'(6”notify”,K· '(œÏ! monitora—Ì(ÍÊËO$Ð ÑÒsynchronized ! method © block Ó^†; K!ÉÊ.Wait ¾ notify —Ì( method 6 ÔÕd Object —(ÖוJ6»Ø¸'(Ö × Ó ! method © block Ù †;ÚÐÑÒ synchronizedÛK=¬3ÜÖ×Ýg h°ÞSÜÖ×!”lock”^†;¬3ߌJ r Ú à á â S Ü Ö×!”lock”Nãdظ threadÝ^rÔäÍÊ./0ÜF6(œÏ !DEF1;¬3Ÿ NX…ˆN¥$ å* G©e debug GÙ\æçab•èé K!pêrëҗ˜ìí!<=î/K ï(ð'ñ(Ö×ËK'˜ condition vari-ableòÊ inter-nested ! synchronized method óôÝ”lock”NrÚõAöËOÊ÷à á! signalïQ$ wait !¤nø ¾ù°ú;³û˜ü .

7 7 $`€ Java G!ƒ„…´ýGuard-based system 6ÇÈþ3S!“”· CJava CORRELATE  ; ³ active object [8,12,13,14,15]Vù#6å* …ˆª «èéNépê†6ŽX6Ü ‰Š!‹#.Ü1;Žr6/0 MgK(Í!N! ¾É `€! ÜK†O6Q$Êû( Ê!©e6;'(ÏÛÊ daemon3   Ü !¯rÚ3 R0'(ÍÊ!Ü Î'(<=!¥"#$d¸Ý R ¾ !ÍÊN¤¥63 busy waiting ©e63 wait-notify !…  R ¾  V1=[! context switch 'rNY1 ;¤¥6'˜FË=6–3 guard-based system +!VŽÙNr\.

(2)

2 ì$‘K!DEFpd monitor 6Vý'(ÉÊ\!FV<= ! #0$D'(Ý!"ËrK'( †;$ monitor "#K=C$ monitor !Ý%KVf!Q$ M!ÊÜݗ(&'C$ monitor ! J=ÚàáâS$ monitor "!õ A monitor lock Å^†;C$.Monitor !Î( '( )Œ6MK *+(condition variable) ;³¾V,!Ì(ÍÊ”wait”¾”signal”Û $ monitor "!pì"-! ¤n. Ôä ÝJràá$û( *+ bõAq lock !/K0âSÚVf! ô1( signal ).

7 7 1;r2Œ monitor 6/0 Java HI! DEFJ6–3 monitor !™šaÒ!$ 3šG•\èé4b$Ž…-V context switch•5Ç guard-based system 6=7! 1 ; Ü  < = J689 Java HI:; monitor !DEF¬V†;K( * +b†;R inter-nested !óôaNrK !pê·Ü#; Java  op!}3 <Œ¤¥$å* !=éúG©e$>§ …-ÙrÇ3 Java î 1%&!F6 ! ?@VŽ…-•NrÇȏ.     A  [5] Ó   †;BC'(DH! monitor rKï˜NDù°ú! queue 3  EFGAND!—ï˜ queue H0 entry-queuecondition-queuesignaler-queue ; ³ waiting-queueVý†! queue Kö˜  H 0 entry-queue  signaler-queue  ; ³ waiting-queue†;I—ö˜ queue R q˜ND! monitor†60JKLMN (starvation)O !$Ú signal ÅV †;$ monitor NÚPÍS!EF \Q!Ÿ ;³gO‡$ monitor " - !    † ; R Q !  SaõA monitor lockKÌTUgVW'6ñ( monitor "V queue !!ù°úg=X Î'(Œ6 entry queue !ù°úg61 K queue !‰Y!1;PQ¬3! monitor ËK̘'˜6 blocking monitor Î'˜Œ 6 non-blocking monitor.

Blocking monitorZ!6$monitor"! $ signal û( *+Å=[G‡Ú signal !Ÿ \Œ=àá$ signaler queueÓ1;—ö˜ queue !ù°ú 0 Wp>Sp>Ep(] waiting queue ù°ú^ d signaler queue ^d entry queue).,_! non-blocking monitorŒ6$ signal û( * +Å=`àá$condition queue ÓaS

waiting queueÓbc")a\Œ†; Ôä$ monitor V1=!Ê1;Vù °ú0 Sp>Wp>Ep.Ü̘ monitor ÆKÆ! #$ blocking monitor Ó$ monitor "! û( ‘pê!Ý%$û( condition queue ÓbcÜ !†;N‘ a[GŸ a$ non-blocking monitor ÓQ$!†;'º signal ! *+aN=àáN$bcÜ ! $de")C$ monitor ÝfZg= R !ÍÊ;gÜ monitor 6ßKÚ B*#hKŒ†;A@!C$ monitorß ŒJg")$àá$û( *+.† ;i=2Œ'(jÛ! Monitor· context switchÇÈY!abg NrÚBS!J †;2Œ non-blocking monitor.

7 7 $ nested monitor call …-K̘O [2]:

1. Intra-nested monitor call

D'(Ö×! monitor lock ÚD'( =kº

2. Inter-nested monitor call =kND! monitor lock a. Open call Û=loÜmonitor aC$m '( monitor €=õA €1ÞS! monitor lock. b. Close call $ÞSND! monitor lock ÅËKgàá$û(  *+!Ý%^r¯1ÞS! lockU-õq.

n'˜!nested callË=¯ lock counter o'J † ;Janò˜ nested call $loû( monitor€J=pV counter›V6 close callP= pV monitor Ö×bSS nested callqrî ! monitor.`loÜ monitor €! rs.N$qrî°! monitor ÝK†OKVf!±Q$Ü monitor "tNO[G_rC$Ü monitorg$ '( queue ÓuGv/Ü$¾€!ï˜ queue  'Ÿw! monitor xKy˜ queue>J condition queue (Vfï˜ queue Ù6† queue•6K̘ monitor 6K3 !N$o$uG! queue ÅVù°ú Œ*Ò·1]:

Signal Characteristics Priority

Blocking

Signal and Urgent Wait Ep < Sp < Rp < Wp Priority Blocking (PB) Non-Blocking

Signal and Continue Ep < Rp < Wp < Sp Priority Non-locking (PNB)

(3)

3 Vý Rp ])zo! queue !ù°ú1 ; r—{|}VÁ›0$S inter nested monitor call ÅÜO~Qr î°! monitor ~L6NO[G¤T×!r Ü monitor;LpêN'€! F1;Ü queue!ù°ú Rp '=Yd Wp#O^d Sp!JR‚^d Sp1;JrOÒÜ! F.  H 1Rq !K¾Vfƃ! ƒ„…nR(ÇÈV1„S!+¢]†w q!…nùd`€!Vf…n¤¥6$ Ž…-©e* å!=éúG…r¯ $'"pd†(!,‡ˆG.  ظh=  ‰Š!Vî/N( ‹6ÏF!V1ì!Ž¤nŒ£¬ 3e1;hKÁ›6= ¬3ŽÇÈ N!FL6`€$ Java G!ƒ„…´ #6=k=K!ŽŒVå* !=úr z^>§Né_ #6=kO…ˆ! å* Oåqé4!* ŒVŽf ZNr\/ÜBŽ`€ Java 1%&! DEF$* 45!¹ºG%&¼ ½  ‡* +e¬3;_S…ˆå;³N§ !Ž>Ü(¬3e•†;$NB*¬3 ·D¬3î  Java 1%&!DEF '{Ôä¬31+! monitor.  !

[1].Scott Oaks and Henry Wong, “Java Threads”, O’REILLY & Associates, Inc. 1997

[2]. Andrews, Gregory R. “Concurrent pro-gramming, principles and practice”, New York Benjamin Cummings, 1991

[3].Andrews S. Tanenbaum. “Distributed Oper-ating Systems”, Prentice-Hall, Inc. A Simon & Schuster Company, 1995.

[4]Andrews S. Tanenbaum. “Modern Operating Systems”, Prentice-Hall, Inc. A Simon &

Schuster Company, 1992.

[5].Peter A. Buhr and Michel Fortier. “Monitor Classification,” ACM Computing Surveys, Vol. 27, No. 1, March 1995. pp. 69-73, pp. 89.

[6].Mukesh Singhal. “Deadlock Detection in Distributed Systems,” IEEE Computer, No-vember 1989. pp. 37-40

[7].Young Man Kim; Ten Hwang Lai; Sounda-rajan, N. “Efficient distributed deadlock de-tection and resolution using probes, tokens, and barriers”, IEEE Parallel and Distributed Systems, 1997. Proceedings. pp. 584-590.

[8].Martin Carroll, “Active Objects Made Easy,” PRACTICE AND EXPERIENCE, Vol. 28(1), 1-21, January 1998. pp. 1-5, pp. 13-20.

[9].Jose R. Gonzalez de Mendivil, Federico Fa-rina, Carlos F. Alastruey. “ A safe distributed deadlock resolution algorithm”, Journal of Systems Architecture 1998. pp. 887-891

[10].Miyoshi, A.; Kitayama, T.; Tokuda, H. “Implementation and Evaluation of Real-Time Java Threads”, Real-Time Sys-tems Symposium, 1997. Proceedings., The 18th IEEE, pp. 166-173

[11].Demartini, C.; Sisto, R. “Static analysis of Java multithreaded and distributed applica-tions”, IEEE Software Engineering for Par-allel and Distributed Systems, 1998. Pro-ceedings. pp. 215-221.

(4)

4 [12].Carlos A. Varela, Gul A. Agha. “What after

Java? From objects to actors”, Computer Networks and ISDN Systems 1998. pp. 573-576.

[13].Gianpaolo Cugola and Carlo Ghezzi. “Cjava: Introduction concurrent Objects in Java” Dipartimento di Elettronica e Infor-mazione, Politecnico di Milano.

[14].Chao-Hsin Lin; Elrad, T. “An enhanced reflective architecture for adaptation of the object-oriented language/software”, IEEE Software Engineering Conference, 1998. Proceedings. pp. 20-24.

[15].Ciaran McHale “Synchronization in Con-current Object-oriented Languages: Expres-sive Power, Genericity and Inheritance”, A thesis submitted to University of Dublin, Trinity College.

[16].http://java.sun.com/docs/books/jls/html/ind ex.html

[17].C. H. Wu “Enhancing Thread Synchroni-zation Mechanism of Java“ Master Thesis, Institute of Computer and Information Sci-ence, College of Electrical Engineering and Computer Science, National Chiao Tung University, June 1998.

參考文獻

相關文件

Overview of a variety of business software, graphics and multimedia software, and home/personal/educational software Web applications and application software for

To assist with graphics and multimedia projects To assist with graphics and multimedia projects To support home, personal, and educational tasks To support home, personal,

important to not just have intuition (building), but know definition (building block).. More on

研究不同的、新的教學方法/模式 試教行動 Æ 分享經驗 Æ

For better efficiency of parallel and distributed computing, Apache Hadoop distributes the imported data randomly on data nodes.. This mechanism provides some advantages

Selcuk Candan, ”GMP: Distributed Geographic Multicast Routing in Wireless Sensor Networks,” IEEE International Conference on Distributed Computing Systems,

D.Wilcox, “A hidden Markov model framework for video segmentation using audio and image features,” in Proceedings of the 1998 IEEE Internation Conference on Acoustics, Speech,

Different types of customers to their pet's health will be different values and knowledge, this study questionnaires were distributed and 280 min, recovery 252, the use