⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lotteryscheduler.java

📁 Nachos 5 java version
💻 JAVA
字号:
package nachos.threads;import nachos.machine.*;import java.util.TreeSet;import java.util.HashSet;import java.util.Iterator;/** * A scheduler that chooses threads using a lottery. * * <p> * A lottery scheduler associates a number of tickets with each thread. When a * thread needs to be dequeued, a random lottery is held, among all the tickets * of all the threads waiting to be dequeued. The thread that holds the winning * ticket is chosen. * * <p> * Note that a lottery scheduler must be able to handle a lot of tickets * (sometimes billions), so it is not acceptable to maintain state for every * ticket. * * <p> * A lottery scheduler must partially solve the priority inversion problem; in * particular, tickets must be transferred through locks, and through joins. * Unlike a priority scheduler, these tickets add (as opposed to just taking * the maximum). */public class LotteryScheduler extends PriorityScheduler {    /**     * Allocate a new lottery scheduler.     */    public LotteryScheduler() {    }        /**     * Allocate a new lottery thread queue.     *     * @param	transferPriority	<tt>true</tt> if this queue should     *					transfer tickets from waiting threads     *					to the owning thread.     * @return	a new lottery thread queue.     */    public ThreadQueue newThreadQueue(boolean transferPriority) {	// implement me	return null;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -