使用java刺激操作系统中的作业调度? [英] Stimulate job scheduling in an operating system with using java?

查看:82
本文介绍了使用java刺激操作系统中的作业调度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个java程序来模拟操作系统中的作业调度。作业随机生成。每个作业都有1到4的随机优先级,其中1是最高优先级,并且是完成执行的随机时间量。

作业不会开始执行并运行完成,而是分享处理器。操作系统执行称为时间片的固定时间单位的作业。在时间片结束时,当前作业的执行被暂停。然后将作业放在优先级队列中,等待下一个处理器时间份额。然后从优先级队列中删除具有最高优先级的作业并执行时间片。

首次生成作业时,如果处理器空闲,它将立即开始执行。否则它将被放置在优先队列中。



我尝试过:



据我所知,我知道参数应该是

Time_slice = 3,

持续时间= 50,

新工作的百分比对于每个单位时间= 20

I want to write a java program to simulate job scheduling in an operating system. Jobs are generated at random times. Each job is given both a random priority from 1 to 4, where 1 is the highest priority and a random amount of time to complete its execution.
Jobs do not begin execution and run to completion, but instead share the processor. The operating system executes a job for a fixed unit of time called a time slice. At the end of the time slice, the current job’s execution is suspended. The job is then placed on a priority queue, where it waits for its next share of processor time. The job having the highest priority is then removed from the priority queue and executed for a time slice.
When a job is first generated, it will begin executing immediately if the processor is free. Otherwise it will be placed on the priority queue.

What I have tried:

From what i understand, i know Parameters should be
Time_slice=3,
Duration=50,
Percentage of new job for each unit time=20

推荐答案

这是你的作业,所以我们不打算给你代码!

你可能想要从一些轻读开始:使用协处理器设计和开发实时调度模拟器(教学工具) ) [ ^ ](请记住,那里开发的东西不会是你想要的,但它应该给你设计思路 - 希望足以识别你的解决方案的整体形状。



这不是一项简单的任务:你需要模仿一个处理器,以及具有执行任务切换的计时器的监控系统,多个任务队列(每个优先级一个),一个任务状态系统放入队列并保存每个任务信息(时间运行,优先级,使用的时间),以及一些指示任务从任务(或处理器)到系统完成的方法。最重要的是,你将需要某种形式的UI来显示结果和发生的事情...

处理器仿真可能非常简单:除了耗尽之外,它并没有真正做任何事情时间片,所以我从那开始。



基本上,将任务分解为更简单的子任务,直到你得到你可以做的子任务。然后做,测试,再彻底测试,然后继续下一步。

试一试。这听起来很复杂 - 但是如果你认为它是子单位,并且把它们全部集中在一起而不是整体上,它就可以了。
This is your homework, so we aren't going to give you code!
You might want to start with some "light reading": Design and Development of Real Time Scheduler Simulator with Co-processor (Teaching Tool)[^] (bear in mind that what is developed there won't be exactly what you want, but it should give you design ideas - hopefully sufficient to identify the "overall shape" of your solution).

This is not a trivial task: you need to emulate a processor, and a supervisor system with a timer to do task switching, several task queues (one for each priority), a task status system to put in the queues and hold each tasks info (time run, priority, time used), and some method of indicating that a task is complete from the task (or processor) to the system. On top of that, you are going to need some form of UI to display the results and what is happening...
The processor emulation can be pretty trivial: it's not really doing anything except "using up time slices", so I'd start with that.

Basically, break down the task into simpler subtasks until you get to subtasks you can do. Then do it, test it, test it again more thoroughly, and move on to the next.
Give it a try. It sound complex - it is - but it's do-able if you think of it as sub units, and concentrate of each of those instead of the whole.


这篇关于使用java刺激操作系统中的作业调度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