Click here to Skip to main content
14,970,948 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to do multilevel queue scheduling where

- priority==1 || priority==2 is using round robin in queue 1
- priority==3 || priority==4 is using first come first serve (fcfs) in queue 2
- priority > 4 is using fcfs in queue 3

the code that I've tried is incomplete but I try to run to see whether it works or not for the first 3 inputs, but there is an unknown error (I don't know what the error called) where the program run but it doesn't show any output and the program is not terminated.

process AT BT priority
p0 0 6 3
p1 1 4 3
p2 5 6 1

What I have tried:

public void sortMultilevel(int[] AT, int[] BT, int[] prio, int[] status, int TP)
		int i=0, current=AT[i], j, test;
			if(prio[i]==1 || prio[i]==2)
				System.out.println("Queue 1:");
				System.out.print("p" + p[i] + " from " + current + " to ");
				// if(nonew())
				// {}
				// else {
				BT[i] = BT[i]-quantum;
				// }
			else if(prio[i]==3 || prio[i]==4)
				System.out.println("Queue 2:");
				System.out.print("p" + p[i] + " from " + AT[i] + " to ");
				// if(nonew())
				// {
				// }
				// else
				// {
					for(j=0; j<TP; j++)
								BT[i] = BT[i]-(AT[j]-current);
				// }
		} // close while loop
Updated 8-Sep-18 12:07pm
Richard MacCutchan 9-Sep-18 3:43am
Add some more print statements at the end of the while loop to see which variables are not changing. That's the best I can suggest as I cannot figure out what exactly that code is supposed to do.

1 solution

The program is running but there's no output and the program is not terminated

What about watching you program performing to understand what is going on.

Your code do not behave the way you expect, or you don't understand why !

There is an almost universal solution: Run your code on debugger step by step, inspect variables.
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't know what your cpde is supposed to do, it don't find bugs, it just help you to by showing you what is going on. When the code don't do what is expected, you are close to a bug.
To see what your code is doing: Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.
Debugger - Wikipedia, the free encyclopedia[^][^][^]
The debugger is here to only show you what your code is doing and your task is to compare with what it should do.
Member 13620781 8-Sep-18 23:42pm
may I know how to debug my java code in notepad++? I have searched it online and watched the youtube about it but I don't get it. Do I need to install dbgp plugin? sorry, but I'm really new in this field. Thank you in advance.
Patrice T 9-Sep-18 2:36am
I will not be of great help on this because I don't use NotePad++ or Java.
but there should be something useful in the 400000 answers of Google notepad++ java debugger

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900