Difference between revisions of "Scheduler Client Assignment"

From CSE231 Wiki
Jump to navigation Jump to search
Line 8: Line 8:
 
</syntaxhighlight>}}
 
</syntaxhighlight>}}
 
==SchedulerClient main==
 
==SchedulerClient main==
−
{{CollapsibleCode|SchedulerClient|<syntaxhighlight lang="java">
+
{{CollapsibleCode|SchedulerClient main|<syntaxhighlight lang="java">
 
public class SchedulerClient {
 
public class SchedulerClient {
 
private static void output(Scheduler scheduler, int N) {
 
private static void output(Scheduler scheduler, int N) {
Line 19: Line 19:
 
scheduler.joinAll();
 
scheduler.joinAll();
 
}
 
}
−
}
+
}</syntaxhighlight>}}
−
}}
 
  
 
=Code To Implement=
 
=Code To Implement=

Revision as of 18:35, 8 May 2025

Motivation

Code To Investigate

interface Scheduler

Scheduler  
public interface Scheduler {
	void void_fork(Runnable runnable);
}

SchedulerClient main

SchedulerClient main  
public class SchedulerClient {
	private static void output(Scheduler scheduler, int N) {
		throw new NotYetImplementedException();
	}

	public static void main(String[] args) throws InterruptedException, ExecutionException {
		ExecutorServiceScheduler scheduler = new ExecutorServiceScheduler();
		output(scheduler, 10);
		scheduler.joinAll();
	}
}

Code To Implement

class: SchedulerClient.java Java.png
methods: output
package: scheduler.group
source folder: student/src/main/java

method: private static void output(Scheduler scheduler, int N) Parallel.svg (parallel implementation required)

Fork N tasks via scheduler.void_fork which print the indices [0..N).

Code To Run

Run SchedulerClient in the scheduler.group package (the file you are editing).

The output should look something like this (not necessarily in this order as it should be parallel).

SchedulerClient output  
0
3
2
1
4
5
6
7
8
9