7 inclusion of the above copyright notice. This software may not |
7 inclusion of the above copyright notice. This software may not |
8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
|
12 |
|
13 'From Smalltalk/X, Version:3.1.3 on 7-jan-1997 at 17:23:38' ! |
12 |
14 |
13 Object subclass:#ProcessorScheduler |
15 Object subclass:#ProcessorScheduler |
14 instanceVariableNames:'quiescentProcessLists scheduler zombie activeProcess |
16 instanceVariableNames:'quiescentProcessLists scheduler zombie activeProcess |
15 currentPriority readFdArray readSemaphoreArray readCheckArray |
17 currentPriority readFdArray readSemaphoreArray readCheckArray |
16 writeFdArray writeSemaphoreArray timeoutArray timeoutActionArray |
18 writeFdArray writeSemaphoreArray timeoutArray timeoutActionArray |
182 "Created: 23.9.1996 / 13:44:57 / stefan" |
184 "Created: 23.9.1996 / 13:44:57 / stefan" |
183 ! ! |
185 ! ! |
184 |
186 |
185 !ProcessorScheduler class methodsFor:'instance release'! |
187 !ProcessorScheduler class methodsFor:'instance release'! |
186 |
188 |
187 informDispose |
189 update:something with:aParameter from:changedObject |
188 "some Process has been garbage collected |
190 "some Process has been garbage collected |
189 - terminate the underlying thread. |
191 - terminate the underlying thread. |
190 Usually this does not happen; instead, the process terminates itself |
192 Usually this does not happen; instead, the process terminates itself |
191 by sending #terminate." |
193 by sending #terminate." |
192 |
194 |
193 |id sz "{ Class: SmallInteger }"| |
195 |id sz "{ Class: SmallInteger }"| |
194 |
196 |
195 sz := KnownProcessIds size. |
197 something == #ElementExpired ifTrue:[ |
196 1 to:sz do:[:index | |
198 sz := KnownProcessIds size. |
197 "/ (KnownProcesses at:index) isNil ifTrue:[ |
199 1 to:sz do:[:index | |
198 (KnownProcesses at:index) == 0 ifTrue:[ |
200 "/ (KnownProcesses at:index) isNil ifTrue:[ |
199 id := KnownProcessIds at:index. |
201 (KnownProcesses at:index) == 0 ifTrue:[ |
200 id notNil ifTrue:[ |
202 id := KnownProcessIds at:index. |
201 'PROCESSOR: terminating thread ' errorPrint. |
203 id notNil ifTrue:[ |
202 id errorPrint. |
204 'PROCESSOR: terminating thread ' errorPrint. |
203 ' (no longer refd)' errorPrintNL. |
205 id errorPrint. |
204 |
206 ' (no longer refd)' errorPrintNL. |
205 self threadDestroy:id. |
207 |
206 KnownProcessIds at:index put:nil. |
208 self threadDestroy:id. |
207 ]. |
209 KnownProcessIds at:index put:nil. |
208 KnownProcesses at:index put:nil. |
210 ]. |
209 ] |
211 KnownProcesses at:index put:nil. |
|
212 ] |
|
213 ] |
210 ] |
214 ] |
|
215 |
|
216 "Created: 7.1.1997 / 16:45:42 / stefan" |
211 ! ! |
217 ! ! |
212 |
218 |
213 !ProcessorScheduler class methodsFor:'primitive process primitives'! |
219 !ProcessorScheduler class methodsFor:'primitive process primitives'! |
214 |
220 |
215 threadCreate:aProcess withId:id |
221 threadCreate:aProcess withId:id |
929 |
935 |
930 wasBlocked := OperatingSystem blockInterrupts. |
936 wasBlocked := OperatingSystem blockInterrupts. |
931 index := 1. |
937 index := 1. |
932 sz := KnownProcessIds size. |
938 sz := KnownProcessIds size. |
933 [index <= sz] whileTrue:[ |
939 [index <= sz] whileTrue:[ |
934 (KnownProcesses at:index) isNil ifTrue:[ |
940 (KnownProcesses at:index) isNil ifTrue:[ |
935 oldId := KnownProcessIds at:index. |
941 oldId := KnownProcessIds at:index. |
936 oldId notNil ifTrue:[ |
942 oldId notNil ifTrue:[ |
937 self class threadDestroy:oldId. |
943 self class threadDestroy:oldId. |
938 ]. |
944 ]. |
939 KnownProcesses at:index put:aProcess. |
945 KnownProcesses at:index put:aProcess. |
940 KnownProcessIds at:index put:aProcess id. |
946 KnownProcessIds at:index put:aProcess id. |
941 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
947 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
942 ^ self |
948 ^ self |
943 ]. |
949 ]. |
944 index := index + 1 |
950 index := index + 1 |
945 ]. |
951 ]. |
946 |
952 |
947 KnownProcessIds grow:index. |
953 KnownProcessIds grow:index. |
948 KnownProcessIds at:index put:aProcess id. |
954 KnownProcessIds at:index put:aProcess id. |
949 |
955 |
950 oldSize := KnownProcesses size. |
956 oldSize := KnownProcesses size. |
951 (index > oldSize) ifTrue:[ |
957 (index > oldSize) ifTrue:[ |
952 newShadow := WeakArray new:(oldSize * 2). |
958 newShadow := WeakArray new:(oldSize * 2). |
953 newShadow watcher:self class. |
959 newShadow addDependent:self class. |
954 newShadow replaceFrom:1 with:KnownProcesses. |
960 newShadow replaceFrom:1 with:KnownProcesses. |
955 KnownProcesses := newShadow |
961 KnownProcesses := newShadow |
956 ]. |
962 ]. |
957 KnownProcesses at:index put:aProcess. |
963 KnownProcesses at:index put:aProcess. |
958 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
964 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
965 |
|
966 "Modified: 7.1.1997 / 16:48:39 / stefan" |
959 ! |
967 ! |
960 |
968 |
961 unRemember:aProcess |
969 unRemember:aProcess |
962 "forget aProcess - dispose processing will not consider this one" |
970 "forget aProcess - dispose processing will not consider this one" |
963 |
971 |
979 |
987 |
980 |nPrios "{ Class: SmallInteger }" |
988 |nPrios "{ Class: SmallInteger }" |
981 p l| |
989 p l| |
982 |
990 |
983 KnownProcesses isNil ifTrue:[ |
991 KnownProcesses isNil ifTrue:[ |
984 KnownProcesses := WeakArray new:30. |
992 KnownProcesses := WeakArray new:30. |
985 KnownProcesses watcher:self class. |
993 KnownProcesses addDependent:self class. |
986 KnownProcessIds := OrderedCollection new. |
994 KnownProcessIds := OrderedCollection new. |
987 ]. |
995 ]. |
988 |
996 |
989 " |
997 " |
990 create a collection with process lists; accessed using the priority as key |
998 create a collection with process lists; accessed using the priority as key |
991 " |
999 " |
1034 " |
1042 " |
1035 ObjectMemory ioInterruptHandler:self. |
1043 ObjectMemory ioInterruptHandler:self. |
1036 ObjectMemory timerInterruptHandler:self. |
1044 ObjectMemory timerInterruptHandler:self. |
1037 ObjectMemory childSignalInterruptHandler:self. |
1045 ObjectMemory childSignalInterruptHandler:self. |
1038 |
1046 |
1039 "Modified: 12.4.1996 / 10:12:56 / stefan" |
|
1040 "Modified: 29.7.1996 / 12:10:59 / cg" |
1047 "Modified: 29.7.1996 / 12:10:59 / cg" |
|
1048 "Modified: 7.1.1997 / 16:48:26 / stefan" |
1041 ! |
1049 ! |
1042 |
1050 |
1043 reinitialize |
1051 reinitialize |
1044 "all previous processes (except those marked as restartable) are made dead |
1052 "all previous processes (except those marked as restartable) are made dead |
1045 - each object should reinstall its process(s) upon restart; |
1053 - each object should reinstall its process(s) upon restart; |