Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!dutrun!winfwrd From: winfwrd@dutrun.UUCP (Paul van der Weerd) Newsgroups: comp.lang.smalltalk Subject: Re: anyone using time-sliced scheduling w/st80? Message-ID: <15211@dutrun.UUCP> Date: 22 Mar 91 14:33:22 GMT References: <4861@ns-mx.uiowa.edu> <3095@laura.UUCP> <15113@dutrun.UUCP> <3109@laura.UUCP> Reply-To: winfwrd@dutrun.tudelft.nl.UUCP (Paul van der Weerd) Organization: Delft University of Technology, The Netherlands Lines: 62 In article <3109@laura.UUCP>, huba@ls5.informatik.uni-dortmund.de, (Hubert Baumeister) writes: >... >I suppose you use Smalltalk 80 v2.5 or earlier. These versions assume that >when drawing on a window this window is completely visible. To achieve this the >TextCollectorViews use the method displaySafe: aBlock in ControlManager. This >method tops the window and executes aBlock. >When both TextCollectorViews want to display themselves at the same time >there is a race condition in displaySafe:. Indeed the ControlManager gets lost (Smalltalk-80 v2.5). So I extended the example with extra protection: | p1 p2 t1 t2 displayMutex | "Protect the display code." displayMutex _ Semaphore forMutualExclusion. "Define some textcollectors." [t1 := TextCollector new. TextCollectorView open: t1 label: 'Process 1'] fork. [t2 := TextCollector new. TextCollectorView open: t2 label: 'Process 2'] fork. "Define some processess." p1 := [[true] whileTrue: [displayMutex critical: [t1 show: 'A']]] newProcess. p2 := [[true] whileTrue: [displayMutex critical: [t2 show: 'B']]] newProcess. "Run processes alternately." (p1 priority: 3) resume. (p2 priority: 3) resume. 300 timesRepeat: [ (Delay forMilliseconds: 200) wait. (Processor suspendFirstAt: 3) resume]. p1 terminate. p2 terminate. This works fine. Also the appearance of the display during execution is okay. Hubert Continues: >In Smalltalk Release 4.0 this works fine since there it is possible to draw on >partly hidden windows and thus it needs no hack like the one described above. Hearing the word "hack" I added a classVariable DisplayMutex to StandardSystemView and changed the class initialization method in: !StandardSystemView class methodsFor: 'class initialization'! initialize FillInHoles _ true. DisplayMutex _ Semaphore forMutualExclusion! ! This also works fine (no loss of control), but the display becomes a mess during execution (use restore display afterwards). Is this the kind of hack you had in mind? -- Paul van der Weerd Tel. +31 15 782523 Delft University of Technology Fax. +31 15 786522 Dept. of Computer Science Email winfwrd@dutrun.tudelft.nl Julianalaan 132 2628 BL Delft The Netherlands ...................................................................