-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Force rescheduling of inactive process when changing its priority
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
source/Ansible-Pharo-Pending-Patches/ProcessorScheduler.extension.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Extension { #name : 'ProcessorScheduler' } | ||
|
||
{ #category : '*Ansible-Pharo-Pending-Patches' } | ||
ProcessorScheduler >> interpriorityYield: modifiedProcess [ | ||
"The original yield only works within processes of the same priority. | ||
The primitive does not try to resume a process in a higher priority. | ||
By suspending and resuming the modified process, we force it to be rescheduled. | ||
When modifying the active process, we must handle the resume from a forked process. | ||
We must also be careful not to resume a process that was suspended to begin with. | ||
(In particular, processes all receive #priority: as part of their creation, before | ||
it is safe to resume them.) | ||
This message should not be used directly. | ||
The only application so far is when changing the priority of a process. | ||
" | ||
|
||
modifiedProcess isActive | ||
ifTrue: [ | ||
[ modifiedProcess resume ] fork. | ||
modifiedProcess suspend ] | ||
ifFalse: [ | ||
(modifiedProcess suspendingList isKindOf: ProcessList) ifTrue: [ | ||
modifiedProcess | ||
suspend; | ||
resume ] ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters