Add assignment 2
This commit is contained in:
parent
7e77743b9d
commit
d7cc2be178
15
Assignment1/.idea/aws.xml
Normal file
15
Assignment1/.idea/aws.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="accountSettings">
|
||||||
|
<option name="activeRegion" value="us-east-1" />
|
||||||
|
<option name="recentlyUsedRegions">
|
||||||
|
<list>
|
||||||
|
<option value="us-east-1" />
|
||||||
|
<option value="us-east-2" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="connectionManager">
|
||||||
|
<option name="activeConnectionId" value="sso;us-east-1;https://view.awsapps.com/start" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
Assignment2/.idea/.gitignore
vendored
Normal file
8
Assignment2/.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
|
2
Assignment2/.idea/Assignment2.iml
Normal file
2
Assignment2/.idea/Assignment2.iml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
11
Assignment2/.idea/aws.xml
Normal file
11
Assignment2/.idea/aws.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="accountSettings">
|
||||||
|
<option name="activeRegion" value="us-east-1" />
|
||||||
|
<option name="recentlyUsedRegions">
|
||||||
|
<list>
|
||||||
|
<option value="us-east-1" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
4
Assignment2/.idea/misc.xml
Normal file
4
Assignment2/.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||||
|
</project>
|
8
Assignment2/.idea/modules.xml
Normal file
8
Assignment2/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/Assignment2.iml" filepath="$PROJECT_DIR$/.idea/Assignment2.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
Assignment2/.idea/vcs.xml
Normal file
6
Assignment2/.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>
|
6
Assignment2/CMakeLists.txt
Normal file
6
Assignment2/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
project(Assignment2 C)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
|
||||||
|
add_executable(Assignment2 main.c)
|
BIN
Assignment2/documentation/Assignment2-v1.pdf
Normal file
BIN
Assignment2/documentation/Assignment2-v1.pdf
Normal file
Binary file not shown.
47
Assignment2/documentation/sample_execution.txt
Normal file
47
Assignment2/documentation/sample_execution.txt
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
(870665) Please input your shell command:
|
||||||
|
onechild
|
||||||
|
(870665)Hello, I am a parent process
|
||||||
|
(870666)Hello, I am a child process
|
||||||
|
(870665) Please input your shell command:
|
||||||
|
addnumbers
|
||||||
|
(870665)Please input number, (0) to terminate
|
||||||
|
1
|
||||||
|
(870665)Read 1
|
||||||
|
(870665)Please input number, (0) to terminate
|
||||||
|
(870667)The subtotal is: 1
|
||||||
|
2
|
||||||
|
(870665)Read 2
|
||||||
|
(870665)Please input number, (0) to terminate
|
||||||
|
(870667)The subtotal is: 3
|
||||||
|
3
|
||||||
|
(870665)Read 3
|
||||||
|
(870665)Please input number, (0) to terminate
|
||||||
|
(870667)The subtotal is: 6
|
||||||
|
4
|
||||||
|
(870665)Read 4
|
||||||
|
(870665)Please input number, (0) to terminate
|
||||||
|
(870667)The subtotal is: 10
|
||||||
|
0
|
||||||
|
(870665)Read 0
|
||||||
|
(870667)The subtotal is: 10
|
||||||
|
(870665)The sum is 10
|
||||||
|
(870665) Please input your shell command:
|
||||||
|
exec
|
||||||
|
(870665) Please input exec subcommand
|
||||||
|
ls
|
||||||
|
;
|
||||||
|
a.out sample_run_1.txt solution.c
|
||||||
|
(870665) Please input your shell command:
|
||||||
|
processtree
|
||||||
|
Please input the integer
|
||||||
|
3
|
||||||
|
(870665)The value is 0
|
||||||
|
(870671)The value is 4
|
||||||
|
(870672)The value is 2
|
||||||
|
(870676)The value is 3
|
||||||
|
(870674)The value is 1
|
||||||
|
(870673)The value is 6
|
||||||
|
(870675)The value is 5
|
||||||
|
(870677)The value is 7
|
||||||
|
(870665) Please input your shell command:
|
||||||
|
stop
|
77
Assignment2/documentation/sample_execution_2.txt
Normal file
77
Assignment2/documentation/sample_execution_2.txt
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
(870697) Please input your shell command:
|
||||||
|
onechild
|
||||||
|
(870697)Hello, I am a parent process
|
||||||
|
(870698)Hello, I am a child process
|
||||||
|
(870697) Please input your shell command:
|
||||||
|
onechild
|
||||||
|
(870697)Hello, I am a parent process
|
||||||
|
(870699)Hello, I am a child process
|
||||||
|
(870697) Please input your shell command:
|
||||||
|
addnumbers
|
||||||
|
(870697)Please input number, (0) to terminate
|
||||||
|
3
|
||||||
|
(870697)Read 3
|
||||||
|
(870697)Please input number, (0) to terminate
|
||||||
|
(870700)The subtotal is: 3
|
||||||
|
5
|
||||||
|
(870697)Read 5
|
||||||
|
(870697)Please input number, (0) to terminate
|
||||||
|
(870700)The subtotal is: 8
|
||||||
|
7
|
||||||
|
(870697)Read 7
|
||||||
|
(870697)Please input number, (0) to terminate
|
||||||
|
(870700)The subtotal is: 15
|
||||||
|
0
|
||||||
|
(870697)Read 0
|
||||||
|
(870700)The subtotal is: 15
|
||||||
|
(870697)The sum is 15
|
||||||
|
(870697) Please input your shell command:
|
||||||
|
exec
|
||||||
|
(870697) Please input exec subcommand
|
||||||
|
ls
|
||||||
|
-al
|
||||||
|
;
|
||||||
|
total 40
|
||||||
|
drwxr-xr-x 2 hidden fcsgrad 61 Sep 21 23:40 .
|
||||||
|
drwxr-xr-x 5 hidden fcsgrad 61 Sep 21 11:41 ..
|
||||||
|
-rwxr-xr-x 1 hidden fcsgrad 26824 Sep 21 23:40 a.out
|
||||||
|
-rw-r--r-- 1 hidden fcsgrad 1093 Sep 21 23:40 sample_run_1.txt
|
||||||
|
-rw-r--r-- 1 hidden fcsgrad 5503 Sep 21 23:39 solution.c
|
||||||
|
(870697) Please input your shell command:
|
||||||
|
processtree
|
||||||
|
Please input the integer
|
||||||
|
5
|
||||||
|
(870697)The value is 0
|
||||||
|
(870711)The value is 1
|
||||||
|
(870708)The value is 2
|
||||||
|
(870704)The value is 16
|
||||||
|
(870706)The value is 4
|
||||||
|
(870709)The value is 20
|
||||||
|
(870713)The value is 18
|
||||||
|
(870705)The value is 8
|
||||||
|
(870715)The value is 10
|
||||||
|
(870714)The value is 6
|
||||||
|
(870710)The value is 12
|
||||||
|
(870707)The value is 24
|
||||||
|
(870712)The value is 28
|
||||||
|
(870697) Please input your shell command:
|
||||||
|
(870718)The value is 3
|
||||||
|
(870719)The value is 17
|
||||||
|
(870720)The value is 5
|
||||||
|
(870722)The value is 21
|
||||||
|
(870723)The value is 19
|
||||||
|
(870716)The value is 22
|
||||||
|
(870725)The value is 9
|
||||||
|
(870730)The value is 29
|
||||||
|
(870727)The value is 11
|
||||||
|
(870726)The value is 7
|
||||||
|
(870721)The value is 26
|
||||||
|
(870728)The value is 13
|
||||||
|
(870731)The value is 23
|
||||||
|
(870732)The value is 27
|
||||||
|
(870729)The value is 25
|
||||||
|
(870717)The value is 14
|
||||||
|
(870724)The value is 30
|
||||||
|
(870734)The value is 15
|
||||||
|
(870733)The value is 31
|
||||||
|
stop
|
25
Assignment2/main.c
Normal file
25
Assignment2/main.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
bool is_looping = true;
|
||||||
|
// Listen loop
|
||||||
|
while (is_looping) {
|
||||||
|
char input[5][100];
|
||||||
|
char buffer[500];
|
||||||
|
//Print prompt
|
||||||
|
printf("[%d]> ", getpid());
|
||||||
|
if (fgets(buffer, 500, stdin) == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//split buffer on spaces into input array
|
||||||
|
sscanf(buffer, "%s %s %s %s %s", input[0], input[1], input[2], input[3], input[4]);
|
||||||
|
|
||||||
|
if (strcmp(input[0], "stop") == 0) {
|
||||||
|
is_looping = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user