954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Java Queue and Average Waiting Time

hi there

how do i determine the average Number of Queue Items that leave the queue (example: processes leaving the ready queue in order to be Running in the CPU) per second?

i need this value to calculate for the average waiting time.
the formula is:
w = n/X
where n is the average queue size and
X is the average number of queue items leaving the queue per second.

deviliq
Light Poster
26 posts since Oct 2010
Reputation Points: 10
Solved Threads: 1
 

Huh? You are misunderstanding about the equation for CPU scheduling...

The average waiting time is the total waiting time of all processes divide by the total number of all processes. It is not your 'queue' size at all. Using queue time will be very dangerous and can be easily inaccurate.

/*
For example
process   required process time   arrival time unit
p1                10                    0
p2                12                    7
p3                 7                    9

Ignoring the CPU burst, now the process will be put into scheduling as...
0         10        20        30
|---------|---------|---------|-----
|         |           |      |
p1        p2          p3     end

Now compute the waiting time...
p1 -> arrives and starts => 0
p2 -> arrives at 7 but waits until 10 to start => 3 (10-7)
p3 -> arrives at 9 but waits until 22 to start => 13 (22-9)

w = (0 + 3 + 13) / 3   <-- total waiting time / total number of process
*/
Taywin
Posting Virtuoso
1,727 posts since Apr 2010
Reputation Points: 229
Solved Threads: 239
 

aye, W=N/X is called "Little's Formula"
i googled it meself... :)

deviliq
Light Poster
26 posts since Oct 2010
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: