-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Class contains all processes to generate some information about them
- Loading branch information
1 parent
30636cf
commit a429049
Showing
15 changed files
with
174 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | ||
http://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
|
||
<activeProfiles> | ||
<activeProfile>github</activeProfile> | ||
</activeProfiles> | ||
|
||
<profiles> | ||
<profile> | ||
<id>github</id> | ||
<repositories> | ||
<repository> | ||
<id>central</id> | ||
<url>https://repo1.maven.org/maven2</url> | ||
</repository> | ||
<repository> | ||
<id>github</id> | ||
<url>https://maven.pkg.github.com/Mahdi-jamil/FCFS-scheduling-algorithm</url> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
</profile> | ||
</profiles> | ||
|
||
<servers> | ||
<server> | ||
<id>github</id> | ||
<username>Mahdi-jamil</username> | ||
<password>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</password> | ||
</server> | ||
</servers> | ||
</settings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/main/java/com/mahdi/process/CreateAndTrackProcesses.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.mahdi.process; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.util.ArrayList; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Scanner; | ||
|
||
import com.mahdi.main.MainTest; | ||
import com.mahdi.main.NewState; | ||
|
||
public class CreateAndTrackProcesses { | ||
private List<Process> p=new ArrayList<>(); | ||
|
||
|
||
public List<Process> CreateProcesses(String fileName) throws FileNotFoundException { | ||
File file=new File(fileName); | ||
Scanner in=new Scanner(file); | ||
|
||
int count=0; | ||
|
||
Process testProcess; | ||
int id; | ||
int at; | ||
LinkedList<Integer> btTest; | ||
LinkedList<Integer> IOTest; | ||
|
||
while (in.hasNextLine()) { | ||
String line = in.nextLine(); | ||
String[] tokens = line.split(" "); | ||
|
||
if (tokens.length < 2) { | ||
continue; | ||
} | ||
|
||
id = Integer.parseInt(tokens[0]); | ||
at = Integer.parseInt(tokens[1]); | ||
|
||
btTest = new LinkedList<>(); | ||
IOTest = new LinkedList<>(); | ||
|
||
for (int i = 2; i < tokens.length; i++) { | ||
// Parse each token as an integer and add it to the appropriate list | ||
int value = Integer.parseInt(tokens[i]); | ||
if (i % 2 == 0) { | ||
btTest.add(value); | ||
} else { | ||
IOTest.add(value); | ||
} | ||
} | ||
count++; | ||
testProcess = new Process(id, at, btTest, IOTest); | ||
p.add(testProcess); | ||
} | ||
MainTest.NUMBER_OF_PROCESSES=count; | ||
in.close(); | ||
return p; | ||
|
||
} | ||
|
||
|
||
public void generateReport() { | ||
System.out.println("terminated with"); | ||
System.out.println("Pid AT BT CT TT WT"); | ||
for(Process process:p) { | ||
System.out.println(process.getInfo()); | ||
} | ||
} | ||
|
||
|
||
public float getAvgWaitingTime() { | ||
float avg=0; | ||
for (Process process : p) { | ||
avg+=process.getWT(); | ||
} | ||
MainTest.avgWT=avg/p.size(); | ||
System.out.println("AVG Waiting Time "+ MainTest.avgWT); | ||
return MainTest.avgWT; | ||
} | ||
|
||
|
||
|
||
public void AddToReady(NewState newState) { | ||
for(Process process:p) { | ||
newState.addToReady(process); | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
target/classes/META-INF/maven/com.mahdi.scheduling/process-scheduling/pom.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#Generated by Maven Integration for Eclipse | ||
#Tue Sep 26 23:41:39 PDT 2023 | ||
#Wed Sep 27 07:15:25 PDT 2023 | ||
artifactId=process-scheduling | ||
groupId=com.mahdi.scheduling | ||
m2e.projectLocation=C\:\\scheduling_project | ||
m2e.projectName=process-scheduling | ||
version=0.0.1-SNAPSHOT | ||
version=1.0.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.