• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Time in a program issues

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what I am trying to do is to have a process (this is just a object) with certiant values like:

public String name;
public int priority; //not to exceed 4
public int serviceTimeTotal; //holds the cumlitive service time
public int waitTimeTotal; //holds the cumulative wait time
public int arrivalTime;
public int burstTime;
public boolean added;
public boolean active;
public boolean isDone;

And I want to keep track of how much time each process gets service and how much time each process waits whle the other process gets service. I dont know if im keeping track of the time right or not I want the time in milliseconds and I think thats what it is in, im using the .nanoTime When I run the program it runs but the wait time does not increase at all but the service time for the one that is running does increase so I think I got that one right So here is how I am dong this;



This runs the process and then calculates the service time, priority, and th wait time for each process in the linked list.

In the MyProcess class I calculate the priority like this



and the service time and wait time like this



This seams like it should work but it does not. am i missing something here Thanks for any help with this
 
Marshal
Posts: 76866
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to check the arithmetic for calculating priority. You are mixing doubles and int casts, and I don’t think you will get the results you want.
Find out about Thread#sleep. Beware: that method declares a checked Exception.
 
Matt Millar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you were right took all weekend to get it fixed but now i got everything into a long format so it working now thanks
 
Campbell Ritchie
Marshal
Posts: 76866
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well done
It might have taken lots of effort, but it will be a long time before you forget it. And no puns were intended
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic