added more code for process scheduling
This commit is contained in:
80
stix/kernel/Process.st
Normal file
80
stix/kernel/Process.st
Normal file
@ -0,0 +1,80 @@
|
||||
#class(#pointer) Process(Object)
|
||||
{
|
||||
#dcl sp state prev next.
|
||||
|
||||
#method prev
|
||||
{
|
||||
^self.prev.
|
||||
}
|
||||
|
||||
#method next
|
||||
{
|
||||
^self.next.
|
||||
}
|
||||
|
||||
#method next: aProcess
|
||||
{
|
||||
self.next := aProcess.
|
||||
}
|
||||
|
||||
#method prev: aProcess
|
||||
{
|
||||
self.prev := aProcess.
|
||||
}
|
||||
}
|
||||
|
||||
#class ProcessScheduler(Object)
|
||||
{
|
||||
#dcl tally head tail active.
|
||||
|
||||
#method new
|
||||
{
|
||||
"instantiation is not allowed"
|
||||
^nil. "TODO: raise an exception"
|
||||
}
|
||||
|
||||
#method activeProcess
|
||||
{
|
||||
^self.active.
|
||||
}
|
||||
|
||||
#method add: aProcess
|
||||
{
|
||||
<primitive: #_scheduler_add>
|
||||
|
||||
(self.tally = 0)
|
||||
ifTrue: [
|
||||
self.head := aProcess.
|
||||
self.tail := aProcess.
|
||||
self.tally := 1.
|
||||
]
|
||||
ifFalse: [
|
||||
aProcess next: self.head.
|
||||
self.head prev: aProcess.
|
||||
self.head := aProcess.
|
||||
self.tally := self.tally + 1.
|
||||
].
|
||||
}
|
||||
|
||||
#method remove: aProcess
|
||||
{
|
||||
"<primitive: #_scheduler_remove>"
|
||||
|
||||
"TODO: "
|
||||
|
||||
}
|
||||
|
||||
"
|
||||
#method yield
|
||||
{
|
||||
<primitive: #processYield>
|
||||
self primitiveFailed
|
||||
}
|
||||
|
||||
#method enter: aContext
|
||||
{
|
||||
<primitive: #processEnter>
|
||||
self primitiveFailed
|
||||
}
|
||||
"
|
||||
}
|
Reference in New Issue
Block a user