From dd40b3fef829f093ab52f95eecde72407d1ebee9 Mon Sep 17 00:00:00 2001 From: hieuvdbi9102 <59214816+hieuvdbi9102@users.noreply.github.com> Date: Mon, 13 Jan 2020 22:40:25 -0500 Subject: [PATCH 1/7] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 511ad59..4328653 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,6 @@ Students are expected to: Student Info ========================= -* Student Name: *Put your name here* -* Student ID: *Put your ID here* +* Student Name: Vũ Đức Hiếu +* Student ID: BI9-102 From 3276d79b1437b1e49c7742154141b4e017b2dcb2 Mon Sep 17 00:00:00 2001 From: hieuvdbi9102 <59214816+hieuvdbi9102@users.noreply.github.com> Date: Fri, 14 Feb 2020 07:53:54 +0700 Subject: [PATCH 2/7] Lab 1 --- 01.report.shell.commands.txt | 46 ++++++++++++++++++++++++++++++++++++ 02.report.pipe.txt | 18 ++++++++++++++ 03.process.shell.txt | 16 +++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 01.report.shell.commands.txt create mode 100644 02.report.pipe.txt create mode 100644 03.process.shell.txt diff --git a/01.report.shell.commands.txt b/01.report.shell.commands.txt new file mode 100644 index 0000000..2158d50 --- /dev/null +++ b/01.report.shell.commands.txt @@ -0,0 +1,46 @@ +root@Admin:~# echo hello word +hello word +root@Admin:~# passwd +New password: +Retype new password: +passwd: password updated successfully +root@Admin:~# date +Tue 14 Jan 2020 05:16:05 AM EST +root@Admin:~# hostname +Admin +root@Admin:~# arch +x86_64 +root@Admin:~# uname -a +Linux Admin 5.3.0-kali3-amd64 #1 SMP Debian 5.3.15-1kali1 (2019-12-09) x86_64 GNU/Linux +root@Admin:~# dmesg +[37621.154873] [drm] ring test on 3 succeeded in 4 usecs +[37621.154881] [drm] ring test on 4 succeeded in 4 usecs +[37621.330603] [drm] ring test on 5 succeeded in 2 usecs +[37621.330608] [drm] UVD initialized successfully. +[37621.330669] [drm] ib test on ring 0 succeeded in 0 usecs +[37621.330732] [drm] ib test on ring 1 succeeded in 0 usecs +[37621.330780] [drm] ib test on ring 2 succeeded in 0 usecs +[37621.330814] [drm] ib test on ring 3 succeeded in 0 usecs +[37621.330846] [drm] ib test on ring 4 succeeded in 0 usecs +[37622.009224] [drm] ib test on ring 5 succeeded +root@Admin:~/Desktop# uptime + 05:19:26 up 11:41, 1 user, load average: 0.62, 0.57, 0.57 +root@Admin:~/Desktop# who am i +root@Admin:~/Desktop# whoami +root +root@Admin:~/Desktop# who +root tty7 2020-01-13 17:39 (:0) +root@Admin:~/Desktop# id +uid=0(root) gid=0(root) groups=0(root) +root@Admin:~/Desktop# last +root tty7 :0 Mon Jan 13 17:39 still logged in + +wtmp begins Fri Dec 20 13:57:13 2019 +root@Admin:~/Desktop# finger +Login Name Tty Idle Login Time Office Office Phone +root root tty7 11:41 Jan 13 17:39 (:0) +root@Admin:~/Desktop# w + 05:20:03 up 11:41, 1 user, load average: 0.72, 0.59, 0.58 +USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT +root tty7 :0 17:39 11:41m 47:27 47:27 /usr/lib/xorg/Xorg :0 -seat seat0 -au + diff --git a/02.report.pipe.txt b/02.report.pipe.txt new file mode 100644 index 0000000..5d5d070 --- /dev/null +++ b/02.report.pipe.txt @@ -0,0 +1,18 @@ +root@Admin:~# ls | grep list +root@Admin:~# wc -l /etc/passwd +54 /etc/passwd +root@Admin:~# free + total used free shared buff/cache available +Mem: 8136024 2028432 4716216 348744 1391376 5454432 +Swap: 8300540 12272 8288268 + +root@Admin:~# cat /proc/cpuinfo | grep core +core id : 0 +cpu cores : 2 +core id : 1 +cpu cores : 2 + +root@Admin:~/Downloads# find *.jpg | wc -l +8 + + diff --git a/03.process.shell.txt b/03.process.shell.txt new file mode 100644 index 0000000..280af9d --- /dev/null +++ b/03.process.shell.txt @@ -0,0 +1,16 @@ +root@Admin:~# ps -A + PID TTY TIME CMD + 1 ? 00:00:02 systemd + 2 ? 00:00:00 kthreadd + 3 ? 00:00:00 rcu_gp + 4 ? 00:00:00 rcu_par_gp + 6 ? 00:00:00 kworker/0:0H-kblockd + 9 ? 00:00:00 mm_percpu_wq + 10 ? 00:00:00 ksoftirqd/0 +root@Admin:~# wireshark +root@Admin:~# ps -A | grep wireshark + 18981 pts/1 00:00:00 wireshark +root@Admin:~# kill -STOP 18981 +root@Admin:~# kill -CONT 18981 +root@Admin:~# kill -KILL 18981 + From a9fb7bd285724e1c8ddfb45dd82989eb59f9484e Mon Sep 17 00:00:00 2001 From: hieuvdbi9102 <59214816+hieuvdbi9102@users.noreply.github.com> Date: Sat, 2 May 2020 12:58:00 +0700 Subject: [PATCH 3/7] commit lab 4 --- 04.practical.work.fork.exec.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 04.practical.work.fork.exec.c diff --git a/04.practical.work.fork.exec.c b/04.practical.work.fork.exec.c new file mode 100644 index 0000000..4ab9113 --- /dev/null +++ b/04.practical.work.fork.exec.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include + +int main(int argc, char const *argv[]) { + printf("Main before fork()\n"); + int pid = fork(); + + if (pid == 0){ + int pid2 = fork(); + + if (pid2 == 0){ + printf("I am child after fork(), launching ps -ef\n"); + char *args[] = {"/bin/ps", "-ef", NULL}; + execvp("/bin/ps", args); + } + else { + wait(NULL); + printf("I am parent after fork(), child is %d\n", pid2); + } + + printf("I am child after fork(), launching free -h\n"); + char *args[] = {"free", "-h", NULL}; + execvp("free", args); + } + else { + wait(NULL); + printf("I am parent after fork(), child is %d\n", pid); + } + printf("Complete!\n"); + return 0; + +} From b0f5e70eca22a129ed298493068eb5c4bf35d00a Mon Sep 17 00:00:00 2001 From: hieuvdbi9102 <59214816+hieuvdbi9102@users.noreply.github.com> Date: Sat, 2 May 2020 13:09:05 +0700 Subject: [PATCH 4/7] Commit lab 5 --- 05.report.proccess.scheduler.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 05.report.proccess.scheduler.txt diff --git a/05.report.proccess.scheduler.txt b/05.report.proccess.scheduler.txt new file mode 100644 index 0000000..a98058b --- /dev/null +++ b/05.report.proccess.scheduler.txt @@ -0,0 +1,14 @@ +/proc/sched_debug + +vdhieu@Admin:~$ cat /proc/sched_debug | grep -e systemd | awk '{print $5}' +120 +2746650 +1014 +1642 +35074 + +/proc//sched + +vdhieu@Admin:~$ cat /proc/1/sched | grep nr_switches +nr_switches : 2762212 + From 2132b30dc42400738af1bc3b7f9bd8ae45a7df66 Mon Sep 17 00:00:00 2001 From: hieuvdbi9102 <59214816+hieuvdbi9102@users.noreply.github.com> Date: Sat, 2 May 2020 13:14:23 +0700 Subject: [PATCH 5/7] Commit lab 7 --- 07.report.thread.info.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 07.report.thread.info.txt diff --git a/07.report.thread.info.txt b/07.report.thread.info.txt new file mode 100644 index 0000000..797ce74 --- /dev/null +++ b/07.report.thread.info.txt @@ -0,0 +1,6 @@ +vdhieu@Admin:~$ ps -o nlwp 59481 + 58 + +vdhieu@Admin:~$ ls /proc/59481/task | wc -w + 56 + From 8151ab8e5e26b30e7efb76c42a02b9f9a5f372be Mon Sep 17 00:00:00 2001 From: hieuvdbi9102 <59214816+hieuvdbi9102@users.noreply.github.com> Date: Sat, 2 May 2020 13:15:58 +0700 Subject: [PATCH 6/7] Commit lab 8 --- 08.report.works.pthread.c | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 08.report.works.pthread.c diff --git a/08.report.works.pthread.c b/08.report.works.pthread.c new file mode 100644 index 0000000..c854b30 --- /dev/null +++ b/08.report.works.pthread.c @@ -0,0 +1,44 @@ + +#include +#include +#include + +void *primeCalc() +{ + int n = 0; + for (int i = 2; i < 1000000; i++) + { + int isPrime = 1; + for (int j = 2; j < sqrt(i); j++) + if (i % j == 0) + { + isPrime = 0; + break; + } + if (isPrime == 1) printf("Prime number %d: %d\n",n++,i); + } +} +void *fiboCalc() +{ + printf("Fibo number 1:1\n"); + printf("Fibo number 2:1\n"); + int first = 2, sec = 3, n = 3; + while (first < 1000000 && sec < 1000000) + { + printf("Fibo number %d:%d\n", n++,first); + printf("Fibo number %d:%d\n", n++,sec); + first += sec; + sec += first; + } + +} + +int main() +{ + pthread_t prime_t, fibo_t; + pthread_create(&prime_t, NULL, primeCalc, NULL); + pthread_create(&fibo_t, NULL, fiboCalc, NULL); + pthread_join(prime_t, NULL); + pthread_join(fibo_t, NULL); + return 0; +} From 49b2485b311eb2f9fb47b8c1dee46f041e69468b Mon Sep 17 00:00:00 2001 From: hieuvdbi9102 <59214816+hieuvdbi9102@users.noreply.github.com> Date: Sat, 2 May 2020 13:17:25 +0700 Subject: [PATCH 7/7] Commit lab 9 --- 09.report.scheduling.txt | 80 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 09.report.scheduling.txt diff --git a/09.report.scheduling.txt b/09.report.scheduling.txt new file mode 100644 index 0000000..d40d217 --- /dev/null +++ b/09.report.scheduling.txt @@ -0,0 +1,80 @@ +Skip to content +Search or jump to… + +Pull requests +Issues +Marketplace +Explore + +@hieuvdbi9102 +Learn Git and GitHub without any code! +Using the Hello World guide, you’ll start a branch, write comments, and open a pull request. + + +Sylbanie +/ +os2020 +forked from SonTG/os2020 +0 +076 + Code + Pull requests 0 Actions + Projects 0 + Wiki + Security 0 + Insights +os2020/09.report.scheduling.txt +@gdxpub gdxpub Add parts of answer for exercise 9 +f11cc67 on Mar 31 +50 lines (42 sloc) 3.06 KB + + +-------------------------------------------+ + | | + p1 | 8ms | + | | + +-------------------------------------------+ + + +---------------------+ + | | + p2 | 4ms | + | | + +---------------------+ + + +------+ + | | + p3 | 1ms | + | | + +------+ + + +--------------------------+ + | | + p4 | 5ms | + | | + +--------------------------+ + + +-------------------------------------------+---------------------+------+--------------------------+ + | | | | | + FCFS | 8ms | 4ms | 1ms | 5ms | 0, 8-0.4, 12-1, 13-1.3 ms + | | | | | + +-------------------------------------------+---------------------+------+--------------------------+ + + +-------------------------------------------+------+---------------------+--------------------------+ + | | | 1ms) | | + SJF | 8ms | 1ms | 4ms | 5ms | 0, 9-0.4, 8-1, 13-1.3ms + | | | | | + +-------------------------------------------+------+---------------------+--------------------------+ + + +--+---+------+--------------------+---------------------------+-------------------------------------+ + | | | | | | | + SRTF |p1|p2 | p3 | p2 | p4 | p1 | (0.6+1+3.4+5), (0+1), 0, (5.4-1.3)ms + | | | | | | | + +--+---+------+--------------------+---------------------------+-------------------------------------+ + 0.4 0.6 1ms 3.4ms 5ms 7.6ms + + +--+---+--+------+------+------+----+------+------+------+------+------+------+--+ + | | | | | | | | | | | | | | | +RR |p1|p2 |p3| p4 | p1 | p2 |p3 | p1 | p2 | p4 | p1 | p2 | p4 |p2| + | | | | | | | | | | | | | | | + +--+---+--+------+------+------+----+------+------+------+------+------+------+--+ + .4 .6 .3 1ms 1 1 .7 1 1 1 1 1 1 .4 +