Process.st
author Claus Gittinger <cg@exept.de>
Thu, 25 Apr 1996 18:20:46 +0200
changeset 1290 15ba3221b89b
parent 1273 f8449f53a6a3
child 1294 e26bbb61f6b2
permissions -rw-r--r--
documentation
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
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
Link subclass:#Process
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    14
	instanceVariableNames:'id prio state startBlock name restartable interruptActions
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
    15
		exitActions suspendSemaphore singleStepping
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
    16
		emergencySignalHandler suspendActions'
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    17
	classVariableNames:'TerminateSignal CoughtSignals'
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    18
	poolDictionaries:''
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    19
	category:'Kernel-Processes'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    21
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    22
!Process class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    23
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    24
copyright
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    25
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    26
 COPYRIGHT (c) 1992 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
    27
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    28
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    29
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    30
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    32
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    33
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    34
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    35
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    36
!
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    37
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    38
documentation
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    39
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    40
    Instances of Process represent lightweight smalltalk processes 
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    41
    (i.e. threads). These all run in a shared smalltalk/X address space,
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    42
    and can thus access and communicate via any objects.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    43
    Do not confuse these with (heavy-weight) unix processes, which are
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    44
    created differently, and do NOT run in the same address space.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    45
    Also notice, that heavy-weight process creation takes much longer.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    46
    (see OperatingSystemclass>>fork).
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    47
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    48
    Processes are typically created by sending #fork or #forkAt: to a block;
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    49
    the block creates a new process, defines itself as its startBlock,
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    50
    and (optionally) tells the Processor about the new process.
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    51
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    52
    Scheduling is done by Processor, which is the sole instance of 
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    53
    ProcessorScheduler.
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    54
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    55
    Processes can be terminated either soft or via a hardTerminate.
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    56
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    57
    A soft terminate (see Process>>terminate) will raise a TerminationSignal
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    58
    in the process, which can be handled by the process. 
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    59
    If no other handler was specified, the processes own handler 
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    60
    (see Process>>start) will catch the signal and terminate the process. 
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    61
    During this signal processing, normal unwind processing takes place,
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    62
    this means that with a soft terminate, all valueOnUnwind:/valueNowOrOnUnwind: 
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    63
    cleanup blocks are evaluated.
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    64
    (so a process which has set up those blocks correctly does not have to
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    65
     care especially about cleanup in case of termination).
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    66
    Other than that, the TerminateSignal can be cought for special cleanup or
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    67
    even to make the process continue execution.
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    68
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    69
    A hard terminate (Process>>terminateNoSignal) will NOT do all of the above,
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    70
    but quickly (and without any cleanup) terminate the process.
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    71
    The debugger offers a quickTerminate option on its popupMenu for
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    72
    situations, when soft termination fails. (for example, if some error was
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    73
    coded into a handler or unwind block).
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    74
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    75
    Notice: 
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
    76
        in Smalltalk/X, processes are gone, when an image is restarted;
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
    77
        this means, that you have to take care of process re-creation yourself.
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
    78
        Usually, this is done by depending on ObjectMemory, recreating the
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
    79
        process(es) when the #returnFromSnapshot-change notifiction arrives.
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
    80
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
    81
        All views (actually windowGroups) recreate their window process
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
    82
        on image-restart. You have to do so manually for your own processes.
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    83
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    84
    A later version will allow specification of automatic restart, but
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    85
    thats not yet implemented. However, even when implemented, restartable processes
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    86
    will be recreated to restart from the beginning. It will not be possible to
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    87
    automatically continue a processes execution where it left off.
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    88
    This is a consequence of the portable implementation of ST/X, since in order to
375
claus
parents: 359
diff changeset
    89
    implement process continuation, the machines stack had to be preserved and 
claus
parents: 359
diff changeset
    90
    recreated.  Although this is possible to do (and actually not too complicated), 
claus
parents: 359
diff changeset
    91
    this has not been implemented, since the machines stack layout is highly machine/compiler 
