Add assignment 6 starter
This commit is contained in:
parent
fd4de4cefe
commit
e7fed25b0a
5
Assignment6/.gitignore
vendored
Normal file
5
Assignment6/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# Built program
|
||||
program1
|
||||
|
||||
# Testing output
|
||||
student_out/*
|
8
Assignment6/.idea/.gitignore
vendored
Normal file
8
Assignment6/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
20
Assignment6/.idea/misc.xml
Normal file
20
Assignment6/.idea/misc.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MakefileSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<MakefileProjectSettings>
|
||||
<option name="buildDirectory" value="" />
|
||||
<option name="buildTarget" value="build" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="version" value="2" />
|
||||
</MakefileProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
</project>
|
8
Assignment6/.idea/runConfigurations/all.xml
Normal file
8
Assignment6/.idea/runConfigurations/all.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="all" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile">
|
||||
<makefile filename="$PROJECT_DIR$/Makefile" target="all" workingDirectory="" arguments="">
|
||||
<envs />
|
||||
</makefile>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
8
Assignment6/.idea/runConfigurations/build.xml
Normal file
8
Assignment6/.idea/runConfigurations/build.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="build" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile">
|
||||
<makefile filename="$PROJECT_DIR$/Makefile" target="build" workingDirectory="" arguments="">
|
||||
<envs />
|
||||
</makefile>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
8
Assignment6/.idea/runConfigurations/clean.xml
Normal file
8
Assignment6/.idea/runConfigurations/clean.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="clean" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile">
|
||||
<makefile filename="$PROJECT_DIR$/Makefile" target="clean" workingDirectory="" arguments="">
|
||||
<envs />
|
||||
</makefile>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
8
Assignment6/.idea/runConfigurations/test.xml
Normal file
8
Assignment6/.idea/runConfigurations/test.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="test" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile">
|
||||
<makefile filename="$PROJECT_DIR$/Makefile" target="test" workingDirectory="" arguments="">
|
||||
<envs />
|
||||
</makefile>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
6
Assignment6/.idea/vcs.xml
Normal file
6
Assignment6/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
41
Assignment6/Makefile
Normal file
41
Assignment6/Makefile
Normal file
@ -0,0 +1,41 @@
|
||||
.PHONY: clean build test 1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
||||
|
||||
all: clean build test
|
||||
|
||||
test: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
||||
|
||||
clean:
|
||||
rm -rf ./program1
|
||||
rm -rf student_out/*
|
||||
|
||||
build:
|
||||
gcc -g -O0 ./code/*.c -o program1
|
||||
|
||||
1:
|
||||
./program1 -s 10 -f < ./in/test1.in > ./student_out/test1-a.out && diff ./student_out/test1-a.out ./out/test1.out
|
||||
2:
|
||||
./program1 -s 10 -f < ./in/test2.in > ./student_out/test2-a.out && diff ./student_out/test2-a.out ./out/test2.out
|
||||
3:
|
||||
./program1 -s 10 -f < ./in/test3.in > ./student_out/test3-a.out && diff ./student_out/test3-a.out ./out/test3.out
|
||||
4:
|
||||
./program1 -s 10 -f < ./in/test4.in > ./student_out/test4-a.out && diff ./student_out/test4-a.out ./out/test4.out
|
||||
5:
|
||||
./program1 -s 10 -f < ./in/test5.in > ./student_out/test5-a.out && diff ./student_out/test5-a.out ./out/test5.out
|
||||
6:
|
||||
./program1 -s 10 -f < ./in/test6.in > ./student_out/test6-a.out && diff ./student_out/test6-a.out ./out/test6.out
|
||||
7:
|
||||
./program1 -s 5 -f < ./in/test7.in > ./student_out/test7-a.out && diff ./student_out/test7-a.out ./out/test7-a.out
|
||||
8:
|
||||
./program1 -s 5 -b < ./in/test7.in > ./student_out/test7-b.out && diff ./student_out/test7-b.out ./out/test7-b.out
|
||||
9:
|
||||
./program1 -s 5 -w < ./in/test7.in > ./student_out/test7-c.out && diff ./student_out/test7-c.out ./out/test7-c.out
|
||||
10:
|
||||
./program1 -s 5 -f < ./in/test8.in > ./student_out/test8-a.out && diff ./student_out/test8-a.out ./out/test8-a.out
|
||||
11:
|
||||
./program1 -s 5 -b < ./in/test8.in > ./student_out/test8-b.out && diff ./student_out/test8-b.out ./out/test8-b.out
|
||||
12:
|
||||
./program1 -s 5 -w < ./in/test8.in > ./student_out/test8-c.out && diff ./student_out/test8-c.out ./out/test8-c.out
|
||||
13:
|
||||
./program1 -s 5 -w < ./in/test9.in > ./student_out/test13.out && diff ./student_out/test13.out ./out/test13.out
|
||||
14:
|
||||
./program1 -s 103 -f < ./in/test10.in > ./student_out/test14.out && diff ./student_out/test14.out ./out/test14.out
|
102
Assignment6/code/starter_code.c
Normal file
102
Assignment6/code/starter_code.c
Normal file
@ -0,0 +1,102 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// 1 - best fit
|
||||
// 2 - worst fit
|
||||
// 3 - first fit
|
||||
enum Algorithm {
|
||||
BEST_FIT = 1,
|
||||
WORST_FIT = 2,
|
||||
FIRST_FIT = 3
|
||||
};
|
||||
int algorithm;
|
||||
int memSize;
|
||||
int totalAllocated = 0;
|
||||
int totalMemAllocated = 0;
|
||||
int totalFailed = 0;
|
||||
int totalTerminated = 0;
|
||||
int totalFreedMemory = 0;
|
||||
|
||||
|
||||
int doFree(int processId) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int doAllocate(int howMuchToAllocate, int processId) {
|
||||
|
||||
switch (algorithm) {
|
||||
case 1: {
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
printf("There was an error, the algorithm is uninitialized");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int calcFinalMemory() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getNumberOfChunks() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getSmallest() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getBiggest() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i = 0;
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-b") == 0) {
|
||||
algorithm = 1;
|
||||
} else if (strcmp(argv[i], "-w") == 0) {
|
||||
algorithm = 2;
|
||||
} else if (strcmp(argv[i], "-s") == 0) {
|
||||
memSize = atoi(argv[i + 1]);
|
||||
} else if (strcmp(argv[i], "-f") == 0) {
|
||||
algorithm = 3;
|
||||
}
|
||||
}
|
||||
if (memSize >= 0) {
|
||||
// initialize your memory here
|
||||
} else {
|
||||
printf("The program requires size\n");
|
||||
exit(0);
|
||||
}
|
||||
char operation;
|
||||
int id = 1337;
|
||||
int size;
|
||||
while (EOF != scanf("%c", &operation)) {
|
||||
switch (operation) {
|
||||
case 'N':
|
||||
scanf(" %d %d\n", &id, &size);
|
||||
doAllocate(size, id);
|
||||
break;
|
||||
case 'T':
|
||||
scanf(" %d\n", &id);
|
||||
doFree(id);
|
||||
break;
|
||||
case 'S':
|
||||
printf("Total Processes created %d, Total allocated memory %d, Total Processes\nterminated %d, Total freed memory %d, Final memory available %d, Final\nsmallest and largest fragmented memory sizes %d and %d, total failed requests:%d, number of memory chunks: %d\n",
|
||||
totalAllocated, totalMemAllocated, totalTerminated, totalFreedMemory, calcFinalMemory(), getSmallest(), getBiggest(), totalFailed,
|
||||
getNumberOfChunks());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
BIN
Assignment6/documentation/Assignment 6-v2.pdf
Normal file
BIN
Assignment6/documentation/Assignment 6-v2.pdf
Normal file
Binary file not shown.
BIN
Assignment6/documentation/sample_test_suite-2023.zip
Normal file
BIN
Assignment6/documentation/sample_test_suite-2023.zip
Normal file
Binary file not shown.
2
Assignment6/in/test1.in
Normal file
2
Assignment6/in/test1.in
Normal file
@ -0,0 +1,2 @@
|
||||
N 1 5
|
||||
S
|
102
Assignment6/in/test10.in
Normal file
102
Assignment6/in/test10.in
Normal file
@ -0,0 +1,102 @@
|
||||
N 1 1
|
||||
N 2 1
|
||||
N 3 1
|
||||
N 4 1
|
||||
N 5 1
|
||||
N 6 1
|
||||
N 7 1
|
||||
N 8 1
|
||||
N 9 1
|
||||
N 10 1
|
||||
N 11 1
|
||||
N 12 1
|
||||
N 13 1
|
||||
N 14 1
|
||||
N 15 1
|
||||
N 16 1
|
||||
N 17 1
|
||||
N 18 1
|
||||
N 19 1
|
||||
N 20 1
|
||||
N 21 1
|
||||
N 22 1
|
||||
N 23 1
|
||||
N 24 1
|
||||
N 25 1
|
||||
N 26 1
|
||||
N 27 1
|
||||
N 28 1
|
||||
N 29 1
|
||||
N 30 1
|
||||
N 31 1
|
||||
N 32 1
|
||||
N 33 1
|
||||
N 34 1
|
||||
N 35 1
|
||||
N 36 1
|
||||
N 37 1
|
||||
N 38 1
|
||||
N 39 1
|
||||
N 40 1
|
||||
N 41 1
|
||||
N 42 1
|
||||
N 43 1
|
||||
N 44 1
|
||||
N 45 1
|
||||
N 46 1
|
||||
N 47 1
|
||||
N 48 1
|
||||
N 49 1
|
||||
N 50 1
|
||||
N 51 1
|
||||
N 52 1
|
||||
N 53 1
|
||||
N 54 1
|
||||
N 55 1
|
||||
N 56 1
|
||||
N 57 1
|
||||
N 58 1
|
||||
N 59 1
|
||||
N 60 1
|
||||
N 61 1
|
||||
N 62 1
|
||||
N 63 1
|
||||
N 64 1
|
||||
N 65 1
|
||||
N 66 1
|
||||
N 67 1
|
||||
N 68 1
|
||||
N 69 1
|
||||
N 70 1
|
||||
N 71 1
|
||||
N 72 1
|
||||
N 73 1
|
||||
N 74 1
|
||||
N 75 1
|
||||
N 76 1
|
||||
N 77 1
|
||||
N 78 1
|
||||
N 79 1
|
||||
N 80 1
|
||||
N 81 1
|
||||
N 82 1
|
||||
N 83 1
|
||||
N 84 1
|
||||
N 85 1
|
||||
N 86 1
|
||||
N 87 1
|
||||
N 88 1
|
||||
N 89 1
|
||||
N 90 1
|
||||
N 91 1
|
||||
N 92 1
|
||||
N 93 1
|
||||
N 94 1
|
||||
N 95 1
|
||||
N 96 1
|
||||
N 97 1
|
||||
N 98 1
|
||||
N 99 1
|
||||
N 100 1
|
||||
N 101 1
|
||||
S
|
3
Assignment6/in/test2.in
Normal file
3
Assignment6/in/test2.in
Normal file
@ -0,0 +1,3 @@
|
||||
N 1 5
|
||||
T 1
|
||||
S
|
4
Assignment6/in/test3.in
Normal file
4
Assignment6/in/test3.in
Normal file
@ -0,0 +1,4 @@
|
||||
N 1 5
|
||||
N 2 5
|
||||
N 3 5
|
||||
S
|
3
Assignment6/in/test4.in
Normal file
3
Assignment6/in/test4.in
Normal file
@ -0,0 +1,3 @@
|
||||
N 1 5
|
||||
T 7 5
|
||||
S
|
5
Assignment6/in/test5.in
Normal file
5
Assignment6/in/test5.in
Normal file
@ -0,0 +1,5 @@
|
||||
N 1 5
|
||||
N 2 5
|
||||
N 3 5
|
||||
T 3
|
||||
S
|
6
Assignment6/in/test6.in
Normal file
6
Assignment6/in/test6.in
Normal file
@ -0,0 +1,6 @@
|
||||
N 1 5
|
||||
N 2 5
|
||||
T 2
|
||||
T 1
|
||||
N 1 3
|
||||
S
|
8
Assignment6/in/test7.in
Normal file
8
Assignment6/in/test7.in
Normal file
@ -0,0 +1,8 @@
|
||||
N 1 1
|
||||
N 2 1
|
||||
N 3 1
|
||||
N 4 1
|
||||
T 2
|
||||
T 1
|
||||
N 5 1
|
||||
S
|
8
Assignment6/in/test8.in
Normal file
8
Assignment6/in/test8.in
Normal file
@ -0,0 +1,8 @@
|
||||
N 1 1
|
||||
N 2 1
|
||||
N 3 1
|
||||
N 4 1
|
||||
T 2
|
||||
T 4
|
||||
N 5 1
|
||||
S
|
9
Assignment6/in/test9.in
Normal file
9
Assignment6/in/test9.in
Normal file
@ -0,0 +1,9 @@
|
||||
N 1 1
|
||||
N 2 1
|
||||
N 3 1
|
||||
N 4 1
|
||||
T 4
|
||||
T 2
|
||||
N 5 1
|
||||
T 5
|
||||
S
|
3
Assignment6/out/test1.out
Normal file
3
Assignment6/out/test1.out
Normal file
@ -0,0 +1,3 @@
|
||||
Total Processes created 1, Total allocated memory 5, Total Processes
|
||||
terminated 0, Total freed memory 0, Final memory available 5, Final
|
||||
smallest and largest fragmented memory sizes 5 and 5, total failed requests:0, number of memory chunks: 1
|
3
Assignment6/out/test13.out
Normal file
3
Assignment6/out/test13.out
Normal file
@ -0,0 +1,3 @@
|
||||
Total Processes created 5, Total allocated memory 5, Total Processes
|
||||
terminated 3, Total freed memory 3, Final memory available 3, Final
|
||||
smallest and largest fragmented memory sizes 1 and 2, total failed requests:0, number of memory chunks: 2
|
3
Assignment6/out/test14.out
Normal file
3
Assignment6/out/test14.out
Normal file
@ -0,0 +1,3 @@
|
||||
Total Processes created 101, Total allocated memory 101, Total Processes
|
||||
terminated 0, Total freed memory 0, Final memory available 2, Final
|
||||
smallest and largest fragmented memory sizes 2 and 2, total failed requests:0, number of memory chunks: 1
|
3
Assignment6/out/test2.out
Normal file
3
Assignment6/out/test2.out
Normal file
@ -0,0 +1,3 @@
|
||||
Total Processes created 1, Total allocated memory 5, Total Processes
|
||||
terminated 1, Total freed memory 5, Final memory available 10, Final
|
||||
smallest and largest fragmented memory sizes 10 and 10, total failed requests:0, number of memory chunks: 1
|
4
Assignment6/out/test3.out
Normal file
4
Assignment6/out/test3.out
Normal file
@ -0,0 +1,4 @@
|
||||
Process 3 failed to allocate 5 memory
|
||||
Total Processes created 2, Total allocated memory 10, Total Processes
|
||||
terminated 0, Total freed memory 0, Final memory available 0, Final
|
||||
smallest and largest fragmented memory sizes 0 and 0, total failed requests:1, number of memory chunks: 0
|
4
Assignment6/out/test4.out
Normal file
4
Assignment6/out/test4.out
Normal file
@ -0,0 +1,4 @@
|
||||
Process 7 failed to free memory
|
||||
Total Processes created 1, Total allocated memory 5, Total Processes
|
||||
terminated 0, Total freed memory 0, Final memory available 5, Final
|
||||
smallest and largest fragmented memory sizes 5 and 5, total failed requests:1, number of memory chunks: 1
|
5
Assignment6/out/test5.out
Normal file
5
Assignment6/out/test5.out
Normal file
@ -0,0 +1,5 @@
|
||||
Process 3 failed to allocate 5 memory
|
||||
Process 3 failed to free memory
|
||||
Total Processes created 2, Total allocated memory 10, Total Processes
|
||||
terminated 0, Total freed memory 0, Final memory available 0, Final
|
||||
smallest and largest fragmented memory sizes 0 and 0, total failed requests:2, number of memory chunks: 0
|
3
Assignment6/out/test6.out
Normal file
3
Assignment6/out/test6.out
Normal file
@ -0,0 +1,3 @@
|
||||
Total Processes created 3, Total allocated memory 13, Total Processes
|
||||
terminated 2, Total freed memory 10, Final memory available 7, Final
|
||||
smallest and largest fragmented memory sizes 7 and 7, total failed requests:0, number of memory chunks: 1
|
3
Assignment6/out/test7-a.out
Normal file
3
Assignment6/out/test7-a.out
Normal file
@ -0,0 +1,3 @@
|
||||
Total Processes created 5, Total allocated memory 5, Total Processes
|
||||
terminated 2, Total freed memory 2, Final memory available 2, Final
|
||||
smallest and largest fragmented memory sizes 1 and 1, total failed requests:0, number of memory chunks: 2
|
3
Assignment6/out/test7-b.out
Normal file
3
Assignment6/out/test7-b.out
Normal file
@ -0,0 +1,3 @@
|
||||
Total Processes created 5, Total allocated memory 5, Total Processes
|
||||
terminated 2, Total freed memory 2, Final memory available 2, Final
|
||||
smallest and largest fragmented memory sizes 2 and 2, total failed requests:0, number of memory chunks: 1
|
3
Assignment6/out/test7-c.out
Normal file
3
Assignment6/out/test7-c.out
Normal file
@ -0,0 +1,3 @@
|
||||
Total Processes created 5, Total allocated memory 5, Total Processes
|
||||
terminated 2, Total freed memory 2, Final memory available 2, Final
|
||||
smallest and largest fragmented memory sizes 1 and 1, total failed requests:0, number of memory chunks: 2
|
3
Assignment6/out/test8-a.out
Normal file
3
Assignment6/out/test8-a.out
Normal file
@ -0,0 +1,3 @@
|
||||
Total Processes created 5, Total allocated memory 5, Total Processes
|
||||
terminated 2, Total freed memory 2, Final memory available 2, Final
|
||||
smallest and largest fragmented memory sizes 2 and 2, total failed requests:0, number of memory chunks: 1
|
3
Assignment6/out/test8-b.out
Normal file
3
Assignment6/out/test8-b.out
Normal file
@ -0,0 +1,3 @@
|
||||
Total Processes created 5, Total allocated memory 5, Total Processes
|
||||
terminated 2, Total freed memory 2, Final memory available 2, Final
|
||||
smallest and largest fragmented memory sizes 2 and 2, total failed requests:0, number of memory chunks: 1
|
3
Assignment6/out/test8-c.out
Normal file
3
Assignment6/out/test8-c.out
Normal file
@ -0,0 +1,3 @@
|
||||
Total Processes created 5, Total allocated memory 5, Total Processes
|
||||
terminated 2, Total freed memory 2, Final memory available 2, Final
|
||||
smallest and largest fragmented memory sizes 1 and 1, total failed requests:0, number of memory chunks: 2
|
Loading…
Reference in New Issue
Block a user