-
Notifications
You must be signed in to change notification settings - Fork 1
Processes 101
Dr. Nicola Mingotti edited this page Feb 4, 2022
·
7 revisions
- Here we see how to create, name, prioritize, suspend, resume and terminate a process.
- Open a Transcript window and a the ProcessBrowser ( for example clicking
World -> Open -> Process Browser
) keep them open and run what's next. - We create a process that every second prints in the Transcript window a text line and random number after it, like this:
pr1 _ [ [true] whileTrue: [
Transcript log: 'process runnning -- id: ', (100 atRandom asString) .
(Delay forDuration: (Duration seconds: 1)) wait.
] ] newProcess.
- You should see already pr1 in the ProcessBrowser, but let's give it a name so you will see it better
pr1 name: 'test --- pr1'.
- You should also see in the ProcessBrowser, on the left side, the priority of out new process is 40. As the Morphic UI. We don't like that, we want our processes to have inferior priority in general, just to be sure they are not going to starve our user interface.
- We change the priority of a process with:
pr1 priority: 30.
" or, with more readability and no magic numbers "
pr1 priority: (ProcessorScheduler userBackgroundPriority).
- In the Transcript window you still see no output, indeed the process is by default in a suspended state
pr1 isSuspended . "=> true "
- let's activate the process sending it the
resume
message.
pr1 resume.
- now you see stuff getting printed in the Transcript
- try to freeze it sending the
suspend
message
pr1 suspend.
- When you are sick of the of resume and suspend and you just want to get rid of the process then kill it with:
pr1 terminate.
- Observe that after this you can't see the process in ProcessBrowser any more.
-
Exercise. The 'bomb', a process that will make you loose control of Cuis. Be sure you have nothing to loose in your running Cuis. Redefine pr1 without the 1 second delay. Make pr1 of priority 30, then run it. You will see line+numbers getting printed quite fast in the Transcript but still, you have control of the user interface. Suspend pr1, give it priority 50, higher than the UI, resume it ... bam ! You are almost fried now. You may be able to recover pressing
Alt+.
.