claus
parents: 359
diff changeset
    92
    dependent, thus leading to much bigger porting effort of ST/X (which conflicts
claus
parents: 359
diff changeset
    93
    with ST/X's design goal of being highly portable).
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    94
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
    95
    Process synchronization:
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
    96
        Synchronization with cooperating processes is supported as usual,
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
    97
        via Semaphores (see Semaphore, Delay, SharedQueue etc.)
375
claus
parents: 359
diff changeset
    98
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
    99
        With uncooperative processes, only synchronization on suspend
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   100
        and termination is possible:
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   101
          any other process can wait for a process to suspend or terminate. 
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   102
          This waiting is implemented by using suspendSemaphore and exitBlocks
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   103
          (where an exitSemaphore is signalled).
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   104
          See waitUntilSuspended / waitUntilTerminated.
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   105
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   106
    [Instance variables:]
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   107
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   108
        id                     <SmallInteger>   a unique process-id
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   109
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   110
        prio                   <SmallInteger>   the processes priority
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   111
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   112
        state                  <Symbol>         the processes state
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   113
                                                (for process-monitor)
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   114
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   115
        startBlock             <Block>          the startup-block (the one that forked)
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   116
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   117
        name                   <String-or-nil>  the processes name (if any)
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   118
                                                (for process-monitor)
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   119
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   120
        suspendSemaphore       <Semaphore>      triggered when suspend (if nonNil)
217
a0400fdbc933 *** empty log message ***
claus
parents: 213
diff changeset
   121
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   122
        restartable            <Boolean>        is restartable (not yet implemented)
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   123
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   124
        interruptActions       <Collection>     interrupt actions as defined by interruptWith:,
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   125
                                                performed at interrupt time
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   126
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   127
        exitActions            <Collection of Block>          
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   128
                                                additional cleanup actions to perform 
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   129
                                                on termination (if nonEmpty)
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   130
                                                
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   131
        emergencySignalHandler <Block>          can be used for per-process
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   132
                                                emergency signal handling
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   133
    [Class variables:]
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   134
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   135
        TerminateSignal         <Signal>        signal used to terminate processes
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   136
                                                (should not be cought - or at least
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   137
                                                 rejected in handlers)
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   138
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   139
    [see also:]
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   140
        ProcessorScheduler
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   141
        Block
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   142
        Sempahore SemaphoreSet Delay SharedQueue
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   143
        WindowGroup
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   144
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   145
"
213
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   146
!
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   147
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   148
examples 
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   149
"
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   150
    start a background process, computing 1000 factorial 100 times;
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   151
    the processes priority is set to not disturb any interactive process.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   152
    Since its prio is higher than the 3D animation demos prio, you will notice,
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   153
    that those are suspended while the computation runs. But Interactive views
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   154
    (like browsers) will continue to react normal.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   155
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   156
    [
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   157
       'starting' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   158
       100 timesRepeat:[1000 factorial].
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   159
       'done with factorial' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   160
    ] forkAt:(Processor userBackgroundPriority).
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   161
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   162
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   163
    start a background process, computing 1000 factorial 100 times;
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   164
    the processes priority is set to not disturb any process.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   165
    The prio is set to 1 (which is the lowest possible) notice that now,
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   166
    the 3D animation demos also continue to run. 
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   167
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   168
    [
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   169
       'starting' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   170
       100 timesRepeat:[1000 factorial].
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   171
       'done with factorial' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   172
    ] forkAt:1.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   173
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   174
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   175
    start a background process, reading a pipe without blocking other
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   176
    processes;
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   177
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   178
    [
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   179
       |p|
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   180
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   181
       'starting' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   182
       p := PipeStream readingFrom:'ls -lR .'.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   183
       [p atEnd] whileFalse:[
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   184
	   p readWait.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   185
	   p nextLine printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   186
       ].
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   187
       p close.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   188
       'done with pipe' printNL.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   189
    ] forkAt:1.
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   190
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   191
    see more examples in doc/coding 
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   192
    (or search in the browser for senders of fork*)
3b56a17534fd *** empty log message ***
claus
parents: 202
diff changeset
   193
"
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
   194
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   195
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   196
!Process class methodsFor:'initialization'!
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   197
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   198
initialize
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   199
    TerminateSignal isNil ifTrue:[
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   200
	TerminateSignal := Signal new mayProceed:true.
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   201
	TerminateSignal nameClass:self message:#terminateSignal.
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   202
	TerminateSignal notifierString:'unhandled process termination'.
302
1f76060d58a4 *** empty log message ***
claus
parents: 252
diff changeset
   203
1f76060d58a4 *** empty log message ***
claus
parents: 252
diff changeset
   204
	CoughtSignals := SignalSet with:AbortSignal with:TerminateSignal.
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   205
    ]
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   206
! !
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   207
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   208
!Process class methodsFor:'instance creation'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   209
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   210
for:aBlock priority:aPrio
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   211
    "create a new (unscheduled) process which will execute aBlock at
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   212
     a given priority, once scheduled. The process will start execution once
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   213
     it gets a #resume-message."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   214
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   215
    ^ self new for:aBlock priority:aPrio
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   216
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   217
345
claus
parents: 339
diff changeset
   218
!Process class methodsFor:'Signal constants'!
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   219
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   220
terminateSignal
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   221
    "return the signal used for process termination"
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   222
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   223
    ^ TerminateSignal
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   224
! !
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   225
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   226
!Process methodsFor:'accessing'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   227
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   228
changePriority:aNumber
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   229
    "same as priority:, but returns the old priority.
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   230
     (cannot do this in #priority: for ST-80 compatibility)"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   231
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   232
    |oldPrio|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   233
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   234
    oldPrio := prio.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   235
    Processor changePriority:aNumber for:self.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   236
    ^ oldPrio
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   237
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   238
    "Modified: 23.12.1995 / 18:38:53 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   239
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   240
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   241
id
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   242
    "return the processes id"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   243
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   244
    ^ id
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   245
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   246
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   247
name
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   248
    "return the processes name"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   249
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   250
    ^ name
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   251
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   252
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   253
name:aString
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   254
    "set the processes name"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   255
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   256
    name := aString
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   257
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   258
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   259
priority
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   260
    "return the receivers priority"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   261
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   262
    ^ prio
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   263
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   264
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   265
priority:aNumber
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   266
    "set my priority"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   267
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   268
    Processor changePriority:aNumber for:self.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   269
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   270
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   271
restartable:aBoolean
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   272
    "set/clear, the restartable flag.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   273
     Restartable processes will automatically be restarted by the
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   274
     ProcessorScheduler upon image restart. 
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   275
     Others have to be restarted manually."
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   276
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   277
    startBlock isNil ifTrue:[
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   278
        self error:'cannot be made restartable when already started'.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   279
        ^ self
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   280
    ].
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   281
    restartable := aBoolean
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   282
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   283
    "Modified: 23.12.1995 / 18:38:32 / cg"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   284
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   285
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   286
singleStep:aBoolean
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   287
    singleStepping := aBoolean
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   288
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   289
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   290
startBlock
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   291
    "return the processes startup-block"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   292
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   293
    ^ startBlock
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   294
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   295
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   296
state
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   297
    "return a symbol describing the processes state"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   298
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   299
    ^ state
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   300
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   301
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   302
state:aSymbol
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   303
    "set the state - only to be used from scheduler"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   304
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   305
    state := aSymbol
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   306
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   307
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   308
suspendedContext
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   309
    "return the processes suspended context 
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   310
     - this is the context from which a process switch into the scheduler
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   311
     or another process occured.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   312
     Typically, only the debugger is interested in this one."
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   313
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   314
%{  /* NOCONTEXT */
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   315
    OBJ i;
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   316
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   317
    if (__isSmallInteger(i = __INST(id))) {
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   318
	RETURN (__threadContext(__intVal(i)));
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   319
    }
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   320
%}.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   321
    ^ nil
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   322
! !
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   323
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   324
!Process methodsFor:'accessing-change notifications'!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   325
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   326
emergencySignalHandler
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   327
    "return the emergencySignalHandler block.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   328
     See Signal>>documentation for more info."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   329
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   330
    ^ emergencySignalHandler
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
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   333
emergencySignalHandler:aOneArgBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   334
    "set the emergencySignalHandler block.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   335
     See Signal>>documentation for more info."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   336
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   337
    emergencySignalHandler := aOneArgBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   338
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   339
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   340
exitAction:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   341
    "add aBlock to the processes exit actions.
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   342
     This block will be evaluated right before the process dies.
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   343
     An argument of nil clears removes all exitActions."
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   344
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   345
    aBlock isNil ifTrue:[
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   346
	exitActions := nil.
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   347
	^ self.
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   348
    ].
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   349
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   350
    exitActions isNil ifTrue:[
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   351
	exitActions := OrderedCollection new
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   352
    ].
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   353
    exitActions add:aBlock
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   354
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   355
    "Modified: 13.12.1995 / 13:44:03 / stefan"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   356
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   357
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   358
suspendAction:aBlock
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   359
    "add aBlock to the processes suspend actions.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   360
     This block will be evaluated when a process gets suspended.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   361
     A nil argument removes all suspendActions."
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   362
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   363
    aBlock isNil ifTrue:[
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   364
	suspendActions := nil.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   365
	^ self.
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   366
    ].
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   367
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   368
    suspendActions isNil ifTrue:[
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   369
	suspendActions := OrderedCollection new
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   370
    ].
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   371
    suspendActions add:aBlock
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   372
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   373
    "Created: 13.12.1995 / 13:35:54 / stefan"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   374
    "Modified: 13.12.1995 / 13:44:31 / stefan"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   375
! !
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   376
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   377
!Process methodsFor:'accessing-stack'!
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   378
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   379
maximumStackSize
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   380
    "returns the processes stack limit - i.e. the process will be 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   381
     interrupted with a recursionSignal-raise, if it ever
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   382
     needs more stack (in bytes) than this number"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   383
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   384
%{  /* NOCONTEXT */
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   385
    extern int __threadMaxStackSize();
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   386
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   387
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   388
    if (__isSmallInteger(i = __INST(id))) {
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   389
	RETURN( __MKSMALLINT(__threadMaxStackSize(__intVal(i))) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   390
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   391
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   392
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   393
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   394
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   395
setMaximumStackSize:limit
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   396
    "sets the processes stack limit - i.e. the process will be
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   397
     interrupted with a recursionSignal-raise, if it ever
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   398
     needs more stack (in bytes) than this number.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   399
     Returns the old value."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   400
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   401
%{  /* NOCONTEXT */
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   402
    extern int __threadSetMaxStackSize();
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   403
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   404
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   405
    if (__isSmallInteger(i = __INST(id)) 
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   406
     && __isSmallInteger(limit) ) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   407
	RETURN ( __MKSMALLINT(__threadSetMaxStackSize(__intVal(i), __intVal(limit))) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   408
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   409
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   410
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   411
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   412
712
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   413
setStackInitialSize:initial increment:increment safe:safe
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   414
    "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
   415
     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
   416
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   417
%{  /* NOCONTEXT */
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   418
    extern int __threadSetJunkSizes();
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   419
    OBJ i;
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   420
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   421
    if (__isSmallInteger(i = __INST(id))
712
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   422
     && __isSmallInteger(initial)
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   423
     && __isSmallInteger(increment)
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   424
     && __isSmallInteger(safe)) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   425
	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
   426
    }
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   427
%}.
40906c842cd2 added entry to control a processes stack allocation
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
   428
    ^ false
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   429
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   430
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   431
!Process methodsFor:'interrupts'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   432
1092
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   433
addInterruptAction:aBlock 
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   434
    "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
   435
     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
   436
     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
   437
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   438
    self uninterruptablyDo:[
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   439
        interruptActions isNil ifTrue:[
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   440
            interruptActions := OrderedCollection with:aBlock.
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   441
        ] ifFalse:[
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   442
            interruptActions addLast:aBlock.
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   443
        ].
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   444
    ].
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   445
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   446
    "Created: 5.3.1996 / 17:10:10 / cg"
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   447
    "Modified: 8.3.1996 / 13:03:10 / cg"
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   448
!
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   449
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   450
forceInterruptOnReturnOf:aContext
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   451
    "helper entry for debugger. Force a stepInterrupt whenever aContext
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   452
     returns either directly or via an unwind."
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   453
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   454
    aContext markForUnwind.
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   455
%{
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   456
    OBJ i;
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   457
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   458
    if (__isSmallInteger(i = __INST(id))) {
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   459
	__threadContextStepInterrupt(__intVal(i), 1);
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   460
    }
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   461
%}
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   462
    
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   463
!
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   464
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   465
interrupt
1092
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   466
    "evaluate my interrupt-actions.
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   467
     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
   468
     after doing this."
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   469
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   470
    |action|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   471
1165
c9108e9a4fdd just to make certain: disable interrupts when removing interruptAction
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   472
    [interruptActions size > 0] whileTrue:[
c9108e9a4fdd just to make certain: disable interrupts when removing interruptAction
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   473
        self uninterruptablyDo:[
c9108e9a4fdd just to make certain: disable interrupts when removing interruptAction
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   474
            action := interruptActions removeFirst
c9108e9a4fdd just to make certain: disable interrupts when removing interruptAction
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   475
        ].
1092
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   476
        action value
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   477
    ].
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   478
    interruptActions := nil
1092
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   479
1165
c9108e9a4fdd just to make certain: disable interrupts when removing interruptAction
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   480
    "Modified: 12.4.1996 / 12:43:31 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   481
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   482
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   483
interruptWith:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   484
    "interrupt the receiver and make it evaluate aBlock.
1092
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   485
     If the receiver is currently suspended it is resumed."
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   486
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   487
    self addInterruptAction:aBlock.
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   488
    Processor scheduleForInterrupt:self.
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   489
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   490
    "Modified: 8.3.1996 / 13:00:24 / cg"
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   491
!
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   492
1092
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   493
onResumeDo:aBlock
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   494
    "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
   495
     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
   496
     (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
   497
     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
   498
     when it awakes."
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   499
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   500
    self addInterruptAction:aBlock.
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   501
    Processor scheduleInterruptActionsOf:self.
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   502
2a8acc60f5b5 added mechanism for a block to be evaluated onResume
Claus Gittinger <cg@exept.de>
parents: 1086
diff changeset
   503
    "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
   504
    "Modified: 8.3.1996 / 13:01:21 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   505
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   506
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   507
!Process methodsFor:'monitoring'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   508
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   509
numberOfStackBoundaryHits
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   510
    "internal monitoring only - will vanish"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   511
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   512
%{  /* NOCONTEXT */
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   513
    extern int __threadNumberOfStackBoundaryHits();
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   514
    int n;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   515
    OBJ i;
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   516
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   517
    if (__isSmallInteger(i = __INST(id))) {
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   518
	n = __threadNumberOfStackBoundaryHits(__intVal(i));
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   519
	n &= 0x3FFFFFFF;
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   520
	RETURN( __MKSMALLINT(n) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   521
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   522
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   523
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   524
!
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
numberOfStackSegments
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   527
    "return the processes number of stack segments currently used.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   528
     This method is for monitoring purposes only - it may vanish."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   529
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   530
%{  /* NOCONTEXT */
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   531
    extern int __threadTotalStackSize();
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   532
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   533
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   534
    if (__isSmallInteger(i = __INST(id))) {
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   535
	RETURN( __MKSMALLINT(__threadStackSegments(__intVal(i))) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   536
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   537
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   538
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   539
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   540
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   541
totalStackSize
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   542
    "return the processes maximum used stack size.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   543
     This method is for monitoring purposes only - it may vanish."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   544
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   545
%{  /* NOCONTEXT */
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   546
    extern int __threadTotalStackSize();
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   547
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   548
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   549
    if (__isSmallInteger(i = __INST(id))) {
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   550
	RETURN( __MKSMALLINT(__threadTotalStackSize(__intVal(i))) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   551
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   552
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   553
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   554
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   555
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   556
usedStackSize
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   557
    "Return the processes current stack size.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   558
     This method is for monitoring purposes only - it may vanish."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   559
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   560
%{  /* NOCONTEXT */
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   561
    extern int __threadUsedStackSize();
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   562
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   563
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   564
    if (__isSmallInteger(i = __INST(id))) {
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   565
	RETURN( __MKSMALLINT(__threadUsedStackSize(__intVal(i))) );
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   566
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   567
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   568
    ^ nil
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   569
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   570
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   571
vmTrace:aBoolean
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   572
    "turn on/off VM message tracing for the receiver.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   573
     This is meant for ST/X debugging, and may vanish.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   574
     Expect lots of output, once this is turned on."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   575
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   576
%{  /* NOCONTEXT */
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   577
    OBJ i;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   578
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   579
    if (__isSmallInteger(i = __INST(id))) {
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   580
	__threadTracing(__intVal(i), aBoolean);
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   581
    }
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   582
%}.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   583
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   584
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   585
!Process methodsFor:'printing & storing'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   586
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   587
printOn:aStream
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   588
    "a little more info in my printed representation"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   589
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   590
    aStream nextPutAll:state article;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   591
	    space;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   592
	    nextPutAll:state;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   593
	    nextPutAll:' Process (';
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   594
	    nextPutAll:self nameOrId;
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   595
	    nextPutAll:')'
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   596
! !
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   597
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   598
!Process methodsFor:'private'!
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   599
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   600
for:aBlock priority:aPrio
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   601
    "setup the new process - the receiver is not scheduled for
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   602
     execution, to get it running, send it #resume"
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   603
339
claus
parents: 337
diff changeset
   604
    |nm active|
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   605
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   606
    prio := aPrio.
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   607
    startBlock := aBlock.
339
claus
parents: 337
diff changeset
   608
    restartable := false.
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   609
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   610
    (Processor newProcessFor:self) ifFalse:[ 
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   611
	"for some reason, the Processor was unable to create
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   612
	 a VM process for me ...."
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   613
	^ nil
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   614
    ].
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   615
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   616
    "
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   617
     give me a user-friendly name
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   618
    "
339
claus
parents: 337
diff changeset
   619
    active := Processor activeProcess.
claus
parents: 337
diff changeset
   620
    (nm :=  active name) notNil ifTrue:[
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   621
	"
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   622
	 avoid name inflation
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   623
	"
314
7581a5c57224 *** empty log message ***
claus
parents: 302
diff changeset
   624
	(nm endsWith:' sub') ifFalse:[
339
claus
parents: 337
diff changeset
   625
	    nm := nm , ' [' ,  active id printString , '] sub'
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   626
	].
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   627
	name := nm
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   628
    ]
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   629
! !
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   630
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   631
!Process methodsFor:'private scheduler access'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   632
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   633
setId:idNumber state:stateSymbol
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   634
    "set id and state - not for public use"
375
claus
parents: 359
diff changeset
   635
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   636
    id := idNumber.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   637
    state := stateSymbol.
182
f531860566fc more queries
claus
parents: 159
diff changeset
   638
!
f531860566fc more queries
claus
parents: 159
diff changeset
   639
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   640
setPriority:aNumber
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   641
    "set priority without telling processor - not for public use"
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   642
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   643
    prio := aNumber
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   644
!
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   645
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   646
setStartBlock:aBlock
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   647
    "set the receivers startup block"
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   648
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   649
    startBlock := aBlock
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   650
!
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   651
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   652
setStateTo:newState if:oldState
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   653
    state == oldState ifTrue:[state := newState]
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   654
!
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   655
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   656
setStateTo:newState if:oldState1 or:oldState2
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   657
    (state == oldState1 or:[state == oldState2]) ifTrue:[state := newState]
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   658
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   659
818
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   660
!Process methodsFor:'queries'!
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
isDead
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   663
    "return true, iff the receiver is a dead process"
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 isNil or:[state == #dead])
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   666
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   667
    "Modified: 23.12.1995 / 18:35:29 / cg"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   668
!
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
isRestartable
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   671
    "return true, iff the receiver is restartable"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   672
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   673
    ^ restartable
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   674
!
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
isSingleStepping
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   677
    ^ singleStepping
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   678
!
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   679
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   680
nameOrId
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   681
    "return a string to identify the process - either name or id"
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   682
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   683
    name notNil ifTrue:[^ name].
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   684
    ^ id printString
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   685
! !
dce34af5a40f category changes
Claus Gittinger <cg@exept.de>
parents: 772
diff changeset
   686
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   687
!Process methodsFor:'special'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   688
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   689
millisecondDelay:millis
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   690
    "suspend the current process for some time.
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   691
     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
   692
     this blocks the whole smalltalk for the time delta;
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   693
     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
   694
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   695
    (Processor isSystemProcess:self) ifTrue:[
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   696
        OperatingSystem millisecondDelay:millis
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   697
    ] ifFalse:[
874
fc2f0ffb75ae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 818
diff changeset
   698
        Delay waitForMilliseconds:millis
772
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   699
    ]
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   700
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   701
    "Created: 16.12.1995 / 13:10:53 / cg"
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   702
!
f86b117950c5 non-blocking/blocking millisecondDelay added
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
   703
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   704
trapRestrictedMethods:trap
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   705
    "Allow/deny the execution of restricted methods.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   706
     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
   707
     redirected to ObjectMemory and causes a system wide restriction.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   708
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   709
     Notice: method restriction is a nonstandard feature, not supported
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   710
     by other smalltalk implementations and not specified in the ANSI spec.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   711
     This is EXPERIMENTAL - and being evaluated for usability.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   712
     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
   713
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   714
    ^ObjectMemory trapRestrictedMethods:trap
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   715
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   716
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   717
	Processor activeProcess trapRestrictedMethods:true
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   718
	Processor activeProcess trapRestrictedMethods:false
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   719
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   720
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   721
    "Created: 8.11.1995 / 19:45:04 / stefan"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   722
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   723
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   724
uninterruptablyDo:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   725
    "execute aBlock with interrupts blocked. 
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   726
     This does not prevent preemption by a higher priority processes
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   727
     if any becomes runnable due to the evaluation of aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   728
     (i.e. if a semaphore is signalled there)."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   729
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   730
    |wasBlocked|
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   731
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   732
    "we must keep track of blocking-state if this is called nested"
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
    wasBlocked := OperatingSystem blockInterrupts.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   735
    ^ aBlock valueNowOrOnUnwindDo:[
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   736
	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   737
	0 "stc hint"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   738
    ]
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   739
!
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   740
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   741
waitUntilSuspended
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   742
    "wait until the receiver is suspended."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   743
1033
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   744
    [
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   745
        suspendSemaphore isNil ifTrue:[suspendSemaphore := Semaphore new].
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   746
        suspendSemaphore wait
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   747
    ] valueUninterruptably
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   748
1033
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   749
    "Modified: 28.2.1996 / 21:38:00 / 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
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   752
waitUntilTerminated
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   753
    "wait until the receiver is terminated.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   754
     This method allows another process to wait till the receiver finishes."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   755
1033
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   756
    |sema|
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   757
1033
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   758
    [
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   759
        sema := Semaphore new.
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   760
        self exitAction:[sema signal].
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   761
        sema wait.
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   762
    ] valueUninterruptably
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   763
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
   764
    "Modified: 28.2.1996 / 21:38:21 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   765
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   766
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   767
withLowerPriorityDo:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   768
    "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
   769
     time-consuming operations at a more user-friendly priority."
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   770
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   771
    ^ self withPriority:(prio - 1) do:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   772
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   773
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   774
     Processor activeProcess withLowerPriorityDo:[3000 factorial]
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   775
    "
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
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   778
withPriority:aPrio do:aBlock
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   779
    "execute aBlock at another priority. This can be used to perform
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   780
     time-consuming operations at a more user-friendly priority,
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   781
     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
   782
     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
   783
     at 24)"
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
    |oldprio|
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
    oldprio := prio.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   788
    self priority:aPrio.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   789
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   790
    ^ aBlock valueNowOrOnUnwindDo:[
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   791
	self priority:oldprio
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   792
    ]
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
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   795
     Processor activeProcess withPriority:7 do:[3000 factorial]
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   796
    "
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   797
    "be careful - even ^C wont work until done:
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   798
     Processor activeProcess withPriority:25 do:[3000 factorial]
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   799
    "
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   800
! !
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   801
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   802
!Process methodsFor:'startup '!
116
58fb8728e1a5 added emergencySignalHandler
claus
parents: 93
diff changeset
   803
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   804
restart
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   805
    "restart the process from the beginning.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   806
     This is sent by the ProcessorScheduler to all restartable processes."
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   807
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   808
"/  ('restart process ' , id printString) errorPrintNL.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   809
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   810
    (Processor newProcessFor:self withId:id) ifFalse:[ 
1086
7b0641a2e1ef nicer message
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
   811
        "for some reason, the Processor was unable to create
7b0641a2e1ef nicer message
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
   812
         a VM process for me ...."
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   813
1086
7b0641a2e1ef nicer message
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
   814
        ('PROCESS: process ' , id printString , ' failed to restart.') errorPrintNL.
7b0641a2e1ef nicer message
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
   815
        ^ nil
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   816
    ].
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   817
    self resume
1086
7b0641a2e1ef nicer message
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
   818
7b0641a2e1ef nicer message
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
   819
    "Modified: 7.3.1996 / 19:21:50 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   820
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   821
116
58fb8728e1a5 added emergencySignalHandler
claus
parents: 93
diff changeset
   822
start
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   823
    "start the process - this is sent by the VM to the process to get
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   824
     the process up and running.
329
claus
parents: 326
diff changeset
   825
     Sending #start to the process (instead of directly executing the startBlock)
claus
parents: 326
diff changeset
   826
     allows more flexible handling of processes, since anything that responds 
claus
parents: 326
diff changeset
   827
     to #start can be handled transparently by the VM then ..."
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   828
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   829
    |block|
116
58fb8728e1a5 added emergencySignalHandler
claus
parents: 93
diff changeset
   830
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   831
    (block := startBlock) notNil ifTrue:[
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   832
	"
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   833
	 just for your convenience ...
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   834
	"
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   835
	name isNil ifTrue:[
359
claus
parents: 348
diff changeset
   836
	    name := '(' , block displayString , ')'
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   837
	].
329
claus
parents: 326
diff changeset
   838
	restartable ~~ true ifTrue:[startBlock := nil].
302
1f76060d58a4 *** empty log message ***
claus
parents: 252
diff changeset
   839
	CoughtSignals handle:[:ex |
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   840
	    ex return
182
f531860566fc more queries
claus
parents: 159
diff changeset
   841
	] do:block.
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 182
diff changeset
   842
375
claus
parents: 359
diff changeset
   843
	self terminateNoSignal.
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   844
    ] ifFalse:[
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   845
	"is this artificial restriction useful ?"
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   846
	self error:'a process cannot be started twice'
116
58fb8728e1a5 added emergencySignalHandler
claus
parents: 93
diff changeset
   847
    ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   848
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   849
a27a279701f8 Initial revision
claus
parents:
diff changeset
   850
!Process methodsFor:'suspend / resume'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   851
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   852
resume
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   853
    "resume the receiver process"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   854
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   855
    Processor resume:self
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   856
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   857
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   858
resumeForSingleSend
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   859
    "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
   860
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   861
    Processor resumeForSingleSend:self
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   862
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   863
326
d2902942491d *** empty log message ***
claus
parents: 314
diff changeset
   864
stop
d2902942491d *** empty log message ***
claus
parents: 314
diff changeset
   865
    "suspend the receiver process - will continue to run when a resume is sent.
d2902942491d *** empty log message ***
claus
parents: 314
diff changeset
   866
     A stopped process will not be resumed for interrupt processing."
d2902942491d *** empty log message ***
claus
parents: 314
diff changeset
   867
d2902942491d *** empty log message ***
claus
parents: 314
diff changeset
   868
    state := #stopped.
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   869
    self suspend
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   870
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   871
    "Modified: 13.12.1995 / 13:22:58 / stefan"
326
d2902942491d *** empty log message ***
claus
parents: 314
diff changeset
   872
!
d2902942491d *** empty log message ***
claus
parents: 314
diff changeset
   873
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   874
suspend
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   875
    "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
   876
     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
   877
     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
   878
     a suspend (see wait code in Semaphore).
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   879
     Use #stop for a hard-suspend, which is not affected by interrupts."
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   880
329
claus
parents: 326
diff changeset
   881
    suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll].
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   882
    suspendActions notNil ifTrue:[
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   883
	suspendActions do:[:action | action value]
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   884
    ].
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   885
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   886
    "
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   887
     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
   888
     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
   889
     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
   890
     (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
   891
    "
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   892
    (state == #active or:[state == #run]) ifTrue:[
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   893
	state := #suspended
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   894
    ].
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   895
    Processor suspend:self
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   896
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   897
    "Modified: 13.12.1995 / 14:20:26 / stefan"
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   898
!
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   899
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   900
suspendWithState:aStateSymbol
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   901
    "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
   902
     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
   903
     in the ProcessMonitor (instead of #suspended).
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   904
     (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
   905
     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
   906
     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
   907
     a suspend (see wait code in Semaphore).
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   908
     Use #stop for a hard-suspend, which is not affected by interrupts."
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   909
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   910
    suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll].
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   911
    suspendActions notNil ifTrue:[
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   912
	suspendActions do:[:action | action value]
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   913
    ].
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   914
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   915
    "
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   916
     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
   917
     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
   918
     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
   919
     (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
   920
    "
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   921
    (state == #active or:[state == #run]) ifTrue:[
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   922
	state := aStateSymbol.
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   923
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   924
    Processor suspend:self
a27a279701f8 Initial revision
claus
parents:
diff changeset
   925
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   926
a27a279701f8 Initial revision
claus
parents:
diff changeset
   927
terminate
375
claus
parents: 359
diff changeset
   928
    "terminate the receiver process. Termination is done by raising
claus
parents: 359
diff changeset
   929
     the terminateSignal in the receiver process, which can be cought.
claus
parents: 359
diff changeset
   930
     All unwind actions and the exit-actions (if any)
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   931
     will be performed before the process is really terminated."
10
claus
parents: 5
diff changeset
   932
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   933
    Processor activeProcess == self ifTrue:[
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   934
	Signal noHandlerSignal handle:[:ex |
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   935
	    ex return.
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   936
	] do:[
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   937
	    TerminateSignal raise.
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   938
	].
375
claus
parents: 359
diff changeset
   939
	self terminateNoSignal.
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   940
    ] ifFalse:[
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   941
	self interruptWith:[self terminate]
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   942
    ]
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   943
!
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   944
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   945
terminateNoSignal
375
claus
parents: 359
diff changeset
   946
    "terminate the receiver process without sending a terminateSignal
claus
parents: 359
diff changeset
   947
     or performing any unwind-handling.
claus
parents: 359
diff changeset
   948
     However, exit-actions are performed."
claus
parents: 359
diff changeset
   949
claus
parents: 359
diff changeset
   950
    |block|
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   951
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   952
    "/ this is treated like the final suspend
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   953
    suspendActions notNil ifTrue:[
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   954
	[suspendActions notEmpty] whileTrue:[
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   955
	    block := suspendActions removeFirst.
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   956
	    block value.
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   957
	]
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   958
    ].
375
claus
parents: 359
diff changeset
   959
    exitActions notNil ifTrue:[
claus
parents: 359
diff changeset
   960
	[exitActions notEmpty] whileTrue:[
claus
parents: 359
diff changeset
   961
	    block := exitActions removeFirst.
claus
parents: 359
diff changeset
   962
	    block value.
claus
parents: 359
diff changeset
   963
	]
claus
parents: 359
diff changeset
   964
    ].
329
claus
parents: 326
diff changeset
   965
    suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll].
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   966
    Processor terminateNoSignal:self
752
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   967
0259dd855289 new suspendAction, Semaphore & ProcSched stuff from stefan
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   968
    "Modified: 13.12.1995 / 13:40:14 / stefan"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   969
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   970
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   971
!Process class methodsFor:'documentation'!
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   972
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   973
version
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1165
diff changeset
   974
    ^ '$Header: /cvs/stx/stx/libbasic/Process.st,v 1.49 1996-04-23 19:33:18 cg Exp $'
159
514c749165c3 *** empty log message ***
claus
parents: 116
diff changeset
   975
! !
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   976
Process initialize!