RecursionLock.st
author Stefan Vogel <sv@exept.de>
Mon, 25 Oct 1999 17:28:14 +0200
changeset 4938 d5640f1c8894
parent 3670 91b4524a74b3
child 5104 99233ab3f6f5
permissions -rw-r--r--
Add #numberOfWaitingProcesse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
330
claus
parents:
diff changeset
     1
"
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
341
claus
parents: 330
diff changeset
     3
	      All Rights Reserved
330
claus
parents:
diff changeset
     4
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    10
 hereby transferred.
claus
parents:
diff changeset
    11
"
claus
parents:
diff changeset
    12
claus
parents:
diff changeset
    13
claus
parents:
diff changeset
    14
Object subclass:#RecursionLock
776
f3c0c579c0d2 commentary
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    15
	instanceVariableNames:'process sema'
f3c0c579c0d2 commentary
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    16
	classVariableNames:''
f3c0c579c0d2 commentary
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    17
	poolDictionaries:''
f3c0c579c0d2 commentary
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    18
	category:'Kernel-Processes'
330
claus
parents:
diff changeset
    19
!
claus
parents:
diff changeset
    20
claus
parents:
diff changeset
    21
!RecursionLock class methodsFor:'documentation'!
claus
parents:
diff changeset
    22
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    23
copyright
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    24
"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    25
 COPYRIGHT (c) 1995 by Claus Gittinger
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    26
	      All Rights Reserved
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    27
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    28
 This software is furnished under a license and may be used
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    29
 only in accordance with the terms of that license and with the
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    31
 be provided or otherwise made available to, or used by, any
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    32
 other person.  No title to or ownership of the software is
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    33
 hereby transferred.
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    34
"
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    35
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    36
!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    37
330
claus
parents:
diff changeset
    38
documentation
claus
parents:
diff changeset
    39
"
claus
parents:
diff changeset
    40
    like a Semaphore for mutual exclusion, but avoids the deadlock
claus
parents:
diff changeset
    41
    if a critical region is reentered by the same process again.
2143
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    42
    I.e. allows reentering the critical region IFF the current process 
341
claus
parents: 330
diff changeset
    43
    is the one which did the original locking.
330
claus
parents:
diff changeset
    44
3524
b5fe623f0e4d warning in documentation
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
    45
    WARNING:
b5fe623f0e4d warning in documentation
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
    46
        for now, recursionLocks are not unlocked when an image is
b5fe623f0e4d warning in documentation
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
    47
        restarted. You may have to recreate them to avoid a deadLock.
