summaryrefslogtreecommitdiffstats
path: root/src/examples
diff options
context:
space:
mode:
authorMikael Asplund <mikael.asplund@liu.se>2020-02-12 13:14:55 +0100
committerMikael Asplund <mikael.asplund@liu.se>2020-02-12 13:14:55 +0100
commitb62d6af33a473cbd205e1797f099a351071c9ac3 (patch)
treee03f354290f074f9b492532f621921ce938f68ee /src/examples
parentefc06d038b98a2887306ebbce058361e43a68e77 (diff)
downloadpintos-b62d6af33a473cbd205e1797f099a351071c9ac3.tar.gz
Added test files for lab 3 and 4
Diffstat (limited to 'src/examples')
-rwxr-xr-xsrc/examples/lab3test1.c17
-rwxr-xr-xsrc/examples/lab3test2.c23
-rwxr-xr-xsrc/examples/lab4test1.c21
3 files changed, 61 insertions, 0 deletions
diff --git a/src/examples/lab3test1.c b/src/examples/lab3test1.c
new file mode 100755
index 0000000..a0070c3
--- /dev/null
+++ b/src/examples/lab3test1.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <syscall.h>
+
+//compile it, copy to the pintos virtual disk an call this program with arguments using the command
+// pintos --qemu -- run lab3test1
+//if lab 3 is correctly implemented this program should call itself in an infinite loop and spawn itself as a child process indefinetly
+//the PID of each child process created should be printed to the screen
+// In order to see if your implementation works check if the PID of each new child process is incremented as it should
+
+int
+main (int argc, char *argv[])
+{
+ int pid=exec("lab3test1");
+ printf("Child process ID: %d",pid);
+
+ return EXIT_SUCCESS;
+}
diff --git a/src/examples/lab3test2.c b/src/examples/lab3test2.c
new file mode 100755
index 0000000..255deae
--- /dev/null
+++ b/src/examples/lab3test2.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <syscall.h>
+
+//compile it, copy to the pintos virtual disk an call this program with arguments using the command
+// pintos --qemu -- run lab3test2
+//if lab 3 is correctly implemented this program should call printf 5 times, and spawn a child process for each of these calls
+//the PID of each child process created should be printed to the console.
+// In order to see if your implementation works check if the string "You got it, use your debugging skills during the labs!" is printed 5 times and if the PID of each new child process is incremented as it should
+
+
+int
+main (int argc, char *argv[])
+{
+
+ int pid=-1;
+ for(int i=0;i<5;i++)
+ {
+ pid=exec("printf");
+ printf("Child %d process ID: %d\n",i,pid);
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/src/examples/lab4test1.c b/src/examples/lab4test1.c
new file mode 100755
index 0000000..f64a066
--- /dev/null
+++ b/src/examples/lab4test1.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <syscall.h>
+
+//compile it, copy to the pintos virtual disk an call this program with arguments using the command
+// pintos --qemu -- run 'lab4test1 arg1 arg2 arg3'
+//if lab 4 is correctly implemented the arguments should be printed to the console
+// try it wih different arguments and different number of arguments
+
+int
+main (int argc, char *argv[])
+{
+
+ for(int i=0;i<argc;i++)
+ {
+ printf("Parameter: %d: %s \n",i,argv[i];
+ }
+
+ return EXIT_SUCCESS;
+}
+
+