Process.st
author Stefan Vogel <sv@exept.de>
Tue, 28 Apr 2020 11:49:45 +0200
changeset 25367 e117c14e2800
parent 25244 6df56799dd3e
permissions -rw-r--r--
#BUGFIX by stefan class: FileStream changed: #copy:into:bufferSize: #position #position: Linux: sendfile() fix.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24844
334662dd5a40 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24819
diff changeset
     1
"{ Encoding: utf8 }"
334662dd5a40 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24819
diff changeset
     2
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     3
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     4
 COPYRIGHT (c) 1992 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
     5
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
"
5377
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
    14
"{ Package: 'stx:libbasic' }"
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
    15
17407
e82159e43f55 class: Process
Stefan Vogel <sv@exept.de>
parents: 17244
diff changeset
    16
"{ NameSpace: Smalltalk }"
e82159e43f55 class: Process
Stefan Vogel <sv@exept.de>
parents: 17244
diff changeset
    17
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
Link subclass:#Process
19292
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
    19
	instanceVariableNames:'id lookupActivations lookupDisabled prio state startBlock name
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
    20
		restartable interruptActions exitActions suspendSemaphore
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
    21
		singleStepping emergencySignalHandler suspendActions creatorId
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
    22
		processGroupId interruptsDisabled priorityRange
21324
7913ef769c20 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21313
diff changeset
    23
		exceptionHandlerSet processType environment startTimestamp'
16562
Claus Gittinger <cg@exept.de>
parents: 16421
diff changeset
    24
	classVariableNames:'TerminateSignal RestartSignal CaughtSignals'
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    25
	poolDictionaries:''
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    26
	category:'Kernel-Processes'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    27
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    28
1784
af6446feffae optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
    29
!Process class methodsFor:'documentation'!
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    30
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    31
copyright
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    32
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    33
 COPYRIGHT (c) 1992 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
    34
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    35
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    36
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    37
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    38
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    39
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    40
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    41
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    42
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    43
!
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    44
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    45
documentation
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    46
"
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
    47
    WARNING:
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    48
        the offsets of the instance variables lookupActivations and lookupDisabled are known in the VM
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
    49
        do not remove them, and do not insert/remove instance variables before them
18189
e06ab6591712 hardcoding instvar offsets is VERY BAD (fix for Jan's lookup bug)
Claus Gittinger <cg@exept.de>
parents: 17544
diff changeset
    50
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
    51
    Instances of Process represent lightweight smalltalk processes
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    52
    (i.e. threads). These all run in a shared smalltalk/X address space,
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    53
    and can thus access and communicate via any objects.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    54
    Do not confuse these with (heavy-weight) unix processes, which are
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    55
    created differently, and do NOT run in the same address space.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    56
    Also notice, that heavy-weight process creation takes much longer.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    57
    (see OperatingSystemclass>>fork).
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    58
21777
15ec3200837d #OTHER by mawalch
mawalch
parents: 21668
diff changeset
    59
    Smalltalk processes do not necessarily need to be implemented as native
4646
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
    60
    threads - it may, but the actual implementation depends on the underlying
21777
15ec3200837d #OTHER by mawalch
mawalch
parents: 21668
diff changeset
    61
    OS's features. However, even if implemented as native thread, the ST/X
4646
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
    62
    kernel makes certain, that only one thread executes at a time (with certain,
20230
47a4de3366cf #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 20067
diff changeset
    63
    well-defined exceptions). The reason is that the required locking in the
4646
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
    64
    runtime system would make things slower in most cases.
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
    65
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    66
    Processes are typically created by sending #fork or #forkAt: to a block;
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    67
    the block creates a new process, defines itself as its startBlock,
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    68
    and (optionally) tells the Processor about the new process.
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    69
4646
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
    70
    Scheduling is done by Processor, which is the sole instance of ProcessorScheduler.
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
    71
    In ST/X, the scheduling algorithms are fully implemented (and visible) on the
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
    72
    smalltalk level - beside the threadSwitch primitive, there is virtually no VM
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
    73
    support (i.e. it can be easily changed).
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
    74
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    75
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    76
    Processes can be terminated either soft or via a hardTerminate.
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    77
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    78
    A soft terminate (see Process>>terminate) will raise a TerminationSignal
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
    79
    in the process, which can be handled by the process.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
    80
    If no other handler was specified, the processes own handler
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
    81
    (see Process>>start) will catch the signal and terminate the process.
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    82
    During this signal processing, normal unwind processing takes place,
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
    83
    this means that with a soft terminate, all valueOnUnwind:/valueNowOrOnUnwind:
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    84
    cleanup blocks are evaluated.
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    85
    (so a process which has set up those blocks correctly does not have to
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    86
     care especially about cleanup in case of termination).
2689
ada9b102abcf typo fix
Claus Gittinger <cg@exept.de>
parents: 2636
diff changeset
    87
    Other than that, the TerminateSignal can be caught for special cleanup or
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    88
    even to make the process continue execution.
4415
dff1649c072c resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
    89
    If the process is suspended at termination time, it will be resumed
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
    90
    in order to perform its cleanup actions (i.e. the cleanup is always
4415
dff1649c072c resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
    91
    done in the context of the terminating process itself).
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    92
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    93
    A hard terminate (Process>>terminateNoSignal) will NOT do all of the above,
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    94
    but quickly (and without any cleanup) terminate the process.
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    95
    The debugger offers a quickTerminate option on its popupMenu for
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    96
    situations, when soft termination fails. (for example, if some error was
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    97
    coded into a handler or unwind block).
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    98
20777
4814f57b71d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20682
diff changeset
    99
    Leaving the processes startBlock has the same effect as a soft-terminate
4415
dff1649c072c resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   100
    (i.e. there is no need to send an explicit terminate).
dff1649c072c resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   101
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   102
    Notice:
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   103
        in Smalltalk/X, processes are gone, when an image is restarted;
21777
15ec3200837d #OTHER by mawalch
mawalch
parents: 21668
diff changeset
   104
        this means that you have to take care of process re-creation yourself.
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   105
        Usually, this is done by depending on ObjectMemory, recreating the
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   106
        process(es) when the #returnFromSnapshot-change notifiction arrives.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   107
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   108
        All views (actually windowGroups) recreate their window process
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   109
        on image-restart. You have to do so manually for your own processes.
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   110
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   111
    A later version will allow specification of automatic restart, but
13563
a82e5ddf671a changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 13398
diff changeset
   112
    that's not yet implemented. However, even when implemented, restartable processes
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   113
    will be recreated to restart from the beginning. It will not be possible to
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   114
    automatically continue a processes execution where it left off.
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   115
    This is a consequence of the portable implementation of ST/X, since in order to
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   116
    implement process continuation, the machines stack had to be preserved and
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   117
    recreated.  Although this is possible to do (and actually not too complicated),
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   118
    this has not been implemented, since the machines stack layout is highly machine/compiler
375
claus
parents: 359
diff changeset
   119
    dependent, thus leading to much bigger porting effort of ST/X (which conflicts
claus
parents: 359
diff changeset
   120
    with ST/X's design goal of being highly portable).
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   121
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   122
    Process synchronization:
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   123
        Synchronization with cooperating processes is supported as usual,
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   124
        via Semaphores (see Semaphore, Delay, SharedQueue etc.)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   125
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   126
        With uncooperative processes, only synchronization on suspend
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   127
        and termination is possible:
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   128
          any other process can wait for a process to suspend or terminate.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   129
          This waiting is implemented by using suspendSemaphore and exitBlocks
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   130
          (where an exitSemaphore is signalled).
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   131
          See waitUntilSuspended / waitUntilTerminated.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   132
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   133
    Implementation note:
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   134
        for historic and compatibility reasons, Process is a subclass of Link,
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   135
        which means, that instances are directly usable as nodes in a linkedList.
21777
15ec3200837d #OTHER by mawalch
mawalch
parents: 21668
diff changeset
   136
        However, this also means that processes can only be elements of a single LinkedList.
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   137
        This is somewhat dangerous, as unknowledgable programmers may unwillingly break the
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   138
        scheduler, by placing a process onto another linked list.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   139
        Therefore, we plan to change this in the future.
21777
15ec3200837d #OTHER by mawalch
mawalch
parents: 21668
diff changeset
   140
3784
181c246ea421 comment
Claus Gittinger <cg@exept.de>
parents: 3783
diff changeset
   141
    Process states:
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   142
        #dead           process has (been) terminated;
21777
15ec3200837d #OTHER by mawalch
mawalch
parents: 21668
diff changeset
   143
                        the process instance has no underlying
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   144
                        thread.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   145
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   146
        #run            the process is willing to run,
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   147
                        but not active (i.e. another higher prio
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   148
                        process is currently executing)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   149
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   150
        #active         the process is the current process
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   151
                        (there is only one)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   152
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   153
        #ioWait         waiting on some io-related semaphore
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   154
                        (typically in #readWait / #writeWait)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   155
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   156
        #eventWait      waiting on some GUI event
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   157
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   158
        #timeWait       waiting on a timer-related semaphore
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   159
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   160
        #wait           waiting on some (other) semaphore
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   161
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   162
        #suspended      stopped from execution; however, an interrupt
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   163
                        will return it into the run state.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   164
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   165
        #stopped        stopped from execution; an interrupt will
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   166
                        NOT return it into the run state (for debugging)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   167
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   168
        #debug          debugger sitting on top of the processes
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   169
                        stack.
3784
181c246ea421 comment
Claus Gittinger <cg@exept.de>
parents: 3783
diff changeset
   170
181c246ea421 comment
Claus Gittinger <cg@exept.de>
parents: 3783
diff changeset
   171
    Win32 only:
181c246ea421 comment
Claus Gittinger <cg@exept.de>
parents: 3783
diff changeset
   172
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   173
        #osWait         waiting on an OS-API call to finish.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   174
                        can be interrupted, terminated and aborted
21777
15ec3200837d #OTHER by mawalch
mawalch
parents: 21668
diff changeset
   175
                        (i.e. the usual context actions are possible).
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   176
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   177
        #halted         thread was caught while in a blocking API call
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   178
                        or primitive endless loop and has been halted by
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   179
                        the scheduler.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   180
                        Can only be resumed or hard-terminated - abort
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   181
                        or soft terminate or unwind actions are not possible.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   182
                        (due to win32 limitations)
3784
181c246ea421 comment
Claus Gittinger <cg@exept.de>
parents: 3783
diff changeset
   183
181c246ea421 comment
Claus Gittinger <cg@exept.de>
parents: 3783
diff changeset
   184
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   185
    [Instance variables:]
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   186
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   187
        id                     <SmallInteger>   a unique process-id
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   188
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   189
        creatorId              <SmallInteger>   the id of the process that
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   190
                                                created me (useful for debugging
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   191
                                                or monitoring).
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   192
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   193
        processGroupId                          usually the id of the creator,
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   194
                                                unless the process detached from
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   195
                                                the group and became a groupLeader.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   196
                                                Groups can be easily terminated
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   197
                                                as a whole.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   198
                                                Group leaders have a groupId of nil.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   199
                                                A groupId of 0 (zero) marks a system
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   200
                                                process; these do not prevent a standAlone
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   201
                                                app from exiting.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   202
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   203
        prio                   <SmallInteger>   the processes priority
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   204
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   205
        priorityRange          <Interval>       the processes dynamic priority range
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   206
                                                (or nil)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   207
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   208
        state                  <Symbol>         the processes state
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   209
                                                (for process-monitor)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   210
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   211
        startBlock             <Block>          the startup-block (the one that forked)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   212
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   213
        name                   <String-or-nil>  the processes name (if any)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   214
                                                (for process-monitor)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   215
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   216
        suspendSemaphore       <Semaphore>      triggered when suspend (if nonNil)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   217
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   218
        restartable            <Boolean>        is restartable; if true, the process
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   219
                                                will be restarted when an image is
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   220
                                                restarted. Otherwise, it remains dead.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   221
                                                Running processes cannot be continued
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   222
                                                at the point where leftOff after an
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   223
                                                image-restart.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   224
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   225
        interruptActions       <Collection>     interrupt actions as defined by interruptWith:,
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   226
                                                performed at interrupt time
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   227
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   228
        exitActions            <Collection of Block>
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   229
                                                additional cleanup actions to perform
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   230
                                                on termination (if nonEmpty)
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   231
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   232
        emergencySignalHandler <Block>          can be used for per-process
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   233
                                                emergency signal handling
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   234
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   235
        interruptsDisabled     <Boolean>        flag if interrupts (as installed
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   236
                                                via #interruptWith:) are currently
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   237
                                                disabled. (i.e. on-hold).
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   238
                                                Interrupts will be delivered when
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   239
                                                reenabled.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   240
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   241
        exceptionHandlerSet    <ExceptionhandlerSet>
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   242
                                                Handled by any process; allows for
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   243
                                                exceptionHandlers and query-answerers to
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   244
                                                be added/removed dynamically.
4646
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   245
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   246
    [Class variables:]
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   247
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   248
        TerminateSignal         <Signal>        signal used to terminate processes
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   249
                                                (should not be caught - or at least
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   250
                                                 rejected in handlers).
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   251
                                                If caught and proceeded, a process
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   252
                                                cannot be terminated via #terminate.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   253
                                                For hardTermination (in case of emergency),
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   254
                                                send it a #erminateNoSignal message.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   255
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   256
        RestartSignal           <Signal>        signal used to restart a process.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   257
                                                Can be caught in additional handler(s),
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   258
                                                to perform all kind of re-initialization.
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   259
                                                However, these handlers should reject,
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   260
                                                for the restart to be really performed.
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   261
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   262
    [see also:]
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   263
        ProcessorScheduler
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   264
        Block
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   265
        Sempahore SemaphoreSet Delay SharedQueue
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   266
        WindowGroup
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   267
        (``Working with processes'': programming/processes.html)
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   268
1294
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   269
    [author:]
19969
654d2e1a2dc4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19860
diff changeset
   270
        Claus Gittinger
1294
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   271
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   272
"
213
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   273
!
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   274
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   275
examples
213
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   276
"
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   277
    start a background process, computing 1000 factorial 100 times;
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   278
    the processes priority is set to not disturb any interactive process.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   279
    Since its prio is higher than the 3D animation demos prio, you will notice,
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   280
    that those are suspended while the computation runs. But Interactive views
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   281
    (like browsers) will continue to react normal.
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
   282
									[exBegin]
213
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   283
    [
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   284
       'starting' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   285
       100 timesRepeat:[1000 factorial].
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   286
       'done with factorial' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   287
    ] forkAt:(Processor userBackgroundPriority).
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
   288
									[exEnd]
213
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   289
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   290
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   291
    start a background process, computing 1000 factorial 100 times;
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   292
    the processes priority is set to not disturb any process.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   293
    The prio is set to 1 (which is the lowest possible) notice that now,
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   294
    the 3D animation demos also continue to run.
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
   295
									[exBegin]
213
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   296
    [
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   297
       'starting' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   298
       100 timesRepeat:[1000 factorial].
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   299
       'done with factorial' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   300
    ] forkAt:1.
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
   301
									[exEnd]
213
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   302
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   303
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   304
    start a background process, reading a pipe without blocking other
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   305
    processes;
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
   306
									[exBegin]
213
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   307
    [
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   308
       |p|
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   309
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   310
       'starting' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   311
       p := PipeStream readingFrom:'ls -lR .'.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   312
       [p atEnd] whileFalse:[
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
   313
	   p readWait.
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
   314
	   p nextLine printNL.
213
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   315
       ].
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   316
       p close.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   317
       'done with pipe' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   318
    ] forkAt:1.
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
   319
									[exEnd]
213
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   320
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   321
    see more examples in doc/coding
213
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   322
    (or search in the browser for senders of fork*)
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   323
"
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   324
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   325
1784
af6446feffae optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   326
!Process class methodsFor:'initialization'!
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   327
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   328
initialize
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   329
    TerminateSignal isNil ifTrue:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   330
	TerminateSignal := TerminateProcessRequest.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   331
	TerminateSignal notifierString:'unhandled process termination'.
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   332
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   333
	RestartSignal := RestartProcessRequest.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   334
	RestartSignal notifierString:'unhandled process restart'.
302
1f76060d58a4 *** empty log message ***
claus
parents: 252
diff changeset
   335
16562
Claus Gittinger <cg@exept.de>
parents: 16421
diff changeset
   336
	CaughtSignals := SignalSet
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   337
			    with:AbortAllOperationRequest
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   338
			    with:TerminateProcessRequest
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   339
			    with:RestartProcessRequest.
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   340
    ]
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   341
6212
65624195f937 exceptions now class-based
Claus Gittinger <cg@exept.de>
parents: 6204
diff changeset
   342
    "Modified: / 17.11.2001 / 11:07:29 / cg"
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   343
! !
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   344
1784
af6446feffae optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   345
!Process class methodsFor:'instance creation'!
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   346
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   347
for:aBlock priority:aPrio
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   348
    "create a new (unscheduled) process which will execute aBlock at
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   349
     a given priority, once scheduled. The process will start execution once
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   350
     it gets a #resume-message."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   351
2268
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   352
    ^ self basicNew for:aBlock priority:aPrio
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   353
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   354
    "Modified: 25.1.1997 / 01:23:12 / cg"
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   355
!
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   356
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   357
new
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   358
    "create a new (unscheduled) process which will execute the start
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   359
     method, when scheduled. The process will start execution once
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   360
     it gets a #resume-message."
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   361
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   362
    ^ self basicNew for:nil priority:(Processor activePriority).
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   363
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   364
    "Created: 25.1.1997 / 01:31:05 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   365
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   366
1784
af6446feffae optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   367
!Process class methodsFor:'Signal constants'!
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   368
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   369
restartSignal
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   370
    "return the signal used for process restart"
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   371
22693
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
   372
    ^ RestartProcessRequest
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
   373
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
   374
    "Created: / 28-10-1996 / 20:26:50 / cg"
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
   375
    "Modified: / 23-04-2018 / 14:01:47 / stefan"
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   376
!
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
   377
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   378
terminateSignal
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   379
    "return the signal used for process termination"
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   380
22693
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
   381
    ^ TerminateProcessRequest
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
   382
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
   383
    "Modified: / 23-04-2018 / 14:00:26 / stefan"
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   384
! !
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   385
1784
af6446feffae optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   386
!Process class methodsFor:'defaults'!
1346
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   387
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   388
defaultMaximumStackSize
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   389
    "return the default max stack size. All new processes get
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   390
     this limit initially.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   391
     It may be changed for individual processes with:
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   392
	aProcess setMaximumStackSize:limit"
1346
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   393
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   394
%{  /* NOCONTEXT */
19293
81e42b6626fb #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19292
diff changeset
   395
    extern INT __defaultThreadMaxStackSize();
1346
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   396
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8877
diff changeset
   397
    RETURN ( __mkSmallInteger( __defaultThreadMaxStackSize() ));
1346
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   398
%}
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   399
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   400
    "
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   401
     Process defaultMaximumStackSize
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   402
    "
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   403
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   404
    "Modified: 8.5.1996 / 10:22:24 / cg"
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   405
!
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   406
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   407
defaultMaximumStackSize:numberOfBytes
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   408
    "set the default max stack size, return the previous value.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   409
     All new processes get this stack limit initially.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   410
     It may be changed for individual processes with:
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   411
	aProcess setMaximumStackSize:limit
1346
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   412
     Notice:
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   413
	There is seldom any need to change the default setting,
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   414
	except for highly recursive programs."
1346
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   415
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   416
%{  /* NOCONTEXT */
19293
81e42b6626fb #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19292
diff changeset
   417
    extern INT __threadSetDefaultMaxStackSize();
1346
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   418
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   419
    if (__isSmallInteger(numberOfBytes)) {
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   420
	RETURN ( __mkSmallInteger(__threadSetDefaultMaxStackSize(__intVal(numberOfBytes)) ));
1352
Claus Gittinger <cg@exept.de>
parents: 1346
diff changeset
   421
    }
1346
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   422
%}
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   423
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   424
    "
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   425
     Process defaultMaximumStackSize:500*1024
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   426
    "
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   427
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   428
    "Modified: 8.5.1996 / 10:23:26 / cg"
19292
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   429
!
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   430
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   431
wrapStackSize
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   432
    "return the wrap stack size.
19292
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   433
     Under windows, blocking API calls are executed on a separate stack with this size.
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   434
     If you ever encounter that a call to n external library function requires more stack than
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   435
     this, you may change this size in your startup (or programmatically) during early startup.
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   436
     Returns nil on non-windows machines."
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   437
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   438
%{  /* NOCONTEXT */
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   439
    INT sz = 0;
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   440
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   441
#ifdef __win32__
19292
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   442
    extern INT __getWrapStackSize();
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   443
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   444
    sz = __getWrapStackSize();
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   445
#endif
19295
df293bd0c3f0 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19294
diff changeset
   446
    RETURN (__MKINT(sz));
19292
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   447
%}
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   448
!
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   449
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   450
wrapStackSize:newSize
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   451
    "set the wrap stack size.
19292
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   452
     Under windows, blocking API calls are executed on a separate stack with this size.
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   453
     If you ever encounter that a call to n external library function requires more stack than
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   454
     this, you may change this size in your startup (or programmatically) during early startup.
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   455
     An argument of 0 changes the size back to the default.
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   456
     Returns the previous size."
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   457
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   458
%{  /* NOCONTEXT */
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   459
    INT __oldSize = 0;
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   460
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   461
    if (__isSmallInteger(newSize)) {
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   462
	INT __newSize = __intVal(newSize);
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   463
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   464
	if (__newSize >= 0) {
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   465
#ifdef __win32__
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   466
	    extern INT __setWrapStackSize(INT);
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   467
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   468
	    __oldSize = __setWrapStackSize(__newSize);
19292
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   469
#endif
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   470
	}
19292
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   471
    }
19295
df293bd0c3f0 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19294
diff changeset
   472
    RETURN (__MKINT(__oldSize));
19292
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
   473
%}
1346
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   474
! !
429d560b7013 allow access to the default stack limit
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   475
3783
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   476
!Process class methodsFor:'instance retrieval'!
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   477
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   478
findProcessWithId:id
21129
c2dbb76648b1 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21008
diff changeset
   479
    <resource: #obsolete>
3783
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   480
    "return a process with a particular id.
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   481
     This is only a debugging helper, to allow
21129
c2dbb76648b1 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21008
diff changeset
   482
     easy access of a process by name in the MiniDebugger.
c2dbb76648b1 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21008
diff changeset
   483
     Do not use - ask Processor instead!!"
c2dbb76648b1 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21008
diff changeset
   484
3783
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   485
9226
81391c5bf4a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9085
diff changeset
   486
    ^ self allSubInstances detect:[:aProcess | aProcess id = id] ifNone:nil.
3783
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   487
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   488
    "
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   489
     Process findProcessWithId:1
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   490
    "
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   491
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   492
    "Modified: / 26.8.1998 / 15:39:55 / cg"
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   493
!
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   494
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   495
findProcessWithName:name
21129
c2dbb76648b1 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21008
diff changeset
   496
    <resource: #obsolete>
3783
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   497
    "return a process with a particular name.
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   498
     This is only a debugging helper, to allow
21129
c2dbb76648b1 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21008
diff changeset
   499
     easy access of a process by name in the MiniDebugger
c2dbb76648b1 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21008
diff changeset
   500
     Do not use - ask Processor instead!!"
3783
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   501
9226
81391c5bf4a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9085
diff changeset
   502
    ^ self allSubInstances detect:[:aProcess | aProcess name = name] ifNone:nil.
3783
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   503
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   504
    "
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   505
     Process findProcessWithName:'scheduler'
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   506
    "
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   507
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   508
    "Modified: / 26.8.1998 / 15:40:54 / cg"
9008
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   509
!
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   510
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   511
findProcessesWithGroupId:aGroupId
21129
c2dbb76648b1 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21008
diff changeset
   512
    <resource: #obsolete>
9008
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   513
    "return a collection of processes with the particular group id.
21129
c2dbb76648b1 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21008
diff changeset
   514
     Do not use - ask Processor instead!!"
9008
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   515
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   516
    ^ self allSubInstances select:[:aProcess | aProcess processGroupId = aGroupId ].
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   517
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   518
    "
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   519
     Process findProcessesWithGroupId: 0
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   520
    "
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   521
c4d718e416f1 find all process of the same id, used to suspend all of a group.
ab
parents: 8913
diff changeset
   522
    "Modified: / 26.8.1998 / 15:40:54 / cg"
3783
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   523
! !
5ac905a9a8c0 added process-retrievers (for MiniDebugger)
Claus Gittinger <cg@exept.de>
parents: 3776
diff changeset
   524
16182
44e2baa0f9b8 class: Process
Claus Gittinger <cg@exept.de>
parents: 16047
diff changeset
   525
21333
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
   526
24238
51ace3995288 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24224
diff changeset
   527
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   528
!Process methodsFor:'accessing'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   529
4874
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
   530
beGUIProcess
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
   531
    "mark the receiver as a gui process.
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
   532
     This is currently not used, but allows end-user applications
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
   533
     to terminate all subprocesses which are GUI related, and leave
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
   534
     other background processes in the same process group untouched."
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
   535
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
   536
    processType := #gui
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
   537
!
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
   538
1531
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
   539
beGroupLeader
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
   540
    "make the receiver a processGroupLeader.
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
   541
     This detaches the process from its creator, so that it will not
10742
186b8a15cad6 comment
Claus Gittinger <cg@exept.de>
parents: 10553
diff changeset
   542
     be terminated when it terminates via #terminateGroup.
5088
053e015a218a comments only
Claus Gittinger <cg@exept.de>
parents: 5087
diff changeset
   543
     Also, processes forked from a groupLeader belong to that group
053e015a218a comments only
Claus Gittinger <cg@exept.de>
parents: 5087
diff changeset
   544
     and can be terminated via #terminateGroup - unless they become
053e015a218a comments only
Claus Gittinger <cg@exept.de>
parents: 5087
diff changeset
   545
     group leaders themself.
1531
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
   546
     (windowgroup processes do this)."
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
   547
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
   548
    processGroupId := id
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
   549
10742
186b8a15cad6 comment
Claus Gittinger <cg@exept.de>
parents: 10553
diff changeset
   550
    "Created: / 08-07-1996 / 14:08:44 / cg"
186b8a15cad6 comment
Claus Gittinger <cg@exept.de>
parents: 10553
diff changeset
   551
    "Modified: / 17-10-2007 / 10:49:09 / cg"
1531
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
   552
!
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
   553
2196
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   554
beSystemProcess
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   555
    "make the receiver a system process.
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   556
     These processes have a groupId of 0.
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   557
     When executed as standAlone application, smalltalk exits when
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   558
     no more user processes are running.
5088
053e015a218a comments only
Claus Gittinger <cg@exept.de>
parents: 5087
diff changeset
   559
     (i.e. when there are only systemProcesses left)
2196
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   560
     To prevent any daemon processes from preventing this exit,
5088
053e015a218a comments only
Claus Gittinger <cg@exept.de>
parents: 5087
diff changeset
   561
     you should make them systemProcesses"
2196
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   562
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   563
    processGroupId := 0
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   564
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   565
    "Created: 17.1.1997 / 21:42:46 / cg"
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   566
!
8ae161b98239 added #beSystemProcess
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   567
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   568
changePriority:aNumber
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   569
    "same as priority:, but returns the old priority.
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   570
     (cannot do this in #priority: for ST-80 compatibility)"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   571
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   572
    |oldPrio|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   573
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   574
    oldPrio := prio.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   575
    Processor changePriority:aNumber for:self.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   576
    ^ oldPrio
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   577
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   578
    "Modified: 23.12.1995 / 18:38:53 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   579
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   580
1530
dfa58f01505c remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   581
creatorId
24779
71fe9e710937 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24775
diff changeset
   582
    "return the processcreator's id.
1530
dfa58f01505c remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   583
     This has no semantic meaning, but is useful to identify processes
dfa58f01505c remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   584
     when debugging."
dfa58f01505c remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   585
dfa58f01505c remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   586
    ^ creatorId
dfa58f01505c remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   587
!
dfa58f01505c remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   588
4646
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   589
exceptionHandlerSet
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   590
    "retrieve the exceptionHandlerSet, which includes the set of
23258
1d65d1a0af5d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23050
diff changeset
   591
     exceptions which are caught by the process.
4646
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   592
     Initially being empty, this allows for default handlers to be
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   593
     dynamically added/removed from the set of handled exceptions/queries."
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   594
4877
e9c91ce4a6e3 exceptionHandlerSet creation
ca
parents: 4875
diff changeset
   595
    exceptionHandlerSet isNil ifTrue:[
23258
1d65d1a0af5d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23050
diff changeset
   596
        exceptionHandlerSet := ExceptionHandlerSet new.
4877
e9c91ce4a6e3 exceptionHandlerSet creation
ca
parents: 4875
diff changeset
   597
    ].
4646
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   598
    ^ exceptionHandlerSet
23258
1d65d1a0af5d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23050
diff changeset
   599
1d65d1a0af5d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 23050
diff changeset
   600
    "Modified (comment): / 03-08-2018 / 08:48:38 / Claus Gittinger"
4646
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   601
!
8103e1cbce8a added exceptionHandlerSet & corresponding docu
Claus Gittinger <cg@exept.de>
parents: 4522
diff changeset
   602
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   603
id
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   604
    "return the processes id"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   605
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   606
    ^ id
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   607
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   608
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   609
name
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   610
    "return the processes name"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   611
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   612
    ^ name
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   613
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   614
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   615
name:aString
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   616
    "set the processes name"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   617
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   618
    name := aString
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   619
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   620
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   621
priority
19452
b884f7087b9f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19388
diff changeset
   622
    "return the receiver's priority"
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   623
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   624
    ^ prio
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   625
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   626
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   627
priority:aNumber
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   628
    "set my priority"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   629
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   630
    Processor changePriority:aNumber for:self.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   631
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   632
3679
ed4a806da8b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3293
diff changeset
   633
priorityRange
3723
141777110a64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3679
diff changeset
   634
    "return my dynamic priority range"
3679
ed4a806da8b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3293
diff changeset
   635
ed4a806da8b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3293
diff changeset
   636
    ^ priorityRange
ed4a806da8b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3293
diff changeset
   637
3723
141777110a64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3679
diff changeset
   638
    "Modified: / 3.8.1998 / 22:55:53 / cg"
3679
ed4a806da8b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3293
diff changeset
   639
!
ed4a806da8b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3293
diff changeset
   640
ed4a806da8b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3293
diff changeset
   641
priorityRange:anInterval
3723
141777110a64 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3679
diff changeset
   642
    "change my dynamic priority range"
3679
ed4a806da8b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3293
diff changeset
   643
16421
b787a8bd318b class: Process
Claus Gittinger <cg@exept.de>
parents: 16312
diff changeset
   644
    |lowPri hiPri newPrio|
9084
f8b30a6104b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9059
diff changeset
   645
f8b30a6104b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9059
diff changeset
   646
    priorityRange := anInterval.
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   647
    anInterval isNil ifTrue:[
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   648
        ^ self.
9084
f8b30a6104b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9059
diff changeset
   649
    ].
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   650
    
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   651
    lowPri := priorityRange start.
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   652
    hiPri := priorityRange stop.
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   653
    (newPrio := prio) isNil ifTrue:[
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   654
        newPrio := lowPri
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   655
    ] ifFalse:[
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   656
        prio < lowPri ifTrue:[
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   657
            newPrio := lowPri
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   658
        ] ifFalse:[
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   659
            prio > hiPri ifTrue:[
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   660
                newPrio := hiPri
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   661
            ].
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   662
        ].
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   663
    ].
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   664
    newPrio ~~ prio ifTrue:[
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   665
        self priority:newPrio
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   666
    ]
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   667
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   668
    "Modified: / 03-08-1998 / 22:56:05 / cg"
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
   669
    "Modified: / 05-02-2020 / 16:33:30 / Stefan Vogel"
3679
ed4a806da8b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3293
diff changeset
   670
!
ed4a806da8b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3293
diff changeset
   671
1529
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   672
processGroupId
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   673
    "return the processes processGroup id.
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   674
     Normally, when created, a processes creator id is taken and used
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   675
     as the processGroup id.
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   676
     When #terminateGroup is sent to a process, the process and all of its
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   677
     group members are terminated together.
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   678
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   679
     Processes can detach themself from the process group to prevent being
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   680
     killed when the parent terminates (windowgroup processes do this)."
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   681
1530
dfa58f01505c remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   682
    ^ processGroupId
1529
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   683
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   684
    "Created: 8.7.1996 / 13:47:47 / cg"
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   685
!
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   686
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   687
processGroupId:aGroupLeadersProcessID
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   688
    "set the processes processGroup id.
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   689
     Normally, when created, a processes creator id is taken and used
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   690
     as the processGroup id.
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   691
     When #terminateGroup is sent to a process, the process and all of its
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   692
     group members are terminated together.
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   693
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   694
     Processes can detach themself from the process group to prevent being
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   695
     killed when the parent terminates (windowgroup processes do this)."
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   696
1530
dfa58f01505c remember creating processes id - helpful when debugging
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   697
    processGroupId := aGroupLeadersProcessID
1529
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   698
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   699
    "Created: 8.7.1996 / 13:47:53 / cg"
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   700
!
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
   701
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   702
restartable:aBoolean
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   703
    "set/clear, the restartable flag.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   704
     Restartable processes will automatically be restarted by the
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   705
     ProcessorScheduler upon image restart.
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   706
     Others have to be restarted manually."
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   707
24058
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
   708
    startTimestamp notNil ifTrue:[
23016
ff70b217d135 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22693
diff changeset
   709
        self proceedableError:'cannot be made restartable when already started'.
ff70b217d135 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22693
diff changeset
   710
        ^ self
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   711
    ].
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   712
    restartable := aBoolean
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   713
23016
ff70b217d135 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22693
diff changeset
   714
    "Modified: / 23-12-1995 / 18:38:32 / cg"
ff70b217d135 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22693
diff changeset
   715
    "Modified: / 24-05-2018 / 21:04:04 / Claus Gittinger"
24058
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
   716
    "Modified: / 11-04-2019 / 14:52:12 / Stefan Vogel"
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   717
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   718
24224
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
   719
setStateRun
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
   720
    "set the state - only to be used from scheduler"
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
   721
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
   722
    state := #run
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
   723
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
   724
    "Created: / 29-05-2019 / 01:04:38 / Claus Gittinger"
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
   725
!
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
   726
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   727
singleStep:aBoolean
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   728
    singleStepping := aBoolean
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   729
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   730
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   731
startBlock
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   732
    "return the processes startup-block"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   733
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   734
    ^ startBlock
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   735
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   736
21326
6fbeb3dcaceb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21324
diff changeset
   737
startTimestamp
6fbeb3dcaceb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21324
diff changeset
   738
    "return the processes' start time"
6fbeb3dcaceb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21324
diff changeset
   739
6fbeb3dcaceb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21324
diff changeset
   740
    startTimestamp notNil ifTrue:[
6fbeb3dcaceb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21324
diff changeset
   741
        ^ startTimestamp
6fbeb3dcaceb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21324
diff changeset
   742
    ].
24058
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
   743
    id == 0 ifTrue:[
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
   744
        "/ the very first system process has no starttime set
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
   745
        startTimestamp := Smalltalk imageStartTime.
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
   746
    ].
21326
6fbeb3dcaceb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21324
diff changeset
   747
    ^ startTimestamp
24058
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
   748
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
   749
    "Modified: / 11-04-2019 / 15:16:02 / Stefan Vogel"
21326
6fbeb3dcaceb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21324
diff changeset
   750
!
6fbeb3dcaceb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21324
diff changeset
   751
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   752
state
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   753
    "return a symbol describing the processes state"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   754
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   755
    ^ state
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   756
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   757
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   758
state:aSymbol
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   759
    "set the state - only to be used from scheduler"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   760
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   761
    state := aSymbol
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   762
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   763
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   764
suspendedContext
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   765
    "return the processes suspended context
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   766
     - this is the context from which a process switch into the scheduler
20251
449ecd831246 #OTHER by mawalch
mawalch
parents: 20230
diff changeset
   767
     or another process occurred.
5088
053e015a218a comments only
Claus Gittinger <cg@exept.de>
parents: 5087
diff changeset
   768
     For the active process, a dead process, or one which
2888
3e8b5166d90f a rocess which had no chance yet to run, can be #terminated with
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
   769
     had no chance to run yet, nil is returned.
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   770
     Typically, only the debugger is interested in this one."
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   771
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   772
%{  /* NOCONTEXT */
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   773
    OBJ i;
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   774
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   775
    if (__isSmallInteger(i = __INST(id))) {
20251
449ecd831246 #OTHER by mawalch
mawalch
parents: 20230
diff changeset
   776
        RETURN (__threadContext(__intVal(i)));
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   777
    }
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   778
%}.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   779
    ^ nil
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   780
! !
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   781
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   782
!Process methodsFor:'accessing-change notifications'!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   783
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   784
addExitAction:aBlock
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   785
    "add aBlock to the processes exit actions.
5088
053e015a218a comments only
Claus Gittinger <cg@exept.de>
parents: 5087
diff changeset
   786
     This block will be evaluated right before the process dies,
053e015a218a comments only
Claus Gittinger <cg@exept.de>
parents: 5087
diff changeset
   787
     and can be used to trigger actions somewhere else (i.e. synchronization)."
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   788
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   789
    exitActions isNil ifTrue:[
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
   790
	exitActions := OrderedCollection new
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   791
    ].
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   792
    exitActions add:aBlock
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   793
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   794
    "Created: 12.1.1997 / 00:34:51 / cg"
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   795
!
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   796
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   797
addSuspendAction:aBlock
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   798
    "add aBlock to the processes suspend actions.
5088
053e015a218a comments only
Claus Gittinger <cg@exept.de>
parents: 5087
diff changeset
   799
     This block will be evaluated when a process gets suspended.
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   800
     You may ask what that is useful for - it is useful to flush
5088
053e015a218a comments only
Claus Gittinger <cg@exept.de>
parents: 5087
diff changeset
   801
     buffered graphic commands of a GUI process (i.e. to force xlib
053e015a218a comments only
Claus Gittinger <cg@exept.de>
parents: 5087
diff changeset
   802
     to send buffered commands to the display)."
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   803
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   804
    suspendActions isNil ifTrue:[
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
   805
	suspendActions := OrderedCollection new
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   806
    ].
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   807
    suspendActions add:aBlock
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   808
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   809
    "Modified: 13.12.1995 / 13:44:31 / stefan"
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   810
    "Created: 12.1.1997 / 00:35:11 / cg"
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   811
!
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   812
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   813
emergencySignalHandler
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   814
    "return the emergencySignalHandler block.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   815
     See Signal>>documentation for more info."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   816
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   817
    ^ emergencySignalHandler
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   818
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   819
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   820
emergencySignalHandler:aOneArgBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   821
    "set the emergencySignalHandler block.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   822
     See Signal>>documentation for more info."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   823
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   824
    emergencySignalHandler := aOneArgBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   825
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   826
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   827
removeAllExitActions
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   828
    "remove all exit actions."
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   829
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   830
    exitActions := nil.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   831
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   832
    "Created: 12.1.1997 / 00:36:02 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   833
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   834
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   835
removeAllSuspendActions
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   836
    "remove all suspend actions."
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   837
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   838
    suspendActions := nil.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   839
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   840
    "Created: 12.1.1997 / 00:36:16 / cg"
13016
sr
parents: 12764
diff changeset
   841
!
sr
parents: 12764
diff changeset
   842
sr
parents: 12764
diff changeset
   843
removeExitAction:anExitAction ifAbsent:exceptionBlock
sr
parents: 12764
diff changeset
   844
    "remove the identical exitAction; if found, remove and return it;
sr
parents: 12764
diff changeset
   845
    if not, return the value from evaluating exceptionBlock"
sr
parents: 12764
diff changeset
   846
sr
parents: 12764
diff changeset
   847
    exitActions notNil ifTrue:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   848
	^ exitActions removeIdentical:anExitAction ifAbsent:exceptionBlock.
13016
sr
parents: 12764
diff changeset
   849
    ].
sr
parents: 12764
diff changeset
   850
    ^ exceptionBlock value.
24238
51ace3995288 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24224
diff changeset
   851
!
51ace3995288 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24224
diff changeset
   852
51ace3995288 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24224
diff changeset
   853
terminateActionBlock:aBlock
51ace3995288 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24224
diff changeset
   854
    "for compatibility with OSProcess,
51ace3995288 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24224
diff changeset
   855
     this adds a block to be called when the process terminates"
51ace3995288 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24224
diff changeset
   856
51ace3995288 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24224
diff changeset
   857
    self addExitAction:aBlock
51ace3995288 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24224
diff changeset
   858
51ace3995288 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24224
diff changeset
   859
    "Created: / 29-05-2019 / 23:18:12 / Claus Gittinger"
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   860
! !
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   861
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   862
!Process methodsFor:'accessing-stack'!
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   863
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   864
maximumStackSize
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   865
    "returns the processes stack limit - i.e. the process will be
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   866
     interrupted with a recursionSignal-raise, if it ever
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   867
     needs more stack (in bytes) than this number"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   868
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   869
%{  /* NOCONTEXT */
19294
c28bb1e37444 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19293
diff changeset
   870
    extern INT __threadMaxStackSize();
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   871
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   872
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   873
    if (__isSmallInteger(i = __INST(id))) {
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   874
	RETURN( __MKINT(__threadMaxStackSize(__intVal(i))) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   875
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   876
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   877
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   878
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   879
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   880
setMaximumStackSize:limit
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   881
    "sets the processes stack limit - i.e. the process will be
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   882
     interrupted with a recursionSignal-raise, if it ever
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   883
     needs more stack (in bytes) than this number.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   884
     Returns the old value."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   885
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   886
%{  /* NOCONTEXT */
19294
c28bb1e37444 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19293
diff changeset
   887
    extern INT __threadSetMaxStackSize(int, unsigned INT);
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   888
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   889
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   890
    if (__isSmallInteger(i = __INST(id))
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   891
     && __isSmallInteger(limit) ) {
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   892
	RETURN ( __MKINT(__threadSetMaxStackSize(__intVal(i), __intVal(limit))) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   893
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   894
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   895
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   896
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   897
712
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   898
setStackInitialSize:initial increment:increment safe:safe
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   899
    "hook for fine-tuning. Sets the processes initialStackSize- and
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   900
     and stackIncrement-parameters. Not for normal use."
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   901
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   902
%{  /* NOCONTEXT */
19294
c28bb1e37444 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19293
diff changeset
   903
    extern INT __threadSetJunkSizes(int, unsigned INT, unsigned INT, unsigned INT);
19296
b0f995007c66 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19295
diff changeset
   904
712
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   905
    OBJ i;
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   906
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   907
    if (__isSmallInteger(i = __INST(id))
712
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   908
     && __isSmallInteger(initial)
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   909
     && __isSmallInteger(increment)
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   910
     && __isSmallInteger(safe)) {
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
   911
	RETURN ( __threadSetJunkSizes(__intVal(i), __intVal(initial), __intVal(increment), __intVal(safe)) ? true : false );
712
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   912
    }
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   913
%}.
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   914
    ^ false
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   915
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   916
24058
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
   917
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   918
!Process methodsFor:'interrupts'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   919
2725
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   920
blockInterrupts
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   921
    "disable interrupt processing for the receiver process
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   922
     - if disabled, incoming interrupts will be registered and handled as
2725
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   923
     soon as interrupts are reenabled via unblockInterrupts.
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   924
     Returns the previous blocking status i.e. true if interrupts
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   925
     where already blocked. You need this information for proper
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   926
     unblocking, in case of nested block/unblock calls.
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   927
     This is similar to OperatingSystem>>blockInterrupts, but only
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
   928
     affects interrupts for the receiver process
2725
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   929
     (i.e. those which are installed via #interruptWith:)"
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   930
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   931
    |disabledBefore|
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   932
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   933
    disabledBefore := interruptsDisabled.
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   934
    interruptsDisabled := true.
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
   935
    ^ disabledBefore
2726
d54c86279d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   936
d54c86279d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   937
    "
d54c86279d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   938
     |p1|
d54c86279d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   939
d54c86279d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   940
     p1 := [
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
   941
             Transcript showCR:'disabled ...'.
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
   942
             Transcript showCR:Processor activeProcess blockInterrupts.
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
   943
             Transcript showCR:'busy ...'.
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
   944
             Delay waitForSeconds:10.
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
   945
             Transcript showCR:'enabled ...'.
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
   946
             Processor activeProcess unblockInterrupts.
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
   947
           ] forkAt:9.
2726
d54c86279d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   948
d54c86279d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   949
     p1 interruptWith:[Transcript showCR:'interrupted'].
d54c86279d2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   950
    "
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
   951
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
   952
    "Modified: / 25-10-2017 / 18:03:39 / stefan"
2725
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   953
!
f5419dbc5f32 allow thread interrupts to be disabled/enabled
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
   954
5491
Claus Gittinger <cg@exept.de>
parents: 5490
diff changeset
   955
hasInterruptActions
Claus Gittinger <cg@exept.de>
parents: 5490
diff changeset
   956
    "return true, if there are any interrupt actions to evaluate
Claus Gittinger <cg@exept.de>
parents: 5490
diff changeset
   957
     (i.e. if the receiver has been interrupted)."
Claus Gittinger <cg@exept.de>
parents: 5490
diff changeset
   958
8544
732ed0a3d7ca use #~~ instead of #> for speed
Stefan Vogel <sv@exept.de>
parents: 8495
diff changeset
   959
    ^ interruptActions size ~~ 0
5491
Claus Gittinger <cg@exept.de>
parents: 5490
diff changeset
   960
!
Claus Gittinger <cg@exept.de>
parents: 5490
diff changeset
   961
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   962
interruptWith:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   963
    "interrupt the receiver and make it evaluate aBlock.
1784
af6446feffae optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   964
     If the receiver is currently suspended it is resumed.
af6446feffae optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   965
     Notice, that the process will only perform the block immediately,
af6446feffae optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   966
     IFF its priority is higher than the current processes priority.
22628
15c0c8da81a2 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22526
diff changeset
   967
     Otherwise, it will remain suspended, until its time comes.
15c0c8da81a2 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22526
diff changeset
   968
15c0c8da81a2 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22526
diff changeset
   969
     aBlock is evaluated with an optional argument: the context, that has been 
15c0c8da81a2 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22526
diff changeset
   970
     interrupted."
1092
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   971
21448
59c38b4d195a #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 21447
diff changeset
   972
    Processor activeProcess == self ifTrue:[
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   973
        aBlock value
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
   974
    ] ifFalse:[
21448
59c38b4d195a #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 21447
diff changeset
   975
        self isDead ifTrue:[    
21463
67a7ff4869e0 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21448
diff changeset
   976
            "/ trying to register interrupt for dead process.
67a7ff4869e0 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21448
diff changeset
   977
            ^ self.
21448
59c38b4d195a #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 21447
diff changeset
   978
        ].    
25202
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
   979
        self addInterruptAction:aBlock asFirstAction:false.
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   980
        Processor scheduleForInterrupt:self.
2724
9fb9ea4bf858 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2689
diff changeset
   981
    ].
8613
b74b646a830b no, last change leads to a blocking Debugger
Claus Gittinger <cg@exept.de>
parents: 8591
diff changeset
   982
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   983
    "
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   984
        Processor timeoutHandlerProcess interruptWith:[Transcript showCR:Processor activeProcess].
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   985
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   986
        |p|
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   987
        p := [] fork.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   988
        p waitUntilTerminated.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   989
        p interruptWith:[Transcript showCR:Processor activeProcess].
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   990
    "
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   991
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
   992
    "Modified: / 12-01-1997 / 00:52:05 / cg"
21463
67a7ff4869e0 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21448
diff changeset
   993
    "Modified: / 16-02-2017 / 18:09:38 / stefan"
22628
15c0c8da81a2 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22526
diff changeset
   994
    "Modified (comment): / 16-03-2018 / 15:34:46 / stefan"
1092
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   995
!
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   996
1092
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   997
onResumeDo:aBlock
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   998
    "prepare for the receiver to evaluate aBlock when resumed.
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   999
     This is like #interruptWith:, but does not resume the receiver
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
  1000
     (i.e. it continues its sleep).
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
  1001
     This is useful to place a breakpoint on a sleeping process, to be fired
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
  1002
     when it awakes."
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
  1003
25202
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
  1004
    self addInterruptAction:aBlock asFirstAction:true.
1092
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
  1005
    Processor scheduleInterruptActionsOf:self.
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
  1006
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
  1007
    "Created: 5.3.1996 / 17:28:04 / cg"
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
  1008
    "Modified: 8.3.1996 / 13:01:21 / cg"
2839
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1009
!
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1010
2857
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1011
stepInterruptHandler:anObject
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1012
    "set the handler for stepInterrupts occurring in the receiver process.
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1013
     This is an interface for the debugger and allows it to monitor a threads
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1014
     stepInterrupts. Returns the previous handler.
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1015
     Not for general use."
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1016
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1017
%{  /* NOCONTEXT */
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1018
    extern OBJ __threadStepInterruptHandler();
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1019
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1020
    RETURN( __threadStepInterruptHandler(anObject) );
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1021
%}
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1022
!
2e9e294d679c allow setting the stepInterruptHandler
Claus Gittinger <cg@exept.de>
parents: 2845
diff changeset
  1023
2839
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1024
unblockInterrupts
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1025
    "enable interrupt processing for the receiver process
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1026
     - if any interrupts are pending, these will be handled immediately.
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1027
     When unblocking interrupts, take care of nested block/unblock
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1028
     calls - you should only unblock after a blockcall if they where
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1029
     really not blocked before.
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1030
     This is similar to OperatingSystem>>unblockInterrupts, but only
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1031
     affects interrupts for the receiver process
2839
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1032
     (i.e. those which are installed via #interruptWith:)"
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1033
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1034
    interruptsDisabled := false.
21008
cea72e322520 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 20808
diff changeset
  1035
    (interruptActions size ~~ 0 and:[Processor activeProcess == self]) ifTrue:[
cea72e322520 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 20808
diff changeset
  1036
        self interrupt.
2839
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1037
    ]
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1038
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1039
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1040
!Process methodsFor:'interrupts-private'!
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1041
25202
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
  1042
addInterruptAction:aBlock asFirstAction:aBoolean
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1043
    "make the receiver evaluate aBlock when resumed/interrupted.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1044
     The name is somewhat misleading (actually, its historic):
25202
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
  1045
     the block is also evaluated on resume.
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
  1046
     With asFirstAction, if another interrupt action is already pending,
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
  1047
     aBlock will be executed first (to allow interrupting a debugged thread)."
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1048
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1049
    |wasBlocked|
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1050
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1051
    wasBlocked := OperatingSystem blockInterrupts.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1052
    interruptActions isNil ifTrue:[
25202
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
  1053
        interruptActions := OrderedCollection with:aBlock.
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1054
    ] ifFalse:[
25202
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
  1055
        aBoolean ifTrue:[
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
  1056
            interruptActions addFirst:aBlock.
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
  1057
        ] ifFalse:[
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
  1058
            interruptActions add:aBlock.
a9947abc32f8 #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 24844
diff changeset
  1059
        ]
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1060
    ].
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1061
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1062
!
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1063
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1064
evaluateInterruptActionsWithContext:aContext
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1065
    "evaluate my interrupt-actions."
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1066
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1067
    |wasBlocked|
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1068
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1069
    wasBlocked := OperatingSystem blockInterrupts.
21668
74cc7095adb7 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21463
diff changeset
  1070
    [interruptActions notEmptyOrNil] whileTrue:[
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1071
        |action|
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1072
21668
74cc7095adb7 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21463
diff changeset
  1073
        action := interruptActions removeFirst.
74cc7095adb7 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21463
diff changeset
  1074
        interruptActions isEmpty ifTrue:[
74cc7095adb7 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21463
diff changeset
  1075
            interruptActions := nil
74cc7095adb7 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21463
diff changeset
  1076
        ].
74cc7095adb7 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21463
diff changeset
  1077
        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1078
        action valueWithOptionalArgument:aContext.
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1079
        OperatingSystem blockInterrupts.
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1080
    ].
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1081
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1082
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1083
    "Modified: / 25-10-2017 / 17:45:46 / stefan"
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1084
!
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1085
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1086
forceInterruptOnReturnOf:aContext
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1087
    "helper entry for debugger. Force a stepInterrupt whenever aContext
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1088
     returns either directly or via an unwind."
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1089
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1090
    aContext markForInterruptOnUnwind.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1091
%{
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1092
    OBJ i;
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1093
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1094
    if (__isSmallInteger(i = __INST(id))) {
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1095
	__threadContextStepInterrupt(__intVal(i), 1);
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1096
    }
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1097
%}
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1098
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1099
!
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1100
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1101
interrupt
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1102
    "evaluate my interrupt-actions.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1103
     The process will go back to where it got interrupted
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1104
     after doing this.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1105
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1106
     This is also sent by the VM."
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1107
25222
2140d86c8d42 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25202
diff changeset
  1108
    interruptActions notEmptyOrNil ifTrue:[
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1109
        self evaluateInterruptActionsWithContext:thisContext sender.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1110
    ].
25222
2140d86c8d42 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25202
diff changeset
  1111
2140d86c8d42 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25202
diff changeset
  1112
    "Modified: / 30-01-2020 / 16:01:12 / Stefan Vogel"
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1113
!
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1114
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1115
interruptedIn:aContext
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1116
    "evaluate my interrupt-actions.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1117
     This is indirectly called by the VM, when some #interruptWith: action
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1118
     was scheduled for the process, and the process is resumed.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1119
     The process will go back to where it got interrupted after doing this."
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1120
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1121
    "/ the returned value here has a subtle effect:
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1122
    "/ if false, the interrupt is assumed to be not taken,
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1123
    "/ and will be redelivered.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1124
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1125
    interruptsDisabled ifTrue:[
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1126
        "/ no, I don't want interrupts right now;
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1127
        "/ try again later.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1128
        ^ false
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1129
    ].
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1130
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1131
    "/ I tend to disable interrupts, while processing interrupt actions;
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1132
    "/ however, this leads to a blocking Debugger sometimes (scroll).
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1133
"/    [
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1134
"/        interruptsDisabled := true.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1135
        self evaluateInterruptActionsWithContext:aContext.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1136
"/    ] ensure:[
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1137
"/        interruptsDisabled := false.
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1138
"/    ].
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1139
    ^ true
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1140
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1141
    "Created: / 18-10-1996 / 20:43:39 / cg"
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1142
    "Modified: / 25-10-2017 / 18:04:01 / stefan"
21447
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1143
! !
98a2f12066a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21433
diff changeset
  1144
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1145
!Process methodsFor:'monitoring'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1146
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1147
numberOfStackBoundaryHits
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1148
    "internal monitoring only - will vanish"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1149
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1150
%{  /* NOCONTEXT */
19294
c28bb1e37444 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19293
diff changeset
  1151
    extern INT __threadNumberOfStackBoundaryHits();
c28bb1e37444 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19293
diff changeset
  1152
    INT n;
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1153
    OBJ i;
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1154
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1155
    if (__isSmallInteger(i = __INST(id))) {
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  1156
	n = __threadNumberOfStackBoundaryHits(__intVal(i));
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  1157
	n &= _MAX_INT;
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  1158
	RETURN( __mkSmallInteger(n) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1159
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1160
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1161
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1162
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1163
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1164
numberOfStackSegments
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1165
    "return the processes number of stack segments currently used.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1166
     This method is for monitoring purposes only - it may vanish."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1167
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1168
%{  /* NOCONTEXT */
19297
674bdfe7b7ed #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19296
diff changeset
  1169
    extern int __threadStackSegments();
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1170
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1171
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1172
    if (__isSmallInteger(i = __INST(id))) {
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  1173
	RETURN( __mkSmallInteger((INT)__threadStackSegments(__intVal(i))) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1174
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1175
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1176
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1177
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1178
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1179
totalStackSize
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1180
    "return the processes maximum used stack size.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1181
     This method is for monitoring purposes only - it may vanish."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1182
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1183
%{  /* NOCONTEXT */
19294
c28bb1e37444 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19293
diff changeset
  1184
    extern INT __threadTotalStackSize();
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1185
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1186
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1187
    if (__isSmallInteger(i = __INST(id))) {
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  1188
	RETURN( __MKINT(__threadTotalStackSize(__intVal(i))) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1189
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1190
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1191
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1192
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1193
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1194
usedStackSize
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1195
    "Return the processes current stack size.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1196
     This method is for monitoring purposes only - it may vanish."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1197
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1198
%{  /* NOCONTEXT */
14724
03fbc7b1d07e 64bit fix
Claus Gittinger <cg@exept.de>
parents: 14722
diff changeset
  1199
    extern unsigned INT __threadUsedStackSize();
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1200
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1201
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1202
    if (__isSmallInteger(i = __INST(id))) {
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  1203
	RETURN( __MKINT(__threadUsedStackSize(__intVal(i))) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1204
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1205
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1206
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1207
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1208
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1209
vmTrace:aBoolean
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1210
    "turn on/off VM message tracing for the receiver.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1211
     This is meant for ST/X debugging, and may vanish.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1212
     Expect lots of output, once this is turned on."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1213
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1214
%{  /* NOCONTEXT */
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1215
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1216
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1217
    if (__isSmallInteger(i = __INST(id))) {
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
  1218
	__threadTracing(__intVal(i), aBoolean);
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1219
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1220
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1221
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1222
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1223
!Process methodsFor:'obsolete'!
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1224
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1225
exitAction:aBlock
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1226
    "Obsoleted by addExitAction: / removeAllExitActions.
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1227
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1228
     Add aBlock to the processes exit actions.
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1229
     This block will be evaluated right before the process dies.
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1230
     An argument of nil removes all exitActions."
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1231
5870
0d87233b9e16 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 5812
diff changeset
  1232
    <resource:#obsolete>
0d87233b9e16 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 5812
diff changeset
  1233
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1234
    self obsoleteMethodWarning:'use addExitAction: / removeAllExitActions'.
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1235
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1236
    aBlock isNil ifTrue:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1237
	^ self removeAllExitActions.
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1238
    ].
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1239
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1240
    ^ self addExitAction:aBlock
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1241
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1242
    "Modified: 13.12.1995 / 13:44:03 / stefan"
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1243
    "Modified: 12.1.1997 / 00:39:59 / cg"
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1244
!
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1245
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1246
suspendAction:aBlock
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1247
    "Obsoleted by addSuspendAction: / removeAllSuspendActions.
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1248
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1249
     Add aBlock to the processes suspend actions.
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1250
     This block will be evaluated when a process gets suspended.
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1251
     A nil argument removes all suspendActions."
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1252
5870
0d87233b9e16 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 5812
diff changeset
  1253
    <resource:#obsolete>
0d87233b9e16 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 5812
diff changeset
  1254
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1255
    self obsoleteMethodWarning:'use addSuspendAction: / removeAllSuspendActions'.
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1256
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1257
    aBlock isNil ifTrue:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1258
	^ self removeAllSuspendActions.
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1259
    ].
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1260
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1261
    ^ self addSuspendAction:aBlock
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1262
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1263
    "Modified: 12.1.1997 / 00:38:22 / cg"
9361
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1264
!
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1265
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1266
terminateAllSubprocesses
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1267
    <resource:#obsolete>
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1268
    self obsoleteMethodWarning:'use #terminateAllSubprocessesInGroup'.
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1269
    self terminateAllSubprocessesInGroup.
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1270
!
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1271
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1272
terminateWithAllSubprocesses
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1273
    <resource:#obsolete>
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1274
    self obsoleteMethodWarning:'use #terminateWithAllSubprocessesInGroup'.
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1275
    self terminateWithAllSubprocessesInGroup.
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1276
! !
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1277
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1278
!Process methodsFor:'printing & storing'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1279
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1280
printOn:aStream
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1281
    "a little more info in my printed representation"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1282
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1283
    aStream nextPutAll:state article;
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1284
	    space;
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1285
	    nextPutAll:state;
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1286
	    nextPutAll:' Process (';
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1287
	    nextPutAll:self nameOrId.
6944
491b35cf0bf3 printString changed to include id
Claus Gittinger <cg@exept.de>
parents: 6784
diff changeset
  1288
    name notNil ifTrue:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1289
	aStream
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1290
	    nextPutAll:', id=';
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1291
	    nextPutAll:id printString.
6944
491b35cf0bf3 printString changed to include id
Claus Gittinger <cg@exept.de>
parents: 6784
diff changeset
  1292
    ].
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1293
    aStream
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1294
	    nextPutAll:')'
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1295
! !
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1296
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1297
!Process methodsFor:'private'!
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1298
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1299
for:aBlock priority:aPrio
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1300
    "setup the new process - the receiver is not scheduled for
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1301
     execution, to get it running, send it #resume"
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1302
339
claus
parents: 337
diff changeset
  1303
    |nm active|
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1304
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1305
    prio := aPrio.
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1306
    startBlock := aBlock.
339
claus
parents: 337
diff changeset
  1307
    restartable := false.
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1308
    interruptsDisabled := false.
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1309
10436
2782fa4bd45a #newProcess et al never return nil - but raise an exception
Stefan Vogel <sv@exept.de>
parents: 9361
diff changeset
  1310
    Processor newProcessFor:self.
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1311
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1312
    "
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1313
     give me a user-friendly name
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1314
    "
339
claus
parents: 337
diff changeset
  1315
    active := Processor activeProcess.
2268
e7e1f98c3bce allow Process new (for subclasses)
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
  1316
    (nm := active name) notNil ifTrue:[
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1317
        "
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1318
         avoid name inflation
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1319
        "
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1320
        (nm endsWith:' sub') ifFalse:[
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1321
            nm := nm , ' [' ,  active id printString , '] sub'
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1322
        ].
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1323
        name := nm
1529
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
  1324
    ].
5675
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1325
    creatorId := active id.
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1326
    processGroupId := active processGroupId.
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1327
    (processGroupId isNil or:[processGroupId == 0]) ifTrue:[
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1328
        processGroupId := creatorId.
5675
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1329
    ].
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1330
4880
c87bf6d60fe2 oops - processGroup==0 marks a systemProcess.
ca
parents: 4877
diff changeset
  1331
    "/ since groupId is used to detect a systemProcess (0),
c87bf6d60fe2 oops - processGroup==0 marks a systemProcess.
ca
parents: 4877
diff changeset
  1332
    "/ do not allow a 0 here; need an explicit beSystemProcess.
c87bf6d60fe2 oops - processGroup==0 marks a systemProcess.
ca
parents: 4877
diff changeset
  1333
    processGroupId == 0 ifTrue:[processGroupId := nil].
1529
0ba3d19f90d6 set the processGroupId when created
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
  1334
22326
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1335
    "Modified: / 25-01-1997 / 01:28:54 / cg"
3326c18b05a5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22183
diff changeset
  1336
    "Modified: / 25-10-2017 / 18:02:52 / stefan"
5812
e23a3fdc75cb already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents: 5683
diff changeset
  1337
! !
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1338
7257
b9f0fb923c72 method category rename
Claus Gittinger <cg@exept.de>
parents: 6944
diff changeset
  1339
!Process methodsFor:'private-scheduler access'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1340
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1341
setId:idNumber state:stateSymbol
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1342
    "set id and state - not for public use"
375
claus
parents: 359
diff changeset
  1343
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1344
    id := idNumber.
4880
c87bf6d60fe2 oops - processGroup==0 marks a systemProcess.
ca
parents: 4877
diff changeset
  1345
    creatorId := 0.
c87bf6d60fe2 oops - processGroup==0 marks a systemProcess.
ca
parents: 4877
diff changeset
  1346
    processGroupId := nil.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1347
    state := stateSymbol.
8787
6539f06fbac0 *** empty log message ***
penk
parents: 8707
diff changeset
  1348
    singleStepping isNil ifTrue:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1349
	singleStepping := false
8787
6539f06fbac0 *** empty log message ***
penk
parents: 8707
diff changeset
  1350
    ].
6539f06fbac0 *** empty log message ***
penk
parents: 8707
diff changeset
  1351
    restartable isNil ifTrue:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1352
	restartable := false
8787
6539f06fbac0 *** empty log message ***
penk
parents: 8707
diff changeset
  1353
    ].
6539f06fbac0 *** empty log message ***
penk
parents: 8707
diff changeset
  1354
    interruptsDisabled isNil ifTrue:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1355
	interruptsDisabled := false
8787
6539f06fbac0 *** empty log message ***
penk
parents: 8707
diff changeset
  1356
    ].
1844
66d98c3a96f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1839
diff changeset
  1357
66d98c3a96f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1839
diff changeset
  1358
    "Modified: 30.10.1996 / 00:35:29 / cg"
182
f531860566fc more queries
claus
parents: 159
diff changeset
  1359
!
f531860566fc more queries
claus
parents: 159
diff changeset
  1360
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1361
setPriority:aNumber
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1362
    "set priority without telling processor - not for public use"
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1363
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1364
    prio := aNumber
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1365
!
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1366
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1367
setStartBlock:aBlock
19452
b884f7087b9f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19388
diff changeset
  1368
    "set the receiver's startup block"
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1369
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1370
    startBlock := aBlock
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1371
!
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  1372
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1373
setStateTo:newState if:oldState
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1374
    state == oldState ifTrue:[state := newState]
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1375
!
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1376
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1377
setStateTo:newState if:oldState1 or:oldState2
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1378
    (state == oldState1 or:[state == oldState2]) ifTrue:[state := newState]
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1379
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1380
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1381
!Process methodsFor:'queries'!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1382
5397
24e1061d3452 Define #isActive
Stefan Vogel <sv@exept.de>
parents: 5377
diff changeset
  1383
isActive
24e1061d3452 Define #isActive
Stefan Vogel <sv@exept.de>
parents: 5377
diff changeset
  1384
    "return true if I am the active process"
24e1061d3452 Define #isActive
Stefan Vogel <sv@exept.de>
parents: 5377
diff changeset
  1385
24e1061d3452 Define #isActive
Stefan Vogel <sv@exept.de>
parents: 5377
diff changeset
  1386
    ^ Processor activeProcess == self
24e1061d3452 Define #isActive
Stefan Vogel <sv@exept.de>
parents: 5377
diff changeset
  1387
!
24e1061d3452 Define #isActive
Stefan Vogel <sv@exept.de>
parents: 5377
diff changeset
  1388
24844
334662dd5a40 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24819
diff changeset
  1389
isAlive
334662dd5a40 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24819
diff changeset
  1390
    "for protocol compatibility with OSProcess"
334662dd5a40 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24819
diff changeset
  1391
334662dd5a40 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24819
diff changeset
  1392
    ^ self isDead not
334662dd5a40 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24819
diff changeset
  1393
!
334662dd5a40 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 24819
diff changeset
  1394
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1395
isDead
10553
297602960627 #isDead
Stefan Vogel <sv@exept.de>
parents: 10502
diff changeset
  1396
    "return true, if the receiver is a dead process"
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1397
10553
297602960627 #isDead
Stefan Vogel <sv@exept.de>
parents: 10502
diff changeset
  1398
    ^ (id isNil or:[state isNil or:[state == #dead]])
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1399
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1400
    "Modified: 23.12.1995 / 18:35:29 / cg"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1401
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1402
14359
794447210c24 added: #isDebugged
Claus Gittinger <cg@exept.de>
parents: 13563
diff changeset
  1403
isDebugged
794447210c24 added: #isDebugged
Claus Gittinger <cg@exept.de>
parents: 13563
diff changeset
  1404
    "return true, iff the receiver process is currently being debugged
794447210c24 added: #isDebugged
Claus Gittinger <cg@exept.de>
parents: 13563
diff changeset
  1405
     (i.e. is stopped and a debugger sits on top of it)"
794447210c24 added: #isDebugged
Claus Gittinger <cg@exept.de>
parents: 13563
diff changeset
  1406
794447210c24 added: #isDebugged
Claus Gittinger <cg@exept.de>
parents: 13563
diff changeset
  1407
    ^ (state == #debug)
794447210c24 added: #isDebugged
Claus Gittinger <cg@exept.de>
parents: 13563
diff changeset
  1408
794447210c24 added: #isDebugged
Claus Gittinger <cg@exept.de>
parents: 13563
diff changeset
  1409
    "Created: / 26-09-2012 / 14:56:36 / cg"
794447210c24 added: #isDebugged
Claus Gittinger <cg@exept.de>
parents: 13563
diff changeset
  1410
!
794447210c24 added: #isDebugged
Claus Gittinger <cg@exept.de>
parents: 13563
diff changeset
  1411
24224
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1412
isDebuggedOrStopped
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1413
    "return true, iff the receiver process is currently being stopped
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1414
     and possibly debugged (i.e. is stopped and a debugger sits on top of it)"
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1415
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1416
    ^ (state == #debug) or:[state == #stopped]
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1417
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1418
    "Created: / 29-05-2019 / 01:01:20 / Claus Gittinger"
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1419
!
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1420
22526
9b0aeeccd6f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22326
diff changeset
  1421
isDebuggerProcess
9b0aeeccd6f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22326
diff changeset
  1422
    "return true, iff the receiver process is currently running a Debugger or
9b0aeeccd6f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22326
diff changeset
  1423
     an Inspector. Senders may behave differently and e.g. timeout on 
9b0aeeccd6f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22326
diff changeset
  1424
     endless blocking operations."
9b0aeeccd6f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22326
diff changeset
  1425
9b0aeeccd6f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22326
diff changeset
  1426
    ^ self environmentAt:#isDebuggerProcess ifAbsent:false.
9b0aeeccd6f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22326
diff changeset
  1427
9b0aeeccd6f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22326
diff changeset
  1428
    "Created: / 01-02-2018 / 10:15:49 / stefan"
9b0aeeccd6f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22326
diff changeset
  1429
!
9b0aeeccd6f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22326
diff changeset
  1430
4874
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
  1431
isGUIProcess
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
  1432
    "return true, if this is a GUI process.
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
  1433
     I.e. a windowGroup process.
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
  1434
     This is currently not used, but allows end-user applications
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
  1435
     to terminate all subprocesses which are GUI related, and leave
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
  1436
     other background processes in the same process group untouched."
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
  1437
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
  1438
    ^ processType == #gui
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
  1439
!
2af584ce2793 added a processType attribute (for beGUI / isGUI)
Claus Gittinger <cg@exept.de>
parents: 4735
diff changeset
  1440
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1441
isRestartable
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1442
    "return true, iff the receiver is restartable"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1443
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1444
    ^ restartable
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1445
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1446
24224
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1447
isRunning
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1448
    "return true, iff the receiver is running (state == #run);
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1449
     this does not mean that it is currently active 
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1450
     (it might be suspended by the current process)"
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1451
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1452
    ^ (state == #run)
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1453
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1454
    "Created: / 29-05-2019 / 01:00:17 / Claus Gittinger"
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1455
!
312bc1454cf6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 24058
diff changeset
  1456
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1457
isSingleStepping
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1458
    ^ singleStepping
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1459
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1460
5643
0fe1ec12c5e8 added #isStopped
Claus Gittinger <cg@exept.de>
parents: 5592
diff changeset
  1461
isStopped
0fe1ec12c5e8 added #isStopped
Claus Gittinger <cg@exept.de>
parents: 5592
diff changeset
  1462
    "return true, iff the receiver is stopped"
0fe1ec12c5e8 added #isStopped
Claus Gittinger <cg@exept.de>
parents: 5592
diff changeset
  1463
0fe1ec12c5e8 added #isStopped
Claus Gittinger <cg@exept.de>
parents: 5592
diff changeset
  1464
    ^ (state == #stopped)
0fe1ec12c5e8 added #isStopped
Claus Gittinger <cg@exept.de>
parents: 5592
diff changeset
  1465
0fe1ec12c5e8 added #isStopped
Claus Gittinger <cg@exept.de>
parents: 5592
diff changeset
  1466
    "Modified: 23.12.1995 / 18:35:29 / cg"
0fe1ec12c5e8 added #isStopped
Claus Gittinger <cg@exept.de>
parents: 5592
diff changeset
  1467
!
0fe1ec12c5e8 added #isStopped
Claus Gittinger <cg@exept.de>
parents: 5592
diff changeset
  1468
2636
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1469
isSystemProcess
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1470
    "return true if aProcess is a system process,
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1471
     which should not be suspended/terminated etc.."
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1472
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1473
    ^ (Processor isPureEventDriven
2636
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1474
       or:[id == 0
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1475
       or:[processGroupId == 0
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1476
       or:[(Display notNil and:[Display dispatchProcess == self])
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1477
       ]]])
2636
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1478
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1479
    "
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1480
     Processor activeProcessIsSystemProcess
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1481
    "
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1482
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1483
    "Created: 17.4.1997 / 12:57:37 / stefan"
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1484
!
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1485
17407
e82159e43f55 class: Process
Stefan Vogel <sv@exept.de>
parents: 17244
diff changeset
  1486
isUserProcess
e82159e43f55 class: Process
Stefan Vogel <sv@exept.de>
parents: 17244
diff changeset
  1487
    "return true if aProcess is a user process."
e82159e43f55 class: Process
Stefan Vogel <sv@exept.de>
parents: 17244
diff changeset
  1488
e82159e43f55 class: Process
Stefan Vogel <sv@exept.de>
parents: 17244
diff changeset
  1489
    ^ processGroupId ~~ 0 and:[id ~~ 0]
e82159e43f55 class: Process
Stefan Vogel <sv@exept.de>
parents: 17244
diff changeset
  1490
!
e82159e43f55 class: Process
Stefan Vogel <sv@exept.de>
parents: 17244
diff changeset
  1491
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1492
nameOrId
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1493
    "return a string to identify the process - either name or id"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1494
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1495
    name notNil ifTrue:[^ name].
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1496
    ^ id printString
5675
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1497
!
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1498
9361
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1499
parentProcess
17244
2d730416819c class: Process
Claus Gittinger <cg@exept.de>
parents: 16846
diff changeset
  1500
    "answer my parent.
2d730416819c class: Process
Claus Gittinger <cg@exept.de>
parents: 16846
diff changeset
  1501
     Notice: we do only keep the id here, to prevent the parentProcess from being
2d730416819c class: Process
Claus Gittinger <cg@exept.de>
parents: 16846
diff changeset
  1502
     referenced (and therefore not garbage collected if it terminates)"
9361
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1503
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1504
    ProcessorScheduler knownProcessesDo:[:p|
17544
486f5796b42e unused variable removed
Claus Gittinger <cg@exept.de>
parents: 17407
diff changeset
  1505
	p id = creatorId ifTrue:[^ p].
14443
31dd04f0917f changed: #parentProcess
Claus Gittinger <cg@exept.de>
parents: 14359
diff changeset
  1506
    ].
31dd04f0917f changed: #parentProcess
Claus Gittinger <cg@exept.de>
parents: 14359
diff changeset
  1507
    ^ nil.
9361
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1508
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1509
    "
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1510
      Processor activeProcess parentProcess
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1511
    "
14443
31dd04f0917f changed: #parentProcess
Claus Gittinger <cg@exept.de>
parents: 14359
diff changeset
  1512
31dd04f0917f changed: #parentProcess
Claus Gittinger <cg@exept.de>
parents: 14359
diff changeset
  1513
    "Modified: / 26-10-2012 / 13:15:55 / cg"
9361
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1514
!
4538fc85ea19 new: #parentProcess
Stefan Vogel <sv@exept.de>
parents: 9300
diff changeset
  1515
5675
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1516
processGroupLeader
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1517
    "answer the parent of this process group"
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1518
5681
95c1ed5be6c3 Fix #processGroupLeader
Stefan Vogel <sv@exept.de>
parents: 5675
diff changeset
  1519
    |processes leader next creatorId|
5675
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1520
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1521
    processes := ProcessorScheduler knownProcesses.
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1522
    leader := processes detect:[:p| p id = processGroupId] ifNone:nil.
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1523
    leader isNil ifTrue:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1524
	leader := self.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1525
	[
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1526
	    creatorId := leader creatorId.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1527
	    next := processes detect:[:p| p id = creatorId
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1528
					  and:[p processGroupId = processGroupId]]
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1529
			      ifNone:nil.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1530
	] doWhile:[next notNil and:[leader := next. true]].
5675
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1531
    ].
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1532
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1533
    ^ leader.
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1534
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1535
    "
34d5b32f9259 Do not create a new process group for each grandchild process.
Stefan Vogel <sv@exept.de>
parents: 5643
diff changeset
  1536
      Processor activeProcess processGroupLeader
5812
e23a3fdc75cb already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents: 5683
diff changeset
  1537
    "
e23a3fdc75cb already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents: 5683
diff changeset
  1538
! !
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
  1539
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1540
!Process methodsFor:'special'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1541
15964
ee3faaeb7427 class: Process
Claus Gittinger <cg@exept.de>
parents: 15117
diff changeset
  1542
externalLookupPopIfEqual: lookupObject
ee3faaeb7427 class: Process
Claus Gittinger <cg@exept.de>
parents: 15117
diff changeset
  1543
    "Called by method lookup MOP when an lookup context is to be unwound
ee3faaeb7427 class: Process
Claus Gittinger <cg@exept.de>
parents: 15117
diff changeset
  1544
     to cleanup lookup stack"
ee3faaeb7427 class: Process
Claus Gittinger <cg@exept.de>
parents: 15117
diff changeset
  1545
    lookupActivations first == lookupObject ifTrue:[
16562
Claus Gittinger <cg@exept.de>
parents: 16421
diff changeset
  1546
	lookupActivations := lookupActivations second.
15964
ee3faaeb7427 class: Process
Claus Gittinger <cg@exept.de>
parents: 15117
diff changeset
  1547
    ].
ee3faaeb7427 class: Process
Claus Gittinger <cg@exept.de>
parents: 15117
diff changeset
  1548
ee3faaeb7427 class: Process
Claus Gittinger <cg@exept.de>
parents: 15117
diff changeset
  1549
    "Created: / 04-10-2013 / 10:46:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ee3faaeb7427 class: Process
Claus Gittinger <cg@exept.de>
parents: 15117
diff changeset
  1550
    "Modified (comment): / 04-10-2013 / 12:08:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ee3faaeb7427 class: Process
Claus Gittinger <cg@exept.de>
parents: 15117
diff changeset
  1551
!
ee3faaeb7427 class: Process
Claus Gittinger <cg@exept.de>
parents: 15117
diff changeset
  1552
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
  1553
millisecondDelay:millis
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
  1554
    "suspend the current process for some time.
16846
60b0b8de3c25 class: Process
Claus Gittinger <cg@exept.de>
parents: 16563
diff changeset
  1555
     Attention:
17544
486f5796b42e unused variable removed
Claus Gittinger <cg@exept.de>
parents: 17407
diff changeset
  1556
	If the receiver is a system process (i.e. scheduler or event dispatcher)
486f5796b42e unused variable removed
Claus Gittinger <cg@exept.de>
parents: 17407
diff changeset
  1557
	this blocks the whole Smalltalk for the time delta;
486f5796b42e unused variable removed
Claus Gittinger <cg@exept.de>
parents: 17407
diff changeset
  1558
	if it's a normal thread, only that thread is suspended."
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
  1559
2636
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1560
    (self isSystemProcess) ifTrue:[
17544
486f5796b42e unused variable removed
Claus Gittinger <cg@exept.de>
parents: 17407
diff changeset
  1561
	OperatingSystem millisecondDelay:millis
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
  1562
    ] ifFalse:[
17544
486f5796b42e unused variable removed
Claus Gittinger <cg@exept.de>
parents: 17407
diff changeset
  1563
	Delay waitForMilliseconds:millis
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
  1564
    ]
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
  1565
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
  1566
    "Created: 16.12.1995 / 13:10:53 / cg"
2636
8cb50e1b0688 Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 2384
diff changeset
  1567
    "Modified: 17.4.1997 / 13:02:25 / stefan"
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
  1568
!
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
  1569
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1570
trapRestrictedMethods:trap
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1571
    "Allow/deny the execution of restricted methods.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1572
     Process specific method restriction is not implemented yet, so this call is
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1573
     redirected to ObjectMemory and causes a system wide restriction.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1574
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1575
     Notice: method restriction is a nonstandard feature, not supported
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1576
     by other smalltalk implementations and not specified in the ANSI spec.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1577
     This is EXPERIMENTAL - and being evaluated for usability.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1578
     It may change or even vanish (if it shows to be not useful)."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1579
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1580
    ^ObjectMemory trapRestrictedMethods:trap
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1581
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1582
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1583
	Processor activeProcess trapRestrictedMethods:true
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1584
	Processor activeProcess trapRestrictedMethods:false
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1585
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1586
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1587
    "Created: 8.11.1995 / 19:45:04 / stefan"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1588
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1589
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1590
uninterruptablyDo:aBlock
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1591
    "execute aBlock with interrupts blocked.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1592
     This does not prevent preemption by a higher priority processes
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1593
     if any becomes runnable due to the evaluation of aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1594
     (i.e. if a semaphore is signalled there)."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1595
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1596
    "we must keep track of blocking-state if this is called nested"
2302
259d1b9326ed in uninterruptablyDo::
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
  1597
    (OperatingSystem blockInterrupts) ifTrue:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1598
	"/ already blocked
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1599
	^ aBlock value
2302
259d1b9326ed in uninterruptablyDo::
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
  1600
    ].
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1601
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6322
diff changeset
  1602
    ^ aBlock ensure:[OperatingSystem unblockInterrupts]
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1603
!
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1604
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1605
waitUntilSuspended
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1606
    "wait until the receiver is suspended."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1607
5377
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
  1608
    self isDead ifFalse:[
22175
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1609
        [
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1610
            "/ must check again - interrupt could have happened
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1611
            "/ and process already terminated.
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1612
            self isDead ifFalse:[
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1613
                suspendSemaphore isNil ifTrue:[
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1614
                    suspendSemaphore := Semaphore name:'process suspend'
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1615
                ].
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1616
                suspendSemaphore wait
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1617
            ]
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1618
        ] valueUninterruptably
5377
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
  1619
    ]
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1620
22175
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1621
    "Modified: / 09-08-2017 / 11:55:51 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1622
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1623
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1624
waitUntilTerminated
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1625
    "wait until the receiver is terminated.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1626
     This method allows another process to wait till the receiver finishes."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1627
6774
6711472e6df4 oops - waitUntil terminated for a process that did not rune
penk
parents: 6739
diff changeset
  1628
    self waitUntilTerminatedWithTimeout:nil
1033
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1629
1789
16798944c715 commentary
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
  1630
    "
16798944c715 commentary
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
  1631
     |p|
16798944c715 commentary
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
  1632
6774
6711472e6df4 oops - waitUntil terminated for a process that did not rune
penk
parents: 6739
diff changeset
  1633
     p := [100 timesRepeat:[1000 factorial]] forkAt:4.
1789
16798944c715 commentary
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
  1634
16798944c715 commentary
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
  1635
     Transcript showCR:'now waiting ...'.
16798944c715 commentary
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
  1636
     p waitUntilTerminated.
16798944c715 commentary
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
  1637
     Transcript showCR:'done.'
16798944c715 commentary
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
  1638
    "
16798944c715 commentary
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
  1639
2158
aab75d6439d0 renamed exitAction: and suspendAction: messages - the old name
Claus Gittinger <cg@exept.de>
parents: 2130
diff changeset
  1640
    "Modified: 12.1.1997 / 00:40:59 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1641
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1642
4735
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1643
waitUntilTerminatedWithTimeout:secondsOrNil
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1644
    "wait until the receiver is terminated or (if non-nil) until
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1645
     the time period exired.
13206
bffd4afb5be0 comment/format in: #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 13016
diff changeset
  1646
     Returns true if a timeout occurred.
8566
a8101fa70c6c comment
Stefan Vogel <sv@exept.de>
parents: 8544
diff changeset
  1647
     This method allows another process to wait until the receiver finishes
4735
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1648
     (optionally) within some time."
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1649
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1650
    |sema didTimeout|
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1651
10553
297602960627 #isDead
Stefan Vogel <sv@exept.de>
parents: 10502
diff changeset
  1652
    didTimeout := false.
297602960627 #isDead
Stefan Vogel <sv@exept.de>
parents: 10502
diff changeset
  1653
5377
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
  1654
    self isDead ifFalse:[
22175
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1655
        [
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1656
            "/ must check again - interrupt could have happened
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1657
            "/ and process already terminated.
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1658
            self isDead ifFalse:[
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1659
                sema := Semaphore name:'process termination'.
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1660
                self addExitAction:[sema signal].
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1661
                didTimeout := (sema waitWithTimeout:secondsOrNil) isNil
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1662
            ]
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1663
        ] valueUninterruptably.
5377
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
  1664
    ].
10553
297602960627 #isDead
Stefan Vogel <sv@exept.de>
parents: 10502
diff changeset
  1665
    ^ didTimeout
4735
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1666
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1667
    "
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1668
     |p|
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1669
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1670
     p := [10 timesRepeat:[10000 factorial]] forkAt:4.
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1671
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1672
     Transcript showCR:'now waiting ...'.
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1673
     (p waitUntilTerminatedWithTimeout:2) ifTrue:[
22175
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1674
         Transcript showCR:'timeout occurred.'
4735
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1675
     ]
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1676
    "
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1677
22175
bc30f02e5cf5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21777
diff changeset
  1678
    "Modified: / 09-08-2017 / 11:55:56 / cg"
4735
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1679
!
f4aad6d584d1 added #waitUntilTerminatedWithTimeout:
Claus Gittinger <cg@exept.de>
parents: 4646
diff changeset
  1680
9059
cc0a1250153f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9008
diff changeset
  1681
withHigherPriorityDo:aBlock
cc0a1250153f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9008
diff changeset
  1682
    "execute aBlock at a higher priority."
cc0a1250153f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9008
diff changeset
  1683
cc0a1250153f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9008
diff changeset
  1684
    ^ self withPriority:(prio + 1) do:aBlock
cc0a1250153f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9008
diff changeset
  1685
cc0a1250153f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9008
diff changeset
  1686
    "
cc0a1250153f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9008
diff changeset
  1687
     Processor activeProcess withHigherPriorityDo:[3000 factorial]
cc0a1250153f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9008
diff changeset
  1688
    "
cc0a1250153f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9008
diff changeset
  1689
!
cc0a1250153f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9008
diff changeset
  1690
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1691
withLowerPriorityDo:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1692
    "execute aBlock at a lower priority. This can be used to perform
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1693
     time-consuming operations at a more user-friendly priority."
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1694
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1695
    ^ self withPriority:(prio - 1) do:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1696
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1697
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1698
     Processor activeProcess withLowerPriorityDo:[3000 factorial]
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1699
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1700
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1701
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1702
withPriority:aPrio do:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1703
    "execute aBlock at another priority. This can be used to perform
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1704
     time-consuming operations at a more user-friendly priority,
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1705
     or some critical action at a higher priority. Do not use too high
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1706
     of a priority to avoid locking up the system (event processing takes place
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1707
     at 24)"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1708
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1709
    |oldprio|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1710
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1711
    oldprio := prio.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1712
    self priority:aPrio.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1713
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6322
diff changeset
  1714
    ^ aBlock ensure:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1715
	self priority:oldprio
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1716
    ]
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1717
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1718
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1719
     Processor activeProcess withPriority:7 do:[3000 factorial]
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1720
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1721
    "be careful - even ^C wont work until done:
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1722
     Processor activeProcess withPriority:25 do:[3000 factorial]
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1723
    "
2839
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1724
!
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1725
4433
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1726
withPriority:lowPrio to:highPrio do:aBlock
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1727
    "execute aBlock at a priority range. This can be used to perform
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1728
     time-consuming operations at a more user-friendly priority,
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1729
     or some critical action at a higher priority. Do not use too high
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1730
     of a priority to avoid locking up the system (event processing takes place
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1731
     at 24)"
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1732
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1733
    |oldprio oldRange|
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1734
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1735
    oldprio := prio.
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1736
    oldRange := priorityRange.
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1737
    self priorityRange:(lowPrio to:highPrio).
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1738
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6322
diff changeset
  1739
    ^ aBlock ensure:[
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1740
	self priorityRange:oldRange.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1741
	self priority:oldprio.
4433
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1742
    ]
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1743
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1744
    "
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1745
     Processor activeProcess withPriority:7 to:8 do:[3000 factorial]
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1746
    "
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1747
!
f367dc0b0a02 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4415
diff changeset
  1748
2839
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1749
withSystemBackgroundPriorityDo:aBlock
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1750
    "execute aBlock at system background priority.
2839
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1751
     This can be used to perform
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1752
     background operations at a more user-friendly priority."
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1753
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1754
    ^ self withPriority:(Processor systemBackgroundPriority) do:aBlock
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1755
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1756
    "
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1757
     Processor activeProcess withSystemBackgroundPriorityDo:[3000 factorial]
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1758
    "
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1759
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1760
    "Created: 7.8.1997 / 12:56:23 / cg"
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1761
!
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1762
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1763
withUserBackgroundPriorityDo:aBlock
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1764
    "execute aBlock at background priority. This can be used to perform
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1765
     time-consuming operations at a more user-friendly priority."
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1766
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1767
    ^ self withPriority:(Processor userBackgroundPriority) do:aBlock
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1768
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1769
    "
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1770
     Processor activeProcess withUserBackgroundPriorityDo:[3000 factorial]
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1771
    "
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1772
22c472b4d24f added #withUserBackgroundPrioDo / #withSystemBackgroundPrioDo:
Claus Gittinger <cg@exept.de>
parents: 2727
diff changeset
  1773
    "Created: 6.8.1997 / 15:40:02 / cg"
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
  1774
! !
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
  1775
24819
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  1776
!Process methodsFor:'start & stop'!
116
58fb8728e1a5 added emergencySignalHandler
claus
parents: 93
diff changeset
  1777
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1778
imageRestart
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1779
    "restart the process from the beginning.
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1780
     This is sent by the ProcessorScheduler at image restart time,
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1781
     to all restartable processes."
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1782
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1783
    |savedGroupId|
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1784
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1785
"/  ('restart process ' , id printString) errorPrintNL.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1786
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1787
    savedGroupId := processGroupId.
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1788
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1789
    (Processor newProcessFor:self withId:id) ifFalse:[
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  1790
	"for some reason, the Processor was unable to create
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  1791
	 a VM process for me ...."
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1792
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  1793
	('Process [warning]: process ' , id printString , ' failed to restart.') errorPrintCR.
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  1794
	^ nil
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1795
    ].
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1796
    processGroupId := savedGroupId.
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1797
    self resume
1086
7b0641a2e1ef nicer message
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  1798
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1799
    "Created: 28.10.1996 / 20:32:34 / cg"
2130
b9e7e1cf98bd newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1800
    "Modified: 10.1.1997 / 18:01:13 / cg"
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1801
!
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1802
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1803
restart
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1804
    "restart the process from the beginning.
21433
548194f34708 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 21333
diff changeset
  1805
     This is only possible, if it's restartable."
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1806
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1807
    restartable ifFalse:[
23016
ff70b217d135 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22693
diff changeset
  1808
        ^ self proceedableError:'process is not restartable'
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1809
    ].
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1810
22693
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  1811
    self interruptWith:[RestartProcessRequest raise]
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1812
21433
548194f34708 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 21333
diff changeset
  1813
    "Modified: / 12-01-1997 / 00:54:32 / cg"
548194f34708 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 21333
diff changeset
  1814
    "Modified (comment): / 13-02-2017 / 20:29:07 / cg"
22693
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  1815
    "Modified: / 23-04-2018 / 14:01:40 / stefan"
23016
ff70b217d135 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22693
diff changeset
  1816
    "Modified: / 24-05-2018 / 21:03:56 / Claus Gittinger"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1817
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1818
116
58fb8728e1a5 added emergencySignalHandler
claus
parents: 93
diff changeset
  1819
start
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1820
    "start the process - this is sent by the VM to the process to get
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1821
     the process up and running.
329
claus
parents: 326
diff changeset
  1822
     Sending #start to the process (instead of directly executing the startBlock)
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1823
     allows more flexible handling of processes, since anything that responds
329
claus
parents: 326
diff changeset
  1824
     to #start can be handled transparently by the VM then ..."
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1825
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1826
    |block|
116
58fb8728e1a5 added emergencySignalHandler
claus
parents: 93
diff changeset
  1827
24058
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
  1828
    (restartable ~~ true and:[startTimestamp notNil]) ifTrue:[
21333
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1829
        "is this artificial restriction useful ?"
23016
ff70b217d135 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22693
diff changeset
  1830
        self proceedableError:'a process cannot be started twice'.
21333
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1831
        ^ self.
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1832
    ].
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1833
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1834
    "/
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1835
    "/ just for your convenience ...
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1836
    "/
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1837
    startTimestamp := Timestamp now.
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1838
    name isNil ifTrue:[
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1839
        name := '(' , startBlock displayString , ')'
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1840
    ].
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1841
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1842
    "save block for possible restart"
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1843
    block := startBlock.
24058
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
  1844
"/    restartable ~~ true ifTrue:[
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
  1845
"/        startBlock := nil
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
  1846
"/    ].
21333
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1847
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1848
    [
21324
7913ef769c20 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21313
diff changeset
  1849
        "/
21333
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1850
        "/ block is the one which received the fork/newProcess some time ago...
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1851
        "/
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1852
        self exceptionHandlerSet handleDo:block
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1853
    ] on:CaughtSignals do:[:ex |
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1854
        "/
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1855
        "/ CaughtSignals: handle Process-Termination, Process-Restart and Abort
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1856
        "/       
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1857
        ex creator == RestartProcessRequest ifTrue:[
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1858
             ex restart
21324
7913ef769c20 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21313
diff changeset
  1859
        ].
21333
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1860
        ex return
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1861
    ] ensure:[
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1862
        self terminateNoSignal
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1863
    ].
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1864
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1865
    "Modified: / 17-11-2001 / 16:45:32 / cg"
e89a5aa9b463 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21326
diff changeset
  1866
    "Modified: / 31-01-2017 / 16:41:05 / stefan"
23016
ff70b217d135 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22693
diff changeset
  1867
    "Modified: / 24-05-2018 / 21:04:12 / Claus Gittinger"
24058
5ae2c27577c1 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23258
diff changeset
  1868
    "Modified: / 11-04-2019 / 14:56:09 / Stefan Vogel"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1869
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1870
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1871
terminate
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1872
    "terminate the receiver process.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1873
     Termination is done by raising the terminateSignal in the receiver process,
2689
ada9b102abcf typo fix
Claus Gittinger <cg@exept.de>
parents: 2636
diff changeset
  1874
     which can be caught.
22693
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  1875
     If the process is stopped, it will be resumed so that it can die.
375
claus
parents: 359
diff changeset
  1876
     All unwind actions and the exit-actions (if any)
4415
dff1649c072c resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
  1877
     will be performed before the process is really terminated.
dff1649c072c resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
  1878
     Notice, that the terminate actions are performed by the receiver,
dff1649c072c resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
  1879
     at its current priority. Therefore, in case higher prio processes are
dff1649c072c resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
  1880
     running, it may take any arbitrary time until the termination is eventually
dff1649c072c resume the process when terminated.
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
  1881
     done."
10
claus
parents: 5
diff changeset
  1882
22693
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  1883
    self terminateWithException:TerminateProcessRequest newException.
21313
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1884
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1885
    "Modified: / 24-08-1998 / 18:29:46 / cg"
22693
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  1886
    "Modified: / 23-04-2018 / 14:31:06 / stefan"
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  1887
    "Modified (comment): / 23-04-2018 / 15:40:43 / stefan"
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1888
!
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1889
4875
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  1890
terminateAllGUISubprocesses
19452
b884f7087b9f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19388
diff changeset
  1891
    "terminate all the receiver's gui subprocesses and their children as well
5683
3312d4d798dc terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents: 5681
diff changeset
  1892
     (i.e. all processes which are offsprings of the receiver, except for
4875
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  1893
      the receiver itself)."
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  1894
5377
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
  1895
    id isNil ifTrue:[
20808
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1896
        "/ problem:
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1897
        "/ if receiver is already dead, its id is nil.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1898
        "/ children are found by looking for processes with a parentID identical to
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1899
        "/ mine - ifNil, system processes are found, which is probably not what you
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1900
        "/ want ...
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1901
        "/ FIX: remember the id (or don't nil it when terminating)
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1902
        "/ requires VM changes.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1903
        ProcessorScheduler invalidProcessSignal
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1904
            raiseRequestWith:self
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1905
            errorString:'process is already dead - cannot determine child processes'.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1906
        ^ self
5377
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
  1907
    ].
4875
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  1908
    ProcessorScheduler knownProcesses do:[:aProcess |
21313
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1909
        (aProcess ~~ self and:[aProcess creatorId == id and:[aProcess isGUIProcess]]) ifTrue:[
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1910
            aProcess terminateWithAllGUISubprocesses
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1911
        ].
4875
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  1912
    ].
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  1913
14443
31dd04f0917f changed: #parentProcess
Claus Gittinger <cg@exept.de>
parents: 14359
diff changeset
  1914
    "Created: / 28-10-1996 / 20:43:32 / cg"
31dd04f0917f changed: #parentProcess
Claus Gittinger <cg@exept.de>
parents: 14359
diff changeset
  1915
    "Modified: / 26-10-2012 / 13:16:35 / cg"
21313
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1916
    "Modified: / 24-01-2017 / 17:38:10 / stefan"
5812
e23a3fdc75cb already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents: 5683
diff changeset
  1917
!
4875
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  1918
6783
013e21518b98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6775
diff changeset
  1919
terminateAllSubprocessesInGroup
013e21518b98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6775
diff changeset
  1920
    "terminate all subprocesses which have the receiver process as groupID,
013e21518b98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6775
diff changeset
  1921
     and their group-children as well.
19452
b884f7087b9f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19388
diff changeset
  1922
     (i.e. all processes in the receiver's process group, except for the receiver itself,
6783
013e21518b98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6775
diff changeset
  1923
      and recursively oll of their group processes.)."
1531
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
  1924
5377
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
  1925
    id isNil ifTrue:[
20808
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1926
        "/ problem:
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1927
        "/ if receiver is already dead, its id is nil.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1928
        "/ children are found by looking for processes with a parentID identical to
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1929
        "/ mine - ifNil, system processes are found, which is probably not what you
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1930
        "/ want ...
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1931
        "/ FIX: remember the id (or don't nil it when terminating)
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1932
        "/ requires VM changes.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1933
        ProcessorScheduler invalidProcessSignal
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1934
            raiseRequestWith:self
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1935
            errorString:'process is already dead - cannot determine child processes'.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1936
        ^ self
5377
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
  1937
    ].
9300
94f4a2f63aa8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9226
diff changeset
  1938
    self terminateAllSubprocessesInGroup:id
94f4a2f63aa8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9226
diff changeset
  1939
!
94f4a2f63aa8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9226
diff changeset
  1940
94f4a2f63aa8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9226
diff changeset
  1941
terminateAllSubprocessesInGroup:aGroup
94f4a2f63aa8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9226
diff changeset
  1942
    "terminate all subprocesses which have aGroup as groupID,
94f4a2f63aa8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9226
diff changeset
  1943
     and their group-children as well.
19452
b884f7087b9f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19388
diff changeset
  1944
     (i.e. all processes in the receiver's process group, except for the receiver itself,
9300
94f4a2f63aa8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9226
diff changeset
  1945
      and recursively oll of their group processes.)."
94f4a2f63aa8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9226
diff changeset
  1946
1531
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
  1947
    ProcessorScheduler knownProcesses do:[:aProcess |
21313
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1948
        (aProcess ~~ self and:[aProcess processGroupId == aGroup]) ifTrue:[
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1949
            aProcess terminateWithAllSubprocessesInGroup
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1950
        ].
1531
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
  1951
    ].
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1952
21313
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1953
    "Created: / 28-10-1996 / 20:43:32 / cg"
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1954
    "Modified: / 03-11-1997 / 00:28:06 / cg"
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1955
    "Modified: / 24-01-2017 / 17:42:33 / stefan"
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1956
!
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1957
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1958
terminateGroup
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  1959
    "terminate the receiver with all of its created subprocesses
19452
b884f7087b9f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19388
diff changeset
  1960
     that are in the receiver's process group."
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  1961
5683
3312d4d798dc terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents: 5681
diff changeset
  1962
    id isNil ifTrue:[
20808
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1963
        "/ problem:
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1964
        "/ if receiver is already dead, its id is nil.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1965
        "/ children are found by looking for processes with a parentID identical to
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1966
        "/ mine - ifNil, system processes are found, which is probably not what you
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1967
        "/ want ...
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1968
        "/ FIX: remember the id (or don't nil it when terminating)
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1969
        "/ requires VM changes.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1970
        ProcessorScheduler invalidProcessSignal
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1971
            raiseRequestWith:self
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1972
            errorString:'process is already dead - cannot determine child processes'.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  1973
        ^ self
5683
3312d4d798dc terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents: 5681
diff changeset
  1974
    ].
3312d4d798dc terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents: 5681
diff changeset
  1975
    ProcessorScheduler knownProcesses do:[:aProcess |
21313
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1976
        (aProcess ~~ self and:[aProcess processGroupId == id]) ifTrue:[
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1977
            aProcess terminate
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1978
        ].
5683
3312d4d798dc terminateAllGUISubprocesses no longer restricted to processGroup.
Stefan Vogel <sv@exept.de>
parents: 5681
diff changeset
  1979
    ].
5812
e23a3fdc75cb already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents: 5683
diff changeset
  1980
    self terminate
21313
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1981
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  1982
    "Modified: / 24-01-2017 / 17:41:12 / stefan"
5812
e23a3fdc75cb already-dead is a proceedable error
Claus Gittinger <cg@exept.de>
parents: 5683
diff changeset
  1983
!
1531
2a61dad6c7ce added #beGroupLeader & #terminateGroup
Claus Gittinger <cg@exept.de>
parents: 1530
diff changeset
  1984
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1985
terminateNoSignal
2197
bb9bc22f794b commentary
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  1986
    "hard-terminate the receiver process without sending a terminateSignal
375
claus
parents: 359
diff changeset
  1987
     or performing any unwind-handling.
2197
bb9bc22f794b commentary
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  1988
     However, exit-actions are performed.
bb9bc22f794b commentary
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  1989
     This is useful in case of emergency, when a buggy terminationHandler
bb9bc22f794b commentary
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  1990
     prevents you from getting a process to terminate."
375
claus
parents: 359
diff changeset
  1991
claus
parents: 359
diff changeset
  1992
    |block|
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  1993
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1994
    "/ this is treated like the final suspend
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1995
    suspendActions notNil ifTrue:[
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  1996
	[suspendActions isEmpty] whileFalse:[
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  1997
	    block := suspendActions removeFirst.
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  1998
	    block value.
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  1999
	]
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  2000
    ].
375
claus
parents: 359
diff changeset
  2001
    exitActions notNil ifTrue:[
5450
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  2002
	[exitActions isEmpty] whileFalse:[
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  2003
	    block := exitActions removeFirst.
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  2004
	    block value.
b0edfff99a73 rel5 preps
Claus Gittinger <cg@exept.de>
parents: 5397
diff changeset
  2005
	]
375
claus
parents: 359
diff changeset
  2006
    ].
329
claus
parents: 326
diff changeset
  2007
    suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll].
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  2008
    Processor terminateNoSignal:self
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  2009
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  2010
    "Modified: 13.12.1995 / 13:40:14 / stefan"
2384
ceb4f8de635a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2302
diff changeset
  2011
    "Modified: 12.2.1997 / 12:41:38 / cg"
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2012
!
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2013
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2014
terminateSubprocesses
19751
4e212ebc3961 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19452
diff changeset
  2015
    "terminate all the receiver's subprocesses
19452
b884f7087b9f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19388
diff changeset
  2016
     (i.e. all processes in the receiver's process group, except for
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2017
      the receiver itself)."
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2018
5377
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
  2019
    id isNil ifTrue:[
20808
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2020
        "/ problem:
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2021
        "/ if receiver is already dead, its id is nil.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2022
        "/ children are found by looking for processes with a parentID identical to
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2023
        "/ mine - ifNil, system processes are found, which is probably not what you
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2024
        "/ want ...
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2025
        "/ FIX: remember the id (or don't nil it when terminating)
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2026
        "/ requires VM changes.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2027
        ProcessorScheduler invalidProcessSignal
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2028
            raiseRequestWith:self
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2029
            errorString:'process is already dead - cannot determine child processes'.
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2030
        ^ self
10496
1198c42b85f5 Be conservative when setting helper processes of executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 10436
diff changeset
  2031
    ].
1198c42b85f5 Be conservative when setting helper processes of executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 10436
diff changeset
  2032
    processGroupId == 0 ifTrue:[
20808
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2033
        ProcessorScheduler invalidProcessSignal
e7c52f36bc73 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20777
diff changeset
  2034
            raiseWith:self errorString:'trying to terminate the system process group'.
5377
575184539847 cannot terminate an already dead processes children
ca
parents: 5256
diff changeset
  2035
    ].
21313
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2036
    ProcessorScheduler knownProcesses do:[:eachProcess |
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2037
        eachProcess ~~ self ifTrue:[
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2038
            |eachProcessGroupId|
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2039
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2040
            eachProcessGroupId := eachProcess processGroupId.
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2041
            (eachProcessGroupId == processGroupId or:[eachProcessGroupId == id]) ifTrue:[
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2042
                eachProcess terminate
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2043
            ].
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2044
        ].
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2045
    ].
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2046
21313
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2047
    "Created: / 28-10-1996 / 20:41:49 / cg"
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2048
    "Modified: / 26-08-1997 / 03:09:57 / cg"
056a82337eda #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21129
diff changeset
  2049
    "Modified: / 24-01-2017 / 17:35:25 / stefan"
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2050
!
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2051
4875
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  2052
terminateWithAllGUISubprocesses
6783
013e21518b98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6775
diff changeset
  2053
    "terminate the receiver with all of its created gui subprocesses and their gui children."
4875
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  2054
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  2055
    self terminateAllGUISubprocesses.
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  2056
    self terminate
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  2057
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  2058
    "Modified: 28.10.1996 / 20:42:00 / cg"
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  2059
    "Created: 28.10.1996 / 20:44:07 / cg"
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  2060
!
5c0e3d74978e add terminateAllGui .... processes
ca
parents: 4874
diff changeset
  2061
6783
013e21518b98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6775
diff changeset
  2062
terminateWithAllSubprocessesInGroup
013e21518b98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6775
diff changeset
  2063
    "terminate the receiver with
19452
b884f7087b9f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 19388
diff changeset
  2064
     all subprocesses which have the receiver's process ID as groupID,
6783
013e21518b98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6775
diff changeset
  2065
     and their group-children as well.
19751
4e212ebc3961 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19452
diff changeset
  2066
     (i.e. the receiver plus all processes in the receiver's process group,
6783
013e21518b98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6775
diff changeset
  2067
      and recursively all of their group processes)."
013e21518b98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6775
diff changeset
  2068
013e21518b98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6775
diff changeset
  2069
    self terminateAllSubprocessesInGroup.
1837
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2070
    self terminate
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2071
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2072
    "Modified: 28.10.1996 / 20:42:00 / cg"
7e3b67a1adab more subprocess termination variants
Claus Gittinger <cg@exept.de>
parents: 1789
diff changeset
  2073
    "Created: 28.10.1996 / 20:44:07 / cg"
22693
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2074
!
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2075
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2076
terminateWithException:aTerminateException
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2077
    "terminate the receiver process.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2078
     Termination is done by raising aTerminateException in the receiver process,
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2079
     which can be caught.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2080
     If the process is stopped, it will be resumed so that it can die.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2081
     All unwind actions and the exit-actions (if any)
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2082
     will be performed before the process is really terminated.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2083
     Notice, that the terminate actions are performed by the receiver,
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2084
     at its current priority. Therefore, in case higher prio processes are
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2085
     running, it may take any arbitrary time until the termination is eventually
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2086
     done."
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2087
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2088
    |wasBlocked|
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2089
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2090
    Processor activeProcess == self ifTrue:[
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2091
        "suicide: terminating myself"
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2092
        NoHandlerError handle:[:ex |
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2093
            "unhandled TerminateProcessRequest is not an error -
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2094
             the interrupt may be delivered before a 
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2095
             low priority process has set up the exception handler"
24775
76c608493514 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 24238
diff changeset
  2096
            ex exception ~~ aTerminateException ifTrue:[
22693
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2097
                ex reject.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2098
            ].
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2099
        ] do:[
24775
76c608493514 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 24238
diff changeset
  2100
            "give myself a chance to terminate after cleanup actions
76c608493514 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 24238
diff changeset
  2101
             have been performed by the exception handler"    
22693
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2102
            aTerminateException raise.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2103
        ].
24775
76c608493514 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 24238
diff changeset
  2104
        "still alive - hard terminate myself"
22693
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2105
        self terminateNoSignal.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2106
        "not reached"
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2107
        ^ self.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2108
    ].
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2109
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2110
    "the receiver is terminated from another process"
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2111
    wasBlocked := OperatingSystem blockInterrupts.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2112
    [
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2113
        (state isNil or:[state == #dead]) ifTrue:[
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2114
            ^ self.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2115
        ].
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2116
        state == #osWait ifTrue:[
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2117
            "osWait processes cannot be interrupted"
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2118
            self terminateNoSignal.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2119
            ^ self.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2120
        ].
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2121
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2122
        self suspendedContext isNil ifTrue:[
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2123
            "if the receiver had no chance to execute yet,
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2124
             it can be shot down without a signal"
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2125
            self terminateNoSignal.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2126
            ^ self
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2127
        ]
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2128
    ] ensure:[
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2129
        wasBlocked ifFalse:[OperatingSystem unblockInterrupts]
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2130
    ].
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2131
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2132
    "register an interrupt action, so that I am terminating myself"
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2133
    self interruptWith:[
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2134
        self terminateWithException:aTerminateException.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2135
    ].
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2136
    "maybe I am stopped - resume so that I can die"
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2137
    self resume.
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2138
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2139
    "Created: / 23-04-2018 / 14:29:34 / stefan"
a0bc64103805 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22628
diff changeset
  2140
    "Modified (comment): / 23-04-2018 / 15:41:07 / stefan"
24775
76c608493514 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 24238
diff changeset
  2141
    "Modified (format): / 11-09-2019 / 12:02:34 / Stefan Vogel"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2142
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2143
24819
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2144
!Process methodsFor:'suspend & resume'!
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2145
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2146
abort
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2147
    "raise an AbortOperationRequest in the receiver process.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2148
     Most processes willing to handle this will return to some save state
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2149
     (typically, some kind of event loop).
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2150
     If not handled, this will result in termination of the process."
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2151
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2152
    Processor activeProcess == self ifTrue:[
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2153
	AbortOperationRequest raiseRequest
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2154
    ] ifFalse:[
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2155
	self interruptWith:[
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2156
	    AbortOperationRequest raiseRequest
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2157
	].
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2158
    ]
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2159
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2160
    "Modified: / 16.11.2001 / 17:39:18 / cg"
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2161
!
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2162
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2163
resume
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2164
    "resume the receiver process"
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2165
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2166
    state == #stopped ifTrue:[
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2167
	state := #run.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2168
    ].
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2169
    Processor resume:self
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2170
!
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2171
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2172
resumeForSingleSend
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2173
    "resume the receiver process, but only let it execute a single send."
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2174
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2175
    Processor resumeForSingleSend:self
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2176
!
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2177
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2178
stop
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2179
    "suspend the receiver process - will continue to run when a resume is sent.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2180
     A stopped process will not be resumed for interrupt processing."
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2181
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2182
    self suspendWithState:#stopped.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2183
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2184
    "Modified: / 13.12.1995 / 13:22:58 / stefan"
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2185
    "Modified: / 27.7.1998 / 23:37:15 / cg"
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2186
!
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2187
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2188
suspend
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2189
    "suspend the receiver process - it will continue to run when a resume is sent.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2190
     Notice, that an interrupt will also resume the receiver,
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2191
     so any waiting code should be prepared for premature return from
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2192
     a suspend (see wait code in Semaphore).
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2193
     Use #stop for a hard-suspend, which is not affected by interrupts."
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2194
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2195
    self suspendWithState:#suspended
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2196
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2197
    "Modified: 17.6.1996 / 14:41:34 / cg"
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2198
!
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2199
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2200
suspendWithState:aStateSymbol
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2201
    "like suspend, this suspends the receiver process until a resume is sent.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2202
     This sets the state to the argument, aStateSymbol, which is shown
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2203
     in the ProcessMonitor (instead of #suspended).
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2204
     (i.e. no new functionality, but a bit more debuggability)
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2205
     Notice, that an interrupt will also resume the receiver,
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2206
     so any waiting code should be prepared for premature return from
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2207
     a suspend (see wait code in Semaphore).
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2208
     Use #stop for a hard-suspend, which is not affected by interrupts.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2209
     Should be called with interrupts disabled."
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2210
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2211
    <resource: #skipInDebuggersWalkBack>
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2212
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2213
    suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll].
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2214
    suspendActions notNil ifTrue:[
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2215
        |savedState|
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2216
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2217
        savedState := state.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2218
        state := #aboutToSuspend.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2219
        suspendActions do:[:action | action value].
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2220
        state ~~ #aboutToSuspend ifTrue:[
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2221
            "/ mhmh - one of the suspendActions lead to making me active again;
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2222
            "/ bail out.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2223
            "/ This fixes the Semaphore was signalled, but process did not run error,
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2224
            "/ which can happen when a process with a suspend action goes into a readWait,
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2225
            "/ and the suspend action does a thread switch, and the readWait semaphore gets
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2226
            "/ signalled before we come back here. Then the semaphore wakeup will have already
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2227
            "/ place me back into the run state, so I should not go into a suspend below.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2228
            ^ self.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2229
        ].
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2230
        state := savedState.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2231
    ].
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2232
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2233
    "
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2234
     this is a bit of a kludge: allow someone else to
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2235
     set the state to something like #ioWait etc.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2236
     In this case, do not set the receiver's state to #suspend.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2237
     (All of this to enhance the output of the process monitor ...)
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2238
    "
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2239
    (state == #active
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2240
    or:[state == #run
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2241
    or:[aStateSymbol == #stopped]]) ifTrue:[
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2242
        state := aStateSymbol.
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2243
    ].
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2244
    Processor suspend:self
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2245
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2246
    "Modified: / 30-05-2018 / 13:57:00 / Claus Gittinger"
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2247
! !
8eb7de8ab3d2 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 24779
diff changeset
  2248
24238
51ace3995288 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 24224
diff changeset
  2249
6739
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2250
!Process methodsFor:'thread local storage'!
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2251
19387
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2252
environment
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2253
    "return the dictionary holding thread local variables, or nil if there are none"
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2254
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2255
    ^ environment
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2256
!
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2257
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2258
environment:aDictionary
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2259
    "set the dictionary holding thread local variables, or nil if there are to be none"
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2260
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2261
    environment := aDictionary
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2262
!
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2263
7427
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2264
environmentAt:aKey
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2265
    "return the value of a thread local variable, or raise an error, if no such variable exists"
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2266
14722
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  2267
    ^ self
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  2268
	environmentAt:aKey
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  2269
	ifAbsent:[
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  2270
	    self errorKeyNotFound:aKey.
f481fa77115d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14443
diff changeset
  2271
	]
7427
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2272
!
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2273
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2274
environmentAt:aKey ifAbsent:aBlock
7427
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2275
    "return the value of a thread local variable, or the value of defaultValue if no such variable exists"
6739
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2276
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2277
    environment isNil ifTrue:[
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2278
        ^ aBlock value
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2279
    ].
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2280
    ^ environment at:aKey ifAbsent:aBlock.
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2281
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2282
    "Modified: / 05-02-2020 / 16:51:35 / Stefan Vogel"
6739
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2283
!
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2284
7427
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2285
environmentAt:aKey put:aValue
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2286
    "set the value of a thread local variable. Returns aValue"
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2287
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2288
    environment isNil ifTrue:[
20067
5817f13cb16d #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 19969
diff changeset
  2289
        environment := IdentityDictionary new
7427
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2290
    ].
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2291
    ^ environment at:aKey put:aValue.
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2292
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2293
    "Modified: / 05-02-2020 / 16:52:33 / Stefan Vogel"
7427
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2294
!
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2295
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  2296
environmentIncludesKey:aKey
19388
869a47877c44 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19387
diff changeset
  2297
    "true if there is a thread local variable, false if no such variable exists"
869a47877c44 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19387
diff changeset
  2298
20067
5817f13cb16d #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 19969
diff changeset
  2299
    ^ environment notNil and:[environment includesKey:aKey]
19388
869a47877c44 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19387
diff changeset
  2300
!
869a47877c44 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19387
diff changeset
  2301
19377
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2302
stderr
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2303
    "the processes stderr.
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2304
     By default, this is Stderr, but it can be overwritten
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2305
     (for example to redirect a thread's error output to some other place"
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  2306
19377
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2307
    ^ self environmentAt:#Stderr ifAbsent:Stderr
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2308
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2309
    "
22183
1c6514fa3f89 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22175
diff changeset
  2310
     Processor activeProcess stderr
19377
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2311
    "
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  2312
19377
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2313
    "
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2314
     |out sema|
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  2315
19377
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2316
     out := WriteStream on:''.
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2317
     sema := Semaphore new.
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2318
     [
22183
1c6514fa3f89 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22175
diff changeset
  2319
        Processor activeProcess environmentAt:#Stderr put:out.
1c6514fa3f89 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22175
diff changeset
  2320
        'hello world' errorPrintCR.
1c6514fa3f89 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22175
diff changeset
  2321
        sema signal.
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  2322
     ] fork.
19377
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2323
     sema wait.
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2324
     Transcript showCR:('output was: ''',out contents,'''').
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2325
    "
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2326
!
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2327
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2328
stdin
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2329
    "the processes stdin.
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2330
     By default, this is Stdin, but it can be overwritten
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2331
     (for example to redirect a thread's input from some other place"
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  2332
19377
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2333
    ^ self environmentAt:#Stdin ifAbsent:Stdin
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2334
!
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2335
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2336
stdout
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2337
    "the processes stdout.
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2338
     By default, this is Stdout, but it can be overwritten
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2339
     (for example to redirect a thread's output to some other place"
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  2340
19377
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2341
    ^ self environmentAt:#Stdout ifAbsent:Stdout
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2342
!
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2343
7427
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2344
threadVariableValueOf:aKey
20682
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2345
    "return the value of a thread local variable, 
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2346
     or nil if no such variable exists"
7427
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2347
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2348
    ^ self environmentAt:aKey ifAbsent:nil
16047
98326db8c188 class: Process
Claus Gittinger <cg@exept.de>
parents: 15964
diff changeset
  2349
98326db8c188 class: Process
Claus Gittinger <cg@exept.de>
parents: 15964
diff changeset
  2350
    "
98326db8c188 class: Process
Claus Gittinger <cg@exept.de>
parents: 15964
diff changeset
  2351
     see example in withThreadVariable:boundTo:do:
98326db8c188 class: Process
Claus Gittinger <cg@exept.de>
parents: 15964
diff changeset
  2352
    "
7427
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2353
!
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2354
19377
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2355
transcript
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2356
    "the processes transcript.
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2357
     By default, this is Transcript, but it can be overwritten
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2358
     (for example to redirect a thread's output to some other place"
19860
324edacff5cc unified cpu and os defines;
Claus Gittinger <cg@exept.de>
parents: 19751
diff changeset
  2359
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2360
    ^ self environmentAt:#Transcript ifAbsent:Transcript.
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2361
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2362
    "Modified: / 05-02-2020 / 17:11:14 / Stefan Vogel"
19377
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2363
!
fca073527bd3 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19297
diff changeset
  2364
19387
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2365
withThreadLocalVariables:aDictionary do:aBlock
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2366
    "evaluate a block with threadLocalVariables from aDictionary;
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2367
     restore the old bindings afterwards."
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2368
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2369
    |oldEnv|
19387
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2370
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2371
    oldEnv := environment.
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2372
    environment := aDictionary.
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2373
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2374
    ^ aBlock ensure:[
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2375
        environment := oldEnv.
19387
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2376
    ].
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2377
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2378
    "Modified: / 05-02-2020 / 16:29:08 / Stefan Vogel"
19387
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2379
!
8f5c7d69067e #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19380
diff changeset
  2380
6739
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2381
withThreadVariable:variableNameSymbol boundTo:aValue do:aBlock
7427
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2382
    "evaluate a block with the threadLocalVariable being bound to aValue;
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2383
     undo the variable binding afterwards."
7426b3fe9570 more environment accessors
Claus Gittinger <cg@exept.de>
parents: 7263
diff changeset
  2384
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2385
    |oldValue|
6739
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2386
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2387
    environment isNil ifTrue:[
20682
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2388
        environment := IdentityDictionary new
6739
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2389
    ].
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2390
    oldValue := environment at:variableNameSymbol ifAbsent:Void.
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2391
    environment at:variableNameSymbol put:aValue.
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2392
    
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2393
    ^ aBlock ensure:[
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2394
        oldValue == Void
20682
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2395
            ifTrue:[ environment removeKey:variableNameSymbol]
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2396
            ifFalse:[ environment at:variableNameSymbol put:oldValue ]
6739
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2397
    ].
16047
98326db8c188 class: Process
Claus Gittinger <cg@exept.de>
parents: 15964
diff changeset
  2398
98326db8c188 class: Process
Claus Gittinger <cg@exept.de>
parents: 15964
diff changeset
  2399
    "
98326db8c188 class: Process
Claus Gittinger <cg@exept.de>
parents: 15964
diff changeset
  2400
     |printIt|
98326db8c188 class: Process
Claus Gittinger <cg@exept.de>
parents: 15964
diff changeset
  2401
20682
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2402
     printIt := [ 
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2403
                    Transcript 
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2404
                        showCR:'foo is now ',
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2405
                        (Processor activeProcess threadVariableValueOf:#foo) printString 
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2406
                ].
16047
98326db8c188 class: Process
Claus Gittinger <cg@exept.de>
parents: 15964
diff changeset
  2407
98326db8c188 class: Process
Claus Gittinger <cg@exept.de>
parents: 15964
diff changeset
  2408
     Processor activeProcess
20682
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2409
         withThreadVariable:#foo
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2410
         boundTo:1234
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2411
         do:[
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2412
            printIt value.
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2413
            Processor activeProcess
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2414
                withThreadVariable:#foo
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2415
                boundTo:2345
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2416
                do:[
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2417
                    printIt value
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2418
                ].
efe899873585 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20251
diff changeset
  2419
            ]
16047
98326db8c188 class: Process
Claus Gittinger <cg@exept.de>
parents: 15964
diff changeset
  2420
    "
23050
7a2a7db8aca6 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 23038
diff changeset
  2421
25244
6df56799dd3e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 25222
diff changeset
  2422
    "Modified: / 05-02-2020 / 16:50:19 / Stefan Vogel"
6739
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2423
! !
63fc2acb417a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6738
diff changeset
  2424
1784
af6446feffae optionally pass the interruptedContext to a #interruptWith: block
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
  2425
!Process class methodsFor:'documentation'!
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  2426
19293
81e42b6626fb #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19292
diff changeset
  2427
version
81e42b6626fb #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19292
diff changeset
  2428
    ^ '$Header$'
81e42b6626fb #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19292
diff changeset
  2429
!
81e42b6626fb #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19292
diff changeset
  2430
13398
5c6fd278f26b added: #version_CVS
vrany
parents: 13206
diff changeset
  2431
version_CVS
19292
be9b1c99ec11 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 18189
diff changeset
  2432
    ^ '$Header$'
12764
c3da6be46ff1 use _MAX_INT instead of 0x3fffffff in primitive code when generating SmallIntegers
Stefan Vogel <sv@exept.de>
parents: 11416
diff changeset
  2433
!
c3da6be46ff1 use _MAX_INT instead of 0x3fffffff in primitive code when generating SmallIntegers
Stefan Vogel <sv@exept.de>
parents: 11416
diff changeset
  2434
13398
5c6fd278f26b added: #version_CVS
vrany
parents: 13206
diff changeset
  2435
version_SVN
15964
ee3faaeb7427 class: Process
Claus Gittinger <cg@exept.de>
parents: 15117
diff changeset
  2436
    ^ '$ Id: Process.st 10643 2011-06-08 21:53:07Z vranyj1  $'
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
  2437
! !
6774
6711472e6df4 oops - waitUntil terminated for a process that did not rune
penk
parents: 6739
diff changeset
  2438
15117
d7e7376ee1a4 class: Process
Claus Gittinger <cg@exept.de>
parents: 14724
diff changeset
  2439
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2440
Process initialize!