ccccourse / sp110b

課程:系統程式 -- 筆記、習題與報告
1 stars 50 forks source link

系統程式 第 9 週 -- 簽到討論區 #14

Open ccckmit opened 2 years ago

ccckmit commented 2 years ago

終端機 1

(base) $ gcc forever.c -o forever
(base) $ ./forever
^C
(base) $ ps
  PID TTY           TIME CMD
  720 ttys000    0:00.01 /bin/bash -l
  756 ttys001    0:00.01 /bin/bash -l
  855 ttys002    0:00.02 /bin/bash -l
33663 ttys003    0:00.02 -bash
33687 ttys004    0:00.02 /bin/bash -l
(base) $ ps
  PID TTY           TIME CMD
33663 ttys003    0:00.02 -bash
33687 ttys004    0:00.02 /bin/bash -l
(base) $ ./forever
Terminated: 15

終端機 2

(base) $ ps
  PID TTY           TIME CMD
33663 ttys003    0:00.02 -bash
33687 ttys004    0:00.02 /bin/bash -l
33827 ttys004    0:10.42 ./forever
33833 ttys005    0:00.01 /bin/bash -l
(base) $ kill 33827

forever.c

(base) $ ./forever
^C
(base) $ ./forever &
[1] 34225
(base) $ ps
  PID TTY           TIME CMD
34190 ttys000    0:00.01 /bin/bash -l
34225 ttys000    0:05.99 ./forever
33663 ttys003    0:00.02 -bash
34045 ttys006    0:00.02 /bin/bash -l
(base) $ ./forever &
[2] 34242
(base) $ ps
  PID TTY           TIME CMD
34190 ttys000    0:00.01 /bin/bash -l
34225 ttys000    0:18.68 ./forever
34242 ttys000    0:04.94 ./forever
33663 ttys003    0:00.02 -bash
34045 ttys006    0:00.02 /bin/bash -l
(base) $ ./forever &
[3] 34257
(base) $ ps
  PID TTY           TIME CMD
34190 ttys000    0:00.02 /bin/bash -l
34225 ttys000    0:40.43 ./forever
34242 ttys000    0:26.66 ./forever
34257 ttys000    0:04.55 ./forever
33663 ttys003    0:00.02 -bash
34045 ttys006    0:00.02 /bin/bash -l
(base) $ kill 34225
(base) $ ps
  PID TTY           TIME CMD
34190 ttys000    0:00.02 /bin/bash -l
34242 ttys000    0:38.87 ./forever
34257 ttys000    0:16.78 ./forever
33663 ttys003    0:00.02 -bash
34045 ttys006    0:00.02 /bin/bash -l
[1]   Terminated: 15          ./forever
(base) $ kill 34242
(base) $ ps
  PID TTY           TIME CMD
34190 ttys000    0:00.02 /bin/bash -l
34257 ttys000    0:25.33 ./forever
33663 ttys003    0:00.02 -bash
34045 ttys006    0:00.02 /bin/bash -l
[2]-  Terminated: 15          ./forever
(base) $ kill 34257
(base) $ ps
  PID TTY           TIME CMD
34190 ttys000    0:00.02 /bin/bash -l
33663 ttys003    0:00.02 -bash
34045 ttys006    0:00.02 /bin/bash -l
[3]+  Terminated: 15          ./forever
(base) $ ps
  PID TTY           TIME CMD
34190 ttys000    0:00.02 /bin/bash -l
33663 ttys003    0:00.02 -bash
34045 ttys006    0:00.02 /bin/bash -l

sp/09-posix/02-thread/georgeMary.c

(base) $ gcc georgeMary.c -o georgeMary -lpthread
(base) $ ./georgeMary
----------------
George
Mary
----------------
George
Mary
----------------
George
----------------
George
Mary

/sp/09-posix/02-thread/race.c

(base) $ gcc race.c -o race -lpthread
(base) $ ./race
counter=4484060
(base) $ ./race
counter=-4016974
(base) $ ./race
counter=-3538358

norace.c

(base) $ gcc norace.c -o norace
(base) $ ./norace
counter=0
(base) $ ./norace
counter=0
(base) $ ./norace
counter=0
(base) $ ./norace
counter=0

deadlock.c

base) $ gcc deadlock.c -o deadlock
(base) $ ./deadlock
A lock x
B lock y
(base) $ gcc -w philospher.c -o philospher
(base) $ ./philospher 
Switch=false
 Think 0 1
 Eat 0 1
    Think 1 1
 Think 0 2
    Eat 1 1
        Think 2 1
 Eat 0 2
    Think 1 2
        Eat 2 1
 Think 0 3
    Eat 1 2
        Think 2 2
 Eat 0 3
    Think 1 3
        Eat 2 2
 Think 0 4
    Eat 1 3
        Think 2 3
 Eat 0 4
    Think 1 4
        Eat 2 3
 Think 0 5
    Eat 1 4
        Think 2 4
 Eat 0 5
    Think 1 5
        Eat 2 4
    Eat 1 5
        Think 2 5
        Eat 2 5
Sakura01210 commented 2 years ago

王冠文 在家

RyanChen-01 commented 2 years ago

陳文吉 在家

york31390 commented 2 years ago

林宥呈 在家

QuiLinxinag commented 2 years ago

邱麟翔 在家

jiajianong commented 2 years ago

呂嘉融 在家

zhengyucen commented 2 years ago

鄭宇岑 在家

4YCAaaa commented 2 years ago

李思慧 在家

ray9016 commented 2 years ago

張展睿 在家

Vialbum commented 2 years ago

林鈺翔 在家

cabdy1735 commented 2 years ago

李翊慈 在家

owen4096 commented 2 years ago

劉彥廷 在家

nnnnnnn1266 commented 2 years ago

潘其恩 在家

patrick901218 commented 2 years ago

張昀翰 在家

Mocha777 commented 2 years ago

林孫全 在家

shaoan901226 commented 2 years ago

黃紹安 在家

Roy-Roo commented 2 years ago

羅彥翔 在家

kaifeng273 commented 2 years ago

吳俊億 在家

Selesfia commented 2 years ago

胡禎恩 在家

cynthia1231 commented 2 years ago

張芷榕 在家

404HK416 commented 2 years ago

蘇彥華 在家

YangTiChu commented 2 years ago

楊堤筑 在家

Bernie3852 commented 2 years ago

李柏均 在家

stayjay commented 2 years ago

王證傑在家

feliciachou commented 2 years ago

周佳蒨 在家

wukunru commented 2 years ago

吳昆儒 在家

qwezxca123 commented 2 years ago

曾旭宏 在家

huahua6207 commented 2 years ago

張喜朵 在家

nakirifumiya commented 2 years ago

王澤瑋 在家

Lin610313 commented 2 years ago

林庭光 在家

2001wei commented 2 years ago

姜禹詩 在家

Uriel58 commented 2 years ago

林成也 在家

zraiz commented 2 years ago

邵南翔 在家

WForU commented 2 years ago

何文旺 在家

ChiaYunn commented 2 years ago

張嘉芸 在家

Soober9260 commented 2 years ago

施威帆 在家

Paouser commented 2 years ago

劉煒辰 在家

po-hsiang666 commented 2 years ago

張博翔 在家

OohelloworldoO commented 2 years ago

鄭智陽 在家

Kenttsai1 commented 2 years ago

蔡宗霖 在家

choco427 commented 2 years ago

張詠翔 在家

Sakura01210 commented 2 years ago

王冠文在家

wei-annn commented 2 years ago

趙唯安 在家