Next: Discussions
Up: Implementation of Customized Language
Previous: Termination Detection
In Section 3.4, we have seen an example of
user-level scheduling that is achieved by explicitly sending messages
in application programs. Here, we show a similar scheduling mechanism
that is achieved by implicitly communicating with the scheduler
object. An evaluator class sched-eval and two methods are
defined: (do-method-call) Instead of invoking a method, a
message data is sent to the scheduler object. (eval-entry) At
the end of each method execution, it notifies the scheduler to
yield its thread of control. We assume that the scheduler object
is bound to variable *scheduler* and has methods request
and run-next.
;;; an evaluator class for user-customized scheduling
(defclass sched-eval ())
;;; send a request to the scheduler for method invocation
(defmethod sched-eval do-method-call
(type target method args meta-args env)
(let ((m (make-message
target method args meta-args)))
(request *scheduler*
(cons m (get-priority env)))))
;;; yield the control to the scheduler
(defmethod sched-eval eval-entry (exp env)
(eval-entry super exp env)
(run-next *scheduler*)) ; notify end of execution
;;; an evaluator class for user-customized scheduling
(defclass sched-eval ())
;;; send a request to the scheduler for method invocation
(defmethod sched-eval do-method-call
(type target method args meta-args env)
(let ((m (make-message
target method args meta-args)))
(request *scheduler*
(cons m (get-priority env)))))
;;; yield the control to the scheduler
(defmethod sched-eval eval-entry (exp env)
(eval-entry super exp env)
(run-next *scheduler*)) ; notify end of execution
Next: Discussions
Up: Implementation of Customized Language
Previous: Termination Detection
Matt Hurlbut
1998-07-14