001    // ImportanceParameters.java, created by cata
002    // Copyright (C) 2001 Catalin Francu <cata@mit.edu>
003    // Licensed under the terms of the GNU GPL; see COPYING for details.
004    
005    package javax.realtime;
006    
007    /** Importance is an additional scheduling metric that may be used
008     *  by some priority-based scheduling algorithms during overload
009     *  conditions to differenciate execution order among threads of the
010     *  same priority.
011     *  <p>
012     *  In some real-time systems an external physical process determines
013     *  the period of many threads. If rate-monotonic priority assignment
014     *  is used to assign priorities many of the threads in the system may
015     *  have the same priority because their periods are the same. However,
016     *  it is conceivable that some threads may be more important than
017     *  others and in an overload situation importance can help the
018     *  scheduler decide which threads to execute first. The base scheduling
019     *  algorithm represented by <code>PriorityScheduler</code> is not
020     *  required to use importance. However, the RTSJ strongly suggests to
021     *  implementers that a fairly simple subclass of
022     *  <code>PriorityScheduler</code> that uses importance can offer value
023     *  to some real-time applications.
024     */
025    public class ImportanceParameters extends PriorityParameters {
026        
027        private int importance;
028    
029        /** Create an instance of <code>ImportanceParameters</code>.
030         *
031         *  @param priority The priority assigned to an instance of
032         *                  <code>Schedulable</code>. This value is used in
033         *                  place of <code>java.lang.Thread.priority</code>.
034         *  @param importance The importance value assigned to an instance
035         *                    of <code>Schedulable</code>.
036         */
037        public ImportanceParameters(int priority, int importance) {
038            super(priority);
039            this.importance = importance;
040        }
041    
042        /** Gets the importance value.
043         *
044         *  @return The value of importance for the associated instance of
045         *          <code>Schedulable</code>.
046         */
047        public int getImportance() {
048            return importance;
049        }
050    
051        /** Sets the importance. */
052        public void setImportance(int importance) {
053            this.importance = importance;
054        }
055        
056        /** Print the value of the importance value of the associated instance
057         *  of <code>Schedulable</code>.
058         */
059        public String toString() {
060            return "ImportanceParameters: Priority = " + getPriority()
061                + ", Importance = " + getImportance();
062        }
063    }