b5fe623f0e4d warning in documentation
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
    48
        (this may change in the future, but recreating a recursionLock in
b5fe623f0e4d warning in documentation
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
    49
         the #earlyRestart handling does not hurt)
1294
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    50
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    51
    [author:]
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    52
        Claus Gittinger
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    53
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
    54
    [see also:]
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
    55
        Semaphore
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
    56
        Process ProcessorScheduler
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
    57
"
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
    58
!
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
    59
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
    60
examples
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1216
diff changeset
    61
"
2143
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    62
  example (good):
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    63
                                                                        [exBegin]
2143
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    64
    |lock|
776
f3c0c579c0d2 commentary
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    65
2143
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    66
    lock := RecursionLock new.
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    67
    lock critical:[
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    68
        Transcript showCR:'in lock ...'.
776
f3c0c579c0d2 commentary
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    69
        lock critical:[
2143
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    70
            Transcript showCR:'again ...'
776
f3c0c579c0d2 commentary
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    71
        ]
2143
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    72
    ]
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    73
                                                                        [exEnd]
776
f3c0c579c0d2 commentary
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    74
2143
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    75
  in contrast to (wrong example - deadlocks):
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    76
                                                                        [exBegin]
2143
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    77
    |lock|
776
f3c0c579c0d2 commentary
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    78
2143
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    79
    lock := Semaphore forMutualExclusion.
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    80
    lock critical:[
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    81
        Transcript showCR:'in lock ...'.
776
f3c0c579c0d2 commentary
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    82
        lock critical:[
2143
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    83
            '*** never reached - deadlock because sema is already locked ***'.
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    84
            '    (press CTRL-c and abort in the debugger)'.
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    85
            Transcript showCR:'again ...'
776
f3c0c579c0d2 commentary
Claus Gittinger <cg@exept.de>
parents: 699
diff changeset
    86
        ]
2143
09af9c997961 commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
    87
    ]
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    88
                                                                        [exEnd]
330
claus
parents:
diff changeset
    89
"
claus
parents:
diff changeset
    90
! !
claus
parents:
diff changeset
    91
claus
parents:
diff changeset
    92
!RecursionLock class methodsFor:'instance creation'!
claus
parents:
diff changeset
    93
claus
parents:
diff changeset
    94
new
claus
parents:
diff changeset
    95
    ^ self basicNew initialize
claus
parents:
diff changeset
    96
claus
parents:
diff changeset
    97
! !
claus
parents:
diff changeset
    98
2722
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
    99
!RecursionLock methodsFor:'printing & storing'!
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   100
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   101
displayString
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   102
    "return a string to display the receiver - include the
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   103
     count for your convenience"
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   104
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   105
    ^ self class name , '(' , sema count printString , ' name: ' , (self name ? 'unnamed') , ')'
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   106
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   107
    "Created: 28.6.1997 / 16:20:33 / cg"
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   108
    "Modified: 28.6.1997 / 16:21:28 / cg"
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   109
!
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   110
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   111
name
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   112
    ^ sema name
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   113
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   114
    "Created: 28.6.1997 / 16:19:40 / cg"
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   115
!
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   116
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   117
name:aString
4938
d5640f1c8894 Add #numberOfWaitingProcesse
Stefan Vogel <sv@exept.de>
parents: 3670
diff changeset
   118
    sema name:aString
2722
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   119
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   120
    "Created: 28.6.1997 / 16:19:47 / cg"
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   121
! !
f6c7146fced2 added naming protocol
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   122
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   123
!RecursionLock methodsFor:'private initialization'!
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   124
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   125
initialize
2266
a94af740c68a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2263
diff changeset
   126
    sema := Semaphore forMutualExclusion name:'recursionLock'
a94af740c68a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2263
diff changeset
   127
a94af740c68a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2263
diff changeset
   128
    "Modified: 25.1.1997 / 00:19:15 / cg"
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   129
! !
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   130
1215
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   131
!RecursionLock methodsFor:'queries'!
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   132
4938
d5640f1c8894 Add #numberOfWaitingProcesse
Stefan Vogel <sv@exept.de>
parents: 3670
diff changeset
   133
numberOfWaitingProcesses
d5640f1c8894 Add #numberOfWaitingProcesse
Stefan Vogel <sv@exept.de>
parents: 3670
diff changeset
   134
    "return the number of waiting processes"
d5640f1c8894 Add #numberOfWaitingProcesse
Stefan Vogel <sv@exept.de>
parents: 3670
diff changeset
   135
d5640f1c8894 Add #numberOfWaitingProcesse
Stefan Vogel <sv@exept.de>
parents: 3670
diff changeset
   136
    ^ sema numberOfWaitingProcesses
d5640f1c8894 Add #numberOfWaitingProcesse
Stefan Vogel <sv@exept.de>
parents: 3670
diff changeset
   137
d5640f1c8894 Add #numberOfWaitingProcesse
Stefan Vogel <sv@exept.de>
parents: 3670
diff changeset
   138
    "Created: 18.4.1996 / 17:18:08 / cg"
d5640f1c8894 Add #numberOfWaitingProcesse
Stefan Vogel <sv@exept.de>
parents: 3670
diff changeset
   139
!
d5640f1c8894 Add #numberOfWaitingProcesse
Stefan Vogel <sv@exept.de>
parents: 3670
diff changeset
   140
1215
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   141
wouldBlock
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   142
    "return true, if the receiver would block the activeProcess
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   143
     if a wait was performed. False otherwise."
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   144
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   145
    process == Processor activeProcess ifTrue:[^ false].
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   146
    ^ sema wouldBlock
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   147
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   148
    "Created: 18.4.1996 / 17:18:08 / cg"
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   149
! !
43e8e17fd9f5 added #wouldBlock
Claus Gittinger <cg@exept.de>
parents: 1186
diff changeset
   150
330
claus
parents:
diff changeset
   151
!RecursionLock methodsFor:'wait & signal'!
claus
parents:
diff changeset
   152
claus
parents:
diff changeset
   153
critical:aBlock
claus
parents:
diff changeset
   154
    "evaluate aBlock as a critical region, but do not block,
claus
parents:
diff changeset
   155
     if this lock is already held by the current process."
claus
parents:
diff changeset
   156
3326
ffcf961d203a #critical: did not return the value of the executed block.
Stefan Vogel <sv@exept.de>
parents: 2722
diff changeset
   157
    |active retVal wasBlocked|
330
claus
parents:
diff changeset
   158
claus
parents:
diff changeset
   159
    active := Processor activeProcess.
claus
parents:
diff changeset
   160
    process == active ifTrue:[
3670
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   161
        "/ I already have the lock
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   162
        ^ aBlock value
330
claus
parents:
diff changeset
   163
    ].
3670
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   164
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   165
    "/
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   166
    "/ sema wait & process := active
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   167
    "/ and:
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   168
    "/ proces := nil & sema signal
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   169
    "/ must both be done atomic
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   170
    "/ Scenario:
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   171
    "/   ... recLock critical
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   172
    "/         got lock
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   173
    "/         evaluated
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   174
    "/         set process to nil
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   175
    "/         -> timer interrupt
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   176
    "/              recLock critical in timeOut action
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   177
    "/              process isNil
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   178
    "/                 sema wait !!!!!! DEADLOCK
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   179
    "/
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   180
    wasBlocked := OperatingSystem blockInterrupts.
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   181
    sema critical:[
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   182
        [
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   183
            process := active.
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   184
            wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   185
            retVal := aBlock value.
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   186
            OperatingSystem blockInterrupts.
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   187
        ] valueOnUnwindDo:[
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   188
            process := nil.
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   189
        ]
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   190
    ].
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   191
    process := nil.
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   192
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   193
3326
ffcf961d203a #critical: did not return the value of the executed block.
Stefan Vogel <sv@exept.de>
parents: 2722
diff changeset
   194
    ^ retVal
1186
cf4c57ecabb8 Fix in critical: don't clear process when we didn't get the semaphore when unwinding.
Stefan Vogel <sv@exept.de>
parents: 776
diff changeset
   195
3326
ffcf961d203a #critical: did not return the value of the executed block.
Stefan Vogel <sv@exept.de>
parents: 2722
diff changeset
   196
    "Modified: / 5.3.1998 / 10:22:50 / stefan"
3670
91b4524a74b3 avoid an assignment if I already have the sema (in #critical)
Claus Gittinger <cg@exept.de>
parents: 3524
diff changeset
   197
    "Modified: / 21.7.1998 / 17:44:06 / cg"
330
claus
parents:
diff changeset
   198
! !
claus
parents:
diff changeset
   199
699
12f456343eea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   200
!RecursionLock class methodsFor:'documentation'!
330
claus
parents:
diff changeset
   201
1216
d7cbc6eb8dd4 critical was critical (deadlock with timeouts)
Claus Gittinger <cg@exept.de>
parents: 1215
diff changeset
   202
version
4938
d5640f1c8894 Add #numberOfWaitingProcesse
Stefan Vogel <sv@exept.de>
parents: 3670
diff changeset
   203
    ^ '$Header: /cvs/stx/stx/libbasic/RecursionLock.st,v 1.22 1999-10-25 15:28:14 stefan Exp $'
330
claus
parents:
diff changeset
   204
! !