public void ExecuteAll() { while (true) { if (!scheduler.Empty()) { // get job from scheduler Job job = scheduler.popJob(cores); while (cores < job.CPUsNeeded) { Thread.Sleep(100); } Console.WriteLine("Popped " + job); Task <string> task = Task.Factory.StartNew <string>(() => ExecuteJob(job)); } } }
public void ExecuteAll() { while (!scheduler.Empty()) { // get job from scheduler Job job = scheduler.popJob(); // start job changeState(job, State.Running); String result = job.Process(new string[] { "Processing job started at: " + job.jobId + " owner: " + job.Owner.Name }); // if failed if (result == null) { changeState(job, State.Failed); } // when finished else { changeState(job, State.Terminated); } } }
public void setup() { BS = new BenchmarkSystem(); sch = BS.scheduler; j1 = new Job( (string[] arg) => { foreach (string s in arg) { Console.Out.WriteLine(s); } ; return(""); }, new Owner("one"), 1, // Cpus needed 1000 // Runtime (in milliseconds) ); delayedJob = new Job( (string[] arg) => { foreach (string s in arg) { Console.Out.WriteLine(s); } ; return(""); }, new Owner("delayed"), 3, // Cpus needed 1000 // Runtime (in milliseconds) ); j3 = new Job( (string[] arg) => { foreach (string s in arg) { Console.Out.WriteLine(s); } ; return(""); }, new Owner("three"), 1, // Cpus needed 1000 // Runtime (in milliseconds) ); j4 = new Job( (string[] arg) => { foreach (string s in arg) { Console.Out.WriteLine(s); } ; return(""); }, new Owner("four"), 1, // Cpus needed 1000 // Runtime (in milliseconds) ); j5 = new Job( (string[] arg) => { foreach (string s in arg) { Console.Out.WriteLine(s); } ; return(""); }, new Owner("five"), 1, // Cpus needed 1000 // Runtime (in milliseconds) ); // remove old jobs from the static scheduler while (!sch.Empty()) { sch.popJob(10); } // add them again sch.addJob(j1); sch.addJob(delayedJob); sch.addJob(j3); sch.addJob(j4); sch.addJob(j5); }
public void setup() { BS = new BenchmarkSystem(); sch = BS.scheduler; j1 = new Job( (string[] arg) => { foreach (string s in arg) { Console.Out.WriteLine(s); }; return ""; }, new Owner("one"), 1, // Cpus needed 1000 // Runtime (in milliseconds) ); delayedJob = new Job( (string[] arg) => { foreach (string s in arg) { Console.Out.WriteLine(s); }; return ""; }, new Owner("delayed"), 3, // Cpus needed 1000 // Runtime (in milliseconds) ); j3 = new Job( (string[] arg) => { foreach (string s in arg) { Console.Out.WriteLine(s); }; return ""; }, new Owner("three"), 1, // Cpus needed 1000 // Runtime (in milliseconds) ); j4 = new Job( (string[] arg) => { foreach (string s in arg) { Console.Out.WriteLine(s); }; return ""; }, new Owner("four"), 1, // Cpus needed 1000 // Runtime (in milliseconds) ); j5 = new Job( (string[] arg) => { foreach (string s in arg) { Console.Out.WriteLine(s); }; return ""; }, new Owner("five"), 1, // Cpus needed 1000 // Runtime (in milliseconds) ); // remove old jobs from the static scheduler while (!sch.Empty()) { sch.popJob(10); } // add them again sch.addJob(j1); sch.addJob(delayedJob); sch.addJob(j3); sch.addJob(j4); sch.addJob(j5); }