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