Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!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: <15113@dutrun.UUCP> Date: 18 Mar 91 15:07:10 GMT References: <4861@ns-mx.uiowa.edu> <3095@laura.UUCP> Reply-To: winfwrd@dutrun.tudelft.nl.UUCP (Paul van der Weerd) Organization: Delft University of Technology, The Netherlands Lines: 46 The warning from Hubert Baumeister: >But notice that time slicing is dangerous in the current implementation of the >Smalltalk user interface as shows following example: > ProcessorScheduler startTimeSlicing. > [100 timesRepeat: [Transcript show: 'Process 1';cr]] fork. > [100 timesRepeat: [Transcript show: 'Process 2';cr]] fork. >This will hang up Smalltalk because some recources are not protected against >multiple access. (This is why the example above uses a SharedQueue instead of >a WriteStream) To prevent unprotected simultaneous access to a single Transcript, I took the following approach: ( | p1 p2 t1 t2 | "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: [t1 show: 'A']] newProcess. p2 := [[true] whileTrue: [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. ) Normally this works, but when some windows are overlapping, the system crashes. What is wrong? Question: A forked process is simple to create, but how do you stop it without the process handle? Is something like a ProcessInspector available? -- 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 ...................................................................