Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Schedulling.priority;
- import java.util.ArrayList;
- /**
- *
- * @author Mirra Ariesta Amalia Adiba
- */
- public class Priority extends Schedulling.CpuScheduler{
- public Schedulling.Process getTopPriority(ArrayList<Schedulling.Process> processList){
- Schedulling.Process result=null;
- for (int i = 0; i < processList.size(); i++) {
- if(result==null){
- result=processList.get(i);
- }else{
- if(result.getPriority()>processList.get(i).getPriority()){
- result = processList.get(i);
- }
- }
- }
- return result;
- }
- @Override
- protected void execute() {
- time = 0;
- ArrayList<Schedulling.Process> queue;
- while (getRemainingBurstTime() > 0) {
- if (getCurrent()!=null && (getCurrent().getCurrentBurstTime() <= 0 || getCurrent()!= getTopPriority(getProcessQueue(null))) ) {
- detach();
- }
- if (getCurrent() == null) {
- attach(getTopPriority(getProcessQueue(null)));
- }
- if (getCurrent() != null) {
- getCurrent().doProcess();
- }
- queue = getProcessQueue(getCurrent());
- queueWait(queue);
- time++;
- }
- detach();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment