Está en la página 1de 449

Phin bn cng b c gii hn

Tp 1

Ti liu n thi FE
Ti liu n thi cho k thi k s Cng ngh thng tin c bn

Phn 1: n tp phn thi bui sng Phn 2: Tp bi thi th

Information-Technology Promotion Agency, Japan

Ti liu n thi FE

Tp 1

Mc lc
Phn 1
Chng 1

N TP PHN THI BUI SNG

Khoa hc my tnh c s
1.1 Nguyn l c bn v thng tin 1.1.1 Chuyn i c s 1.1.2 Biu din s 1.1.3 Biu din d liu khng phi s 1.1.4 Cc php ton v chnh xc Cu hi nhanh 1.2 Thng tin v logic 1.2.1 Cc php ton logic 1.2.2 BNF 1.2.3 K php Ba Lan ngc Cu hi nhanh 1.3 Cu trc d liu 1.3.1 Mng 1.3.2 Danh sch 1.3.3 Ngn xp 1.3.4 Hng i (Danh sch i) 1.3.5 Cy 1.3.6 Bm Cu hi nhanh 1.4 Gii thut 1.4.1 Cc gii thut tm kim 1.4.2 Cc gii thut sp xp 1.4.3 Cc gii thut tm kim xu 1.4.4 Cc gii thut trn th Cu hi nhanh Cu hi v p n

2
3 3 7 10 11 14 15 15 18 21 24 25 25 27 29 30 32 34 37 38 38 41 45 48 50 51

Chng 2

Cc h thng my tnh
2.1 Phn cng 2.1.1 Cc phn t thng tin (B nh) 2.1.2 Kin trc b x l 2.1.3 Kin trc b nh 2.1.4 Cc n v bng t 2.1.5 a cng 2.1.6 Cc thut ng lin quan n hiu nng/ RAID 2.1.7 Thit b lu tr ph / Cc n v vo ra 2.1.8 Cc giao tip vo ra Cu hi nhanh 2.2 H iu hnh 2.2.1 Cu hnh v cc mc ch ca h iu hnh 2.2.2 Qun l cng vic 2.2.3 Qun l tc v 2.2.4 Qun l d liu v t chc tp 2.2.5 Qun l b nh Cu hi nhanh 2.3 K thut cu hnh h thng 2.3.1 H thng khch-ch 2.3.2 Cu hnh h thng 2.3.3 X l tp trung v x l phn tn 2.3.4 Phn loi theo ch x l Cu hi nhanh 2.4 Hiu nng v tin cy ca h thng 2.4.1 Cc ch s hiu nng 2.4.2 tin cy 2.4.3 Tnh sn dng Cu hi nhanh 2.5 Cc ng dng h thng 2.5.1 Cc ng dng mng 2.5.2 Cc ng dng c s d liu 2.5.3 Cc h thng a phng tin Cu hi nhanh Cu hi v p n

62
63 63 65 68 70 73 77 79 81 83 85 85 87 89 90 95 99 100 100 102 104 106 108 109 109 111 113 116 118 118 121 123 125 126

ii

Chng 3

Pht trin h thng


3.1 Cc phng php pht trin h thng 3.1.1 Cc ngn ng lp trnh 3.1.2 Cu trc chng trnh v chng trnh con 3.1.3 Cc b x l ngn ng 3.1.4 Cc mi trng pht trin v cc gi phn mm 3.1.5 Cc phng php pht trin 3.1.6 Cc phng php phn tch yu cu 3.1.7 Qun l cht lng phn mm Cu hi nhanh 3.2 Cc cng vic trong cc quy trnh pht trin phn mm 3.2.1 Thit k ngoi 3.2.2 Thit k trong 3.2.3 Cc phng php thit k phn mm 3.2.4 Tiu chun phn r m-un 3.2.5 Lp trnh 3.2.6 Cc kiu v cc th tc kim th 3.2.7 Cc k thut kim th Cu hi nhanh Cu hi v p n

138
139 139 141 143 144 147 149 151 154 155 155 157 159 162 163 165 167 170 172

Chng 4

Cng ngh mng


4.1 Giao thc v kim sot truyn 4.1.1 Kin trc mng 4.1.2 Kim sot truyn Cu hi nhanh 4.2 Cng ngh truyn 4.2.1 Kim sot li 4.2.2 Kim sot ng b 4.2.3 Dn knh v truyn thng 4.2.4 Chuyn mch Cu hi nhanh 4.3 Mng my tnh 4.3.1 Mng cc b (LAN) 4.3.2 Mng ton cu (Internet) 4.3.3 Cc thit b truyn thng 4.3.4 Cc dch v vin thng Cu hi nhanh Cu hi v p n

181
182 182 184 187 188 188 190 192 194 195 196 196 198 200 202 204 205

iii

Chng 5

Cng ngh c s d liu


5.1 Cc m hnh d liu 5.1.1 Lc 3 lp 5.1.2 Cc m hnh d liu logic 5.1.3 M hnh E-R v biu E-R 5.1.4 Chun ha v cc rng buc tham chiu 5.1.5 Thao tc d liu trong c s d liu quan h Cu hi nhanh 5.2 Cc ngn ng c s d liu 5.2.1 DDL v DML 5.2.2 SQL Cu hi nhanh 5.3 Kim sot c s d liu 5.3.1 Cc chc nng kim sot c s d liu 5.3.2 C s d liu phn tn Cu hi nhanh Cu hi v p n

212
213 213 215 217 218 221 223 224 224 226 231 232 232 234 236 237

Chng 6

Bo mt v chun ha

244

6.1 An ton bo mt 245 245 6.1.1 Bo v s an ton 247 6.1.2 Virus my tnh 6.1.3 Ti phm my tnh 249 251 Cu hi nhanh 6.2 Chun ha 252 6.2.1 Cc t chc chun ha v chun ha qu trnh pht trin v mi trng 252 6.2.2 Chun ha d liu 254 6.2.3 Chun ha trao i d liu v phn mm 256 258 Cu hi nhanh Cu hi v p n 259

iv

Chng 7

Tin hc ha v qun l
7.1 Cc chin lc thng tin 7.1.1 iu chnh qun l 7.1.2 Cc chin lc tin hc ha Cu hi nhanh 7.2 K ton doanh nghip 7.2.1 K ton ti chnh 7.2.2 K ton qun l Cu hi nhanh 7.3 K thut qun l 7.3.1 IE 7.3.2 Kim sot lch biu(OR) 7.3.3 Quy hoch tuyn tnh 7.3.4 Kim sot tn kh (OR) 7.3.5 Xc sut thng k Cu hi nhanh 7.4 S dng cc h thng thng tin 7.4.1 Cc h thng sn xut 7.4.2 Cc h thng kinh doanh Cu hi nhanh Cu hi v p n

262
263 263 265 267 268 268 271 275 276 277 279 283 285 287 291 292 292 294 297 298

Phn 2 B bi thi th

TP BI THI TH 309
310 334 382 421

Bi thi th k s Cng ngh thng tin c bn (Bui sng) p n v gii thch Bi thi th k s Cng ngh thng tin c bn (Bui chiu) p n v gii thch

Phn 1

N TP

PHN THI BUI SNG


Cc cu hi trong phn thi bui sng nm trong by lnh vc sau: Khoa hc my tnh c s, h thng my tnh, pht trin h thng, cng ngh mng, cng ngh c s d liu, bo mt v chun ha, tin hc ha v qun l. Phn u ca mi chng s gii thch chi tit v mi lnh vc trn, tip theo l cc cu hi thc t c s dng trong cc bi thi trc y, cc cu tr li v gii thch nm cui mi chng.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

Khoa hc my tnh c s

Mc tiu ca chng ny
tr thnh mt k s cng ngh thng tin, cn phi hiu cu trc ca thng tin c x l bi my tnh v ngha ca qu trnh x l thng tin. Tt c thng tin c lu tr trong my tnh dng s nh phn; do trong phn 1, ta s nghin cu v dng m s thp phn v k t s dng trong cuc sng hng ngy c lu tr trong my tnh. Trong phn 2, ta s nghin cu v cc php ton logic qua cc v d c th ca qu trnh x l thng tin. Trong phn 3, ta s nghin cu v cc cu trc d liu m s bin i trn l cn thit qu trnh x l d liu d dng hn. Cui cng, trong phn 4, ta s nghin cu v cc phng php x l d liu c th.

1.1 1.2 1.3 1.4

Nguyn l c bn v thng tin Thng tin v logic Cu trc d liu Gii thut

[Thut ng v khi nim cn nm vng] C s, nh phn, h 16, du phy c nh, du phy ng, tng logic, tch logic, tng loi tr logic, b cng, danh sch, ngn xp, hng i, tm kim tuyn tnh, tm kim nh phn, sp xp ni bt

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

1. Khoa hc my tnh c s

1.1

Nguyn l c bn v thng tin

M u
Tt c thng tin (k t v s) c biu din trong my tnh bi s kt hp ca cc k t 0 v 1. Mt biu din ch s dng cc k t 1 v 0 c gi l 1 s nh phn. Trong phn ny, ta s hc v dng biu din thng tin

1.1.1 Chuyn i c s
im chnh
Trong my tnh, tt c d liu c biu din bi cc s nh phn Cc s h 16 c biu din bng cch tch cc s nh phn thnh cc nhm 4-bit.

Thut ng Chuyn i c s1 ngha l, v d, chuyn mt s thp phn thnh mt s nh phn. y 10 trong s thp phn v 2 trong s nh phn c gi l cc c s. Trong my tnh tt c d liu c biu din di dng s nh phn tng ng vi 2 trng thi in ON v OFF. Mi ch s ca mt s nh phn ch c th l 0 hoc 1, nn tt c cc s c biu din bi 2 k t 0 v 1. Tuy nhin, cc s nh phn biu din bi s kt hp ca cc k t 0 v 1 di v kh hiu, nn khi nim h c s 16 c a ra. Trong h c s 16, 4 bit2 (tng ng vi cc s t 0 n 15 trong h thp phn) c biu din bi 1 ch s (0..9, A..F) Bng sau ch ra s tng ng gia h thp phn, h nh phn, v h c s 16.
S thp phn 0 1 2 3 4 5 6 7 S nh phn 0000 0001 0010 0011 0100 0101 0110 0111
S h 16

0 1 2 3 4 5 6 7

S thp phn 8 9 10 11 12 13 14 15 16

S nh phn 1000 1001 1010 1011 1100 1101 1110 1111 10000

S h 16

8 9 A B C D E F 10

1 C s: l s to ra trng s ca mi ch s trong h s nh nh phn, h 8, h thp phn, h 16. C s tng ng ca cc h s l 2, 8, 10, 16. H nh phn: s dng 0 v 1 H c s 8: s dng t 0 n 7 H thp phn: s dng t 0 n 9 H c s 16: s dng t 0 n F 2 Bit: n v thng tin nh nht trong 1 my tnh, biu din bi 0 hoc 1. D liu trong my tnh biu din trong dng nh phn, 1 bit biu din 1 ch s trong h nh phn. thun tin, s h 16 v h 8 c biu din bi phn chia s nh phn nh sau: H 4: nhm 2 bit (biu din bi cc ch s t 0 n 3) H 8: nhm 3 bit (biu din bi cc ch s t 0 n 7) H 16: nhm 4 bit (biu din bi cc ch s t 0 n F)

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

1. Khoa hc my tnh c s

Chuyn s nh phn v s h 16 thnh s thp phn


Tng qut, khi mt gi tr a ra trong h m vi c s r (h c s r), ta nhn gi tr mi ch s vi trng s3 tng ng v cng cc tch li ly gi tr trong h thp phn. Vi cc ch s t bn tri ca du phy, trng s l r0, r1, r2, t ch s thp nht. Php chuyn i c trnh by nh sau. (trong cc v d ny, (a) biu din trong h 16 v (b) l trong h nh phn) (12A)16 = 1 162 + 2 161 + A 160 = 256 + 32 + 10 = (298)10

(a)

(1100100)2 = 1 26 + 1 25 + 0 24 + 0 23 + 1 22 + 0 21 + 0 20 = 64 + 32 + 4 (b) = (100)10 Vi cc ch s bn phi ca du phy, trng s ln lt l r-1, r-2, r-3, Nn, php chuyn i c trnh by nh sau. Trong cc v d ny, (c) biu din trong h 16 v (d) l trong h nh phn. (0.4B)16 = 4 16-1 + B 16-2 = 4 / 16 + 11 / 162 = 0.25 + 0.04296875 = (0.29296875)10 (0.01011)2 = 0 2-1 + 1 2-2 + 0 2-3 + 1 2-4 + 1 2-5 = 0.25 + 0.0625 + 0.03125 = (0.34375)10

(c)

(d)

Chuyn s thp phn nguyn thnh s nh phn


Mt cch ton hc, s dng c im ch s th n t bn phi (thp nht) trong h nh phn biu din s c mt ca gi tr 2n-1, ta c th tch s thp phn thnh tng cc ly tha ca 2 (gi tr 2n cho n). (59)10 = 32 + 16 + 8 + 2 + 1 = 25 + 24 + 23 + 21 + 20 = 1 25 + 1 24 + 1 23 + 0 22 + 1 21 + 1 20 (1 1 1 0 1 1)2

Trng s: trng s, gi tr xc nh t l theo v tr trong cc biu din s, nh nh phn, 8, 10 v 16

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

1. Khoa hc my tnh c s

Tuy nhin, ta cng c th chia s cho lin tip cho 2 cho n khi thng bng 0. y l mt phng php chuyn i my mc gip gim bt sai s tnh ton. 4 2 2 2 2 2 2 0 59 29 14 7 3 1 D 1 1 0 1 1 1 (1) 59 / 2 (2) 29 / 2 (3) 14 / 2 (4) 7 / 2 (5) 3 / 2 (6) 1 / 2 =29 d 1 =14 d 1 = 7 d 0 = 3 d 1 = 1 d 1 = 0 d 1
(7)Vit li cc s d t di ln

Qu trnh kt thc khi thng bng 0,

(59)10 = (111011)2

Thm na, chuyn 1 s thp phn thnh s h 16, ta c th s dng 16 thay cho 2. Tng qut, chuyn mt s thp phn thnh s h c s n, dng n thay th cho 2.

Chuyn s thp phn thnh s nh phn


Mt cch ton hc, s dng c im ch s th n sau du phy trong h nh phn biu din s c mt ca gi tr 2-n, ta c th tch s thp phn thnh tng cc ly tha ca 2 (gi tr 2n cho n) (0.59375)10 = 0.5 + 0.0625 + 0.03125 = 2-1 + 2-4 + 2-5 = 1 2-1 +0 2-2 + 0 2-3 + 1 2-4 + 1 2-5 (0.1 0 0 1 1)2

Tuy nhin, ta c th nhn phn thp phn (phn bn phi ca du phy) lin tip 2 n khi phn thp phn bng 0. y l phng php chuyn i my mc nhng gim bt sai s tnh ton. (5) Vit gi tr phn nguyn t u. 0.59375 2= 0.1875 2= 0.375 0.75 0.5 2= 2= 2= 1 0 0 1 1 .1875 .375 .75 .5 (1) Vit phn thp phn xung di. (2) Vit phn thp phn xung di. (3) Vit phn thp phn xung di. (4) Vit phn thp phn xung di. (0.59375)10 = (0.10011)2

.0 X l kt thc khi phn thp phn bng 0.5

chuyn mt s thp phn thnh 1 s h 16, s dng 16 thay cho 2. Tng qut, chuyn 1 s thp phn thnh 1 s h c s n, s dng n thay cho 2.

(Ch ) Khng c g bo m rng nhn phn thp phn vi 2 s cho ra 0. Ta c th kim tra c im ny bng v d chuyn 0.110 thnh s nh phn, n tr thnh phn s nh phn tun hon. Lun lun c th chuyn 1 phn s nh phn thnh 1 phn s thp phn, nhng khng c chiu ngc li. Trong trng hp , ta c th dng qu trnh chuyn i mt v tr thch hp. 5 Thp phn tun hon: mt s thp phn c phn thp phn b lp v hn. V d 1/3 = 0.333, v 1/7 = 0.142857142857, c phn 3 v 142857 tng ng lp v hn. Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

1. Khoa hc my tnh c s

Chuyn i gia h 16 v h nh phn


S dng tnh cht mi ch s trong h 16 biu din bng 4 bit trong h nh phn. CHUYN T H NH PHN SANG H 16 Xem v d sau, chng ta c th nhm s nh phn thnh tng nhm 4 bit, bt u t bit nh nht (bit ngoi cng bn phi), sau gn ch s h 16 tng ng cho tng nhm. Nu nhm cui cng c t hn 4 bit, c th thm cc ch s 0 vo u. (10110111100100)2 (10 1101 1110 0100)2 (2DE4)16 0 (10 1101 0010 (2 1101 D 1110 0100)2 1110 E 0100 4) 16

CHUYN T H 16 SANG H NH PHN Xem v d di, ta c th gn mi ch s trong h 16 bi s nh phn 4-bit tng ng. (2DE4)16 (0010 1101 1110 0100)2 (2 D E 4)16 (0010 1101 1110 0100)2

Chuyn i phn s gia h 16 v h thp phn


chuyn i gia phn s h 16 v phn s h thp phn, ta c th kt hp php chuyn i gia h thp phn v h nh phn vi php chuyn i gia h nh phn v h 16 gim li. CHUYN PHN S THP PHN SANG H 16 Ta c th chuyn t s thp phn sang s nh phn trc, sau chuyn t s nh phn sang s h 16 tng ng. Trong php chuyn s nh phn sang s h 16, ta c th nhm cc bit thnh tng nhm 4-bit, bt u t bit ln nht (bit ngoi cng bn tri) ca phn phn s, v chuyn mi nhm thnh ch s h 16 tng ng. Nu nhm cui cng (ngoi cng bn phi) c t hn 4 bit, c th thm cc ch s 0 vo cui. (0.71875)10 (0. (0. 0. (0. 10111)2 (0.B8)16

1011 1)2 0 1011 B 1000 8)16 0.71875=(0.B8) 16

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

1. Khoa hc my tnh c s

CHUYN T H THP PHN SANG H 166 Trc tin, ta chuyn s h 16 thnh s nh phn tng ng, sau chuyn s nh phn sang s thp phn tng ng. (0.B8)16 (0.10111000)2 0.71875 (0. 1011 1000)2 0 (0.10111000)2 = 2-1 + 2-3 + 2-4 + 2-5 = (0.71875)10

1.1.2 Biu din s


im chnh
S thp phn c biu din dng gi ng hoc dng vng (gi m) S nh phn c biu din dng du phy tnh hoc du phy ng.

S thp phn s dng hng ngy cn c chuyn i sang mt nh dng thun tin cho my tnh x l, c nhiu nh dng c th biu din gi tr s. Mt vi nh dng biu din cc gi tr s trong my tnh c trnh by di y. S thp phn Thp phn dng vng Thp phn gi ng Du phy tnh S nh phn Du phy ng Tng thch cao vi d liu vn bn (cng c bit ti nh s thp phn gi m) Tc x l nhanh hn S dng cho d liu s nguyn, v d nh ch s mng S dng cho d liu s thc nh trong tnh ton khoa hc

6 (FAQ) C nhiu cu hi trn nhiu c s nh u l p n ng (trong dng thp phn) ca php cng cc s h 16 v s nh phn? Nu kt qu cui cng c biu din trong dng thp phn, tt nht chuyn cc s nguyn bn thnh s thp phn trc ri tnh. Nu kt qu cui cng c biu din trong c s khc 10 (nh phn, h 8, h 16..), tt hn l chuyn s nguyn bn thnh s nh phn trc ri tnh.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

1. Khoa hc my tnh c s

Biu din s thp phn


Trong nh dng thp phn dng vng, mi ch s ca s thp phn c biu din bng 8 bit, v 4 bit cao nht ca ch s cui cng c s dng biu din thng tin v du7. Cc bit s ca mi byte cha gi tr s tng ng trong h thp phn
+1234 -1234 0011 0011 1 0001
1

0011 0011

2 0010
2

0011 0011

3 0011
3

+ 1100
-

4 0100
4

Bit du

1100: Dung hoc 0 1101: m

0001
Bit s

0010

0011
Bit du

1100

0100
Bit s

Bit vng8

Bit vng: 0011

Trong nh dng thp phn gi ng, mi ch s ca s thp phn c biu din bng 4 bit, v 4 bit cui cng xc nh du. Khong trng pha u ca byte cao nht c thm cc bit 0. Mu bit du tng t nh trong nh dng thp phn m gi. Trong v d di y, 2 bytes v 4 bit l biu din s, nhng c hai trng hp u phi s dng 3 bytes bng cch thm 4 s 0 vo phn u tin v my tnh lu tr theo n v byte9.
+1234 0 0000 1 0001 2 0010 3 0011 4 0100 + 1100 -1234 0 0000 1 0001 2 0010 3 0011 4 0100 1101

Biu din s du phy tnh


Trong nh dng s du phy tnh, cc s nh phn nguyn c biu din trong dng s nh phn c di c nh. Phng php b 2 c s dng biu din s m, vi bit u tin (bit du) ca 1 s m lun l 1. 8 bit, 16 bit, 32 bit Du 2
n

n-1

2n-2

2n-3

22

21

20 (Du phy)

1: s m, 0: s dng hoc 0

7 (Gi ) Nu du (dng hoc m) khng c s dng trong nh dng thp phn dng vng, bit du c t ging vi cc bit phn vng. 8 (Ch ) Mu bit trong cc bit phn vng l khc nhau ty thuc my tnh. V d di s dng 0011 nhng mt s my s dng 1111. Cc bit s l ging nhau. 9 Byte: 1 byte l 1 n v gm 8 bit. N l n v biu din cc k t

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

1. Khoa hc my tnh c s

biu din s thp phn -20 bng phng php b 2, u tin ta cn biu din s thp phn +20 trong dng nh phn: (+20)10 = +) (-20)10 = 1 1 1 0 1 1 0 0 1 0 1 0 1 1 0 o bit . 0 1 1 0 0 1 0 1 1 0 Phn b 110 Cng 1 Add 1 Phn b 2

Vy (-20)10 c biu din l (11101100)2. Chiu di bit l khc nhau gia cc h my tnh. Tng qut, cc s t -2n-1 ti 2n-1 1, tng cng 2n s, c th c biu din bng n bit. Ch , ch xt gi tr tuyt i, 1 s m c th biu din t 1 s dng.

Biu din s du phy ng


Trong s du phy ng, 1 s thc c biu din dng m ( a = m r e ) s dng s nh phn c chiu di c nh, nn c th biu din c cc s rt ln hoc rt nh, vn hay s dng trong tnh ton khoa hc. Tuy nhin, do thanh ghi my tnh c s lng bit l gii hn, nn sai s c th xy ra trong biu din gi tr thp phn tun hon. 1 bit 0

8 bit 10000100

23 bit ( chnh xc n) 11010000000000000000000

nh tr du 11

S m e

Du phy

nh tr m

y l nh dng chun quc t IEEE754

10 Phn b (Complement): Phn b ca 1 s l gi tr nhn c bng cch ly 1 s c nh, l ly tha ca c s hoc ly tha ca c s tr 1, tr i s . V d, trong dng thp phn, c phn b 10 v phn b 9. Trong h nh phn c phn b 2 v phn b 1. Tng qut trong h r bt k, c phn b r v phn b (r 1). Nu x l 1 s n ch s trong h c s r. Phn b r ca x l (rn-x), v phn b (r-1) ca x l ((rn-1)-x). V d, s 3 ch s 123 trong h thp phn c phn b sau: phn b 10 l 1000 123 = 877, v phn b 9 l 999 123 = 876. S 4 bit 0101 trong h nh phn c cc phn b sau: phn b 2 l 10000 0101 = 1011 v phn b 1 l 1111 0101 = 1010.

B ca 10

B ca 9

B ca 2

B ca 1

Ch phn b 1 trong h nh phn ch l o ca cc bit ( 0 thnh 1 v ngc li). Phn b 2 bng phn b 1 cng 1. FAQC nhiu cu hi chuyn 1 s nh phn cho trc thnh s m tng ng v chuyn 1 s m cho trc thnh s dng tng ng.
11

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

1. Khoa hc my tnh c s

1.1.3 Biu din d liu khng phi s


im chnh
Mi k t c biu din bi 8 bit. Trong a phng tin, d liu lin kt vi d liu nh tnh, d liu nh ng, v d liu m thanh c nm gi.

Biu din phi s l biu din ca d liu khng phi cc gi tr s. Ni cch khc, n lin quan ti biu din k t, m thanh hoc hnh nh. Cch m d liu c biu din l khc nhau gia cc my tnh, do m bo s truyn d liu gia cc my tnh sun s, cn thit phi xy dng cc chun biu din d liu.

Biu din k t
Vi s nh phn n-bit, c 2n kiu m, tng ng 1-1 ca m cho php ta biu din 2n k t (ch ci, ch s, k t c bit, v nhiu k hiu khc). M BCD (Binary Coded Decimal Code) Mi ch s ca s thp phn c th biu din bng 4 bit. Xem v d di. (3 (0 23's bit 0 22's bit 1 21's bit 1 20's bit 0 23's bit 1 22's bit 7)10 1 21's bit 1)2 20's bit
10

S thp phn M BCD


Trng s

Cc b m k t chun M Gii thch M my tnh c nh ngha bi IBM cho cc my tnh a dng. EBCDIC 8 bit biu din 1 k t. M 7-bit c a ra bi ANSI (American National Standards Institute Vin ASCII tiu chun quc gia M), s dng trn PC. ISO646 c a ra nh 1 khuyn co ca T chc Tiu Chun Quc T (ISO), ISO code da trn m ASCII 7 bit, trao i thng tin. Unicode Mt chun cho php my tnh biu din thng nht cc k t ca tt hu ht cc nc. Mi k t di 2 bytes. K t 2-byte v 1-byte c th s dng ng thi trn UNIX (m UNIX m rng) EUC Cc k t ting Trung v Hn cng c x l.

Biu din hnh nh v m thanh


Lng thng tin, nh hnh nh, m thanh, k t c x l bi h thng a phng tin l khng l. Do k thut nn d liu l yu t quyt nh trong xy dng 1 h thng a phng tin. Nhng cng ngh biu din cng rt quan trng. Mt khc, d liu a phng tin nh nh tnh v m thanh rt ph bin trn PC khi k thut s ha d liu tng t c ci tin.
Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

1. Khoa hc my tnh c s

nh tnh nh ng

GIF JPEG12 MPEG

m thanh

PCM MIDI

nh dng lu tr ha, kh nng hin th 256 mu nh dng nn cho nh mu tnh, a ra bi s thng nht ca ISO v ITU-T. nh dng nn cho nh mu ng, a ra bi s thng nht ca ISO v IEC. MPEG-1 D liu c lu tr chnh trn CD-ROM MPEG-2 Lu tr cc hnh nh video, nh thi gian thc MPEG-4 Chun cho thit b u cui di ng Chuyn i tn hiu tng t (nh m thanh) thnh tn hiu s Giao din kt ni mt nhc c vi 1 my tnh

1.1.4 Cc php ton v chnh xc


im chnh
C 2 loi php ton dch: dch s hc v dch logic. Cc php ton trong my tnh da trn s ch s biu din c, nn kt qu c th xy ra sai s trn.

My tnh c trang b cc mch cho php thc hin 4 php ton s hc c bn v cc php dch. Cc php ton nh tnh 2n, tc tnh ton tng ln do s dng php dch (hay di chuyn cc ch s). Tt c cc php ton trn my tnh c thc hin trn thanh ghi. Thanh ghi13 ny ch c hu hn ch s c ngha, do kt qu 1 php ton c th cha li trn.

12 (FAQ) C nhiu cu hi kim tra yu cu hiu bit v t chc thit lp cc hm v chun v JPEG v MPEG. Mt vi t kha nh JPEG, ISO v ITU-T cho nh tnh, MPEG, ISO, IEC cho nh ng cn c u tin chn trong bi lm. 13 Thanh ghi: l b nh dung lng thp v tc cao nm trong CPU cha d liu tm thi, n cha cc thanh ghi a nng c s dng bi CPU thc hin cc thao tc.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

11

1. Khoa hc my tnh c s

Cc php dch
Mt php dch l 1 thao tc di chuyn chui bit sang bn phi hoc bn tri. Cc phng php dch c phn loi nh bng di. Dch tri Dch phi Dch s hc Mt php dch s hc c s dng khi d liu l d liu s c du dng hoc m. l 1 php ton dch chui bit, tr bit du, dng cho s dng du phy c nh. Php dch s hc sang tri chn 1 s 0 vo v tr ngoi cng bn phi (v tr b rng do dch chuyn). Tng qut, php dch s hc sang tri n bit tng s ln 2n ln. Php dch s hc sang phi, chn bit du vo v tr ngoi cng bn tri (v tr b rng do dch chuyn). Tng qut, php dch s hc sang phi n bit gim s i 2-n ln (1/2n). V d sau minh ha php dch s hc. Dch sang tri 1 bit nhn i gi tr trong khi dch sang phi 1 bit gim gi tr i mt na. (Dch tri s hc) Trn 11111010=(-6)10 Bit du 11110100=(-12)10 Chn 0 vo ch trng Dch logic Khng ging nh dch s hc, php dch logic khng quan tm d liu l dng s hay khng, n ch coi d liu l mt chui bit. N dch chuyn ton b chui bit d liu v chn 0 vo v tr b b trng do dch. Trong php dch logic14, khng c mi quan h nh thay i gi tr 2n hay 2-n ln trong php dch s hc. V d di y minh hc php dch logic 1 bit: Trn 01111010 11110100 (Dch tri logic) Trn 10011001 01001100 (Dch phi logic) (Dch phi s hc) Bit du Trn Dch s hc Dch s hc tri Dch s hc phi Dch logic Dch logic tri Dch logic phi

11111010=(-6)10 11111101=(-3)10 Chn bit du vo y

Chn 0 vo ch trng

14 (Ch ) Trong 1 php dch logic, hnh minh ha xc nh rng bit du 0 c th tr thnh 1 sau khi dch. Nu d liu l s, n ngha l 1 s dng chuyn thnh 1 s m bi thao tc dch.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

12

1. Khoa hc my tnh c s

Sai S
Khi cc php ton c thc hin bi cc thanh ghi ca my tnh vi s ch s gii hn, cc gi tr s khng th cha trong thanh ghi s b b qua, dn ti s khc nhau gia kt qu tnh ton v kt qu tht. S khc nhau c gi l sai s. Sai s lm trn Do my tnh khng th x l s thp phn v hn, cc bit nh hn bit xc nh chnh xc u b ct b, lm trn ln hoc lm trn xung ti gi tr gii hn ca s ch s c ngha. Chnh lch gia gi tr tht v kt qu ca php lm trn gi l sai s lm trn15. Mt (trit tiu) ch s c ngha Khi mt s tr i mt s khc xp x n hay khi 2 s, 1 s dng v 1 s m c gi tr tuyt i xp x nhau cng li, s lng ch s c ngha c th b mt rt nhiu, l li trit tiu/ mt ch s c ngha. 356.3622 356.3579 0.0043 Khi kt qu gn bng 0, s ch s c ngha suy gim trm trng. Mt ch s ui Khi 1 s rt ln cng vi 1 s rt nh hoc 1 s tr i 1 s khc, phn thng tin trong nhng bit thp, khng c cha trong vng biu din, c th b mt do gii hn di ca s. Hin tng ny c gi l mt ch s ui. trnh sai s do mt ch s ui, cn phi thc hin cc php cng, tr theo th t u tin cho cc s c tr tuyt i nh. 356.3622 0.000015 356.3622 Cc ch s c gi tr cc nh c th b b qua.

15 Lm trn: L cch xp x 1 s bng cch lm trn, lm trn ln hoc lm trn xung, hoc lm trn cho d hiu vi con ngi. V d n 2.15 c lm trn ti s nguyn gn nht, n c lm trn thnh 2 vi sai s l 0.15.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

13

1. Khoa hc my tnh c s

Cu hi nhanh
Q1 Q2 Q3

Biu din s thp phn 100 trong h nh phn, h c s 8 v h c s 16. Thc hin php dch chuyn s hc v dch chuyn logic sang phi 3 bit trn s nh phn 8 bit 11001100. Gii thch khi nim trit tiu ch s c ngha v mt ch s ui

A1

Trong h nh phn: (1100100)2 Trong h c s 8: (144)8 Trong h 16: (64)16 Chuyn sang h nh phn: 100 = 64 + 32 + 4 = 26 + 25 + 22 = 1 26 + 1 25 + 0 24 + 0 23 + 1 22 + 0 21 + 0 20 = (1100100)2 Chuyn sang h 8: 1 100 100 1 4 48 Chuyn sang h 16: 110 0100 6 11111001 00011001 (Dch logic) 11001100 00011001 416

A2

Dch s hc: Dch logic: (Dch s hc) 11001100 11111001

A3 Trit tiu ch s c ngha: 1 hin tng xy ra khi s ch s c ngha gim trm trng khi 1 s tr i 1 s khc gn bng n, hoc khi cng 1 s dng vi 1 s m c gi tr tuyt i gn bng. Mt ch s ui: Hin tng khi phn thng tin trong nhng bit thp, khng c cha trong vng biu din, c th b mt do gii hn di ca s, khi 1 s rt ln cng vi 1 s rt nh hoc 1 s tr i 1 s khc,

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

14

1. Khoa hc my tnh c s

1.2 Thng tin v logic


M u
lm cho 1 my tnh thc hin 1 nhim v, cn 1 chng trnh c vit theo cc lut. Chng ta s hc v cc php ton logic, BNF v k php Ba Lan ngc. Cc php ton logic l c s cho php ton c kh. BNF l cc lut v c php vit chng trnh. K php Ba Lan ngc c s dng dch cc cng thc ton hc c vit trong chng trnh.

1.2.1 Cc php ton logic


im chnh
Cc php ton logic c bn: tng logic, tch logic, ph nh logic, tng loi tr logic. Ng php ca 1 chng trnh c vit trong BNF.

Cc php ton logic c bn gm: tch logic (AND), tng logic (OR), ph nh logic (NOT), v tng loi tr logic (EOR, XOR).

nh ngha ca cc php ton logic


Di y l bng k hiu v ngha cc php ton16 logic i vi 2 bin logic A v B. Mi bin logic l s nh phn 1 bit, nhn gi tr 1 hoc 0.
Php ton logic Tch logic (AND) Tng logic (OR) Ph nh logic (NOT) Tng loi tr (EOR, XOR) logic K hiu

AB

A+B A A B

ngha Kt qu l 1 khi c 2 bit l 1. Kt qu l 1 khi t nht 1 bit l 1. o bit (0 thnh 1, 1 thnh 0) Kt qu bng 0 nu 2 bit ging nhau v bng 1 nu 2 bit khc nhau

16 (Ch ) Trong my tnh c trang b cc mch tng ng vi php ton logic tch logic, tng logic, ph nh logic. Tt c cc php ton c thc hin bng cc kt hp cc mch ny.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

15

1. Khoa hc my tnh c s

Bng chn l / Cc php ton logic17


Bng tng hp kt qu ca cc php ton logic gi l bng chn l18. y l bng chn l ca cc php ton logic: tch logic, tng logic, tng loi tr logic, ph nh logic. A 0 0 1 1 B 0 1 0 1 Tch logic Tng logic Tng loi tr logic Ph nh logic

A B
0 0 0 1

A+B
0 1 1 1

A B
0 1 1 0

A
1 1 0 0

B
1 0 1 0

Tng loi tr logic c th khai trin nh sau. Nhiu cu hi c th tr li d dng nu bit dng khai trin ca tng loi tr logic, do cn nm c cng thc khai trin ny.

A B = A B + A B
A 0 0 1 1 B 0 1 0 1

A
1 1 0 0

B
1 0 1 0

A B
0 1 1 0

A B
0 0 1 0

A B
0 1 0 0

A B + A B
0 1 1 0

nh l De Morgan's
Mt tp cc cng thc ni ting lin quan ti cc php ton logic l nh l De Morgan's. nh l xc nh mi quan h nh c ch ra di y. C th d dng ghi nh chng nu bn nh s hon i gia tch logic v tng logic khi b ngoc. Nhiu cu hi c th tr li d dng nu bit nh l De Morgans, nn hy chc rng bn nm c cc cng thc.19

( A B) = A + B ( A + B) = A B

Ph nh ca tng logic: ( A + B ) = A B . Ph nh ca tch logic: ( A B ) = A + B (Ch ) Mt s bng chn l biu din 1 bng T (ng) v 0 bng F (sai) 19 (FAQ) Nhiu cu hi c th d dng tr li nu bit nh l De Morgan. C nhiu cu hi c th d dng tr li nu bit dng khai trin ca tng loi tr logic.
17 18

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

16

1. Khoa hc my tnh c s

B cng
Mt b cng l mt mch thc hin php cng s nh phn 1 bit, bao gm cc mch logic: AND, OR, NOT. C 2 loi b cng: b bn cng, khng a vo tng s nh t bit thp hn; b cng y , a vo tng s nh t cc bit thp hn. B bn cng Khi mt tn hiu 0 hoc 1 c gi ti u vo A v B ca mch, kt qu php cng xut hin cc u ra C v S. y C biu th c nh v S l bit thp ca kt qu php cng. Kt qu php cng c th hin di y. C th thy, C l tch logic v S l tng loi tr logic20 A 0 0 1 1 + + + + B 0 1 0 1 = = = = C 0 0 0 1 S 0 1 1 0

Trong hnh v di y, cu trc mch ca b bn cng c th hin bn tri. Hnh bn phi l k hiu n gin ca b bn cng thng c s dng.

K hiu n gin21

(Gi ) Chc chn rng bn hiu chnh xc cc php ton nh phn 1 bit. Tht cn thn v rt d mc phi li. 4 php cng s 1 bit cho di y.

20

Nu A v B u l 1, php cng cho tng l 2, nhng trong h nh phn, ch s dng 0 v 1, mt c trn c t, kt qu tng l 10. Nu mch cng khng nh, u ra l 0. 21 Bn cn ghi nh k hiu mch. Cn thn khng ln ln mch AND, OR.
Mch AND

Mch OR Mch NOT

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

17

1. Khoa hc my tnh c s

B cng y Mt b cng y c 3 u vo, 1 trong s l c nh t bit thp hn. Do , 1 b cng y cng 3 gi tr X, Y, Z. Kt qu php cng c c th hin bng di. Khng nh b bn cng, khng c mi quan h gia tch logic v tng loi tr logic vi b cng y . X 0 0 0 0 1 1 1 1 + + + Y 0 0 1 1 0 0 1 1 Z 0 1 0 1 0 1 0 1 = = = = = = = = C 0 0 0 1 0 1 1 1 S 0 1 1 0 1 0 0 1

Trong hnh v di, cu trc mch ca 1 b cng y c th hin bn tri. T hnh v thy rng b cng y gm 2 b bn cng kt hp vi nhau. Hnh v bn phi l k hiu n gin cho b cng y .

K hiu n gin

1.2.2 BNF
im chnh
Mt cch biu din chnh xc vn phm ca 1 ngn ng lp trnh. Nhng k hiu kt thc l khng th phn tch c na.

nh ngha vn phm ca 1 ngn ng lp trnh (nh ngha c php) phi s dng cc biu thc khng nhp nhng. biu din nhng vn phm nh vy, dng chun BNF hay c s dng.22 BNF nh ngha cc lut ca th t ca k t s dng chnh cc k t; n cng nh ngha php lp v php chn s dng cc k hiu c bit. V ch c cc k t c s dng trong nh ngha nn biu thc n gin v gn ging vi cch biu din cu. Hn na, BNF khng ch a ra cc nh ngha khng nhp nhng, n cn kh d hiu.

22 (Ch ) BNF c s dng ln u nh ngha ALGOL60, 1 ngn ng lp trnh cho tnh ton k thut. BNF l 1 ngn ng nh ngha c php chnh thc, khng quy nh ng ngha. Do , n khng th nh ngha tt c cc lut ca 1 ngn ng, ngy nay nhiu phin bn m rng ca BNF c s dng.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

18

1. Khoa hc my tnh c s

Dng c bn ca BNF
Biu thc BNF cha php tun t, lp v chn. Tun t <x>::=<a><b> 23 K hiu a ra nh ngha phn t c php x l 1 chui ca cc k t a v b. K hiu ::= c ngha c nh ngha l Lp <x>::=<a> K hiu a ra nh ngha phn t c php x l 1 dy lp ca k t a. N cng c ngha l k t a c lp 1 hoc nhiu ln. Chn <x>::=<a | b> K hiu a ra nh ngha phn t c php x nhn k t a hoc k t b. Nu 1 trong cc la chn b b qua, biu thc tip theo c s dng: <x>::=[<a>] K hiu a ra nh ngha phn t c php x nhn k t a hoc k t rng. K hiu [ ] c ngha c th b qua

K hiu kt thc v khng kt thc


Mt phn t c php c nh ngha c th dng nh ngha phn t khc hoc chnh n. Nhng phn t nh vy c gi l nhng k hiu khng kt thc 24. Nhng k t c s dng trc tip trong cu c gi l k hiu kt thc. Trong nh ngha sau, <x> l k hiu khng kt thc trong khi a, b v c l k hiu kt thc. <y>::=<a><x> <x>::=<b><c>

23 24

(Ch ) < >: Ngoc nhn c s dng khi cc k t c t lin tip hoc khi ng bin khng r rng. (Ch ) Cc k hiu khng kt thc: c s dng lm cho nh ngha c php d hiu.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

19

1. Khoa hc my tnh c s

V d v BNF
V d, quy tc c php ca hng du phy ng c nh ngha nh sau: <hng du phy ng>::=
<hng c s> <s m> <chui s> <ch s> <du>

[<du>]<hng c s>[<s m>] | [<du>]<chui s><s m> ::= [<chui s>]<.><chui s>|<chui s><.> ::= <E>[<du>]<chui s> ::= <ch s>|<chui s><ch s> ::= 0|1|2|3|4|5|6|7|8|9 ::= +|

Hy da vo cc quy tc c php trn xem <hng du phy ng> trng c r rng25. gii thch, ta vit cc phn t nh sau:
<hng du phy ng>::=[<du>]<hng c s>[<s m>] | [<du>]<chui s><s m>
(1) (2) (3) (4) (5) (6)

nh ngha <hng du phy ng> c phn tch bi ng |, chng phn tch nhm (1)~(3) vi nhm (4)~(6), nn c th c 2 dng. Ta ly nhm th nht (1)~(3) lm v d xem u l <hng du phy ng>. Mi phn t (1)~(3) c th tri ra nh sau: <du><hng c s><s m> <E><du><chui s> <chui s><.><chui s> y, cn phn tch <chui s>.
26

<chui s> c nh ngha nh sau: <chui s>::= <ch s>|<chui s><ch s> Tip theo, cn dch <ch s>, n c nh ngha nh sau: <ch s>::= <0|1|2|3|4|5|6|7|8|9> Ngha l, biu thc di y l ng: <ch s>::= 0

(FAQ) Mt v d v quy tc c php: thng, cc cu hi la chn cc cu tha mn cc quy tc c php c a ra (Ch ) Mt biu din vi 1 chui k t kt hp vi cc k hiu c bit (nh $, *) c gi l biu thc chnh quy. Cc k t xc nh c gi l cc siu k t. Cc siu k t c ngha c bit. Trong UNIX, Windowsnu tm kim 1 file bng cch nhp *.jpg th h thng s tm tt c cc file c m rng l jpg. y, k hiu * l 1 siu k t.
26

25

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

20

1. Khoa hc my tnh c s

Hn na, t nh ngha <chui s> v <ch s>, 0 cng l <chui s>. Do , ta c biu din sau: <chui s>::= 0<ch s> Vu 01 cng l < chui s>. Tip tc. <chui s>::= 01<ch s> , 012 cng l <chui s>. Do , <chui s> l bt c chui lin tip cc ch s. Vy, v d <hng c s> trng nh sau: <hng c s>::= 123.456 Nn, phn tch ca <hng du phy ng> c th a cho ta v d sau: <du><hng c s><s m> + 123.456 E+123 D nhin, <du> c th l du m hoc c th b qua, chui sau c th l hng s du phy ng. -123.456E-123 -123.456E123 Nh thy trn, nu tt c cc dng c bit u c biu din, cho kt qu l mt lng thng tin khng l. BNF c s dng a ra nh ngha chung nhm trnh tnh hung ny.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

21

1. Khoa hc my tnh c s

1.2.3 K php Ba Lan ngc


im chnh
K php Ba Lan ngc l cch dch cc biu thc ton hc. N c trng bi 2 bin theo sau bi 1 ton t.

K php Ba Lan ngc l 1 phng php biu din cc cng thc ton hc c s dng hng ngy sang dng biu din d x l hn bi my tnh. Khi nim c bn ca k php ny l ton t c t vo cui thay v t vo gia ca cng thc V d, X = A + B * C ngha l tnh tch ca B v C, cng A, sau a kt qu ti X, c biu din nh sau: XABC*+=

Chuyn i cng thc ton hc thnh k php Ba Lan ngc


V d, chuyn e = a b ( c + d ) sang k php Ba Lan ngc27. Th t ca cc php ton l th t thng dng. Phn gch chn c tnh trc28: (1) e = a b ( c + d ) (c+d) c chuyn sang k php Ba lan ngc Ta gi n l chui P (2) e = a b P b P c chuyn sang k php Ba lan ngc Ta gi n l chui Q. (3) e = a Q a Q chuyn sang k php Ba lan ngc Ta gi n l chui R (4) e = R e = R c chuyn sang k php Ba lan ngc

cd +

bP

aQ

eR =

(5) Vit li P, Q, R trong dng k php Ba Lan ngc (gch chn xc nh ni xy ra thay th):

eR =

eaQ =

eabP =

eabcd + =

27 (FAQ) Chuyn sang k php Ba Lan ngc hoc chuyn sang cng thc ton hc l cc ch hay gp trong bi thi. Tt nht l hc cch tr li cc cu hi ny bng trc quan. 28 (Ch ) Bng trc quan, k php Ba Lan ngc c th t cc php ton trong cng thc khi chuyn i nh sau.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

22

1. Khoa hc my tnh c s

Chuyn t k php Ba Lan ngc thnh cng thc ton hc


Cch chuyn t k php Ba Lan ngc thnh cng thc ton hc nh sau: (i) Qut k php Ba Lan ngc t u, tm 1 ton t.29 (ii) Thc hin php ton xc nh bi ton t u tin, s dng 2 bin ngay lin trc ton t. (iii) t kt qu ca php ton (ii) l 1 bin mi v lp li 2 bc u tin (i) v (ii). V d, cho k php Ba Lan ngc sau eabcd + = . N c chuyn nh sau: y, phn gch chn xc nh phn c chuyn i (1) Qut eabcd + = t u, tm kim 1 ton t. Ton t u tin l +, ch ti ton t v 2 bin lin trc n, tc l cd+.

cd +

c+d

t n l P. eabP = (2) Qut biu thc eabP = t u tm kim 1 ton t. Ton t u tin l , ch

bP t n l Q. eaQ = (3) Qut biu thc eaQ = t u, tm kim 1 ton t. Ton t u tin l , nn tp trung vo ton t v 2 bin lin trc n, tc l aQ . aQ a Q t n l R. eR =
(4) Vit li P, Q, v R nh cng thc ton hc (phn gch chn c thay th)

ti ton t v 2 bin lin trc n, tc l bP .

bP

eR =

e=R

e = a Q

e = a b P

e = a (b (c + d ))

B ngoc khng cn thit, ta c kt qu sau:

e = a b (c + d )

K php Ba Lan
Trong k php Ba Lan, a + b c biu din l + ab 30. Trong khi biu din trong k php Ba Lan ngc l ab + , K php Ba Lan t cc ton t trc cc bin. Cc khi nim c bn tng t nh trong k php Ba Lan ngc. Nu chuyn e = a b (c + d ) thnh dng k php Ba Lan ta c:

e = a b (c + d )

= e a b + cd

29 30

(Gi ) trong k php Ba Lan ngc, khi tm kim 1 ton t, ta s lun c 2 bin nm ngay trc n. Trong k php Ba Lan, mi ton t nm trc 2 bin. Nu khng c 2 bin, hy tm kim bin tip theo.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

23

1. Khoa hc my tnh c s

Cu hi nhanh
Q1 Cho gi tr ca cc bin logic x v y nh sau. Hon thnh bng di bng cch tnh tch logic, tng logic v tng loi tr logic.
x
0 0 1 1

y
0 1 0 1

Tch logic

Tng logic

Tng loi tr logic

Q2 Q3

Gii thch khi nim b cng, b bn cng v b cng y . Chuyn cng thc (a + b) (c d) sang dng k php Ba Lan ngc.

A1
x
0 0 1 1

y
0 1 0 1

Tch logic 0 0 0 1

Tng logic 0 1 1 1

Tng loi tr logic 0 1 1 0

A2 B cng: Mch cng cc s nh phn 1 bit. Gm cc mch AND, OR, NOT. B bn cng: Mt b cng m khng a vo kt qu s nh t cc bit thp hn. N c 2 u vo v 2 u ra.

B cng y : Mt b cng m a vo kt qu s nh t cc bit thp hn. N c 3 u vo v 2 u ra. A3

ab+cd Dch l cng a v b, tr c cho d v nhn cc kt qu vi nhau.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

24

1. Khoa hc my tnh c s

1.3 Cu trc d liu


M u
Khi tm kim gii thut cho mt chng trnh, s d dng hn to ra mt gii thut nu t d liu trong cc mu tiu biu. Cc mu c trng c gi l cc cu trc d liu. Mt s cu trc d liu quen thuc l: mng, danh sch, ngn xp, hng i v cy.

1.3.1 Mng (Array)


im chnh
Mng c th s dng trong mi cu trc d liu Mng c truy cp qua ch s.

Mng l mt cu trc d liu to bi nhiu d liu cng kiu. V d, hnh nh l tr xp thnh mt hng n. Trong tnh hung ny, cc i tng c cc thuc tnh ging nhau ( y i tng l tr con) c lp li, tng t nh mt mng. Mi a tr c xc nh nh a th nht, a th hai. Cc s 1, 2, c gi l cc ch s. Mt mng c s dng khi nhiu d liu cng kiu c qun l khng phi ring l m trong mi quan h vi nhau. D liu c truyn qua tn mng, mi trng d liu (phn t) c xc nh bi mt ch s.

Mng mt chiu
Mng mt chiu l khi nim nh sau31: Ch s Mng T 1 a 2 b 3 c 4 d 25 y 26 z

Mi mng c mt tn. Trong v d trn, tn mng l T. xc nh mi phn t s dng ch s. Ch s ch ra v tr ca phn t trong mng32. V d, phn t th t d c xc nh bi T(4), ch s nm trong ngoc n. Mt vi ngn ng s dng ngoc vung [ ]. Tng qut, phn t th n ca mng c biu th bng T(n). Bng cch thay i gi tr ca n, chng ta c th xc nh bt c phn t no ca mng.

31 (FAQ) C nhng cu hi kh v chnh cc mng. V, cc cu hi v cu trc d liu hoc gii thut lun s dng mng. Do cn hiu r tnh cht ca mng. c bit, cn phi hiu r cch s dng ch s. 32 (Gi ) Ch s bt u t 0 trong mt s ngn ng lp trnh. Cc cu hi v gii thut trong bi thi c th nh ch s bt u t 0 hoc 1, hy cn thn.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

25

1. Khoa hc my tnh c s

Mng hai chiu


Mt mng hai chiu l khi nim nh sau33: Dng 1 Dng 2 Dng 3 Ct 1 a (1,1) a (2,1) a (3,1) Ct 2 a (1,2) a (2,2) a (3,2) Ct 3 a (1,3) a (2,3) a (3,3) Ct 4 a (1,4) a (2,4) a (3,4)

Tng qut, phn t ca mng hai chiu c xc nh bng b 2 ch s m v n. K hiu l a(m,n) hoc amn vi m l ch s dng v n l ch s ct. Mng trn l mng hai chiu vi 3 dng v 4 ct, cn c gi l mng 3 nhn 4.

Lu tr theo dng v lu tr theo ct


Khi mt mng c lu tr trong b nh, n c lu tr nh mng mt chiu. Khi cc phn t ca mt mng hai chiu c lu tr nh mng mt chiu, c th s dng 2 phng php, da trn th th cc phn t c lu tr: lu tr theo dng hoc lu tr theo ct34.
Lu tr theo ct

a(1,1) a(2,1) a(3,1) a(1,2) a(2,2) a(3,2) a(1,3) a(2,3) a(3,3) a(1,4) a(2,4) a(3,4)

a(1,1) a(1,2) a(1,3) a(2,1) a(2,2) a(2,3) a(3,1) a(3,2) a(3,3)

Lu tr theo dng a(1,4) a(1,1) a(2,4) a(1,2) a(3,4) a(1,3) a(1,4) a(2,1) a(2,2) a(2,3) a(2,4) a(3,1) a(3,2) a(3,3) a(3,4)

Trong hnh trn, ch s khc nhau ca ch s. Trong phng php lu tr theo ct, ch s x trong a(x, y) thay i trc. Trong phng php lu tr theo dng, ch s y thay i trc. Khi ni ti mng, tm kim cc phn t tun t s hiu qu hn truy cp m b qua ch ny ch khc. Do vy. x l hiu qu, ch s c iu khin nh sau: Theo ct: x trong a(x,y) (x = 1 ti m; y = 1 ti n) thay i trc. Theo dng: y trong a(x,y) (x = 1 ti m; y = 1 ti n) thay i trc. Vi s sp xp ny, tham chiu ti 1 mng hai chiu c lm cho hiu qu hn khi chuyn n thnh 1 mng mt chiu.

33 (Gi ) Mng 1 chiu c s dng khi d liu c lu tr n gin. Mt mng 2 chiu c s dng khi cc i tng lu tr ging cc ma trn ton hc. 34 Gia cc ngn ng lp trnh, Fortran s dng lu tr theo ct trong khi COBOL, PL/I v C s dng lu tr theo dng.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

26

1. Khoa hc my tnh c s

1.3.2 Danh sch (List)


im chnh
Danh sch c c trng bi cc con tr c lin kt Cc thao tc trn danh sch c iu khin bi s thay i gi tr ca cc con tr.

Danh sch l mt tp ca cc d liu ging nhau hoc tng t nhau c t mt cch logic trn mt hng (tuyn tnh35); cu trc ca n gn ging 1 mng. im khc bit l ch, trong khi cc phn t ca mng c t k nhau mt cch vt l, cc phn t ca danh sch c th t nhng v tr c lp v c cc con tr lin kt gia chng. V vy, mng v danh sch ch khc bit im: mng ni ti mt danh sch tuyn tnh, v danh sch ni ti mt danh sch mc ni (do cc phn t c mc ni bi con tr). Tng qut, thut ng danh sch ni ti danh sch mc ni. Do chng ta gi danh sch mc ni n gin l danh sch

Cu trc ca danh sch


Mt danh sch l mt cu trc d liu m cc phn t c kt ni bi cc con tr. Mt con tr l thng tin xc nh v tr lu tr (a ch) ca phn t k tip. Mi phn t c kt ni bi 1 con tr, nn cc phn t khng cn c t theo th t. Mt danh sch c th c cu trc a dng. Hnh v sau c gi l mt danh sch 1 chiu.36
Gc u Phn t Gia Phn d liu Phn con tr Gia Cui

Con tr tr ti phn t u tin c lu tr trong mt bin gi l gc. Phn t cui cng ca danh sch khng c phn t no sau n, nn con tr ca n cha k hiu (X) xc nh rng l phn t cui cng ca danh sch. Trong vi ngn ng lp trnh, k hiu ny c th c lu tr t ng, mt s khc, c th l bt c k hiu g. iu quan trng l n gn cho mt gi tr khng tn ti nh d liu

(Gi ) Thut ng tuyn tnh ch ti 1 tp d liu nm lin k nhau. 1 mng l tuyn tnh khi cc phn t c t trong vng lin tc. Ni cch khc, mt danh sch l 1 cu trc m cc phn t c lin kt bi con tr, chng c th khng nm trong vng lin tc. 36 Bn cch danh sch 1 chiu cn c danh sch 2 chiu v danh sch vng. 1 danh sch 2 chiu l danh sch trong mi phn t c 1 con tr xc nh phn t lin trc v 1 con tr xc nh phn t lin sau. Mt danh sch vng l mt danh sch m phn t cui cng c con tr xc nh v tr ca phn t u tin. Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

35

27

1. Khoa hc my tnh c s

Cc thao tc c bn vi danh sch


C mt s thao tc c bn c thc hin trn danh sch, trong thao tc quan trng nht l chn v xa danh sch. Chn37 chn thm mt phn t vo mt danh sch cho trc. Tt c nhng th cn lm l thay i mt s con tr thch hp. u tin, con tr ca phn t c chn nhn a ch ca phn t m s nm ngay sau n trong danh sch. Tip theo, thay i con tr ca phn t ngay trc phn t c chn vo n c a ch ca phn t c chn vo

Phn t c chn

Xa xa mt phn t khi mt danh sch cho trc, ging nh chn thm vo, ta cn thay i cc con tr. Thay i con tr ca phn t ngay pha trc phn t b xa n ch ti phn t ngay sau phn t b xa. D liu b xa tn ti nh rc n khi danh sch c ti cu trc, do d vo nhng thi im ph hp cn tin hnh dn rc38 xa cc phn t khng cn thit39.

Rc

37 (FAQ) Nhiu cu hi lin quan ti thao tc chn vo v xa khi danh sch. Cn phi xem xt cn thn phn t m con tr ca n c lu tr. 38 Dn rc: L mt th tc nh b nh nh, phn mnh, khng s dng v cc vng khng s dng khc do r r b nh c kt hp vi nhau tng vng nh c th s dng. Nu rc khng c dn, vng nh c th s dng s tip tc gim v cui cng chc nng khi ng li h thng s c gi. 39 R r b nh: N ch tnh hung m b nh chnh c tm t ng bi 1 ng dng khng c gii phng v vi l do v nm li trong b nh chnh. kh r r b nh, dn rc l cn thit.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

28

1. Khoa hc my tnh c s

1.3.3 Ngn xp (Stack)


im chnh
Ngn xp l cu trc d liu kiu LIFO (vo cui ra u/ vo sau ra trc). Ngn xp c s dng qun l a ch tr v ca chng trnh con

Ngn xp l mt cu trc d liu trong d liu chn thm vo v xa i u nm cng mt u ca danh sch. N c minh ha nh hnh di.
nh (mc cao nht ca ngn xp)

y (mc thp nht ca ngn xp)

im u ni cc phn t thm vo v xa c i gi l nh v u kia gi l y. Thao tc thm vo c gi l y xung v xa i gi l ly ra.

Cc thao tc c bn vi ngn xp
Ngn xp l mt cu trc d liu kiu LIFO (Last-In First-Out), ngha l phn t c lu tr cui cng s c ly ra u tin. Trong hnh v di, d liu c lu tr theo th t 3 2 4 v c ly ra theo th t 4 2 3.40

y vo

L y ra

Mt con tr gi l Con tr ngn xp (Stack Point-SP) c s dng gi vt nh ca ngn xp hin ti, chng ta c th chn thm mt phn t hoc xa mt phn t khi v tr c xc nh bi SP. Con tr ngn xp c th tr ti nh tht ca ngn xp, thnh thong tr ti mt im khc ty vo ci t.

S dng ngn xp
Khi mt chng trnh chnh gi mt chng trnh con (th tc con) hoc mt hm, a ch tr v ca chng trnh ang c thc hin c lu tr trong ngn xp, khi chng trnh con hon thnh, a ch tr v ca chng trnh chnh c ly ra khi ngn xp v tr v cho trnh iu khin. Hn na, nu mt chng trnh con gi mt chng trnh con khc, a ch tr v ca chng trnh gi c lu tr tun t trong ngn xp.41

(FAQ) C nhiu cu hi lin quan ti ngn xp. Mu cu c s dng thng xuyn l cc cu hi v iu g s xy ra vi ngn xp cho khi lp li thao tc y vo, ly ra. 41 S dng 1 ngn xp, 1 chng trnh con c th c gi t 1 chng trnh con khc. Mi ln 1 chng trnh con c gi lin tip, a ch tr v c lu tr trong ngn xp. Khi ly ra theo th t ngc vi th th lu tr, chng trnh con c tr v theo th t ngc li. 1 cu trc m 1 chng trnh con c gi t mt chng trnh con khc l cu trc lng. Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

40

29

1. Khoa hc my tnh c s

Ci t ngn xp s dng danh sch


S dng cu trc ca mt danh sch, ta c th ci t mt ngn xp. Trong trng hp ca danh sch sau, mt phn t ch c th thm vo hoc xa i t nh ca danh sch.
Gc

Chn vo danh sch


thm phn t 35 vo danh sch, ta t n lm phn t u tin, tc l trc phn t 10.
Gc

Xa khi danh sch


Ta xa phn t u tin 35 khi danh sch, ni n c chn vo x l trn. H qu l, bng cch kt hp thao tc chn v xa, ta c th ci t ngn xp.
Gc

1.3.4 Hng i (Queue - Danh sch i)


im chnh
Hng i l mt cu trc d liu kiu FIFO (First-In First-Out) vo trc ra trc. Hng i c s dng trong x l giao dch trc tuyn.

Hng i l mt cu trc d liu m thao tc chn c thc hin mt u v thao tc xa (ly ra) c thc hin u kia. Da trn khi nim, n c c m t nh sau.
Chn
Phn t

Xa
Phn t

ui

D liu u tin trong hng i c gi l u v d liu cui cng c gi l ui. Mt hng i cn c gi l danh sch i waiting list, tn ny ly t khi nim ca trnh t x l.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

30

1. Khoa hc my tnh c s

Cc thao tc trn hng i


Hng i l cu trc d liu kiu FIFO (First-In First-Out) vo trc ra trc, ngha l phn t c lu tr trc s c ly ra trc. Trong hnh v di, d liu c lu tr theo th t 1 2 3 v c ly ra theo th t 1 2 3.
Chn Xa

Trong hng i, d liu lun lun c lu tr (enqueued) sau d liu cui cng, v d liu u tin (c nht) lun lun b xa (dequeued) trc.42

Cc v d v hng i
Trong x l a chng trnh, cc chng trnh ang i thc hin c u tin bng nhau c t vo hng i thc hin v ch n khi CPU sn sng. Trong x l cc giao dch trc tuyn43, cc thng ip (vn bn in t) c a vo hng i v c x l theo th t i vo.

Ci t hng i s dng danh sch


ci t hng i t danh sch, cn tm con tr xc nh v tr ca phn t cui cng ca danh sch. Thao tc chn c thc hin im cui ca danh sch v thao tc xa c thc hin u44. Cho danh sch nh sau, y con tr ti phn t cui cng c gn cho ui thun tin.
Gc Cui

V ta gi s rng phn t c chn vo cui ca danh sch, hnh v trn xc nh rng phn t c chn vo v lu tr theo th t 1 2 3 4.

(Ch ) Cc v d v hng i c thy quanh ta hng ngy. V d, 1 hng ngi i mua v tu t 1 my bn v l 1 hng i, h xp hng tr tin trc ly v trc. Vi n d v hng ngi i, thnh thong hng i c gi l danh sch ch. 43 X l giao dch trc tuyn: l ch x l m 1 yu cu x l c thc hin ngay lp tc v tr v kt qu, nh h thng t ch ca tu ha v my bay. V d, khi v c yu cu, n c in ra ngay lp tc. Mt yu cu x l gi l 1 giao dch . 44 (Gi ) Mt h thng chia x thi gian (TSS) c b ngoi ging nh mt qu trnh x l giao dch trc tuyn, nhng phng php x l hon ton khc. 1 hng i cc cng vic cn x l theo th t n ca chng, mt TSS chia thi gian x l gia cc cng vic. Thm ch nu 1 chng trnh khng kt thc qu trnh x l ca n, sau 1 thi gian, 1 chng trnh khc s bt u qu trnh x l. 1 TSS c hon thnh bi a chng trnh. Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

42

31

1. Khoa hc my tnh c s

Chn vo danh sch45


Hnh v di minh ha cch phn t 5 c chn vo. Gi tr con tr xc nh ui cn c thay i tr vo 5. Sau con tr ca phn t 4 vn trc c s dng tr vo phn t cui cng, c thay i tr ti phn t va c chn vo.
Gc Cui

Xa khi danh sch


Khi xa phn t u tin 1, con tr gc b thay i tr ti phn t 2. c phn t 1 v xem gi tr con tr ca n, vn tr ti v tr ca phn t 2.
Gc Cui

1.3.5 Cy (Tree)
im chnh
Cy xc nh 1 cu trc phn lp Trong cc loi cy, cy nh phn s c tm hiu k trong phn ny .

Cy l mt cu trc d liu biu din cu trc phn lp gia cc phn t. N c s dng cho biu t chc ca mt cng ty, cu hnh h thng, N c mt gc trn cng, v cc nt c lin kt bng cc cnh. mt nt ngay trn mt nt khc c gi l cha v mt nt ngay di mt nt khc c gi l con 46. Mi nt c nm mt mc (level) ch ra su, gc nm mc 0. Nt khng c con gi l l. Mt phn ca cy c gi l cy con. Cho mt nt, cy con bn tri ca n c gi l cy con tri, cy con bn phi gi l cy con phi.
Gc Nt Cnh Mc 0 Mc 1 Mc 2 L Cy con phi ca nt (2) Mc 3 Cha Con Cha Con Cha Con

45 a chng trnh: l 1 phng php m nhiu chng trnh xut hin chy cng 1 lc. Khng my tnh no c th thc s chy nhiu chng trnh cng 1 lc. Tuy nhin, my tnh x dng phng php chia x thi gian chuyn, vi khong thi gian chuyn ngn, chng trnh c thc hin nh th c nhiu chng trnh c thc hin cng lc. 46 (Gi ) Mt con tr c s dng 1 nt cha xc nh con ca n. Mi cha c nhiu con tr ti cc con ca n.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

32

1. Khoa hc my tnh c s

Cy nh phn v cy nh phn hon chnh


Mt cy m mi nt c khng qu 2 con c gi l mt cy nh phn. Nu mt cy nh phn m tt c cc l c cng su hoc nu 2 l bt k c su chnh lch nh hn hoc bng mt v cc l c t t tri sang, c gi l cy nh phn hon chnh47.

Cy nh phn

Cy nh phn hon chnh

Cy nh phn tm kim
Mt cy nh phn tm kim l mt cy nh phn m gi tr ca mt phn t c gn cho mi nt tha m cc rng buc48: Gi tr con tri < gi tr phn t cha < gi tr con phi

Gi tr ca tt c cc nt u ln hn gi tr (4) ca gc.

47 (FAQ) Trong bi kim tra FE c bn, cc cu hi ch lin quan ti cy nh phn, hy ghi nh chnh xc c im ca cc loi cy nh phn, nh cy nh phn y , cy nh phn tm kim, ng. 48 (Gi ) Trong 1 cy nh phn tm kim, ch rng phn t vi gi tr nh nht l l ngoi cng bn tri trong khi phn t c gi tr ln nht l l ngoi cng bn phi. y l mt c im ca cy nh phn tm kim.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

33

1. Khoa hc my tnh c s

ng
mt cy nh phn c gi l ng nu gi tr ca nt c gn t mc gc v t tri sang phi trn cng mc vi iu kin sau: 49 Gi tr ca phn t cha > gi tr ca phn t con (hoc gi tr ca phn t cha < gi tr ca phn t con) ng ph hp vi iu kin trn gi l ng cc i, v ng ph hp vi iu kin di l ng cc tiu. Nh mt kt qu, phn t c gi tr ln (hoc nh) cng gn vi nt, ngc li phn t c gi tr nh (ln) hng ti l. N l mt cu trc d liu ph hp cho vic ly gi tr ln nht (hoc nh nht) vi nt l phn t c gi tr ln nht (hoc nh nht). .
Gi tr ln nht Gi tr ln

Gi tr nh

1.3.6
im chnh

Bm (Hash)
Bm l khi nim s dng trc tip gi tr kha nh ch s Hai phng php trnh xung t l phng php a ch m v phng php dy chuyn.

Bm l khi nim s dng trc tip gi tr kha nh v tr lu tr d liu. V d, c mt mng H kch thc 100 phn t. Nu gi tr kha l cc s c 2 ch s t 01 ti 99 khng lp li, cc gi tr kha ny c th s dng nh cc ch s. c gi l phng php tm kim trc tip. Tuy nhin, him khi gi tr kha c s dng trc tip nh ch s. V vy cn chuyn gi tr kha sang ch s, mt hm bm50 c s dng tnh gi tr bm, c s dng nh ch s. Mng lu tr cc phn t s dng phng php ny gi l bng bm. Xem nh hm bm l hm chia gi tr kha cho s phn t ca mng v cng thm mt vo phn d.

49 (Gi ) Ch rng ng y c gi tr ln nht nm gc. Ly phn t gc, ti cu trc ng, v lp li qu trnh x l ny, vi cch ny, c th ly cc phn t theo th t gi tr ca chng t phn t ln nht tn phn t nh nht. 50 Hm bm: 1 hm tnh a ch d liu (v d: ch s) t gi tr kha.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

34

1. Khoa hc my tnh c s

Kha Gi tr kha

D liu

Bng bm (mng) Kha D liu

Ch s 1

Kha Kha

D liu D liu

50 n

Hm bm 50

Nu c n phn t, s d s nm t 0 ti (n 1), cng 1 s tr v gi tr bm t 1 ti n. Chng c th c s dng nh ch s c lu tr trong mng.51 Tuy nhin, kha lin quan ti nhiu gi tr, ch s ging nhau c th sinh ra t gi tr kha khc nhau bng cch tnh ch s (gi tr bm) t 1 n n s dng hm bm. Khi gi tr bm ging nhau c sinh ra theo cch ny c gi l xung t52.

Phng php dy chuyn (phng php bm m)


y l phng php s dng mt danh sch lu tr phn t c gi tr bm ging nhau khi xy ra mt xung t. Bng bm u tin ch cha con tr tr ti d liu u tin ca danh sch. Hnh v di minh ha mt v d c 3 mnh d liu c lu tr trong mt v tr c ch s l 1 trong bng bm. Bng bm ny c mt con tr xc nh d liu u tin. V tr ca d liu tip theo c tm thy bi ln theo phn con tr khi d liu u tin c c.
Bng bm 1 2 Phn con tr

D liu D liu D liu


Phn t u (Home)53

D liu

D liu

3 4
51

(FAQ) Nhiu cu hi lin quan ti bm s hi bn tnh v tr lu tr v 1 hm mod thng c s dng lm hm bm. Trong mod (a,b) l ly s d trong php chia a cho b. 52 Xung t: Khi mt hm bm c s dng tnh a ch lu tr, cc kha khc nhau c th cho cng 1 gi tr bm. Hin tng c gi l xung t. 53 Phn t u (Home): D liu c lu tr u tin khi xy ra xung t 54 Phn t cng kha (Synonym): D liu n sau khi xy ra xung t Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

D liu Phn t cng kha (Synonym)54

35

1. Khoa hc my tnh c s

Phng php a ch m (phng php bm ng)


y l phng php gii quyt/ x l xung t bng bm li. Bm li l tnh ton li v tr lu tr khi mt xung t xy ra v lu tr d liu mi nu v tr rng V d, phn t a, b, c c lu tr trong cc v tr ring bit (xc nh bi ch s) theo gi tr bm c tnh ton. Tip theo, phn t d c gi tr bm l 1, nhng v tr 1 b chim bi phn t a. V d nu phng php bm li l gi tr bm gc + 1, th v tr tip theo c ch ra bi ch s 2. Nhng v tr cng b chim, i tip ti ch s 3. Tm kim v tr 4, v tr trng. Nh kt qu, phn t d c lu tr v tr c ch s 4. Nu xy ra trng hp khng c ch trng ti cui ca bng bm, tr li v tr u tin ca bng v tm kim ch trng u tin theo cch tng t.
Ch s (1) Gi tr bm ca phn t a = 1 (2) Gi tr bm ca phn t b = 2 (3) Gi tr bm ca phn t c = 3 (4) Gi tr bm ca phn t d = 1 n 36 1 2 3 4 5 Bng bm a b c d Bm li Bm li Lu tr

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

1. Khoa hc my tnh c s

Cu hi nhanh
Q1 Ta gi cu trc d liu m khi nim ca n c biu din trong hnh di y l g?

Q2 Q3 Q4 Q5

Ta gi cu trc d liu kiu Last-In First-Out (Vo sau ra trc) l g? Ta gi cu trc d liu kiu First-In First-Out (Vo trc ra trc) l g? nh ngha cy nh phn v cy nh phn hon chnh. Ta gi cy nh phn tha mn quan h sau l g: gi tr ca con tri < gi tr ca phn t cha < gi tr con phi?

A1 A2 A3 A4

Danh sch Ngn xp Hng i

Cy nh phn: Cy m mi nt ca n c khng qu 2 con Cy nh phn hon chnh: Cy nh phn m tt c cc l c chiu su nh nhau hoc 2 l bt k c chnh lch chiu su nh hn hoc bng 1 v cc l hng v pha tri Cy nh phn tm kim

A5

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

37

1. Khoa hc my tnh c s

1.4 Gii thut


M u
Mt tp hp cc th tc gii quyt mt vn gi l mt gii thut. Hnh v biu th tp cc th tc t ti kt qu thch hp gi l lu . Chng ta s nghin cu mt s gii thut c bn.55

1.4.1 Cc gii thut tm kim


im chnh
C 2 loi gii thut tm kim: tm kim tuyn tnh v tm kim nh phn Trong tm kim nh phn, phn t c sp xp theo th t tng dn hoc gim dn

Tm kim ngha l tm mt phn t trong mt bng (mng mt chiu), v c 2 phng php tm kim: tm kim tuyn tnh (tun t) v tm kim nh phn. Tm kim tun t c th thc hin m khng quan tm ti cc phn t c sp xp nh th no, nhng tm kim nh phn yu cu cc phn t c sp xp theo th t tng dn hoc gim dn

Tm kim tuyn tnh (tun t)


y l phng php tm kim cc phn t c yu cu trong bng theo th t t v tr u tin ca bng. N c th thc hin m khng quan tm ti cc phn t c sp xp nh th no, nhng n lu hn tm kim nh phn. Nu N l s phn t, cn t nht 1 php so snh (nu phn t cn tm nm v tr u ca bng) v nhiu nht N php so snh (nu phn t cn tm nm v tr cui cng ca bng hoc khng tn ti) Trong tm kim tuyn tnh, php so snh c to ra t ch s 1 v tip tc cng 1 ti ch s tip theo n khi ch s bng N. V d, phn t 25 trong bng c tm bng phng php tm kim tuyn tnh. N c so snh vi gi tr u tin, th 2, , th 5. Cc s xc nh v tr ca phn t l cc ch s 25 Ch s 15 1 30 2 45 3 40 4 25 5 35 10 5

55 (FAQ) biu din cc gii thut, cc cu hi trong phn thi bui sng s dng cc lu , trong khi cc cu hi trong phn thi bui chiu s dng gi ngn ng. Cc lut trong gi ngn ng khng c trnh by, hy l c lt n

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

38

1. Khoa hc my tnh c s

Tm kim nh phn
y l mt phng php tm kim hiu qu khi cc phn t trong bng c sp xp theo th t tng dn hoc gim dn. Php so snh c thc hin tun t vi gi tr nm gia ca bng. Sau php so snh u tin, na bn phi hoc bn tri ca bng b vt b, v gi tr gia ca phn cn li c s dng cho php so snh tip theo. Phm v tm kim gim mt na sau mi ln, kiu tm kim ny nhanh hn thi gian trung bnh ca tm kim tuyn tnh Gii thch mt gii thut c th, s dng mng sau lm v d, coi nh chng ta tm kim gi tr 11 Ch s Mng T Ln so snh u tin Phm vi l ton b mng. t L l gii hn di v U l gii hn trn ca phm vi. t M l gi tr gia (trung v) Ch s Mng T 1 0 L 2 1 3 3 4 5 6 7 8 9 10 5 7 9 11 13 15 17 Khong tm kim U 1 0 2 1 3 3 4 5 5 7 6 9 7 8 9 10 11 13 15 17

M = (L + U) / 2 = (1 + 10) / 2 = 5.5

5 (Trung v)

Trung v c th tnh bng cch lm trn trn hoc lm trn di u c. y ta chn cch lm trn di. T(M) = T(5) = 7 Gi tr cn tm l 11 nn 11 khng th c tm thy na tri ca bng cha gi tr trung v bi v cc phn t c sp xp theo th t tng dn v gi tr cn tm ln hn gi tr trung v56. Ln so snh th hai Ln so snh th nht ch r rng rng gi tr cn tm khng nm trong na tri ca bng cha gi tr trung v, ta thay i khong tm kim. y, gii hn di b thay i ti gi tr ngay bn phi trung v. Gi tr ca L b thay i nh sau: L=M+1=5+1=6 Kt qu, khong tm kim thay i nh sau Ch s Mng T 1 0 2 1 3 3 4 5 5 7 L 6 9 7 8 9 11 13 15 Khong tm kim 10 17 U

Tng t nh php so snh u tin, chng ta tm trung v mi nh sau: M = (L + U) / 2 = (6 + 10) / 2 = 8 (Trung v)


56 (Gi ) Khi xa na bn tri ca bng, ch s di mi bng trung v cng 1; khi xa na bn phi, ch s trn mi bng trung v tr 1

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

39

1. Khoa hc my tnh c s

T(M) = T(8) = 13 Ta s so snh n vi 11, gi tr cn tm 11 khng th nm na bn phi ca khong tm kim cha gi tr trung v mi. Do cc phn t c sp xp theo th t tng dn v gi tr cn tm nh hn gi tr trung v Ln so snh th ba Ln so snh th hai ch ra rng gi tr cn tm khng nm trong na bn phi ca khong tm kim cha trung v, chng ta s thay i khong tm kim. y, gii hn trn b thay i ti gi tr ngay bn phi ca trung v. Gi tr ca U b thay i nh sau: U=M1=81=7 Kt qu, khong tm kim thay i nh sau Ch s 1 2 3 4 Mng T 0 1 3 5 5 7 6 7 8 9 11 13 L U Khong tm kim 9 15 10 17

Tng t nh ln so snh th 2, ta tm trung v mi nh sau: M = (L + U) / 2 = (6 + 7) / 2 = 6 (Trung v) T(M) = T(6) = 9 Ta s so snh n vi 11, gi tr cn tm 11 khng th nm na tri ca khong tm kim cha gi tr trung v Ln so snh th t Ln so snh th ba ch r rng gi tr cn tm khng nm trong na tri ca khong tm kim cha gi tr trung v, ta s thay i gii hn di ging nh ln so snh th hai L=M+1=6+1=7 Kt qu, khong tm kim nh sau Ch s 1 2 Mng T 0 1 3 3 4 5 5 7 7 8 9 11 13 15 L=U Khong tm kim 6 9 10 17

M = (L + U) / 2 = (7 + 7) / 2 = 7 (trung v) T(M) = T(7) = 11 Ta s so snh n vi 11, ta tm thy gi tr cn tm57 Th tc khi tm kim gp li Gi s ta cn tm 10, trong ln so snh th t, cng thc T(M) = 11 > 10 l ng, ta phi
57 (Gi ) Phn t 11 l T(7) trong mng T, c tm thy sau 4 php so snh trong tm kim nh phn. Tm kim tuyn tnh cn 7 php so snh tm thy gi tr ny

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

40

1. Khoa hc my tnh c s

thay i gii hn trn ca khong tm kim. Khong tm kim mi nh sau: L = 7 (Khng i) U=M1=71=6 V L l gii hn di v U l gii hn trn, nn L M , nhng by gi c L > M. Khi bt ng thc ny xy ra, ta kt lun rng phn t cn tm khng tn ti.

So snh gia phng php tm kim tuyn tnh v tm kim nh phn


Khi s dng phng php tm kim nh phn tm 11, cn 4 php so snh. Tuy nhin, trong phng php tm kim tuyn tnh, do 11 c ch s l 7, n cn 7 php so snh. Do , phng php tm kim nh phn phc tp hn nhng s php so snh gim xung Tuy nhin, xt trng hp tm 0, ch s ca n l 1. Phng php tm kim tuyn tnh c th tm thy kt qu ngay ln so snh u tin trong khi phng php tm kim nh phn cn 3 php so snh. y tm kim nh phn nhanh hn. nh gi vn ny, c mt khi nim gi l phc tp tnh ton. Khi s phn t N l rt ln, gi tr ny ni cho ta bit rng trung bnh cn bao nhiu php so snh. Ta b qua gii thch chi tit y, nhng tha nhn cng thc sau: phc tp ca phng php tm kim tuyn tnh = N / 2 S php so snh ti a ca phng php tm kim tuyn tnh = N phc tp ca phng php tm kim nh phn = [log2N] S php so snh ti a ca phng php tm kim nh phn = s php so snh trung bnh + 1 Ta s dng log2N trong ngoc vung. Nhn chung, log2N khng phi l mt s nguyn, nhng s php so snh phi l mt s nguyn. Do vy, [ ] biu th xa, hoc ct phn thp phn, v d [10.513] l 10

1.4.2 Cc gii thut sp xp


im chnh
Cn thn khi iu khin ch s trong phng php sp xp ni bt, sp xp chn, sp xp chn Li gi qui c s dng trong sp xp nhanh v sp xp trn

Sp xp ngha l b tr li cc phn t v/hoc cc bn ghi ca mt mng theo th t ca kha. Sp xp cc phn t t kha nh nht ti kha ln nht c gi l sp xp theo th t tng dn v sp xp theo chiu t kha ln nht ti kha nh nht gi l sp xp theo th t gim dn. Sp xp ni dung ca 1 vng trong 1 chng trnh, v d 1 mng, c gi l sp xp trong trong khi sp xp d liu c lu tr thit b ngoi vi nh cc bn ghi trong 1 file, c gi l sp xp ngoi (sp xp file). Cc phng php sp xp in hnh ca sp xp trong gm: sp xp ni bt, sp xp chn, sp xp chn, sp xp nhanh, sp xp trn, sp xp v bc, sp
Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

41

1. Khoa hc my tnh c s

xp ng

Sp xp ni bt
Trong sp xp ni bt, mi cp phn t lin nhau c so snh tun t v i ch nu cn thit. Trong trng hp sp xp theo th t tng dn, gi tr ln nht c t l phn t cui cng ca mng. Tip theo, tr li t u, cc gi tr c kim tra v thay i khi cn thit. Trong ln chy th hai, phn t v tr cui cng ca mng b t ra ngoi khong sp xp. Tip tc qu trnh ny, khong sp xp nh dn sau mi ln, v kt thc sp xp khi phn t u tin v phn t th hai c so snh Di y l v d ca sp xp theo th t tng dn
Trc khi sp xp Ln 1

5 5 4 4 4 4 4 3 3 3 3 2 2 2 1

4 4 5 3 3 3 3 4 2 2 2 3 1 1| 2|

3 3 3 5 2 2 2 2 4 1 1| 1| 3 3 3

2 2 2 2 5 1 1| 1| 1| 4| 4 4 4 4 4

1: 1: 1: 1: 1: 5: 5: 5: 5: 5: 5: 5: 5: 5: 5:
i ch 5 v 4 i ch 5 v 3 i ch 5 v 2 i ch 5 v 1 Kt thc ln 1 (gi tr ln nht nm cui cng bn phi) i ch 4 v 3 (gi tr bn phi ca | c sp xp) i ch 4 v 2 i ch 4 v 1 Kt thc ln 2 (gi tr ln th hai nm v tr th hai t bn phi) i ch 3 v 2 (gi tr bn phi ca | c sp xp) i ch 1 v 3 Kt thc ln 3 (gi tr ln th ba nm v tr th ba t bn phi) i ch 2 v 1 (gi tr bn phi ca | c sp xp) Kt thc ln 4, sp xp xong

Ln 2

Ln 3

Ln 4

Sp xp chn
Phng php sp xp chn tm gi tr ln nht (hoc nh nht) t mng v thay i n vi phn t nm cui mng. Tip theo, tm phn gi tr ln nht (hoc nh nht) t mng tr phn t cui cng v i v tr ca n vi phn t th hai t cui ln ca mng. Lp li th tc ny, sp xp chn kt thc khi n so snh phn t u tin v phn t th hai ca mng58 Di y l v d sp xp theo th t tng dn
Ln 1 Ln 2 Ln 3

5 1 1

4 4 2

3 3 3|

2 2| 4

1: 5: 5:

V 5 l gi tr ln nht, n i ch vi phn t cui cng 1. V 4 l gi tr ln nht, n i ch cho phn t cui cng trong ln chy th 2. Sp xp xong

(FAQ) Sp xp ni bt v sp xp chn thng xuyn xut hin trong bi thi. Cc cu hi c a ra theo nhiu cch, v d nh ni dung ca mng trng trng thi trung gian v in vo ch trng trong lu . Hy chc rng bn hiu r gii thut Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

58

42

1. Khoa hc my tnh c s

Sp xp chn
Phng php sp xp chn bt u vi 1 mng c sp xp, so snh phn t cn chn vi cc phn t trong mng t u ti cui, v chn phn t vo v tr thch hp59. V d di, cc phn t bn tri | c sp xp, y ch c duy nht 1 phn t trong ln chy u tin. N coi nh c sp xp. Di y l 1 v d v sp xp theo th t tng dn
Ln 1 Ln 2 Ln 3 Ln 4

5| 4 3 2 1

4 5| 4 3 2

3 3 5| 4 3

2 2 2 5| 4

1: 1: 1: 1: 5:

V 4 l gi tr hp (trc 5) V 3 l gi tr hp (trc 4) V 2 l gi tr hp (trc 3) V 1 l gi tr hp (trc 2) Sp xp xong

nh nht, n c chn vo v tr thch nh nht, n c chn vo v tr thch nh nht, n c chn vo v tr thch nh nht, n c chn vo v tr thch

Sp xp nhanh
Sp xp nhanh la chn 1 gi tr ngu nhin t mng v s dng n nh 1 cht, cc phn t c chia thnh 2 nhm, nhm u tin cha tt c cc phn t nh hn cht v nhm th hai cha tt c cc phn t ln hn cht (gi tr bng c th t 1 trong 2 nhm). Tip theo, th tc tng t c lp i lp li cho mi nhm. N tip tc cho n khi ch cn duy nht 1 phn t trong mi nhm. Kt qu mng c sp xp60 Di y l 1 v d ca sp xp theo th t tng dn. Cc gi tr gch chn l cht. ng | xc nh ranh gii ca khi.
Ln 1 Ln 2 Ln 3 Ln 4

2 2 1 1|

5 1 2| 2|

6 3| 3| 3|

4 5 4| 4|

1 6 5 5|

3: 4: 6: 6:

Chia thnh 2 khi Chia mi khi lm 2 Chia mi khi lm 2 (tr cc nhm ch c 1 phn t) Sp xp xong

59 (Gi ) Khi tm kim 1 v tr chn trong sp xp chn, phn t c chn c so snh t cui ca mng c sp xp. V d, trong ln chy th 3, th t so snh s l 2 v 5, 2 v 4, 2 v 3 60 (Ch ) Sp xp nhanh v sp xp trn khc nhau s phn t lin quan trong qu trnh chia, nhng chng s dng cng 1 phng php. Trong trng hp ny, phng php gi quy c s dng

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

43

1. Khoa hc my tnh c s

Sp xp trn
Trong phng php sp xp trn, 2 hoc nhiu mng, mi mng u c sp xp, c trn vi nhau thnh 1 mng sp xp. Trong sp xp trn, php chia c lp li n khi mi nhm ch c duy nht 1 phn t. Khi mi nhm ch c duy nht 1 phn t, cc phn t c trn vo nhau tun t61. Di y l 1 v d sp xp theo th t tng dn
Ln 1 Ln 2 Ln 3 Ln 4 Ln 5 Ln 6 Ln 7 Chia Trn Trn Trn Chia Chia

Sp xp bng phng php Shellsort


y l mt dng ci tin ca phng php sp xp chn, sp xp c lm nhanh hn bi tng khong cch di chuyn ca cc phn t u tin, cc phn t c sp xp hn n bng phng php chn vi khong trng 1 kch thc no . Sau , sp xp chn c s dng li hon thnh thao tc sp xp Di y l v d ca sp xp theo th th tng dn. Khi u, khong trng c thit lp l 2, v ch sp xp vi cc phn t . Sau , khong trng l 1 v sp xp chn c s dng
Cha sp xp Ln u

2 2 1 1 1 1

4 4 4 4 3 2

5 5 2 2 2 3

3 3 3 3 4 4

1: 1: 5: 5: 5: 5:
Mi phn t khc c sp xp (cc phn t gch chn c sp xp) Chy xong ln u Mi phn t cn li c sp xp (cc phn t gch chn c sp xp) Chy xong ln hai Chy xong ln 3 (sp xp xong)

Ln 2 Ln 3

L do mt phng php phc tp nh vy c s dng l sp sp chn khng cn yu cu thay i cc phn t. V d, xt tnh hung sau
Case A: Case B: 2 2 4 4 6 6 | | 1 8

Trong trng hp A, quyt nh ni chn 1, so snh vi 6 4 2. Sau , tt c cc phn t cn c di chuyn to khong trng chn 1. Ngc li, trong trng hp B,
61 quy: L qu trnh m 1 hm gi chnh n trong bn thn n. Trong Pascal v C gi quy c php nhng COBOL v Fortran khng cho php iu ny.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

44

1. Khoa hc my tnh c s

ngay lp tc gi tr c so snh vi 6, v tr chn c xc nh m khng cn dch chuyn V vy, tng s x l trong phng php chn da trn cc phn t c sp xp nh th no u tin. Sp xp bc v gim vic di chuyn cc phn t bi ln sp xp phc u tin

Sp xp vun ng
1 ng l 1 cy nh phn trong mi cy con c tnh cht: phn t cha c gi tr ln hn cc con ca n. Nu phn t gc c chn, ta c th thu c gi tr ln nht trong khi cc phn t cn li c th ti cu trc thnh ng mi. Ta c th ly li gc, m a cho ta phn t c gi tr ln th hai. Ni cch khc, bng cch lp li thao tc ly gc v ti cu trc ng, sp xp c th hon tt. Phng php sp xp s dng ng gi l sp xp ng62

1.4.3 Cc gii thut tm kim xu


im chnh
Nhn chung, tm kim xu so snh tng k t mt. Cc phng php tm kim su gm: phng php duyt ton b, phng php Boyer-Moore

Tm kim xu l qu trnh tm mt chui k t c bit trong mt vn bn (xu k t). Trong a s trng hp, xu nm trong mng m mi cha 1 k t v c tham chiu bi ch s. Hai mng c cho trc: vn bn v xu tm kim. Gii thut s tm kim xu mu trong xu vn bn. Trong v d di, chng ta mun kim tra xu S l XYZ, c mt 6~8 v 10~12 trong xu R. Rt r rng khi quan st bng mt, nhng trn thc t rt kh vit gii thut kim tra Xu S Xu R V tr
X P 1 Y Q 2 Z A 3 C 4

Mu
Z 5 X 6 Y 7 Z 8 R 9 X 10 Y 11 Z 12

Vn bn

62 (FAQ) Vi sp xp nhanh, sp xp trn, sp xp chn, sp xp ng, sp xp bc v, cc cu hi thng lin quan ti khi nim ca chng, bn cn hiu qu trnh sp xp d liu nh th no

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

45

1. Khoa hc my tnh c s

Phng php duyt ton b


Phng php duyt ton b (tm kim vt cn) l phng php trong xu cn tm c bng cch so snh tng k t t u dy. y l phng php ging vi tm kim tuyn tnh. Tm kim kt thc khi k t cui cng ca dy c so snh vi k t cui cng ca xu cn tm kim. V d sau gii thch c th cho phng php trn63 Vn bn Mu P X Q Y A Z B C Z X Y Z R X Y Z

(1) K t u tin ca mu c so snh vi k t u tin ca vn bn Vn bn Mu

P X

Q Y

A Z

(2) Do khng trng khp, k t th hai ca vn bn c so snh vi k t u tin ca mu Vn bn Mu

P X

Q Y

A Z

(3) Lp li qu trnh ny v n k t th 7 X xy ra trng khp Vn bn Mu

X X

Y Y

Z Z

(4) V c 1 s tng ng, tip theo k t th 8 ca vn bn c so snh vi k t th hai ca mu Vn bn Mu

X X

Y Y

Z Z

(5) V cp th hai cng trng khp, k t th ba c so snh Vn bn Mu

X X

Y Y

Z Z

By gi chng ta xc nhn rng mu k t S nm trong xu k t R

63 (Gi ) Trong tm kim xu, cn 1 ch s cho xu S v 1 ch s khc cho xu R. Khi tr li cu hi, im ct yu l nm vng cch lm th no s dng cc ch s

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

46

1. Khoa hc my tnh c s

Phng php Boyer-Moore


y l mt phng php ly ni dung ca xu mu trong vn bn b qua nhng phn v gi tr. Nu mu v 1 xu ca vn bn khng trng khp, s k t c th nhy qua da trn k t ngoi cng bn phi ca khong tm kim ca vn bn c so snh Ta gii thch chi tit dng v dng nh trong tm kim vt cn (1) Nu k t ngoi cng bn phi ca phn vn bn ang c so snh vi chui l X, v tr tip theo c kh nng m mu c th trng l sau 2 k t, nn 2 k t tip theo c nhy qua (2) Nu k t ngoi cng bn phi ca phn vn bn ang c so snh vi chui l Y, v tr tip theo c kh nng m mu c th trng l sau 1 k t, nn k t tip theo c nhy qua (3) Nu k t ngoi cng bn phi ca phn vn bn ang c so snh vi chui l Z, v tr tip theo c kh nng m mu c th trng l sau 3 k t, nn 3 k t tip theo c nhy qua
Vn bn Trc khi chuyn Sau khi chuyn di di ***X*** XYZ XYZ Vn bn Trc khi chuyn Sau khi chuyn di di ***Y*** XYZ XYZ Vn bn Trc khi chuyn Sau khi chuyn di di ***Z*** XYZ XYZ

(4) Nu k t ngoi cng bn phi ca phn vn bn khng phi l X, Y hoc Z th tnh hung ging ht vi (3), nn 3 k t tip theo c nhy qua64

(Ch ) Trong phng php BM, cn tng tnh ton s k t c nhy qua. V d tho lun y c mu 3 k t, nn s l 2 cho X, 1 cho Y v 3 cho Z hoc bt k k t no khc. Nhng iu ny cn c tnh ton trc khi bt u tm kim xu Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

64

47

1. Khoa hc my tnh c s

1.4.4 Cc gii thut trn th


im chnh
Cy l mt dng th. Th t trn cy tm kim c th l u tin chiu rng hoc u tin chiu su

Mt gii thut trn th l mt gii thut m php tm kim c thc hin trn mt cy, mt cu trc d liu hng cu hi. Da trn th t tm kim, gii thut trn th c th l u tin chiu rng hoc u tin chiu su. Gii thut u tin chiu su thng xut hin trong thi, do phi m bo rng bn hiu r cch ly cc nt trong gii thut ny, Mt th c to thnh bi cc nt v cnh. Mt nt l mt nh ca th v cnh l on ni gia 2 nh. y l v d v 1 th.65
Nt Cnh

Mt cy c th coi l mt th trong khng phi tt c cc nt c ni vi tt c cc nt khc.

Th t u tin chiu rng


Php tm kim bt u gc v duyt ngang qua cc nt mc thp t tri sang phi. Trong v d di y, s cc nt xc nh th t m nt c duyt qua.

65 (Gi ) Khi nghe thut ng th, bn ngh ti 1 biu hnh trn, 1 biu ct nhng trong th gii ton hc n ni ti 1 tp cc nh v cnh

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

48

1. Khoa hc my tnh c s

Th t u tin chiu su
Trong tm kim u tin chiu su66, chng ta bt u gc, duyt t cy con tri ri t l. Da trn thi im m cc nt c duyt, ta c th chia lp nh bng di Phng php duyt Duyt trc Duyt gia Duyt sau Th t duyt cc nt Th t: cha, con tri, con phi Th t: con tri, cha, con phi Th t: con tri, con phi, cha

Trong hnh di, s trn cc nt xc nh th t m nt c duyt Duyt trc Duyt gia Duyt sau

Cc lut cho mi php tm kim c th cha tht s r rng, chng ta s a thm mt s gii thch. Trong php tm kim u tin chiu su, th t tm kim nh hnh di

Trong th t duyt trc, gi tr ca cc nt c ly ra khi duyt qua bn tri ca nt . V th,th t s l + - a b / * c d e. Trong th t duyt gia, gi tr cc nt c ly ra khi duyt qua bn di ca nt. V th th t s l a b + c * d / e. Trong th t duyt sau, gi tr mi nt c truy cp khi duyt qua bn phi ca nt. Do , th t l a b c d * e / +.67

(FAQ) Cu hi duyt theo chiu su thng xut hin trong bi thi, hy hiu r cc nt c ly ra nh th no trong th t duyt trc, duyt gia, duyt sau. 67 (Ch ) Ch kt qu php duyt cy ly cc k hiu v cc bin. Trong duyt trc, kt qu l + a b / * c d e, chnh l k php Ba Lan. Trong duyt gia, kt qu l a b + c * d / e, l dng cng thc ton hc chun. Trong duyt sau, kt qu l a b c d * e / + chnh l dng k php Ba Lan ngc. Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

66

49

1. Khoa hc my tnh c s

Cu hi nhanh
Q1 Trong tm kim nh phn, khi s lng d liu sp xp tng gp 4 ln th s lng php so snh ti a tng bao nhiu? Q2 Trnh by c im ca cc phng php sp xp: shell short, bubble sort, quick sort, and heap sort.

A1 2 ln Khi s lng d liu tng 4 ln, thay th n trong cng thc log2 n + 1 s lng php so snh ti a bng 4n. log2 4n + 1 = (log2 4 + log2 n) + 1 = log2 22 + log2 n + 1 = 2 + log2 n + 1 = 2 + (log2 n + 1) A2 Sp xp Shellsort: Phn t ca mng c ly chnh gia v c sp xp, sau cc phn t c ly bng cch gim khong cch v c sp xp. Sp xp ni bt: Cc phn t lin nhau c so snh v i ch nu khng ng th t, qu trnh ny c lp i lp li. Sp xp nhanh: Chn mt gi tr ( gia) lm gi tr tham chiu, mng c chia thnh tp cc phn t ln hn v tp cc phn t nh hn gi tr tham chiu. Vi mi phn, qu trnh trn c lp i lp li. Sp xp ng: Phn cha c sp xp c biu din di dng cy con, t gi tr ln nht (hoc nh nht) c ly ra v a vo phn c sp xp. Qu trnh ny c lp i lp li gim dn phn cha c sp xp

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

50

1. Khoa hc my tnh c s

Cu hi 1
Q1.

kh: **

Tn sut: ***

C 1 thanh ghi nh phn. Sau khi nhp 1 s nguyn dng x vo thanh ghi ny, thao tc dch thanh ghi sang tri 2 bit ri cng thm x c thc hin. Hi gi tr thanh ghi gp my ln x. Gi thit khng xy ra trn trong qu trnh dch.

a) 3

b) 4

c) 5

d) 6

p n cu 1
p n ng: c
Tng qut, nu khng b trn, php dch n bit sang tri nhn gi tr vi 2n trong khi php dch n bit sang phi nhn gi tr vi 1/2n. Dch sang tri 2 bit l nhn vi 22, nu y l kt qu ca php tnh, y lin h vi x bng phng trnh. y = x 22 + x = x ( 2 2 + 1) = 5 x (y is 5 times x) a) to s ln gp 3 ln x, ta ch cn dch gi tr thanh ghi sang tri 1 bit v cng thm x. Dch 1 bit sang tri nhn gi tr vi 21, kt qu s nh sau

y = x 21 + x = 2 x + x = 3 x
b) to s ln gp 4 ln, chng ta dch thanh ghi sang tri 2 bit, gi tr ban u s c nhn vi 22. Kt qu s l

y = x 22 = 4x
d) to s ln gp 6 ln, ta dch thanh ghi gi tr sang tri 2 bit v cng gi tr ny vi gi tr thu c bng cch dch thanh ghi gi tr ban u sang tri 1 bit. Dch 2 bit sang tri nhn gi tr vi 22 v dch sang tri 1 bit nhn gi tr vi 21, nn kt qu s l

y = x 2 2 + x 21 = 4 x + 2 x = 6 x

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

51

1. Khoa hc my tnh c s

Cu hi 2
Q2. M t no sau y thch hp vi trit tiu ch s c ngha. a)

kh: *

Tn sut: ***

N ngha l s ch s c ngha suy gim trm trng khi mt s du phy ng b tr bi s khc gn bng n b) N tham chiu ti mt li xy ra bi kt qu php tnh vut qu gi tr s ln nht c th x l c) N tham chiu ti mt li xy ra khi lm trn (trn hoc di) s nh hn ch s c ngha thp nht khi s lng ch s trong biu din s hc b gii hn c) N tham chiu ti b qun ch s c trng s thp trong 1 php ton khi cng cc s du phy ng

p n cu 2
p n ng: a
Trit tiu ch s c ngha l hin tng cc ch s c ngha b mt trong php tr 2 gi tr cng du gn bng nhau v trong php cng 2 gi tr ngc du c gi tr tuyt i gn bng nhau. N xy ra do my tnh ch x l cc s c hu hn ch s. V d, n xy ra trong php tnh sau: 123.4567 123.4556 0.0011 y, ch s c ngha cao nht bng 0, s ch s c ngha suy gim nghim trng b) M t trn s c) M t li lm trn d) M t mt ch s ui

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

52

1. Khoa hc my tnh c s

Cu hi 3
Q3.

kh: ***

Tn sut: ***

Bng chn l di y l kt qu ca php ton logic x @ y. Biu din no sau y l tng ng vi php ton ny x y x@y True True False True False False False True True False False False a) c) x OR (NOT y) (NOT x) AND (NOT y) b) d) (NOT x) AND y (NOT x) OR (NOT y)

p n cu 3
p n ng: b
Trong cc php ton logic, ta gn 1 cho ng v 0 cho sai. D dng hn nu s dng k php quen thuc, ta s s dng cc k hiu sau

x y (tch logic) x AND y x OR y x + y (tng logic)


NOT x

x (ph nh logic)

Vy, biu thc logic trong p n c th vit li nh sau: a) x OR (NOT y) b) (NOT x) AND y c) (NOT x) AND (NOT y) d) (NOT x) OR (NOT y)

x+ y x y x y x+ y

Ta kim tra xem biu thc no trong nhm p n trng khp (c kt qu ging) vi php ton logic c a ra: a) b) c) d)

x
1 1 0 0

y
1 0 1 0

x
0 0 1 1

y
0 1 0 1

x+ y
1 1 0 1

x y
0 0 1 0

x y
0 0 0 1

x+ y
0 1 1 1

x@y 0 0 1 0

Do , php ton c kt qu trng vi x @ y l x y .

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

53

1. Khoa hc my tnh c s

Cu hi 4
Q4.
<gi tr <gi tr

kh: **

Tn sut: **

C php cho cc <gi tr s >?


s > ::= <chu

s > c nh ngha nh sau, biu thc no sau y xem nh

i s >|<chu i s >E<chu i s >| <chu i s >E<d u><chu i s > <chu i s > ::= <ch s >|<chu i ch s > <ch s > <ch s > ::= 0|1|2|3|4|5|6|7|8|9 <d u> ::= +|-

a) 12

b) 12E10

+12E10

d) +12E10

p n cu 4
p n ng: b
Cu tr li tun theo dng th 3 (<chui s> E <du> <chui s>) ca nh ngha <gi tr s>. Kiu nh ngha ny c gi l k php BNF. K php BNF c s dng nh 1 cch biu din chnh thc c php ca 1 ngn ng lp trnh Tng quan k php BNF nh sau: ::= K hiu bn tay tri c nh ngha bi k hiu bn tay phi . Ni cch khc, = . < > K hiu ny biu th bin . <> c th b qua | Ngha l hoc ::= | ngha l ::= or .. ::= c th vit n gin l = a) c) Trong nh ngha <gi tr s>, (<du>) phi nm sau E. Phn gch chn khng tha mn nh ngha 12 Trong nh ngha <gi tr s>, + (<du>) phi nm sau E. Phn gch chn khng tha mn nh ngha +12E 10

Trong nh ngha <gi tr s>, + (<du>) phi nm sau E. Phn gch chn khng tha mn nh ngha +12E10

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

54

1. Khoa hc my tnh c s

Cu hi 5
Q5.

kh: **

Tn sut: **

1 kha c to bi 3 k t alphabe. Khi gi tr bm h c quyt nh vi biu thc sau, kha no s xung t vi kha SEP? y a mod b biu din s d khi a chia cho b h = (Tng v tr ca cc ch ci) mod 27 Bng ch ci A B C D E F G H I J K L M V tr 1 2 3 4 5 6 7 8 9 10 11 12 13 Bng ch ci N O P Q R S T U V W X Y Z V tr 14 15 16 17 18 19 20 21 22 23 24 25 26

a) APR

b) FEB

c) JAN

d) NOV

p n cu 5
p n ng: b
Mt kha bm l kt qu bin i kha bi 1 hm bm, c s dng cho qu trnh bm. Thut ng hashing- qu trnh bm/gii thut bm ni ti 1 qu trnh thc hin cc php tnh trn kha bin i n thnh 1 gi tr a ch ly a ch lu tr ca bn ghi trong file. y hm c s dng ly a ch c gi l 1 hm bm. Nu gii thut bm sinh ra gi tr bm ging nhau cho hoc nhiu kha khc nhau, iu gi l xung t. Cc bn ghi sau khi 1 xung t xy ra gi l ng ngha. Tnh gi tr bm cho SEP bng hm bm cho, ta thu c kt qu sau: h = (tng v tr ca mi ch ci c s dng trong kha) mod 27 = (19 + 5 + 16) mod 27 = (40) mod 27 = 13 (40 27 = 1 d 13) a) ARP (1 + 18 + 16) mod 27 = 8 (35 27 = 1 d 8) b) FEB (6 + 5 + 2) mod 27 = 13 (13 27 = 0 d 13) ng c) JAN (10 + 1 + 14) mod 27 = 25 (25 27 = 0 d 25) d) NOV (14 + 15 + 22) mod 27 = 24 (51 27 = 1 d 24)

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

55

1. Khoa hc my tnh c s

Cu hi 6
Q6.

kh: **

Tn sut: **

Cho ng di y, gi tr ca nt cha nh hn gi tr ca cc nt con. Khi chn 1 nt vo ng ny, 1 phn t c thm vo cui cng. Nu phn t nh hn nt cha, cha v con phi chuyn ch cho nhau. Nu phn t 7 c thm vo ng v tr c nh du (*), phn t no s nm v tr A.
9 11 14

A
24 29 34 25 19 28

*
c) 24 d) 25

a) 7

b) 11

p n cu 6
p n ng: b
Thm phn t vo v tr cho sau lp li th tc chuyn ch cha v con khi phn t con c gi tr nh hn gi tr ca cha. 7 c thm vo y

i ch

i ch

i ch

By gi, ng hon thnh. Do phn t v tr A (

) l 11

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

56

1. Khoa hc my tnh c s

Cu hi 7
Q7.

kh: *

Tn sut: ***

Thut ng no sau y biu din c im ca cc thao tc trn ngn xp

a) FIFO

b) LIFO

c) LILO

d) LRU

p n cu 7
p n ng: b
Ngn xp l 1 cu trc d liu dng Last-In First-Out, vi d liu c lu tr cui cng s c ly ra u tin. Thao tc chn d liu vo ngn xp c gi l push v thao tc ly d liu khi ngn xp c gi l pop a) FIFO l cu trc d liu ca hng i vi d liu c lu tr u tin s c ly ra u tin b) LILO (LInux LOader) l 1 b np khi ng (chng trnh np h iu hnh vo b nh) cho php PCs hiu Linux c) LRU ngha l c truy cp t nht trong giai on gn y v c s dng nh 1 gii thut thay trang trong h thng b nh o. y l phng php thay trang b i trang c truy cp t nht

Cu hi 8
Q8.

kh: **

Tn sut: **

Bng quyt nh di y to cc bo co t tp nhn vin. iu g di y c th kt lun t bng quyt nh ny

Di 30 tui Nam kt hn Xut ra bo co 1 Xut ra bo co 2 Xut ra bo co 3 Xut ra bo co 4

Y Y N

Y N Y X

N Y Y

N N N

a) Bo co 1 cha ni dung ca Bo co 4 tr d liu ca nam t 30 tui tr ln b) Bo co 2 cha tt c nam cha ly v c) Nam trong bo co 3 nm trong bo co 2 d) Nhng ngi trong bo co 4 khng nm trong bt k bo co no khc

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

57

1. Khoa hc my tnh c s

p n cu 8
p n ng: d
C ph nh ca kt hn l cha kt hn v ph nh ca nam l n. c m t v p n cn thn. Trong cc gii thch di y, phn gch chn l ph nh (N) a) iu kin tha mn cho bo co 1 l di 30, khng phi nam, kt hn di 30, n, kt hn iu kin tha mn cho bo co 4 l khng di 30, nam, kt hn ti thiu 30, nam, kt hn Nn, bo co 1 ch cha n. Bo co 4 ch cha nam v b i iu kin nam, ti thiu 30 Report 4 lm n tr thnh tp rng. Do vy, m t ny l sai b) iu kin tha mn bo co 2 l khng di 30, khng phi nam, cha kt hn ti thiu 30, n, cha kt hn Nn bo co 2 ch cha n, n khng ng vi mnh tt c nam cha kt hn. Vy m t ny l sai c) iu kin tha mn bo co 3 l di 30, nam, cha kt hn iu kin tha mn bo co 2 l khng di 30, khng phi nam, cha kt hn Nn, bo co 3 cha ch cha nam trong khi bo co 2 ch cha n. M t ny l sai d) Bng cch loi tr, y phi l cu tr li ng, nhng chng ta s kim tra n. T chc tt c cc tiu chun ca tt c cc bo co cu a, b, c trong p n, ta c: Bo co 1: di 30, n, kt hn (t a) Bo co 2: ti thiu 30, n, cha kt hn (t b) Bo co 3: di 30, nam, cha kt hn (t c) Bo co 4: ti thiu 30, nam, kt hn (t a) iu kin ti thiu 30 ca bo co 4 cng ng vi bo co 2, nhng iu kin khc l ph nh ca nhau, nn khng ngi no nm trong c 2. Ngoi ra iu kin nam ng vi bo co 3, nhng iu kin khc l ph nh ca nhau. Tng t, iu kin kt hn ng cho bo co 2, nhng iu kin khc l ph nh ca nhau. Nn, khng c bo co no cha ngi trong bo co 4. y l m t ng

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

58

1. Khoa hc my tnh c s

Cu hi 9
Q9.

kh: **

Tn sut: ***

Lu di minh ha gii thut Euclide tm c chung ln nht ca A v B bng cc lp li php tr. Khi A l 876 v B l 204, c bao nhiu php so snh c thc hin trong qu trnh ny

Start

Output A, B, L End

a) 4

b) 9

c) 10

d) 11

p n cu 9
p n ng: d
Gii thut Euclide l gii thut tm c s chung ln nht ca 2 s nguyn A v B. Tuy vy bn khng cn hiu gii thut ny, ch cn hiu d liu thay i nh th no. u tin gn A L v B S, gi tr ca c chung ln nht t c l L v S. Gii thut qut nh u l s ln hn v tr n cho s nh hn. Khi L=S gii thut kt thc Vi khi to A=876 v B=204, ta tr B (=S) t A (=L) nhiu ln. Ch rng gi tr cn c so snh trc khi tr (1) Vi iu kin L=876 v S=204, lp li php tr n khi L<S. Do 876 204 = 4 d 60, php tr v thay th L S L c thc hin 4 ln trc khi L < S tha mn. Do so snh (L, S) xy ra 4 ln (2) Vi iu kin L=60 v S=204, lp li php tr n khi L>S. Do 204 60 = 3 d 24, php tr v thay th S L S c thc hin 3 ln trc khi L > S tha mn. Do so snh (L, S) xy ra 3 ln (3) Vi iu kin L=60 v S=24, lp li php tr n khi L<S. Do 60 24 = 2 d 12, php tr v thay th L S L c thc hin 2 ln trc khi L < S tha mn. Do so snh (L, S) xy ra 2 ln
Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

59

1. Khoa hc my tnh c s

(4) Vi iu kin L=12 v S=24, lp li php tr n khi L=S. Do 24 12 = 2 d 0, php tr v thay th S L S c thc hin 2 ln trc khi L = S tha mn. Do so snh (L, S) xy ra 2 ln (5) S ln php so snh L:S c tnh nh sau. Ta c th cng cc s t (1) n (4). Tng s php so snh = 4 + 3 + 2 + 2 = 11 ln

Cu hi 10

kh: ***

Tn sut: ***

Q10. Cc gii thut m t bng 2 lu di y c thc hin trn 1 s nguyn dng M, iu kin no cn chn thm vo bn tc sao cho nhn c cng kt qu x? Thao di
Start Start

Operation

Ch : M t lp trong vong lp gii hn c nh ngha nh sau Tn bin: Gi tr ban u, bc nhy, gi tr kt thc.

End a)

End b)

n>M

n>M+1

c)

n > M -1

d)

n<M

p n cu 10
p n ng: a
K php n: M, -1, 1 vng lp c ngha, nh gii thch trong cu hi, nh sau: ly gi tr khi to ca n l M v tr 1 mi ln lp v dng khi t gi tr 1. iu ny ngha l gi tr ca n thay i t M, M-1, , 2, 1 Hy xem xt lu bn tri trc. Bt u vi n = M, v gim gi tr i 1 trong mi vng lp n khi nhn gi tr l 1 ( n = M, M 1, , 2, 1), thao tc sau x n x c thc hin bn trong vng lp. Khi 1 x, gi tr khi to ca x l 1. Ta hy theo di gi tr ca x thay i nh th no khi n thay i n=M: x n = 1 M = M x = M (Gi tr ca x i thnh M.) n=M 1 : x n = M ( M 1) = M ( M 1) x = M ( M 1)

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

60

1. Khoa hc my tnh c s

n=M2: x n = M ( M 1) ( M 2) = M ( M 1)( M 2) x = M ( M 1)( M 2) V tip tc

(Gi tr ca x i thnh M(M 1).)

(Gi tr ca x i thnh M(M 1) (M 2).)

n= 2: x n = M ( M 1)( M 2)...2 x = M ( M 1)( M 2)...2 n=1: x n = M ( M 1)( M 2)...2 1 x = M ( M 1)( M 2)...2 1 = M ! (M giai tha) Kt qu tnh M ( M 1) ( M 2) ... 2 1 . Vi 1 gi tr nguyn M, tch M ( M 1) ( M 2) ... 2 1 c gi l M! (M giai tha) Xem xt lu bn phi. n thay i t 1, 2, , M v ph trnh x n x c lp trong vng lp. Lu tnh giai tha bt u t 1. Hy theo di xem x thay i nh th no vi i vi gi tr n. Nh trong lu bn tri, gi tr khi to ca x l 1. Hn nam mi ln vng lp c thc hin, gi tr ca n tng thm 1. Phn gch chn trong mi dng di l gi tr tip theo ca x n=1: x n = 1 1 = 1 x (x = 1) n=2: x n = 1 2 x (x = 1 2 ) n=3: x n = 1 2 3 x (x = 1 2 3 ) n=4: x n = 1 2 3 4 x (x = 1 2 3 4 ) Hy xem n ln bao nhiu to kt qu ging nh kt qu ca lu bn tri. Lu bn tri lp x n x thc hin tnh ton di Lu bn tri = M ( M 1) ( M 2) ... 2 1 y php nhn bt u vi M; bn phi, php nhn bt u vi 1. Do , nu php nhn tip tc n M, kt qu ca 2 lu s bng nhau Lu bn phi = 1 2 3 ... M Th nn ta phi lp x n x n khi n = M. Theo lu , sau lnh x n x , chng trnh thc hin n + 1 n , nn sau n = M c nhn, ta s c n = (M+1). iu ny ngha l chng trnh cn kt thc khi n=M+1 xy ra. Cc la chn trong nhm p n, iu kin ny l n>M.

Ti liu n thi FE Tp 1
-- Phn1. n tp phn thi bui sng --

61

Cc h thng my tnh

Tng quan
Mt h thng my tnh gm c phn cng v phn mm. C nhiu loi my tnh, nhng nguyn tc hot ng ca chng v c bn l ging nhau. Chng ta s hc v cu to ca my tnh (phn cng) trong phn 1 v phn mm (h iu hnh) cho cc my tnh hiu nng cao trong phn 2. Chng ta cng s hc v cu hnh ca h thng my tnh cho vic ci thin tnh tin cy trong phn 3 v cch nh gi hiu nng ca my tnh trong phn 4. Cui cng trong phn 5 chng ta s hc v cc h thng m s dng my tnh.

2.1 2.2 2.3 2.4 2.5

Phn cng H iu hnh Cng ngh cu hnh h thng Hiu nng v tin cy ca h thng Cc h thng ng dng

[Cc thut ng v khi nim cn bit] n v x l trung tm (CPU), b nh m, giao tip vo/ra, b nh h tr, qun l tc v, qun l cng vic, a lp trnh, b nh o, h thng kp, h thng song cng, h thng khch/ch, tnh sn sng, MTBF, MTTR, Internet

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

62

2. Cc h thng my tnh

2.1 Phn cng


M u
Phn cng l cc thit b cu to nn my tnh. My tnh bao gm khi x l, b nh, cc khi vo ra Phn ny s xem xt cc khi ny trn quan im ca phn cng.

2.1.1 Cc phn t thng tin (B nh)


im chnh
Phn t thng tin gm c ROM v RAM SRAM v DRAM l hai loi tiu biu ca RAM

B nh bn dn l b nh c lm t cc mch tch hp (ICs) s dng cht liu bn dn. B nh bn dn bao gm ROM b nh khng th ghi li c v RAM b nh c th ghi li c

ROM (B nh ch c)
ROM l b nh bn dn m d liu khng b xa khi mt in1. Vi Mask ROM v PROM th d liu ch c ghi mt ln; tuy nhin EPROM d liu c th c ghi nhiu ln s dng mt phng php c bit. Phn loi v c im ca ROM c trnh by trong bng di y
Loi (Tn) Mask ROM PROM (ROM lp trnh c) EPROM (PROM c th xa) EEPROM (Electrically EPROM) Flash memory 2 (B nh cc nhanh) c im D liu c ghi vo ti thi im sn xut. D liu khng th ghi li c sau . D liu PROM c ghi bi ngi dng trong ln u tin s dng. D liu khng th ghi li c cc ln sau. D liu EPROM c ghi bi ngi dng bng in. Ton b d liu c th xa c bng cch s dng tia t ngoi. Ton b d liu c th xa v ghi li c. D liu c xa bng in. Vic xa v ghi li c thc hin mt cch tp trung hoc theo khi. D liu c xa bng in.

1 Tnh kh bin v tnh bt bin: Thuc tnh lm cho ni dung ca b nh b mt khi mt in c gi l tnh kh bin. RAM l loi b nh c tnh kh bin. Ngc li thuc tnh lm cho ni dung ca b nh khng b mt khi mt in gi l tnh bt bin. ROM l loi b nh c tnh bt bin. 2 (Gi ) B nh Flash c phn loi nh EEPROM.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

63

2. Cc h thng my tnh

RAM (B nh truy cp ngu nhin)


RAM l b nh bn dn m ni dung ca n s b mt khi mt in. Khc vi ROM, ni dung ca RAM c th thay i c v vy n c dng cho b nh chnh, b nh ha3 v b nh m. Hai loi RAM thng thng l SRAM v DRAM. c im ca SRAM v DRAM c tng hp v a ra trong bng di y
Cc mc so snh Mc tch hp Tc truy cp Gi thnh Cch dng Hot ng Cu trc SRAM Thp (dung lng nh) Nhanh t B nh m4, Cc thit b hot ng bng pin Khng cn phi lm ti Flip-flop Cu trc phc tp DRAM Cao (dung lng ln) Chm Khng t B nh chnh Cn phi lm ti. T in v cc transistors Cu trc n gin

SRAM (RAM tnh) SRAM c to thnh t cc flip-flop5, v vy khng cn thao tc lm ti v c th tng tc c v ghi thng tin. Tuy nhin gi thnh SRAM cao hn DRAM vi cng mt dung lng do cu trc ca SRAM phc tp hn so vi DRAM. V l do ny n c dng ch yu nhng ni cn tc cao, khng quan trng gi thnh, nhng ni quan trng, v d nh trong b nh m. SRAM cng thng c s dng trong cc thit b hot ng bng pin. DRAM (RAM ng) DRAM c to thnh t cc t in v cc transistor, biu din vic c hoc khng c in tch trong t in bi cc logic 1 v 0. Sau mt thi gian th in tch trong t in s b mt i, l nguyn nhn dn n mt d liu. Do DRAM cn c ghi li (lm ti li) trong nhng khong thi gian nht nh (c mi vi mili giy). V cu trc ca DRAM n gin hn, gi thnh sn xut thp nn c s dng ch yu trong b nh chnh ca my tnh PC6. Cc loi DRAM c trang b chc nng trao i d liu tc cao gm c SDRAM v DDRAM

B nh ha: l b nh c s dng khi nh hay k t c hin th trn mn hnh s dng mt my tnh. N cng c gi l b nh video (VRAM). 4 B nh m: l b nh tc cao nm gia b nh chnh v CPU tng tc c d liu t b nh chnh n CPU. 5 Flip-flop (cn gi l mch 2 trng thi): L mt mch in vi 2 trng thi n nh, n gi cc trng thi cho n khi c mt u vo lm thay i mt trong cc trng thi . 6 (FAQ) Thng xuyn c nhng cu hi so snh gia SRAM v DRAM. Bn cn bit v mc tch hp, cch s dng, cu trc... Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

64

2. Cc h thng my tnh

2.1.2 Kin trc b x l


im chnh
My tnh bao gm 5 khi chnh C rt nhiu phng php nh a ch nh nh a ch trc tip, nh a ch gin tip...

Thut ng kin trc y cn lin quan n cu trc hay t chc. Kin trc b x l cng lin quan n cu hnh v cc hot ng c bn ca my tnh

Cu hnh ca my tnh
Hnh di y ch ra cu hnh c bn ca mt my tnh. Cu hnh ny c gi l 5 khi ln hay 5 chc nng ln7 bi v c 5 thnh phn chnh
Khi x l
Khi iu khin

Lung iu khin Lung d liu

Khi tnh ton Khi vo B nh B nh chnh B nh ngoi Khi ra

Khi iu khin v khi tnh ton kt hp vi nhau gi l khi x l hay khi x l trung tm (CPU).

S tnh ton a ch v cc phng php nh a ch


Mt chng trnh c lu trong b nh chnh v c thc hin theo tng lnh bi khi iu khin. S tnh ton a ch xc nh v tr ca d liu cn c x l. S tnh ton a ch l chc nng ly v a ch thc da trn trng a ch cho trong lnh. Phng php tnh ton a ch c gi l phng php nh a ch. a ch truy cp thc s, kt qu ca php tnh ton a ch c gi l a ch hiu dng. Cc phng php nh a ch c m t chi tit di y

5 khi ln: Khi iu khin: L khi iu khin ton b my tnh. N c lnh t b nh chnh v gi n cc khi cn thit thc hin lnh Khi tnh ton: L khi thc hin cc php tnh ton s hc, cc php tnh ton logic, v cc php tnh ton khc. N bao gm cc b cng, cc thanh ghi, cc b o (n v m chuyn i cc gi tr sang gi tr o ca chng), ... B nh: Thut ng chung ca cc khi lu tr d liu, chng trnh, ... c phn loi thnh b nh chnh v b nh ngoi (b nh ph). Khi vo: Thut ng chung ca cc khi m nhp chng trnh v d liu vo my tnh. Khi ra: Thut ng chung ca khi m a ra cc kt qu x l ca my tnh di dng k t hoc con s m chng ta c th nhn bit c.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

65

2. Cc h thng my tnh

Phng php nh a ch trc tip Trong phng php ny, ni dung nh c lu tr trong trng a ch ca lnh l d liu cn thao tc.
Phng php nh a ch trc tip Trng lnh Trng a ch x

a ch

B nh chnh

0 1 2 x

Phng php nh a ch gin tip

Trong phng php ny, ni dung nh c lu tr trong trng a ch ca lnh cha phi l d liu cn thao tc; M d liu c lu tr ti a ch c ch ra bi ni dung mi l d liu cn thao tc.
Phng php nh a ch gin tip Trng lnh Trng a ch x

a ch

B nh chnh

0 1 x y
Phng php nh a ch ch s (thay i ch s) Trong phng php ny, a ch hiu dng c tnh bng tng gi tr ca a ch (lu trong trng a ch ca lnh) vi gi tr ca thanh ghi ch s. 8 V d, khi x l mt mng, chng ta c th tham chiu ni dung ca cc a ch khc n gin bng cch thay i ni dung ca thanh ghi ch s. 9
Phng php nh a ch ch s Trng lnh i Trng a ch x Ch s
Thanh ghi ch s

a ch

0 1 y

0 1 x x+y

B nh chnh

8 Thanh ghi: L b nh dung lng thp, tc cao ni m d liu c lu tr mt cch tm thi. Thanh ghi c t trong CPU. C rt nhiu thanh ghi, bao gm: cc thanh ghi chung, cho vic lu tr tc thi v kt qu cui cng ca cc php ton; thanh ghi trng thi ch ra trng thi ca CPU sau khi mt lnh c thc hin; thanh ghi ch s cho vic tnh ton a ch; v thanh ghi c s. 9 (FAQ) C nhiu cu hi v khi nim ca cc phng php nh a ch. V d Cu no trong cc cu sau l m t ph hp ca phng php nh a ch trc tip? hy chc chn rng bn nm vng cc phng php ny: phng php nh a ch trc tip, phng php nh a ch ch s, phng php nh a ch tc th...

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

66

2. Cc h thng my tnh

Phng php nh a ch c s Trong phng php ny, a ch hiu dng l tng ca a ch c ch ra bi trng a ch ca lnh v ni dung ca thanh ghi a ch c s10
Phng php nh a ch c s Trng lnh B Trng a ch x Ch s Thanh ghi c s

a ch

0 1 B
Phng php nh a ch tc th

0 1 x

B nh chnh

b+y

Theo phng php ny th trng a ch ca lnh lu tr trc tip d liu cn x l, khng phi l a ch. 11

RISC v CISC
C rt nhiu loi cng ngh c s dng tng tc x l my tnh; RISC v CISC l nhng v d ca cng ngh ny. Vi s tin b ca cng ngh bn dn, mt tch hp ca cc mch tch hp tng ln mt cch lin tc. Hin ti, my tnh c lm t cc mch tch hp, v RICS v CISC l 2 cch tip cn cho vic pht trin cc my tnh. Cc my tnh c cu hnh cho tc cao vi tp lnh n gin v phn cng c n gin ha c gi l RISCs. Ngc li cu trc tp lnh phc tp c cu hnh trong mt mch c gi l CISCs. RISC (My tnh vi tp lnh rt gn) Cc my tnh ny ch c mt tp lnh n gin, cc lnh thng xuyn s dng c tch hp trong mt chip VLSI (tch hp mt rt ln) t c hiu nng cao thng qua vic ci thin tc x l v gim thi gian thc hin lnh. im ng lu ca kin trc RISC l di ca ca cc lnh l c nh v nh nhau, thi gian thc hin mi lnh cng c hn ch. Bng cch lm nh vy d dng p dng iu khin ng ng lnh(pipeline). Tuy nhin, s lng cc lnh phi thc hin tr nn ln tr khi cc chng trnh i tng c hiu sut cao c to, v vy trnh bin dch (compiler) cn thit phi c chc nng ti u ha12. Hu ht cc my tnh trm u thuc loi ny. CISC (My tnh vi tp lnh phc tp) Nhng my tnh ny c tp lnh phc tp c tch hp trn mt VLSI chip theo t c hiu nng ton b cao. Hu ht cc my tnh mc ch chung u c kin trc CISCs.

(Ch ) Phng php nh a ch c s c th c s dng khng cn ch ti chng trnh c lu u trong b nh, n gin bng cch thay i gi tr ca thanh ghi c s. Mt cu trc nh th c gi l cu trc c th xc nh li v tr. 11 (Gi ) Ch rng trong phng php nh a ch tc th khng ch nh a ch ca b nh chnh. 12 S ti u ha: l mt chc nng ca trnh bin dch b i nhng phn tha ca mt chng trnh gim thi gian thc thi ca chng trnh v kch c ca chng trnh. iu ny c thc hin bng nhiu cch, v d nh tnh ton hng s, n gin ha cc cng thc, v gim cc vng lp lng nhau.

10

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

67

2. Cc h thng my tnh

iu khin ng ng lnh
Chng ta cp RISC v CISC nh l nhng cng ngh ci thin tc x l ca my tnh. ci thin hn na tc x l, h thng RISC s dng iu khin ng ng lnh. iu khin ng ng lnh l mt k thut gim thi gian thc hin lnh ca CPU. Vic ny c thc hin nh sau: Cc bc thc hin ca mt lnh c chia ra lm 5 hoc 6 bc nh, v nu mi bc c hon thnh trong mt khong thi gian xc nh v cc bc lnh l c lp vi cc bc khc th chng ta c th ci thin tc x l bng cch tr vic thc hin mi lnh mt bc so vi lnh trc . Tuy nhin trong thc t, vic ghp ni lnh, s mt thi gian khi a ch lnh tip theo cha c xc nh, v mt vi bc khng th hon thnh trong mt khong thi gian c nh. iu khin ng ng lnh x l lnh mt cch ng thi v cung cp mt phng php tng tc ca my tnh mc d mi vic khng phi lc no cng hot ng theo ng tng 13
Thi gian

Th t thc hin

Lnh 1 Lnh 2 Lnh 3 Lnh 4

I1

I2 I1

I3 I2 I1

I4 I3 I2 I1

I5 I4 I3 I2 I5 I4 I3 I5 I4

I1 : Nhn lnh I2 : Gii m I3 : Tnh a ch I4 : Ly d liu I5 : Thc thi I5

2.1.3 Kin trc b nh


im chnh
Cu trc b nh phn cp c a ra t c tc cao v dung lng ln B nh m v k thut an xen c s dng tng tc truy cp b nh

C rt nhiu yu cu i vi b nh, nhng yu cu v tc cao v dung lng ln14 l nhng yu cu quan trng. Tuy nhin, ni chung l b nh tc cao th thng t v c dung lng nh trong khi b nh tc thp th gi thnh thp v c dung lng cao hn. Nh vy vic cn lm l kt hp b nh tc cao nhng dung lng nh vi b nh tc thp nhng dung lng ln to ra b nh c tc cao v dung lng ln.

13 (FAQ) Cc cu hi v iu khin ng ng lnh thng xut hin trong cc bi thi. Hu ht chng u dng chn mt m t ph hp vi iu khin ng ng lnh, v vy bn ch cn bit iu khin ng ng lnh thc thi lnh mt cch ng thi. 14 (Ch ) Bn cnh , yu cu i vi b nh bao gm tnh tin cy, kh nng truy cp ngu nhin, tnh bt bin, chc nng c th ghi li c, kh chuyn, gi thnh thp

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

68

2. Cc h thng my tnh

Phn cp b nh
Phn cp b nh l biu din phn cp ca mi quan h gia tc truy cp v dung lng lu tr ca cc loi b nh.15
t
Gi thnh

Nhanh

Chm

Thanh ghi B nh m16 B nh chnh B nh m cho a B nh ngoi (a cng, v.v) B nh dung lng ln (a quang, v.v)
Dung lng b nh

B nh m nhanh (cache)
B nh m (cache) l b nh tc cao, dung lng thp, nm gia CPU hoc thanh ghi v b nh chnh. Tc ca b nh chnh thp hn so vi tc ca CPU v thanh ghi, do tng hiu qu x l ca CPU th cc d liu v chng trnh truy cp thng xuyn trong b nh chnh c np vo b nh m. Gn y, ngi ta a thm mt b nh m ph vo ci thin hn na tc truy cp b nh. B nh m nm gia cng v b nh chnh c gi l b m a. Hnh di y m t mi quan h gia b nh m v b m a. Khi x l trung tm (CPU) B nh m B nh m mc 1 B nh m mc 217 B nh chnh B nh m a a cng

15 (Ch ) Nu t l thi gian truy cp b nh trung bnh, tm l thi gian truy cp b nh chnh, tc l thi gian truy cp b nh m, v h l t l hit, th ta c phng trnh sau: t = tch + tm(1 h). 16 T l hit: l xc sut m phn chng trnh cn thc thi chng trnh nm trong b nh m. 17 B nh m mc 2: B nh m chnh l b nh m c xy dng trong CPU; B nh m th 2 l b nh m nm gia m chnh v b nh chnh.

Tc

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

69

2. Cc h thng my tnh

K thut an xen (T chc b nh an xen)


B nh chnh c chia thnh rt nhiu khi nh gi l cc bng, v a ch c gn qua cc bng. Thng thng b nh chnh c truy cp thng qua mt di tun t ca a ch mt thi im do tc c th c tng cng bng cch truy cp ng thi mt di tun t a ch. V d ngay c khi bng 0 cha c d liu th bng 1 vn c th truy cp. Hnh di y l mt v d v an xen 4 (vi 4 bng nh)
a ch a ch
Bng 0 0 4 Bng 1 1 5 Bng 2 2 6 Bng 3 3 7

Khi x l trung tm (CPU)18

D liu v chng trnh c lu tr trn mt dy a ch (theo chiu ngang), nhng b nh c truy cp theo cc bng nh (theo chiu dc). iu ny cho php ng thi truy cp n mt di a ch.

2.1.4 Cc n v bng t
im chnh
S tnh ton dung lng theo h s khi (block) v mt bn ghi S tnh ton hiu nng khng bao gm thi gian dng

Bng t l phng tin lu tr d liu trn mt bng c nhim t tnh. Gi ca phng tin nh ny r v c dung lng ln, v vy n c dng cho cc thit b nh a cng.

Tnh ton dung lng


nh dng bn ghi ca bng t c ch ra di y. Ta c th nhn thy trong hnh ny, lu mt khi cn thm vo mt IBG (khong cch gia cc khi) l mt vng xc nh khi v cha m c bit. u c bng t c d liu theo cc khi, v vy vng ny quyt nh n vic xc nh ht mi khi.
Chiu di bn ghi Bn ghi 1 Bn ghi 2 Bn ghi 3 Chiu di khi Chiu di bng t cn lu tr mt khi
18 (FAQ) an xen l mt cch tng tc b nh. Cc cu hi v khi nim an xen cng thng xut hin trong bi thi v vy bn cn phi hiu khi nim ny.

IBG

Bn ghi n

IBG

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

70

2. Cc h thng my tnh

Gi s cc c t ca bng t c cho di y, tnh ton mt cch chnh xc s lng bn ghi c th c lu tr trn mt bng t ny19
[c trng ca tp] Chiu di bn ghi H s khi (block) 80 bytes 100 [c trng ca bng t] Mt bn ghi Khong cch gia cc khi (IBG) Chiu di bng t 64 bytes/mm 15 mm 730 m

Tnh chiu di khi H s khi l 100 100 bn ghi c th c lu tr trn mt khi Chiu di mt bn ghi 80 bytes Do tng s bytes L1 cho mi khi, khng tnh IBG l: L1 = 80 (bytes/record) * 100 (records/block) = 8,000 (bytes/block). Mt bn ghi l 64 bytes/mm 64 bytes c th c lu tr trn 1 mm ca bng t

Nn chiu di ca mt khi L2, khng k IBG l: L2 = 8,000 (bytes/block)/64 (bytes/mm) = 125 (mm/block). Do chiu di ca mt khi L3, k c IBG l: L3 = 125 (mm/block) +15 (mm/block) = 140 (mm/block).
80 bytes20 IBG Record 1 Record 2 Record 3 Record n 15mm IBG

L1=8,000 bytes, L2=125mm L3=140mm

Tng s bn ghi c th c lu tr trn mt bng t By gi chng ta s i tnh chnh xc tng s bn ghi c th c lu tr trn bng t (1) Tnh tng s khi c c th c lu tr trn bng t V chiu di ca bng t l 730 m (730 * 103 mm), tng s khi B1 c th c lu trn 1 bng t l: B1 = (Chiu di ca bng t) / (chiu di ca mt khi) = 730 * 103 / 140 = 5,214.2855,214 (blocks).21
19 (FAQ) Trong mi bi thi, c t nht mt cu hi v tnh ton dung lng hay hiu nng ca bng t hoc cng. Nu bn bit cch lm, bn c th tr li cu hi ny bi v s khc bit ch s liu. 20 (Gi ) Bn cnh bytes/mm, mt bn ghi cn c th c biu din bng ct / mm hoc bpi. Mt ct tng t nh 1 byte. bpi vit tt ca bytes / inch, l s ct trn inch. y cn c s chuyn i t inch sang mm, nhng bn cng khng cn phi nh cng thc chuyn i v cng thc s c a ra trong bi thi.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

71

2. Cc h thng my tnh

Phn phn s 0.285 nh hn 1 block nn chng ta b (2) Tnh tng s bn ghi c th c lu tr trn 1 bng t V 1 bng t c th lu 5214 khi, v mi khi c 100 bn ghi, tng s bn ghi c th c lu trn mt bng t B2 l: B2 = (Tng s khi trn bng t) * (h s khi) = 5,214 * 100 = 521,400 (records)

Tnh ton hiu nng


Tc chy ca bng t l khng i khi c v ghi d liu. Trn l thuyt, bng t bt u gia tc ti v tr chnh gia ca IBG v bt u c hay ghi d liu khi t c tc khng i. Khi bt gp mt IBG khc, bng t gim tc v dng li v tr chnh gia ca IBG.
Tc chy ca bng t
Khi ng

Thi gian

Dng

Chy ti tc khng i Tng tc

Tc khng i

Gi s cc c t ca bng t c cho di y, tnh thi gian bng t c 1 khi (block) d liu22 [c t bng t] Tc trao i d liu Chiu di bn ghi H s khi Thi gian bt u hay dng li Thi gian trao i mt khi d liu Thi gian trao i mt khi d liu c th tnh c bng cch chia chiu di ca khi cho tc trao i d liu Thi gian trao i d liu ca mt khi = (Chiu di mt khi) / (tc trao i d liu) Chiu di khi= (Chiu di bn ghi) * (h s khi) = 80 * 100 = 8,000 (bytes) Thi gian trao i d liu ca mt khi = 8,000 (bytes) / 320 (Kbytes/sec)
21 (Gi ) Phn thp phn ca s khi c loi b y, nhng trong thc t n tr thnh mt khi ngn hn, khi m c t bn ghi hn cc khi khc. 22 (Gi ) Trong tnh ton hiu nng, d liu c truyn theo khi, v vy chng ta khng cn quan tm n chiu di ca IBG.

320 Kbytes/sec 80 bytes 100 6 milliseconds

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

72

2. Cc h thng my tnh

= 8,000 / (320 * 103) = 25 * 10-3 (seconds) = 25 (milliseconds) Thi gian yu cu c mt khi d liu Chng ta cng thm thi gian bt u chy vi thi gian trao i d liu ca mt khi Thi gian yu cu c mt khi = (thi gian bt u) + (thi gian trao i d liu ca mt khi) = 6 (milliseconds) + 25 (milliseconds) = 31 (milliseconds) Ch rng thi gian bt u chy c cng vo nhng thi gian dng li th khng c cng. Khi bt u c, khng c d liu c trao i cho n khi bt u mt khi c c. Do thi gian cho n khi t c iu ny l phn thi gian ch i. Sau d liu c trao i, thi im vic trao i d liu hon thnh hot ng dng v x l chng trnh c thc hin ng thi. V vy khng cn phi cng thm thi gian dng.23

2.1.5 a cng
Ch im
Mt a cng c cu to t cc tr (cylinder) v rnh (track) a cng loi cung (sector) khng c IBGs.

a cng l mt phng tin truy cp ngu nhin v c ghi d liu tc cao, bao gm 1 n 10 a trn c ph cht liu t mt trc v mt sau ca a, quay vi tc cao. Nu ch c mt a n c gi l a mm24
Quay tc cao Mt s a khng ghi d liu trn mt nh v mt s mt y (cc mt bo v). Cc rnh (phn ng trn) Cc tr (phn tr) u c/ghi (Vng c v ghi d liu) Tay truy cp

(Gi ) Thi gian dng thng khng c a vo nh mt iu kin chun trong cu hi thi. (Ch ) Mt phng tin khc a mm, c th c v ghi v d dng mang i mang li l MO (a quang t), kh ph bin bi v dung lng ca n gp khong 600 ln dung lng ca a mm.
24

23

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

73

2. Cc h thng my tnh

Tnh ton dung lng


ng nh trn bng t, d liu c lu tr theo khi trn mt a cng. Tuy nhin, nu mt khi khng th in vo trong mt rnh, khi s khng th c lu.
Khi 1 IBG Khi 2 IBG IBG block n Khi n Khng c ghi

Chiu di rnh

u tin d liu c lu tr trn mt rnh v khi rnh c ghi d liu, tin trnh ghi n rnh tip theo l rnh nm trn ng trn tng ng ca b mt tip theo. Ni cch khc d liu c lu tr trn cc n v tr. Gi s rng c t ca mt a cng c cho di y, c bao nhiu tr thc s cn lu tr 100 000 bn ghi?
[c trng ca tp] Chiu di bn ghi H s khi [c t ca a cng] S tr trn a S rnh trn mt tr Tng s byte trn mt rnh Khong cch gia cc khi

250 bytes 8

400 19 13,000 135 bytes

Chiu di khi (B) B = (chiu di bn ghi) * (h s khi) + (khong h gia 2 khi) = 250 * 8 + 135 = 2,135 (bytes) Tng s khi c th c lu tr trn mt rnh (N) N = Chiu di rnh / 2,135 = 6.0086 (khi) ( ct b phn l) Chng ta ly chn kt qu v phn thp phn khng to thnh c 1 khi Tng s bn ghi c lu tr trn mt rnh (Rt) Rt = N * (h s khi) = 6 * 8 = 48 (records)

Tng s bn ghi c lu tr trn mt tr (RS) Rs = Rt * (s lng rnh trn mt tr) = 48 * 19 = 912 (bn ghi)

Tng s tr cn lu tr 100,000 bn ghi (S) S = (tng s bn ghi) / Rs = 100,000 / 912 = 109.649 110 (tr) (lm trn ln).

Ni chung, cc thng tin ghi trn a di dng gn vi cc n v tr, v vy nu c mt rnh

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

74

2. Cc h thng my tnh

no khng s dng trn tr th s lng tr s c lm trn n s nguyn tip theo.25

Tnh ton hiu nng


Thi gian truy cp a cng c tnh ton nh sau: Thi gian truy cp = Thi gian i + Thi gian trao i d liu = (thi gian tm kim + thi gian tr) + thi gian trao i d liu

Ch : Thi gian i (thi gian nh v + thi gian tr) i khi cng c gi l thi gian truy cp.

Thi gian tm kim l thi gian trong u c/ghi di chuyn n rnh ni c d liu c lu tr. Thi gian tr l thi gian cho n khi d liu cn c hoc ghi chuyn n v tr u c. Thi gian tm kim v thi gian tr c xc nh ph thuc vo vic u c ang v tr no, v vy chng ta s dng gi tr trung bnh. Trong cc cu hi v d, thi gian tm kim lun cho trc, v thi gian tr c th tnh theo thi gian ca mt vng quay, thi gian ny nhn c bng cch ngch o gi tr s vng quay trn mt n v thi gian. V thi gian tr ti thiu l 0 v ti a l thi gian mt vng quay nn thi gian tr trung bnh l khong thi gian na vng quay. Gi s cc c t ca a cng c cho sau y, tnh thi gian truy cp thc cho vic c d liu bao gm mt khi (5,000 bytes). [c t ca a cng]26 S vng quay ca a cng: Dung lng trn mt rnh: Thi gian truy cp trung bnh: Tnh ton thi gian tr trung bnh S vng quay ca a cng ny l 2,500 vng trn pht ngha l c mi pht n quay c 2,500 vng. Do thi gian quay c tnh nh sau: Thi gian 1 vng quay =(1 * 60,000 ms/pht) / 2,500 vng quay/pht = 24 ms/vng quay Cn ch cc n v ca cc i lng. Tc quay cho l s vng quay trn pht, trong khi thi gian quay tnh trn mili giy. Do chng ta cn chuyn i t pht sang mili giy (1 pht = 60s = 60,000 ms). V thi gian tr trung bnh bng thi gian 1 vng quay nn n l 12 miliseconds. Tnh ton tc trao i d liu V mt vng quay cho php trao i d liu trn mt rnh, nn 20,000 bytes c trao i trong vng 24 miliseconds. Do 20,000 /24 (bytes/ms) l tc trao i d liu. Chng ta c th tnh thng s ny, nhng v n khng chia ht nn ta c t s nh vy 2,500 vng trn pht 20,000 bytes 25 milliseconds

25 (FAQ) Trong mi bi thi, c t nht mt cu hi v tnh ton dung lng hay hiu nng ca bng t hay a cng. Nu bn bit cch lm bn c th tr li cu hi ny v s khc bit ch s liu. 26 Seek time/Latency time: seek time i khi cn c gi l thi gian xc nh v tr. latency time i khi cn c gi l thi gian tm.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

75

2. Cc h thng my tnh

Tnh ton thi gian trao i d liu Thi gian yu cu trao i 5,000 bytes c tnh nh sau: Thi gian trao i d liu = (Tng d liu cn trao i) / (Tc trao i) = 5,000 / (20,000 / 24) = 5,000 / 20,000 * 24 = 6 (msec) Tnh ton thi gian truy cp Thi gian truy cp = 25 msec + 12 msec + 6 msec = 43 msec S tnh ton trn l da trn tc quay ca a cng. Tuy nhin, b nh ph nh a cng hay bng t, s trao i d liu vi my tnh thng qua cc knh vo ra27. l l do ti sao cn phi ci t knh vo ra c tc ph hp vi tc trao i d liu28

Tnh ton dung lng ca cng da trn sector


Thut ng sector ni n cch cc phng tin t phn vng trn a mm hoc a cng. Mt sector l mt cung hnh qut trn a chia bi cc tia v t tm ca cc rnh theo cc phn bng nhau. Vo/ra ca phng tin lu tr kiu sector c thc hin theo n v sector (tng khi mt) v khng s dng IBG. Mi sector c th c lp y bi nhiu nht bn ghi c th v phn chia cn li ca sector th khng s dng.
Rnh t (Trn ng trn)

Cung t (hnh cung)

V d, gi s rng mi rnh t c 12 cung t, mi cung t c 1,200 bytes trn mt cng. lu tr d liu trn a vi chiu di bn ghi l 900 bytes, khng c cung t no d ra nh hnh di y
1,200 Sector Bn ghi 900 Bn ghi 900 3,600 3,600 1,200 Sector Bn ghi 900 1,200 Sector Bn ghi 900 3 cung t c s dng 4 bn ghi trong mt khi

27 28

Knh vo/ra: ng truyn d liu cho s trao i d liu gia b nh ph v my tnh (Gi ) Tc truyn d liu ca cng c xc nh bng tc quay ca a, v vy s khng c ngha khi dng mt knh truyn tc cao. Knh truyn c la chn theo tc truyn d liu ca a cng.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

76

2. Cc h thng my tnh

2.1.6 Cc thut ng lin quan n hiu nng/ RAID


im chnh
Lin quan n phng tin lu tr c mt vi thut ng nh thi gian truy cp, thi gian ch i, thi gian trao i d liu, thi gian nh v, thi gian tr. RAID l mt h thng rt nhiu cc a tng cng tnh tin cy v tng tc x l.

Mt vi thut ng lin quan n hiu nng ca cc thit b lu tr bao gm thi gian truy cp, thi gian ch i, thi gian trao i d liu, thi gian nh v, thi gian tr. RAID, i khi cn c gi l dy cc a l phng php iu khin rt nhiu a lm vic song song nh th chng ch l mt a.

Thut ng lin quan n hiu nng


Hnh di y m t cc thi gian x l quan h vi nhau nh th no, bt u ti thi im S khi mt khi x l yu cu vo ra n a cng n thi im T khi d liu c trao i hon tt Thi gian truy cp Thi gian ch i
Thi gian tm kim

Thi gian trao i

Thi gian tr S Yu cu vo/ra T Trao i hon thnh

Bi v u c di chuyn n rnh mong mun trong khi a ang quay nn thi gian quay v thi gian di chuyn chng lp ln nhau mt phn29. Tuy nhin trong cc v d IT, s chng lp ny lun c l i do khng c vn g khi nh ngha thi gian ch i nh sau: Thi gian ch i = thi gian tm kim + thi gian tr

RAID (Redundant Array of Independent Disks)


RAID din t b lu tr h tr, trong rt nhiu a cng lm vic song song v c iu khin nh th l ch c 1 a cng v vy tc vo ra c ci thin v tin cy c th c nng cao. i khi thut ng RAID cng ni n cc b lu tr ph hay mt phng php. RAID c gng tng tc x l bng cch dn tri cc khi d liu trn nhiu a cng v c cc khi d liu mt cch ng thi.

29 (Gi ) Mt cng quay vi mt u t tip xc vi rnh, v vy thi gian nh v v thi gian tr chng lp ln nhau mt phn.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

77

2. Cc h thng my tnh

B nh chnh Khi Khi Khi Khi a 1 a 2 a 3 a 4

RAID c 6 cp c m t di y, t RAID0 n RAID5 RAID0 y l phng php ghi cc khi d liu vi mt kch c c nh trn nhiu cng. Truy cp khng b tp trung vo mt n v, v vy thi gian vo/ra c rt ngn.30 RAID1 Bng cch lu tr d liu ging nhau trn hai a, cu hnh theo kiu ny gip an ton d liu.31 RAID2, RAID3, and RAID4 Cng vi d liu c lu tr trn a cng, c mt a c ch nh l a kim li v ngn nga li. RAID 2 c th sa li. RAID3 v RAID4 c th pht hin li nhng chng khng th sa li. Trong RAID3, d liu c phn vng theo cc bit hoc bytes trong khi RAID4 phn vng d liu theo khi.32 RAID5 y, mi khi d liu c gn cho mt gi tr parity (chn l). D liu v parity c ghi trn nhng a ring bit v vic li trn mt a c th c phc hi. Di y l v d ca RAID5. y 4 a c nhm trong 1 nhm a 1 Khi 1 Khi 4 Khi 7 Parity 10~12 a 2 Khi 2 Khi 5 Parity 7~9 Khi 10 a 3 Khi 3 Parity 4~6 Khi 8 Khi 11 a 4 Parity33 1~3 Khi 6 Khi 9 Khi 12

y, d liu c chia thnh cc khi vi di xc nh, v cc khi ny c hnh thnh mt n v. V d, khi 1 n khi 3 l mt n v v vi mi bit gi tr tng logic loi tr t khi 1 n khi 3 c ghi trn mt a ring bit l cc gi tr chn l t 1 n 3. Tng t, gi tr tng logic loi tr t khi 4 n khi 6 c ghi trn a ring bit l gi tr chn l t 4 n 6. Ngoi ra cn c RAID6, trong cc gi tr chn l c lu ring bit ging nh RAID5 v d liu c th c phc hi ngay c khi hai a b li.34
(Gi ) RAID0 ch c tnh nng l vo ra phn tn, v vy n khng c dng ci thin tin cy. (Ch ) RAID1 c gi l soi gng bi v d liu ging nhau c lu trn cc a cng ring bit. 32 (Ch ) Cn c RAID0+1, kt hp ca RAID0 v RAID1 c s dng. 33 (Ch ) Tnh chn l ca RAID5 s dng tng logic loi tr ca nhiu khi (XOR). V th ngay c khi mt a cng b hng, d liu b mt vn c th c phc hi bng cch ly tng loi tr ca cc khi khc. 34 (FAQ) Thng xuyn trong cc cu hi c dng: Cu no trong cc cu sau y l ph hp lin quan n RAID? Hy nh s khc nhau gia RAID0 v RAID1.
31 30

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

78

2. Cc h thng my tnh

2.1.7 Thit b lu tr ph (h tr)/Cc n v vo ra


Ch im
Thit b lu tr ph bao gm a cng, bng t, a quang t, CDs, DVDs Cc n v vo ra bao gm bn phm, my qut nh, mn hnh, my in

Tt c cc thit b lu tr ngoi tr b nh chnh c gi l thit b lu tr ph (h tr). Thit b lu tr ph c dng b p s thiu dung lng ca b nh chnh. Nhn chung, thit b lu tr ph c dung lng ln hn dung lng ca b nh chnh. Cc khi vo ra bao gm cc khi vo ni d liu c a vo my tnh v cc khi ra ni d liu c a t my tnh ra ngoi. Mt khi c trang b c hai chc nng vo v ra th c gi l khi vo/ra.

Thit b lu tr ph
Cc thit b lu tr ph thng dng bao gm cc phng tin sau. Trong qu kh c mt thi gian khi bng t v mm l cc phng tin ph bin; tuy nhin gn y cc phng tin ch yu gm a cng, a quang t, CDs v DVDs.35
Phng tin a cng DVD DVD-ROM DVD-R DVD+R DVD-RAM DVD-RW DVD+RW CD-ROM CD-R CD-RW Dung lng Nh hn 300GB 4.7 to 9.4BG 3.95 to 7.9GB 3.95 to 7.9GB 700MB 700MB 700MB 128, 230, 640MB, 1.3GB 1.4MB Mt vi GB Ln nht vo khong 24GB Ghi li c C Khng C, ch 1 ln C, nhiu ln Khng C, ch 1 ln C C C C Yes Thuc tnh Mostly built-in Thay th cho CD-ROM C th chi c trn DVD-ROM Rt nhiu c tnh Cho cc gi phn mm. Cho vic sao lu. Cn cc chuyn dng cho vic ghi li c ghi bng t tnh v nh sng c bng nh sng Thun tin cho vic mang i mang li Dng cho sao lu Dng cho sao lu

CD

a quang t36 (MO) a mm a cng DAT37

35 (Ch ) DVD cng l a quang ging nh CD, nhng bng vic gim bc sng ca tia laze, DVD c dung lng lu tr ln hn. Mt cc bn ghi trn a DVD cng ln hn. 36 (Gi ) Mt a quang t s dng nh sng v t tnh ghi d liu nhng ch dng nh sng c d liu. 37 (Ch ) DAT l mt n v lu tr m thanh trn mt bng t s dng tn hiu s. Ban u n c thit k cho m nhc nhng ngy nay n c dng nh mt h thng sao lu v gi thnh r.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

79

2. Cc h thng my tnh

Cc thit b vo/ra
Cc thit b vo gm c bn phm, my qut nh, bng, cc thit b im con tr. Cc thit b ra bao gm mn hnh, my in Cc thit b vo Thit b vo thng dng nht l bn phm v cc thit b con tr. Bn phm c s dng nhp cc con s v k t trong khi cc thit b con tr c s dng nhp vo cc gi tr ta . Cc thit b vo khc c ch ra trong bng di y. Thit b OCR OMR Chut Tablet c m vch My qut nh Chc nng Thit b ny c cc k t vit tay v cc k t in bng quang hc Thit b ny c cc du vit tay bng quang hc Thit b ny dng nhp ta v ca con tr chut Thit b c bit nh bt quang c s dng nhp vo v tr ta c barcodes (m vch) c d liu nh nh cc bc v, nh chp chuyn chng sang d liu s

Cc thit b ra Thit b ra ph bin nht l mn hnh v my in.38 Thit b M t Thit b ny s dng ng phng catot, khng t v Mn CRT thng l nhng mn hnh rng hnh S dng tinh th lng, gi thnh t nhng mng v tit Tinh th lng39 kim nng lng. V c bn ging nh my copy, cht lng in tt nhng Printer My in laser gi thnh t. In bng cch phun mc, nh v gi thnh khng t. My n phun Cht lng in tt nhng yu cu giy in c bit. My in nhit Nung chy mc, cht lng in tt, nhng gi hot ng My in truyn nhit t Gy n nhng gi thnh r c th in hai mt My in im My in cho cc bn v thit k. Plotter

38 (Ch ) OLED: l mt loi mn hnh s dng cng ngh diot pht quang nh sng hu c. N s dng cc vt liu hu c pht ra nh sng khi c in th t vo. So snh vi LCDs, n c gc nhn rng hn, tng phn tt hn, v tc phn hi cao hn, thm vo n cn mng hn v sng hn. 39 (Note) Mn hnh tinh th lng (LCD): Mn hnh tinh th lng c th c nhiu loi nh TFT v STN (ngy nay th dng chnh l DSTN). STN c mt cu trc n gin vi gi thnh sn xut thp, tuy nhin phn gii v tng phn cng thp. DSTN l phin bn ci thin ca STN, vi tng phn c tng ln. TFT c tng phn v phn gii tng ng vi CRT nhng gi thnh t hn.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

80

2. Cc h thng my tnh

2.1.8 Cc giao tip vo v ra


im chnh
Giao tip vo v ra bao gm SCSI, USB USB trang b chc nng cm nng v cm v chy

Giao tip vo v ra l cc giao tip cho php kt ni thit b ngoi vi nh my in, a cng vi PC v cho vic truyn nhn d liu. Ty thuc vo tng loi, vic truyn nhn c th l ni tip hoc song song.40

Cc phng php truyn d liu


C hai phng php truyn d liu gia my tnh v thit b ngoi vi: truyn ni tip v truyn song song. Truyn ni tip l phng php truyn m d liu ra t my tnh l ni tip, 1 bit mt thi im. Truyn song song l phng php truyn m cc bit d liu c truyn mt cch song song. V d nu truyn 8 bit song song th s c 8 ng tn hiu.
Thit b ngoi vi

My tnh

Truyn ni tip
Cc thit b ngoi vi

My tnh

Truyn song song

40 (FAQ) Trong cc cu hi thi thng c cc cu quan tm n s kt hp gia giao tip vo ra v phng php truyn d liu. Cn phi bit cc giao tip vo ra chung v cc phng php truyn d liu.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

81

2. Cc h thng my tnh

Cc loi giao tip vo ra


Di y l bng tng hp cc giao tip vo ra ph bin c dng hin nay. USB l giao tip c dng ph bin nht hin nay, c h tr cc chc nng cm v chy (plug and play41) v cm nng (hot plug) 42
Loi RS-232C SCSI Centronics GPIB USB IEEE1394
43

Phng truyn Ni tip Song song Song song Song song Ni tip Ni tip

php

Thuc tnh Ban u c s dng ni my tnh PC vi modem, ngy nay cng c dng cho cc n v vo ra Daisy chain cho php kt ni vi cc n v tc cao Kt ni my tnh vi my in, tc cao nhng khng cho php khong cch di Kt ni my tnh vi cc thit b o lng, c bit n nh l IEEE-488 Kt ni ti 127 n v trong cu hnh dng cy Kt ni ln ti 63 n v trong daisy chain hoc cu hnh dng cy.

Daisy chain y l phng php kt ni s dng trong SCSI v GPIB, cc thit b ngoi vi c kt ni dc theo mt dng dy. Thit b cui cng trn ng dy yu cu mt in tr kt thc c gi l thit b cui.

a cng ngoi

a quang t

a CD

Thit b cui (t u cui)

USB USB c hai ch : Ch tc cao 12Mb/s v ch tc thp 1.5Mb/s. Trong ch tc cao, cc n v tc cao nh my in hay my qut c kt ni. Trong ch tc thp, cc n v tc thp nh bn phm hay chut c kt ni. Ngy nay, USB 2.0 tng ch tc cao ca n ln n 480Mb/s, v vy hu ht cc n v ngoi vi c th c kt ni. Cc giao tip khc Ngoi cc giao tip trn, cn c cc giao tip khc nh IDE (kt ni vi a cng), ATA (IDE c chun ha bi ANSI) ATAPI (kt ni ATA vi cc n v khc cng nh CDROM) Tuy nhin cc thit b c CD v ghi CD ngy nay thng kt ni thng qua SCSI v USB.
Cm-v-chy (Cm v chy): iu ny ni n chc nng t ng ci t v thit lp driver ca thit b khi cc n v ngoi vi hoc cc card m rng kt ni vi my tnh. H iu hnh kim tra tt c cc n v kt ni vi my tnh khi khi ng, ci t cc driver thit b yu cu. Nu h iu hnh khng c driver thit b ca n v trong th vin ca n, n s yu cu ci t driver cho thit b v nu cn thit s khi ng li my tnh mt cch t ng. 42 Cm nng: y l chc nng cho php chc nng cm v chy trong khi ngun ca my tnh v thit b ngoi vi ang bt. 43 IEEE 1394: Chun tc truyn l 100Mb/s, 200Mb/s, hoc 400Mb/s. Chun ny c trang b chc nng trao i nng (thit b ngoi vi c th kt ni hoc ngt kt ni m khng cn phi tt ngun). Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng -41

82

2. Cc h thng my tnh

Cu hi nhanh
Q1 So snh SRAM v DRAM:
Cc mc so snh Lm ti Mc tch hp Tc truy cp Gi n v trn bit Cch s dng DRAM SRAM

Q2

Trong cc thnh phn to nn my tnh, nhng thnh phn no to nn b x l trung tm (CPU)?


Khi iu khin

Lung iu khin Lung d liu


Khi tnh ton

Khi vo

B nh chnh

Khi ra

B nh

B nh ph

Q3 Q4 Q5

Gii thch vai tr ca b nh m. M t cc c im ca RAID. Giao tip USB l ni tip hay song song?

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

83

2. Cc h thng my tnh

A1
Mc so snh Lm ti Mc tch hp Tc truy cp Gi n v trn bit S dng DRAM Cn thit Cao (Dung lng ln) Chm R B nh chnh SRAM Khng cn Thp (dung lng nh) Nhanh t B nh m

A2 A3

Tp hp ca n v iu khin v n v x l B nh tc cao dung lng nh nm gia CPU hoc thanh ghi v b nh chnh. Tc truy cp b nh chnh l chm hn so vi CPU hoc thanh ghi, v th tng hiu qu x l ca CPU bng cch a cc d liu truy cp thng xuyn vo b nh m

A4

y l thit b lu tr ph m rt nhiu cng c ni song song v c iu khin nh th l chng ch l mt a. V vy tc vo ra c ci thin v tin cy c nng cao. i khi thut ng RAID mun ni n phng php thay v vic lu tr. RAID c gng y nhanh tc x l bng cch dn tri cc bn ghi trn nhiu a v c cc bn ghi mt cch ng thi.

A5

Giao tip ni tip (USB vit tt ca Universal Serial Bus.)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

84

2. Cc h thng my tnh

2.2 H iu hnh
M u
My tnh khng th hot ng nu ch c phn cng. Chng ch c y chc nng bng cch s dng mt phn mm gi l h iu hnh (OS).

2.2.1 Cu hnh v cc mc tiu ca h iu hnh


im chnh
nh ngha khi qut v nh ngha c th h iu hnh Mc tiu ca h iu hnh l s dng hiu qu cc my tnh.

Khng c nh ngha r rng cho h iu hnh. Mt phn mm c s c gi l mt h iu hnh trong mt ng cnh rng trong khi mt chng trnh iu khin c gi l mt h iu hnh trong mt ng cnh hp.

Cu hnh ca h iu hnh
H iu hnh l mt phn mm c s m iu khin hon ton v qun l ton b cc hot ng ca phn cng v phn mm ca mt h thng my tnh. Mt chng trnh c coi nh phn mm c s v vai tr ca n c ch ra nh di y 44.
Chng trnh iu khin (OS ngha hp)

Phn mm c s
44

- Qun l cng vic Qun l d liu Qun l hot ng - Qun l truyn thng Qun l tc v - Qun l b nh - Qun l li v.v
Chng trnh dch v - B son tho lin kt Chng trnh trn/sp xp B sinh m h thng B son tho vn bn Chng trnh trao i truyn thng Chng trnh g li v.v B x l ngn ng - Trnh bin dch Chng trnh dch hp ng - Trnh thng dch B sinh m v.v...

Cc chng trnh dch v v cc b x l ngn ng i khi cng c gi l cc chng trnh x l, chy trn cc chng trnh iu khin. V l do ny, chng trnh iu khin c gi l mt h iu hnh theo ngha hp.

(Gi ) Cc h iu hnh trn my tnh c nhn bao gm Windows XP, Mac OS X, v OS/2. i vi cc my trm bao

gm Windows Server 2003, UNIX, v Mac OS X Server. i vi cc my mc ch chung, thng l MVS pht trin bi IBM. Ngoi ra cn c, chng trnh h iu hnh min ph Linux tng thch vi UNIX. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

85

2. Cc h thng my tnh

Mc ch ca h iu hnh
H iu hnh c gng ci tin hiu nng ca ton b h thng bng cch loi b cc hot ng khng cn thit, b qua cc ti nguyn ngoi vi ca my tnh v vn hnh h thng my tnh mt cch hiu qu. Mc ch ca h iu hnh c ch ra nh trong hnh di y.
S dng hiu qu cc ti nguyn phn cng: Cc mc tiu ca OS p ng cc ch x l khc nhau: m bo tnh tin cy v an ton: Gim thiu gnh nng ca phn mm ng dng: H tr vn hnh v iu khin my tnh: Lp trnh a x l,45 chc nng spooling,46 v.v... X l khi, x l thi gian thc trc tuyn, v.v... Ci tin ch s RASIS, v.v... B nh o,47 qun l th vin,48 v.v X l lin tip, lu gi liu thao tc, v.v...

S dng hiu qu cc ti nguyn phn cng Cc ti nguyn phn cng bao gm khi x l trung tm (CPU), b nh, cc khi vo ra (I/O) (bao gm cc knh vo ra), v.vH iu hnh iu khin cc ngun ti nguyn chng c th c s dng mt cch hiu qu. p ng cc ch x l khc nhau Mt my tnh c th qun l cc ch x l khc nhau nh x l theo khi, x l theo khi t xa, x l trc tuyn, x l thi gian thc, v x l ch tng tc. c bit, khi x l trc tuyn tr nn ph bin th phm vi ca cc ng dng my tnh cng c m rng nhanh chng. Tnh tin cy v an ton Thc o ca tnh tin cy v an ton c a ra bi thut ng RASIS. N l vit tt ch ci u ca cc t: tnh tin cy (Reliability), tnh hiu lc (Availability), kh nng dch v (Serviceability), tnh ton vn (Integrity) v s an ton (Security). Gim thiu gnh nng ca phn mm ng dng Cc phn mm ng dng c bit nh l mt chng trnh chy di iu khin ca h iu hnh. H iu hnh cung cp mt mi trng cho cc chng trnh ng dng c th c thc thi mt cch hiu qu.

Lp trnh a x l: L mt c ch trong cc chng trnh c x l qua li trn mt CPU n c th xut hin mc d nhiu chng trnh ang hot ng cng lc. 46 Spooling: L mt k thut s dng cc a cng tc cao nh mt khi vo/ra o. V d, vic in trc tip trn mt my in tc thp s lm chm tc x l. Thay vo , cc kt qu xut ra c th c ghi vo mt a cng tc cao trc, v sau mt chng trnh phc v, ch quan tm n xut d liu, thc hin vic in khi CPU khng bn. 47 B nh o: y l mt k thut m rng dung lng ca b nh chnh cc chng trnh ln c th c np vo trong b nh ch mt ln. Thng thng, b nh ngoi nh l a cng c s dng nh b nh o. 48 Qun l th vin: y l mt chc nng m tch ly mt cch h thng cc chng trnh th s, cc chng trnh b tr, cc modules ti, v cc chng trnh khc c pht trin. Cho php qun l tch hp cc ti nguyn phn mm m c qun l ring l. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

45

86

2. Cc h thng my tnh

H tr vn hnh v iu khin my tnh H iu hnh loi b s can thip ca con ngi nhiu nht c th, bi v n x l cc chng trnh lin tc v ghi li trng thi hot ng . Thng tin cc trng thi hot ng ghi li s c s dng kim tra cc tnh hung li xy ra. 49
S can thip ca con ngi OS Chun b cng vic 1

Thi ran ri

Cng vic 1 kt thc

Chun b cng vic 2

Thi gian ri Thc thi cng vic 2

Gii phng ti nguyn


Chun b cng vic 1

Thc thi cng vic 1


Chun b cng vic 2

Gii phng ti nguyn T ng


Cng vic 1 kt thc Cng vic 2 kt thc

Thc thi cng vic 1

Thc thi cng vic 2

2.2.2 Qun l cng vic


im chnh
Cng vic l cc n v tc v c a ra trong my tnh, bao gm nhiu chng trnh (cc bc cng vic). Qun l cng vic c cc chc nng nh lp lch v k thut spooling.

Mt trong nhng chc nng ca h iu hnh l qun l cng vic. Trong qun l cng vic, quyn u tin ca cc cng vic s c xc nh, v cc cng vic c ng b vi nhau. Trong x l theo khi, h iu hnh phn tch cc ni dung ca ngn ng iu khin cng vic (JCL Job Control Language) ng k ti nguyn50 v lp lch cho cc cng vic. Trong ch x l tng tc, h iu hnh phn tch cc lnh u vo ng k ti nguyn v lp lch thc hin. Ngoi ra, qun l cng vic c cc chc nng khc nh iu cng vic v phn loi cc th tc.

B lp lch:

Qun l th t thc hin cng vic Giao tip vi ngi thao tc


Qun l s tip nhn, chn la, khi u v kt thc cc cng vic

Lp lch ch

Qun l cng vic

Lp lch cng vic

B c:
B khi to

c cc cng vic
Chun b cho vic bt u ca cc cng vic, chng trnh

B kt thc:

Thu dn sau khi kt thc cc cng vic, chng trnh Qun l u vo cho cc cng vic, qun l u ra cho cc kt qu x l H tr thc thi cc loi cng vic

Spooling:

Th tc phn loi:

49 (FAQ) Lin quan n h iu hnh, c nhiu cu hi lin h n kin thc cc thut ng. Cn m bo hiu cc thut ng nh multiprogramming, virtual memory, v spooling function. 50 Resource: Ti nguyn l mt thit b hoc mt khi thuc rt nhiu loi khc nhau cn thit cho hot ng ca my tnh. l bt c cc thit b g lin quan n b nh, vo, ra, iu khin v cc chc nng khc; c bit bao gm CPU, b nh chnh, v cc tp.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

87

2. Cc h thng my tnh

B lp lch
Trong qun l cng vic, cc cng vic c thc thi lin tip theo mt lch ch v lch cng vic. Lch ch ng vai tr giao tip vi ngi thao tc thng qua bng iu khin.51 Lch cng vic qun l s tip nhn, la chn, khi u v kt thc ca cc cng vic.

B c
c ni dung ca JCL, phn tch chng, lp lch cho cc cng vic v t chng vo mt hng i.

B khi to
Chn la cc chng trnh c quyn thc thi cao trong s cc chng trnh trong hng i v ng k cc ti nguyn cn thit cho cc chng trnh .

B kt thc
Gii phng cc ti nguyn m chng trnh s dng xong. Nu c mt chng trnh khc tip theo, b kt thc s tip tc khi ng b khi to.

K thut Spooling (Spool)


Spooling l chc nng vo/ra ca cc cng vic c lp ca cc chng trnh. Cc kt qu xut n cc khi tc thp nh my in, u tin c lu tr trong mt tp spool. Sau , khi chng trnh kt thc, kt qu u ra c in trn my in t tp spool bi chng trnh dch v ca h iu hnh52. L do s dng k thut ny l khi khi vo ra chm, vic thc hin x l vo ra trc tip s lm gim tc x l ca my tnh.53

Th tc phn loi
Trong iu khin thc thi cng vic, cc x l thng thng nh dch ngn ng c thc hin nh sau: Mt tp hp JCLs c ng k cng nhau ti mt v tr ring bit, v ng k mt tp cc JCL c gi thc hin cc chng trnh. Bng cch ny, my tnh ngn chn c cc li JCL. Tp hp cc JCL c ng k gi l phn loi cc th tc.

51 Console panel (Bng iu khin): L khi thc hin cc thao tc tng tc vi h thng my tnh thng qua cc phm iu khin v gim st cc hot ng ca n ni h thng truyn thng b hng hc, v.v N bao gm mt bn phm v mt mn hnh hin th. 52 (Gi ) Cc tp spool thng s dng trong mt a cng. Chng trnh dch v thc hin gi cc tp spool n mt my in thng c gi l mt chng trnh th k (output writer). 53 (FAQ) Cc cu hi thi phn qun l cng vic thng l v k thut spooling. Chng thng dng la chn thut ng ng, v vy cn phi hiu chnh xc k thut spooling.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

88

2. Cc h thng my tnh

2.2.3 Qun l tc v
im chnh
Tc v l mt n v thc thi nh nht s dng mt ti nguyn. S dng c ch ngt chuyn i gia cc tc v.

Mt trong nhng chc nng ca h iu hnh l qun l tc v. Qun l tc v l chc nng iu khin vic thc thi cc chng trnh v bao gm cc th tc khc nhau nh ng b ha iu khin chng trnh, cp pht ng ti nguyn thc thi chng trnh, v qun l quyn u tin thc thi ca cc chng trnh. N cng kim sot cc loi iu khin ngt khc nhau.

Tc v v cng vic
Cng vic (jobs) l mt n v x l theo ng cnh ngi s dng (mt chng trnh n l hoc mt tp cc chng trnh c thc thi lin tip). Tri li, tc v (tasks) l mt n v x l bn trong c thc thi di h iu hnh. Tc v c xem nh l mt n v x l m phn chia t mt tin trnh chng trnh.54

iu khin thc thi tc v


Qun l tc v to ra cc tc v c yu cu p ng mt lnh v gim st qu trnh thc thi. Khi mt tc v to ra khng cn cn thit na, n s c loi b. Biu dch chuyn trng thi ca cc tc v c ch ra nh sau y:
6. Kt thc Loi b tc v

Chy
2. Gi i 3. Ngt nh thi To tc v 1. ng k 5. Ngt vo/ra

4. Li gi h thng

Sn sng

1. Mt tc v c to ra s c t vo trong hng i tc v chuyn ti trng thi ready (sn sng). 2. thc thi, tc v c chuyn ti trng thi Running (chy) thng qua tc v Dispatcher (gi) chuyn ti trng thi running. 3. Ht thi gian cho php, tc v rt khi trng thi Running nhng cho mt tc v khc c quyn u tin cao hn chuyn n trng thi Ready. 4. Rt khi mt lnh vo/ra chuyn n trng thi Waiting (i). 5. Trng thi i c thc hin ln na sau khi hon thnh vo/ra chuyn n trng thi sn sng. 6. Tt c cc qu trnh c hon thnh Tc v c kt thc.

54 Process: (Tin trnh) y l mt thut ng ch mt chng trnh c thc thi v c s dng thay th cho thut ng tc v (task). Process l t c s dng trong cc h iu hnh nh UNIX. N c s dng thng xuyn trong nhng nm gn y

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

89

2. Cc h thng my tnh

Dispatching l mt bc chn la mt tc v c quyn u tin cao nht trong s cc tc v nm trong trng thi sn sng v chuyn n ti trng thi running.55 Supervisor call (li gi h thng) l mt yu cu mt chc nng ca h iu hnh, trong biu dch chuyn trng thi tc v, n c bit nh l mt lnh vo/ra. Ngt vo/ra thng bo cho bit thao tc vo/ra hon thnh.56

Ngt
Ngt l vic treo tm thi mt chng trnh hin thi ang c thc thi v bt c l do g v chuyn quyn iu khin cho h iu hnh thc thi chng trnh x l cn thit. C cc ngt ngoi gy bi cc trng thi c trng ca phn cng v cc ngt trong c tnh khi chng trnh iu khin c gi t trong mt chng trnh. Khi CPU pht hin ra mt ngt, h iu hnh tip nhn ngt , thay i chng trnh ang thc hin n trng thi cn thit u tin ngt, kim tra nguyn nhn ngt, v chuyn iu khin n chng trnh con x l ngt tng ng. Vng nh m trng thi ny c lu tr c gi l t trng thi chng trnh PSW (program status word). Cng c th xy ra trng hp trong khi mt x l ngt ang din ra, mt ngt khc li xy ra. Khi cc ngt c iu khin da trn quyn u tin ca chng. Bng sau m t cc loi ngt chnh v v d nguyn nhn sinh ngt.
Loi ngt

Tn
Ngt kim tra phn cng Ngt nh thi (timer) Ngt vo/ra57

Cc nguyn nhn c th
Li chc nng ca cc khi, vn v ngun/in p. Khong thi gian nh thi t c mt lng thi gian nh ra. Hon thnh vic vo/ra. Khi vo/ra thay i trng thi. (v.v) Cc lnh t bng iu khin, cc tn hiu ngoi. Trn trn, trn di, thc thi cc m lnh khng c nh ngha, chia cho 0, vi phm vng nh khng cho php. Cc lnh thao tc vo/ra, chuyn i thc hin tc v, li trang, li gi chng trnh iu khin.

Cc ngt ngoi

Cc ngt trong (traps)58

Ngt tn hiu ngoi Ngt chng trnh Li gi h thng

2.2.4 Qun l d liu v t chc tp


im chnh
Qun l d liu cung cp cc phng php kt hp truy cp cc tp. T chc tp bao gm t chc tun t, t chc trc tip, t chc theo ch s, t chc phn vng, v.v

Mt chc nng khc ca h iu hnh l qun l d liu. Qun l d liu l chng trnh iu khin qun l cc d liu vo v ra. N cung cp cc phng php t chc tp khc nhau nh t chc tun t, t chc trc tip, t chc ch s. N lm vic nh mt cu kt ni gia cc tp logic c x l trong mt chng trnh v cc tp vt l c cu trc khc nhau. Qun l d liu cho php ngi lp trnh khng phi quan tm n cu trc vt l ca cc tp.
Dispatcher: L chng trnh ca h iu hnh thc hin dispatching (y tc v t hng i vo trng thi chy), cng c bit nh l mt chng trnh con dispatching. 56 (FAQ) Biu dch chuyn trng thi ca cc tc v hu nh lun xut hin trong cc bi thi. Cn nh k biu ny trong tr nh. 57 (Gi ) Vic pht mt lnh vo/ra c thng bo bng li gi h thng; Vic hon thnh vo/ra c thng bo bi mt ngt vo/ra. 58 Cc ngt trong thng l c tnh bi cc chng trnh, v th thnh thong chng c gi l cc by ngt (traps) Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng -55

90

2. Cc h thng my tnh

Cc phng php truy cp


Cc phng php truy cp bao gm truy cp tun t, truy cp trc tip, truy cp ng (kt hp c 2 phng php trn).

Cc phng php truy cp

Truy cp tun t: Truy cp trc tip: Truy cp ng:

X l cc tp tun t t im bt u59 X l trc tip mt bn ghi c th S dng truy cp trc tip tm v nh v mt bn ghi, sau s dng truy cp tun t.

Truy cp tun t y l phng php truy cp cc bn ghi trong mt tp theo trt t tun t t im bt u. C th c thc hin vi hu ht tt c cc phng tin lu tr. Phng php ny ph hp cho x l chung tt c cc bn ghi trong mt tp cng ch x l. Truy cp trc tip y l phng php truy cp trong mt bn ghi cn thit c truy cp trc tip (mt cch ngu nhin) khng quan tm n th t bn ghi c lu tr. Phng php ny c s dng khi phng tin tp l mt phng tin lu tr c th truy cp trc tip v d nh a cng. N c s dng trong cc h thng trc tuyn thi gian thc ni ch c mt phn ca mt s lng ln cc bn ghi c lu tr trong mt tp cn c truy cp cp nht nhanh chng. Truy cp ng y l phng php truy cp trong s dng truy cp trc tip tm mt bn ghi c th v sau s dng truy cp tun t. Tng t nh truy cp trc tip, phng php ny c s dng khi phng tin lu tr tp l mt phng tin lu tr c kh nng truy cp trc tip.

T chc tp
Cc phng php t chc tp bao gm: t chc tun t, t chc trc tip, t chc theo ch s v t chc phn vng60, v.v
59 (Gi ) Truy cp tun t c th c s dng vi hu ht cc phng tin lu tr; cn truy cp trc tip v truy cp ng b hn ch vi cc thit b c kh nng truy cp trc tip nh a cng. 60 (FAQ) Cc cu hi lin quan n c trng ca cc phng php t chc tp thng c a ra. V vy, cn nm c

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

91

2. Cc h thng my tnh

Cc tp t chc tun t T chc tp Cc tp t chc trc tip Cc tp t chc theo ch s Cc tp t chc phn vng Cc tp t chc tun t

Cc tp c x l theo th t nh chng c ghi trong phng tin lu tr. Cc bn ghi c x l trc tip qua cc gi tr kha. Truy cp trc tip qua ch s v c th km truy cp tun t. Mt tp cha nhiu tp t chc tun t.

Cc bn ghi trong mt tp c lu tr ti nhng v tr lin tip nhau theo mt trt t no . Cc tp loi ny c th c thy hu ht cc loi thit b lu tr nh bng t, a cng, a mm. Nhn chung, ch c phng php truy cp tun t l c th vi cc tp loi ny. Cc tp t chc trc tip a ch lu tr trn phng tin lu tr c tnh ton da trn gi tr kha tm ra a ch mi bn ghi v bn ghi c lu ti v tr .61 truy cp mt bn ghi, u tin phi tnh a ch lu tr theo cng mt cng thc v bn ghi c c ti a ch lu tr . Gi tr kha ca mi bn ghi cng c th c s dng trc tip nh l a ch lu tr ca bn ghi , nhng iu ny khng thit thc lm v n to ra nhiu vng nh rc nu cc gi tr kha l khng lin tc. Cc thc ni chung l s dng mt loi cng thc bin i tnh ra a ch lu tr t gi tr kha ca mi bn ghi. Cch ny c gi l php bin i a ch (mt cch ngu nhin).
Key Store Address calculation Record Record Record Record Record Record Record Record Record

Php bin i a ch i khi sinh ra cng mt a ch cho nhng bn ghi khc nhau. Trong trng hp nh vy, bn ghi c lu tr u tin c gi l bn ghi chnh trong khi bn ghi c ng k sau ti cng a ch c gi l bn ghi ng ngha.62

c trng ca mi phng php t chc tp. 61 (Gi ) Mt trng hp c bit ca t chc trc tip l t chc tng i, trong cc gi tr kha l lin tc v d nh 1, 2, 3, v gi tr kha cng l a ch lu tr ca bn ghi. 62 Synonym/Home: Php bin i a ch c th sinh ra cc gi tr kha khc nhau nhng cng mt gi tr lu tr nh nhau, gi l mt ng ngha. Nu kt qu ca php bin i kha lu tr mt bn ghi, bn ghi ny c gi l bn ghi chnh, v bn ghi m khng th c lu tr gi l bn ghi ng ngha. Mt bn ghi ng ngha cn c lu tr ti bt c ni no bng mt phng php khc (v d dng mt danh sch). Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

92

2. Cc h thng my tnh

Cc tp t chc theo ch s Mi tp s c mt ch s, v chng c t chc ngi s dng c th truy cp n cc bn ghi bng cch tm a ch ca cc bn ghi qua ch s tp. Cc phng php truy cp tun t, truy cp trc tip, v truy cp ng u c th c dng. Trong mi trng hp, cc bn ghi thc t c truy cp ch sau khi tm c a ch ca chng trn phng tin lu tr thng qua ch s, v th phng tin lu tr khng ch cha mt vng d liu c s ni lu tr d liu m n cn cha mt vng ch s. Thm na, ngn chn tnh hung cc bn ghi khng th ghi thm vo vng d liu c s, c thm mt vng nh trn d tr. 63 Cc tp t chc phn vng Trong cc tp ny, cc tp t chc tun t c gp li vo cc n v gi l cc thnh vin, mi mt thnh vin c cung cp mt tn. Sau mt th mc cha cc tn v a ch u ca chng c to ra. Vic truy cp c cho php n cc thnh vin . Mi thnh vin c xem nh mt tp cc tp t chc tun t. Phng php truy cp trc tip c th tm thy ch bt u ca mt thnh vin, v phng php truy cp tun t c th c s dng tm mt bn ghi trong thnh vin . Cc tp t chc phn vng c th c s dng cho cc tp chng trnh v th vin nhng khng c dng nhiu nh cc tp d liu.

Thnh vin A

Thnh vin B

Thnh vin C

Vng th mc (Thanh ghi)

Tp B Tp A

Vng thnh vin

63 (Gi ) C 2 loi vng trn: vng trn cylinder v vng trn c lp. Cc bn ghi trn t cc track khc nhau c lu tr trong vng trn cylinder; Nu vng trn cylinder y, cc bn ghi s c lu tr thm vo mt vng trn c lp c dng chung cho tt c cc tp.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

93

2. Cc h thng my tnh

H thng tp phn cp
UNIX v Windows64 s dng cc h thng tp phn cp nh mt c ch qun l tp mt cch hiu qu. Th mc v tp Mt h thng tp c cu trc phn cp bao gm cc tp v cc th mc (cc th mc l cc thanh ghi tp). nh ca cu trc phn cp l th mc gc, v cc th mc di n c gi l cc th mc con65 Root
DIR 1 File 0 DIR 4 File 2 DIR 2 DIR 5

Th mc gc
DIR 3 File 1

Th mc con

: Th mc : Tp Cc thao tc tp Khi tm kim mt tp, cn ch ra ng dn th mc ni m tp c lu tr. C 2 phng php thc hin iu ny. V d vi trng hp cu trc phn cp nh hnh trn, ta c cc ng dn nh di y.66 ng dn tuyt i Ch r mt ng dn t th mc gc.67 <V d> y l ng dn n file1 \DIR3\file1 (K t u tin \ ch nh th mc gc.) ng dn tng i Ch r mt ng dn t th mc hin thi68 <V d 1> y l ng dn ca file2 khi th mc hin thi l DIR2. DIR4\file2 <V d 2> y l ng dn ca file2 khi th mc hin thi l DIR4. file2

(Gi ) Thut ng directory trong UNIX v MS-DOS tng ng vi folder trong Windows v MacOS. (Gi ) Cc tp v th mc c th c to trong mt th mc, nhng khng th trong mt tp. 66 (FAQ) Lin quan n cc h thng tp phn cp, c cc cu hi thi ging nh Chn mt ng dn tuyt i hoc ng dn tng i. Trong cc cu hi ny, k t phn tch cc th mc v cc tp c s dng s c gii thch trong cu hi. 67 (Gi ) y chng ta s dng k t \ phn tch cc th mc v cc tp, tuy nhin mt vi h iu hnh s dng k t /. 68 Th mc hin thi (Current directory): Th mc hin thi l th mc trong ngi s dng hin ti ang lm vic.
65

64

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

94

2. Cc h thng my tnh

2.2.5 Qun l b nh
im chnh
Qun l b nh s dng 2 loi b nh: b nh thc v b nh o. nh dng c s ca b nh o l phng php phn trang.

Mt vai tr khc ca h iu hnh l qun l b nh. Qun l b nh em li hiu qu s dng b nh cao nht cng nh hn ch vic thiu ht dung lng b nh. Cc b nh ph cng c s dng hiu qu nh mt phn ca b nh chnh.69

H thng b nh thc70
y l mt h thng m qun l khng gian vt l ca b nh chnh. B nh thc c th c iu khin bng nhiu cch: phn vng, hon i, b tr li v cc phng php ghi . Phng php phn vng Khi mt chng trnh c t trong b nh chnh, b nh chnh c phn chia thnh mt s phn vng ni m chng trnh c np.71 Nu khng c qun l b nh, s phn mnh s to ra gy nn tnh trng cn tr cc chng trnh c lu tr mc d khng gian trng vn cn. Do , vic kt hp cc vng nh trng vi nhau l cn thit.72 Hon i (roll-in / roll-out) Hon i l vic chng trnh thc hin chuyn i th t sau v trc gia b nh chnh v b nh ph. Nu mt chng trnh c a vo c quyn u tin cao hn quyn u tin ca chng trnh thc thi hin thi, chng trnh mi s ngay lp tc c np vo b nh chnh v c thc thi. Tuy nhin, nu khng gian nh trng trong b nh chnh khng cn, mt chng trnh bt k trong b nh chnh c th c dch chuyn ra ngoi b nh ph. Do , h thng s b p c s thiu ht dung lng b nh chnh bng cch s dng b nh ph ngoi. Tuy nhin, nu hon i xy ra thng xuyn, c ngha l chng trnh c chuyn i th t trc sau nhiu ln, nh th s lm gim thiu hiu qu x l ca h thng my tnh.

B nh chnh Chng trnh X Chng trnh B Chng trnh A

a ra (roll out) a vo (roll in)

Chng trnh X Chng trnh A

B nh ngoi

R r b nh (Memory leak): i khi v mt s l do, vng nh trong b nh chnh t ng b chim dng bi mt chng trnh ng dng, v khng c gii phng m vn cn trong b nh chnh. y l hin tng r r b nh (Memory leak). loi tr hin tng ny, cn thc hin vic nn b nh. 70 H thng nh thc hay B nh thc (Real memory system or Real Storage (RS)): y l b nh tn ti thc s; n l b nh chnh. 71 (Gi ) Trong phng php phn vng, nhiu chng trnh c th c lu tr ng thi, v th c th x l a nhim. 72 Nn b nh (Compaction): Ngha l thu gom cc vng nh trng c mt vng nh lin tc; cng c gi l thu gom b nh rc. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

69

95

2. Cc h thng my tnh

B tr li (Relocation) B tr li l chc nng trong mt chng trnh c ng k mt vng nh c lu tr li mt vng nh khc. Mt chng trnh m cu trc ca n cho php thc hin b tr li c gi l chng trnh c kh nng b tr li.73 Phng php ghi Gii hn vt l ca b nh chnh c th c loi b, nh vo vic cc chng trnh c phn thnh cc n v on, v ch c cc on74 cn thit c np vo b nh chnh thc thi. Ton b chng trnh c lu tr b nh ngoi, b nh chnh ch cha cc on thng s dng. Cc on khc m khng bao gi c s dng ng thi, c np t b nh ngoi vo b nh chnh khi c yu cu n. V d, gi s rng on A l mt th tc chnh c s dng vi tn s cao trong khi cc on B v C l cc th tc con c gi ring bit t on A. Trong khi on B c thc thi, on C vn lu tr trong b nh ngoi. Khi on C c gi, n s c np vo vng nh ca on B. Do , ton b dung lng b nh chnh l A + B + C, nhng thc t dung lng ca b nh chnh c ch l gi tr ln nht ca A+B hoc A+C.
Chng trnh Li gi

on A on B on C

Np

on A on B on C

Dung lng yu cu

Dung lng chng trnh

Np (B nh ngoi) (B nh chnh)

B nh o
B nh o cung cp mt dung lng ln khng gian lu tr m khng quan tm n kch thc ca b nh chnh.75 Cc chng trnh c lu tr trong b nh o (thng thng trong b nh ngoi), v ch cc phn cn thit thc thi mi c np vo b nh chnh. Khi chng trnh c np vo b nh o, cc lnh v d liu c cp cc a ch o, ci m cn thit phi bin i sang cc a ch thc (cc a ch trong b nh chnh) cho vic thc thi ca chng trnh. Php bin i ny c thc hin bng phn cng gi l b dch a ch ng DAT (Dynamic Address Translator). Nu b nh o c s dng, cn phi bin i t cc a ch b nh o sang a ch vt l trong b nh chnh. Php bin i a ch ny c thc hin tc cao bi DAT. S b tr li cng c thc hin nu b nh chnh c s phn on. Khi s b tr li hon thnh trong sut qu trnh thc hin ca mt chng trnh, n c gi l s b tr li ng. B nh o s dng 3 phng php: phn trang, phn on v phng php kt hp.

(Gi ) Thut ng Relocatable (c th b tr li) c ngha l c th nn (gom li). Segment: (on) l mt n v x l logic ca chng trnh. y, chng ta c th hiu mt on nh mt chng trnh con. 75 Virtual memory system or Virtual Storage (VS): y l mt khi nim lu tr khng tn ti thc s. Mt chng trnh cn thc thi c np vo b nh o, c khng gian b nh ln hn, trong ch cc phn (cc trang v cc on) ca chng trnh vi tn s s dng cao, d liu v cc phn cn thit khc thc thi c np vo b nh chnh.
74

73

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

96

2. Cc h thng my tnh

Phng php phn trang Trong phng php ny, chng trnh c phn thnh cc khi c kch thc c nh gi l cc trang. Mi trang s tr thnh mt khi np vo b nh thc. Cc trang c qun l bi mt bng phn trang, trong mi mt mc tng ng vi mt trang trong b nh o. Nu trang tng ng nm trong b nh thc, bit li trang s bng 0. Bit li trang ch ra c hay khng trang tng ng trong b nh thc.
B nh o Trang 0 Trang 1 Trang 2 Trang 3 Trang n Bng trang 0 a 0 1 b 0 2 1 3 1 n n 0 B nh thc

Chng trnh

a n b

Trang 0 Trang n Trang 1

S hiu trang Phn gii ng

Bit li trang B dch a ch ng Bin i a ch thc

Phng php phn on Trong phng php ny, cc chng trnh v cc tp hp logic ca d liu c xem nh l cc on. Cc a ch o bao gm cc s hiu on v cc a ch trong cc on . Phng php phn trang ch dng cho qun l b nh v nh vy cc chng trnh khng cn ghi nh cc trang . Ngc li, trong phng php phn on, cc on c kch thc khc nhau, cc chng trnh phi ghi nh kch thc ca cc on. Cc on l cc n v x l logic, v th chng c th c i x nh l cc th tc con. Tuy nhin, vic chiu di thay i thng gy kh khn cho vic qun l v hiu nng s dng b nh chnh c th b suy gim. Phng php kt hp phn trang phn on y l mt ci tin ca phng php phn on, trong cc on c phn nh hn thnh cc trang. Cc a ch tht c truy cp theo trt t on trang dch chuyn tng i trong trang.76

76

Relative displacement within the page: ( dch chuyn tng i trong trang) L mt a ch c ng k bt u trang c dch chuyn l 0.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

97

2. Cc h thng my tnh

Cc gii thut phn trang


Nu mt trang cn x l khng tm thy trong b nh thc, mt ngt gi li phn trang xy ra, v trang c c t b nh thc vo b nh o. Qu trnh ny c gi l np trang (page-in). Tri li, loi trang (page-out) l dch chuyn mt trang khng cn thit ra khi b nh o. Cc thao tc np trang v loi trang c gi l phn trang (paging).77 Nu phn trang xy ra thng xuyn, thi gian thc thi chng trnh iu khin tng, gim hiu qu thc hin. iu ny gi l hin tng slashing. gim thiu kh nng xy ra hin tng slashing nhiu nht c th, nhiu gii thut khc nhau c xut chn trang. Cc phng php loi trang (page-out) ph bin v c im ca chng c ch ra nh di y.78 Phng php LRU (Least Recently Used) FIFO (First In First Out) c im Cc trang c so snh thi gian tnh t ln tham chiu cui cng. Trang no c thi gian ny nhiu nht s c ly ra Trang no c thi gian tnh t lc np vo n thi im hin ti di nht s c ly ra trc (vo trc ra trc).

77 (Gi ) Hon i (Swapping) v phn trang (paging) l ging nhau, nhng ch rng hon i din ra trong chng trnh v cc on trong khi phn trang din ra trong cc khi gi l cc trang, l mt phn ca chng trnh. 78 (FAQ) C cc cu hi thi yu cu phn nh r rng np trang, loi trang. V d, nu th t cc trang c s dng l 1, 3, 2, 3, 5, 2 v nu b nh chnh c trang 3, trang no s s c loi trc ? Vi cc cu hi loi ny, cn hiu r cc gii thut LRU v FIFO.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

98

2. Cc h thng my tnh

Cu hi nhanh
Q1 Q2 Gii thch cc vai tr ca qun l tc v Kiu t chc sau y thuc kiu t chc tp no ? Cc tp t chc tun t c phn nhm thnh cc khi gi l cc thnh vin, mi thnh vin c cp mt tn. Mt th mc c to ra bao gm cc tn v cc a ch u v cho php truy cp n cc thnh vin . Q3 Q4 Gii thch k thut hon i (swapping) n v g c np vo b nh chnh trong phng php phn trang ?

A1

y l mt chc nng iu khin vic thc thi chng trnh, thc hin cc chc nng nh iu khin ng b cc chng trnh, cp pht ng cc ti nguyn thc hin cc chng trnh, v qun l quyn u tin ca cc chng trnh. N cng c th kim sot rt nhiu cc iu khin ngt. T chc phn vng Hon i (swapping) l vic chng trnh thc hin chuyn i th t trc v sau gia b nh chnh v b nh ngoi. Nu mt chng trnh c a vo vi quyn u tin cao hn mc u tin ca chng trnh thc thi hin thi, chng trnh mi s ngay lp tc c np vo b nh chnh, bt c chng trnh no trong b nh chnh cng c th c di chuyn ra b nh ngoi. Do , h thng s b p c s thiu ht khng gian nh bng cch s dng b nh ngoi. Trang (page).

A2 A3

A4

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

99

2. Cc h thng my tnh

2.3 K thut cu hnh h thng


M u
Nhiu cu hnh h thng khc nhau c s dng gim thiu chi ph v tng hiu nng ca h thng my tnh. Bao gm cc h thng khch/ch phn tn gnh nng, cc h thng song hnh tng tin cy, v cc h thng kp (d phng).

2.3.1 Cc h thng khch ch


im chnh
H thng khch/ch l mt v d thng thng v x l phn tn. Cc my khch yu cu x l v cc my ch cung cp cc dch v (x l).

H thng khch ch (Client Server System (CSS)) l mt h thng my tnh trong s dng mt mng x l phn tn; y l mt kiu cu hnh h thng.79

Tng quan v h thng khch ch


CSS c cu hnh vi cc my tnh m nhn cc vai tr gi l my khch v my ch (my phc v). Cc my ch cung cp cc dch v (x l) nh qun l tp, qun l c s d liu, sa i v cung cp d liu, iu khin in n, v cc chc nng giao tip, c yu cu bi cc my khch. My khch gi yu cu dch v n my ch, nhn cc kt qu d liu c x l bi my ch, v hin th cc kt qu . Cc my khch v cc my ch phn tn cc x l ca chng c gng lm gim gnh nng trong vic x l ca cc my. Ngoi ra, bng cch chia s cc ti nguyn, ngi s dng c th gim thiu c chi ph tha. V d, bng cch kt ni mt my in tc cao vi my ch, cc my khch c th cng chia s my in tc cao . Chi ph cho mt my in tc cao c th r hn vic chun b cho mi my khch mt my in tc thp, ph thuc vo s lng my khch. Cc my tnh c s dng nh mt my ch thng c hiu nng cao hn cc my khch. phn loi cc chc nng ca cc my ch khc nhau, c th gi tn theo chc nng ca chng, nh my ch tp, my ch c s d liu, my ch in, my ch giao tip.80

79 H thng khch/ch: Trong lp trnh a x l, ngi s dng c th chy c dch v khch v ch trong mt my tnh. Mt khc x l khch/ch khng c ngha l mi th c phn tn. y l mt phng php t c x l phn tn. 80 (Gi ) Nu mt yu cu dch v ca my khch khng c cung cp bi my ch phc v, my ch phc v c th tr thnh mt my khch v yu cu n mt my ch phc v khc x l yu cu .

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

100

2. Cc h thng my tnh

My ch

Yu cu x l Kt qu x l

UNIX, Windows Server 2003, v.v...

My khch

Windows XP, Macintosh, v.v...

Cc loi my ch
Bng sau m t cc loi my ch, da trn cc chc nng cung cp.81
Cc loi my ch My ch tp My ch c s d liu My ch in My ch giao tip Cc dch v cung cp Qun l cc tp c chia s, iu khin vic truy cp v ghi vo cc tp. Qun l c s d liu, thao tc c s d liu vi DBMS (h thng qun l c s d liu) Qun l my in c chia s, in n khi nhn c mt yu cu in. Cung cp cc chc nng giao tip vi bn ngoi s dng kt ni mng.

Cc c trng ca h thng khch/ch


Bi v h thng khch/ch cung cp kiu x l phn tn thng thng, v vy cc c trng ca x l phn tn c p dng l iu d hiu.82 Cc u im ca h thng khch/ch Khi cc x l din ra ti cc my khch, vic phn hi s nhanh hn. Cc chi ph cho ton b h thng thng tin c th c gim thiu, t c t l chi ph/hiu nng tt. Cc chc nng my ch chuyn dng cung cp cho h thng hiu nng v hiu qu kinh t cao hn. D dang m rng, cc my khch v my ch c th c thm vo mt cch linh hot khi cn thit. Thm ch khi cc my khch truy cp n mt my ch, chng cng khng bit l ang trong mt mi trng phn tn.

Cc nhc im ca h thng khch/ch H thng c th gp rc ri nu khng c ngi qun tr my ch r rng. Hiu nng b gim thiu nu ch s dng tp trung trn cc my ch chuyn dng. Hiu nng ca ton b h thng ph thuc vo hiu nng ca mng.83
81

(Gi ) Cc my khch v cc my ch khng cn phi chy cc h iu hnh ging nhau. nhng ni c nhiu my ch, chng khng cn phi chy cc h iu hnh ging nhau. Ngoi ra, nu c nhiu my khch, chng cng khng cn chy cc h iu hnh ging nhau. 82 (Gi ) Nu cc chng trnh khch/ch c phn chia logic vo 3 tng (tng trnh chiu, tng ng dng, v tng d liu) th h thng nh vy c gi l h thng khch/ch 3 tng. Bng cch phn bit 3 tng theo chc nng nh vy, h thng c gng nng cao hiu nng v hiu qu pht trin, bo tr. 83 (FAQ) C nhiu cu hi thi v kin thc h thng khch/ch. Hu ht trong s l v vai tr ca my khch hoc my ch. V vy cn chc chn hiu r cc kin thc v chng. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

101

2. Cc h thng my tnh

2.3.2 Cc cu hnh h thng


im chnh
H thng song hnh l mt cu hnh em li s tin cy cao; h thng d phng l mt cu hnh em li tnh sn dng cao. C 2 loi h thng a b x l: h thng cp i lng lo v h thng cp i cht ch.

C nhiu m hnh cu hnh h thng c th dng cn c theo mc tiu x l thng tin. V d, tnh tin cy ca mt h thng my tnh c th c nng cao bng cch s dng nhiu khi. Chng ta s xem xt cc cu hnh h thng chnh v c trng ca chng trn cc phng din tnh tin cy, hiu qu, chi ph v cc yu t khc.

H thng n cng
H thng ny ch bao gm mt CPU. Tnh tin cy v kh nng x l km hn so vi cc cu hnh khc, nhng n c tnh kinh t hn. y l cu hnh c s dng ph bin. 84

H thng song hnh


y l mt cu hnh h thng m c 2 CPU cng thc hin mt x l v so snh kt qu x l vi nhau. Cu hnh ny c ng dng khi vic x l i hi khng bao gi c php dng, thm ch ch mt lc. Nu mt CPU b li, h thng ngt CPU b li v tip tc x l trn CPU cn li. Tnh tin cy l cc k cao, nhng iu cng lm cho h thng tr nn rt t.85 86

So snh cc kt qu x l1

84 DCE (Data Circuit-terminating Equipment): L thit b bin i cc tn hiu nhn c trn ng truyn thng , gi chng n cc thit b u cui, v cng thc hin cc thao tc ngc li. Thng thng, thit b ny c kt ni ti u cui ca ng truyn thng v c chc nng nh mt giao tip vi my tnh. Mt modem c s dng trn ng tn hiu tng t, v DSU (Digital Service Unit) c s dng trn ng tn hiu s. 85 CCU (Communication control unit): L khi iu khin thu v pht d liu, thc hin iu khin li, v thu thp, phn tch cc k t. 86 DISC: Thit b lu tr ngoi

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

102

2. Cc h thng my tnh

H thng kp (h thng d phng)


H thng ny c 2 CPU, trong h thng chnh c s dng cho x l trc tuyn cn h thng ph th 2 c s dng cho cc x l c quyn u tin thp hn nh x l l.87 Nu h thng chnh b li, vic x l trc tuyn s chuyn sang h thng th 2.88 Thi gian chuyn t vi chc pht n vi gi. Tnh tin cy ca n thp hn h thng song hnh, nhng h thng ny c im tt hn chi ph, v th n cng thng c s dng hn h thng song hnh.
Khi chuyn i Khi chuyn i

(H thng chnh)

(H thng th 2)

H thng a b x l (Cc b x l ng thi)


Trong h thng ny, nhiu b CPU v CCU cng chia s v x l cc tc v, v th y l mt cu hnh h thng c hiu nng x l cao. C 2 loi h thng a b x l. Loi th nht l LCMP89 (loosely coupled multiprocessors h thng cp i lng lo), trong nhiu h thng my tnh c iu khin bi cc h iu hnh ring bit. Loi th 2 l TCMP 90 (tightly coupled multiprocessors h thng cp i cht ch), trong nhiu h thng my tnh chia s b nh chnh v c iu khin bi cng mt h iu hnh. Hnh sau ch ra mt v d v TCMP.

91

(FAQ) C nhiu cu hi thi v c trng ca cc h thng song hnh, d phng v a b x l. Thut ng chnh ca mi h thng l nh sau: so snh cc kt qu x l vi h thng song hnh, Chuyn i gia cc khi vi h thng d phng, v chia s b nh chnh vi h thng a b x l. 88 (Note) Nu c mt li xy ra trong h thng chnh, s mt thi gian chuyn sang h thng th 2. l bi v x l theo l hoc bt c vic g ang c thc trong h thng th 2 phi c tm dng, v h iu hnh phi c khi ng cho h thng trc tuyn. Mt cu hnh h thng d phng nng c th gii quyt vn ny, sn sng thay th bt c khi no. Trong trng hp ny, h iu hnh trn h thng trc tuyn lu li, do vic chuyn i c th din ra ngay lp tc. 89 LCMP (Loosely Coupled Multiprocessor): Mi mt CPU c b nh chnh ring v h iu hnh c lp. Cc CPU cng tham ra vo mt mng tc cao hoc ng dn chia s. y l mt cu hnh trong cc h thng my tnh c lp c kt ni qua mt mng. 90 TCMP (Tightly Coupled Multiprocessor): Mt b nh chnh v mt h iu hnh c chia s chung trong cu hnh ny. Mi CPU c th thc hin cc x l ging nhau, v th nu mt CPU b hng, x l vn c th tip tc, mc d hiu nng thp hn. Cu hnh ny c tnh tin cy cao v v th n c s dng trong cc h thng yu cu kh nng x l mc cao. 91 MM: B nh chnh Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

87

103

2. Cc h thng my tnh

2.3.3 X l tp trung v x l phn tn


im chnh
X l tp trung c mc an ton cao nhng li khng linh hot. X l phn tn c tnh kinh t, nhng kh hiu r v bn cht.

Da vo vic cc my tnh gi v tr nh th no v mt vt l, c 2 kiu x l: X l tp trung v x l theo phn tn.

X l tp trung
X l tp trung l mt cu hnh h thng trong mt my tnh c kt ni vi nhiu thit b cui, v my tnh mt mnh thc hin tt c cc x l. D dng trong vic duy tr tnh nht qun d liu v cng d dng qun l ti nguyn. Nhng u im lm cho cu hnh ny tr nn ph bin nhng ni m mt my tnh mc ch chung c s dng nh mt my ch trong x l tp trung. Di y tm lc s so snh tng i vi x l phn tn.
u im ca x l tp trung D dng ci thin t l chi ph/ hiu nng. (Grosch's Law92) Vn hnh v bo tr i hi t nhn vin hn an ton ca h thng cao Nhc im ca x l tp trung Kh nng m rng km thch hp vi cc cng ngh mi. D xy ra s tc nghn.93 Chi ph cho h iu hnh l rt quan trng. Khi phc mt li my ch s tiu tn thi gian Mt hng hc c th gy nh hng su rng.

X l phn tn
X l phn tn l mt cu hnh h thng trong nhiu my tnh kt ni vi nhau qua mt mng thc hin vic x l. Bi v vic x l c thc hin qua mt mng nn thi gian x l s lu hn so vi x l tp trung. Tuy nhin, n c u im l nu xy ra li mt my th vn khng nh hng n ton b h thng. Di y s tm lc s so snh tng i vi x l tp trung.94
Cc u im ca x l phn tn Cc trch nhim qun l l r rng. (Cc trch nhim qun l c th c phn cho mi t chc.) nh hng ca li h thng ch mang tnh cc b. Vic bo tr d dng. C tnh kinh t v ch nhng khi cn thit c ci t. Cc u im ca x l tp trung Trng thi thc t kh nm bt. Kh xc nh vn li ngay lp tc. Hiu nng ca mng c nh hng ln.. D xy ra s khng nht qun d liu. Cc khi ring bit c qun l lng lo.

Grosch's Law: Pht biu rng Hiu nng t l thun vi bnh phng ca gi tr. Nu gi ca my tnh tng gp i, hiu nng tng gp 4. Tuy nhin, tin b v cng ngh gim thiu ng k gi c ca cc thit b, v vy nh lut ny khng cn c p dng. 93 Backlog: Ngha l cc h thng, phn mm, cc chng trnh, v.v cn thit pht trin nhng s pht trin cha c bt u. Thut ng ny thng ch nhng th m c t chc trong phng cng ngh thng tin trong mt cng ty. 94 (FAQ) Nhiu cu hi thi yu cu ch ra cc c trng ca x l tp trung v x l phn tn. V d, cc cu hi c th c dng Ci no di y l mt c trng thch hp ca h thng x l tp trung? Cn bit cc u im v nhc im ca mi kiu x l. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

92

104

2. Cc h thng my tnh

Nh trong bng sau y, h thng phn tn c th c phn chia theo trng thi phn tn ca cc chc nng v cc ti. Ngi ta cho rng phn tn ti theo chiu dc l khng tn ti trong thc t.
Cu hnh Chc nng Phn tn theo chiu ngang Phn tn theo chiu dc Phn tn chc nng Phn tn chc nng theo chiu ngang Phn tn chc nng theo chiu dc Phn tn ti Phn tn ti theo chiu ngang

Phn tn chc nng theo chiu ngang Mt h thng phn tn chc nng theo chiu ngang l mt h thng trong cc my tnh c phn loi theo kiu ng dng v kiu d liu; cc v d loi ny bao gm s phn tn chc nng x l v s phn tn c s d liu. V d, trong cc th ch ti chnh, cc my ch c th c phn chia thnh nhm trong mt h thng thng tin v nhm trong mt h thng ti khon; s phn chia ny da trn kiu x l, do n l mt v d ca s phn tn chc nng x l. S phn tn c s d liu c ngha l cc my tnh c t trong cc v tr thch hp da trn ni dung ca d liu. Phn tn ti theo chiu ngang y l mt h thng trong nhiu my tnh thc hin chung cc x l khi mt ng dng c thc thi. Khi mt x l c yu cu, mt my tnh ri s phn hi. Trong ch ny, nu mt my tnh b li, x l c chuyn n mt my tnh khc v tip tc thc hin. Do , h thng vn hiu qu trong thi gian b li. Mt h thng a b x l kt i cht ch l mt v d ca kiu phn tn ny. Phn tn chc nng theo chiu dc y l mt h thng trong chc nng x l c chia s gia cc my trm dc theo nhng ngi s dng c nhn cng nh cc my tnh c chia s bi nhiu ngi s dng. Do , y l mt mi quan h theo chiu dc lin quan n chc nng x l. Mt h thng khch/ch l mt v d thng thng ca h thng phn tn chc nng theo chiu dc.95

95 (Gi ) Mt h thng khch/ch c a ra nh th l mt h thng phn tn theo chiu ngang, nhng mt cch ng n n c phn loi l phn tn chc nng theo chiu dc. V mt my ch thc hin x l ca nhiu my khch, nn y l mt mi quan h chc nng theo chiu dc.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

105

2. Cc h thng my tnh

2.3.4 Phn loi theo ch x l


im chnh
Trong ch x l theo l, tt c cc x l c lu tr v x l trong cng mt ln. Trong x l thi gian thc, d liu c x l ngay khi n c to ra.

Da trn quan im v ch x l, cc cu hnh h thng c th c phn thnh 2 loi: x l theo khi v x l thi gian thc. Chng cng c th c phn loi trn c s c hay khng kt ni n mt mng. Ch x l X l theo khi96 X l thi gian thc Ch hot ng X l theo khi trung tm X l theo khi t xa X l ch tng tc X l giao dch trc tuyn iu khin thi gian thc Phng php kt ni Ngoi tuyn Trc tuyn

Cc h thng x l theo khi (Cc h thng x l mt ln)


Thut ng khi (batch) c ngha l mt gi gp chung li (bundle). X l theo khi l bt k mt phng php no trong d liu x l bi mt my tnh c lu tr trong mt khong thi gian no hoc c lu trong mt mng hoc phng tin lu tr v sau c x l chung trong cng mt ln. Cc h thng nh vy c cc c trng sau: My tnh c th c s dng hiu qu v vic x l thc hin trong mt ln. Ph hp vi cc th tc con v cc x l c tnh lp i lp li (cc tc v chun). Kt qu khng t c ngay lp tc v vic x l c hon thnh chung. Trong cc h thng x l theo khi trung tm, x l khi a ra ti mt my tnh trung tm; trong ch x l theo khi t xa97, x l khi c thc hin t mt thit b cui c th kt ni ti qua mt ng truyn thng.

Cc h thng x l tng tc
y l mt phng php trong x l c thc hin trong ch hi thoi vi my tnh. Cc x l trong giao tip vi my tnh c th sa cha cc li ngay lp tc mi khi chng c thng bo; v th, y l mt ch x l ph hp cho vic pht trin chng trnh, v.v Mt h thng x l tng tc yu cu cc phn hi nhanh chng.

96 X l theo khi v x l thi gian thc: X l theo khi l trong d liu c lu tr v c x l chung mt ln. Cc v d c th k ti l tnh ton tin in, tin nc, tin ga. Tnh ton bng lng cng l mt v d ca x l theo l. X l thi gian thc l trong d liu c x l ngay khi n c sinh ra. Cc h thng t ch my bay, tu ha l cc v d ca x l loi ny. 97 X l khi trung tm v x l khi t xa: X l theo khi trung tm khng s dng ng truyn thng. X l theo khi t xa l trong mt thit b cui ngay gn c s dng thc hin x l theo khi ti mt my ch t mt v tr xa. i khi c gi l RJE, vit tt ca Remote Job Entry khi ngi s dng thc hin mt cng vic v tr t xa.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

106

2. Cc h thng my tnh

Mt h thng x l tng tc cng yu cu mt h iu hnh trong h tr chc nng a lp trnh, v x l c thc hin s dng TSS.98

Cc h thng x l giao dch trc tuyn


Mt giao dch l mt chui d liu hoc lnh, thng c gi l mt tp giao dch hoc d liu giao dch. X l giao dch trc tuyn l x l d liu cp nht trn mt tp trc tuyn ti mt my tnh trung tm thng qua mt thit b cui kt ni trc tuyn. Cc v d ca x l giao dch trc tuyn bao gm cc h thng lu tr ti khon trong ngn hng, cc h thng t ch hng khng v ng st. X l giao dch trc tuyn yu cu cc thit b cui chuyn dng c tnh hu dng cao mc ch nng cao hiu nng x l nh cc ATM ngn hng, cc thit b cui phc v pht hnh v ti cc ca t v. Ngoi ra, v d liu c chia s bi nhiu thit b cui, c mt ri ro l vic truy cp cng lc n cng mt d liu c th gy ra vn b tc (deadlock) 99 hoc ph hy d liu. V th, cn phi nng cao bo tr d liu.

iu khin thi gian thc


Nhn chung, iu khin thi gian thc l phng php trong d liu c x l trong thi gian thc mi khi c mt yu cu x l v kt qu tr v ngay lp tc cho i tng yu cu. Khi nim ny cng bao gm x l giao dch trc tuyn. Tuy nhin, trong mt ng cnh hp, y l ch x l c trng t ti cc thit b sn xut, trong h thng c kt ni vi mt h thng cm bin cc chuyn ng vt l ca cc i tng iu khin, cc x l tng ng vi cc tn hiu bn ngoi c thc thi ngay lp tc, v cc kt qu cng ngay lp tc c gi tr v cho cc khi trn cc dy truyn sn xut nh l cc tn hiu iu khin. Cc h thng iu khin sn xut trong mt dy chuyn sn xut thp v nh my t l cc v d v h thng iu khin thi gian thc. Mt v d khc l mt qui trnh gim st h thng in 24/24 gi qun l bi cc my tnh; nu c li xy ra, h thng s thng bo n c quan bo tr theo thi gian thc, hoc khi m d ra s c s b ngt theo thi gian thc.100

TSS (Time Sharing System): H thng cho php nhiu chng trnh c thc thi theo mt th t xc nh trong mt khong thi gian cc ngn trong mi ln. Th tc ny c lp li vic thc hin ca mi chng trnh c th c hon thnh trong mt khong thi gian no . Trn quan im ca ngi s dng, khng c s can thip ca con ngi, v th ngi s dng c th cm thy nh th l h thng my tnh ch s dng dnh ring cho mt chng trnh. 99 B tc (Deadlock): L trng hp trong h thng b tc nghn do nhiu tc v (chng trnh) c gng truy cp vo cng mt ti nguyn (tp, c s d liu, v.v) v i vo trng thi ch. 100 (FAQ) Nhiu cu hi thi lin quan n cc c trng ca x l theo khi t xa v x l tng tc. C 2 u l x l trc tuyn nhng ch rng x l theo khi t xa l kiu x l theo khi trong khi x l tng tc l kiu x l thi gian thc. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

98

107

2. Cc h thng my tnh

Cu hi nhanh
Q1 Q2 Gii thch cc vai tr ca cc my khch v my ch trong mt h thng khch/ch. Hnh di y ch ra loi cu hnh h thng no?
Khi chuyn i Khi chuyn i

(H thng chnh)

(H thng th 2)

Q3

Trong bng di, x l phn tn c phn loi theo trng thi phn tn ca chc nng v ti. H thng khch ch thuc loi no ?
Phn tn chc nng Phn tn chc nng theo chiu ngang Phn chc nng theo chiu dc Phn tn ti Phn tn ti theo chiu ngang

Cu hnh Chc nng Phn tn theo chiu ngang Phn tn theo chiu dc

Q4

S khc nhau gia x l theo khi v x l thi gian thc ?

A1

My khch: Gi cc yu cu dch v n my ch. Cc my ch: Thc hin cc yu cu gi n t my khch v tr v cc kt qu x l. H thng d phng: Cc im phn bit l tn ti 2 CPU v cc khi chuyn i. Phn tn chc nng theo chiu dc. X l theo khi: D liu c lu tr v x l trong cng mt ln. X l thi gian thc: D liu c x l ngay lp tc khi chng c to ra.

A2 A3 A3 A4

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

108

2. Cc h thng my tnh

2.4 Hiu nng v s tin cy ca h thng


M u
nh gi cc h thng my tnh, nhiu phng php khc nhau c a ra. Trong hiu nng tt (tc x l cao) v kh nng chng li (tnh tin cy cao) l rt quan trng.

2.4.1 Cc ch s hiu nng


im chnh
Thi gian p ng, thng lng, v thi gian quay vng c s dng nh gi hiu nng. Hn hp lnh v ch s benchmark c s dng lm cc ch s hiu nng.

nh gi hiu nng ton din ca cc h thng my tnh, bao gm phn mm v phn cng, c th s dng nhiu tiu ch khc nhau nh thi gian p ng, thng lng, v thi gian thay i. Cc ch s nh gi hiu nng, c bit l phn cng bao gm hn hp lnh v ch s benchmark.

Cc thut ng lin quan n nh gi hiu nng ca cc h thng my tnh


nh gi hiu nng ca cc h thng my tinh, vic tnh thi gian x l ca cc cng vic v cc chng trnh l quan trng.101 Thi gian p ng L lng thi gian t lc hon thnh qu trnh nhp t mt u vo n lc bt u qu trnh xut t mt u ra. V d, khi mt yu cu x l sinh ra t bn phm my tnh, thi gian ny l lng thi gian cho n kt qu c hin th trn khi hin th hoc cho n khi bt u in ra. y cng l yu t chnh c s dng nh gi hiu nng ca mt h thng trc tuyn. Thng lng (Kh nng x l) L s lng cng vic c th c x l bi mt h thng my tnh trong mt n v thi gian nht nh, hoc l s lng thi gian x l mt cng vic no . Thi gian x l ny bao gm thi gian CPU dnh ring v thi gian i x l nh chun b cc thao tc vo ra v thi gian dn dp.

101 (Gi ) Hn hp lnh v ch s benchmark dng nh gi hiu nng ca cc my tnh, hn hp lnh dng trong nh gi phn cng. Tuy nhin, mc d phn cng c nhanh th ton b hiu nng h thng vn thp nu hiu nng ca h iu hnh thp. Do , hiu nng ca phn cng thng ch mang tnh tham kho.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

109

2. Cc h thng my tnh

Thi gian quay vng (TAT) V mt k thut, y l lng thi gian to ra s quay vng ca h thng. Trong x l theo khi, y l lng thi gian tn ti t s xem xt ca mt chng trnh ti ca s n khi t c cc kt qu. Trong cc hot ng kinh doanh, y l lng thi gian t khi mt mt khch hng a ra mt yu cu t hng n khi sn phm t hng c chuyn ti khch hng.

Hn hp lnh (Instruction Mix)102


Hn hp lnh c s dng so snh hiu nng phn cng trong cc h thng my tnh. Cho d phn cng tt, nu hiu nng ca h iu hnh thp th hiu nng ca ton b h thng cng thp. Mt hn hp lnh dng cho mt chng trnh mc trung bnh tnh ton thi gian thc hin lnh trung bnh trn mt lnh v gi tr MIPS,103 da trn tn xut thc hin ca mi lnh. S dng cc iu kin sau, chng ta s a ra mt vi tnh ton c th gi tr MIPS Nhm lnh A B C Tc thc hin (microsecond) 0.1 0.2 0.5 Tn s xut hin 40% 30% 30%

u tin, chng ta tnh thi gian thc hin lnh trung bnh. Tc thc hin mi lnh c biu din theo n v micro giy (10-6). Thi gian thc hin lnh trung bnh l tng thi gian (trn ton b cc lnh) ca tch s gia thi gian thc hin lnh vi tn s xut hin tng ng. Thi gian thc hin lnh trung bnh = 0.1 * 10-6 * 0.4 + 0.2 * 10-6 * 0.3+0.5 * 10-6 * 0.3 = (0.04 + 0.06 + 0.15) * 10-6 = 0.25 * 10-6 (giy/lnh) S lnh trung bnh thc hin trong mt giy l nghch o ca thi gian thc hin lnh trung bnh, tnh nh sau: S lnh trung bnh thc hin trong mt giy = 1 / (0.25 * 10-6) = 4 * 106 (lnh/giy) = 4 (MIPS).104 105 FLOPS106 c s dng nh mt ch s tnh hiu nng ca thao tc vi cc s chm ng.

(Gi ) Mt hn hp lnh dnh cho cc tnh ton khoa hc gi l hn hp Gibson, v mt hn hp lnh khc dnh cho cc tnh ton kinh doanh gi l hn hp thng mi. 103 MIPS (Million Instructions Per Second): y l ch s hiu nng miu t s lnh my trong mt giy theo n v triu (106). y ch l hiu nng ca phn cng, v vy n ch c s dng mang tnh tham kho. 104 (FAQ) Cc k thi a ra cc cu hi yu cu tnh gi tr MIPS a ra mt hn hp lnh hoc tnh thi gian trung bnh ca mt lnh. Bn nn lm quen vi cc cu hi tnh ton . 105 Clock: L tn s ca tn hiu xung nhp c to ra bi b to xung nhp. Bi v cc lnh bn trong CPU c ng b vi tn hiu xung nhp khi chng c thc hin, nn tn s xung nhp cng cao, s lnh c thc hin trong mt khong thi gian cng ln. V d, nu tn s xung nhp l 200MHz, c 200 * 106 tn hiu xung nhp trn giy. Thng thng, mt lnh chim vi xung nhp. 106 FLOPS: Vit tt ca floating-point operations per second (S php ton du phy ng trong 1 giy). Nu miu t theo n v triu, k hiu l MFLOPS. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

102

110

2. Cc h thng my tnh

Ch s Benchmark
Ch s benchmark c s dng so snh v nh gi hiu nng ton din ca cc my tnh, bao gm phn cng v h iu hnh, bng cch o thi gian thc thi ca chng trnh chun107

2.4.2 Tnh tin cy


im chnh
Cc ch s tin cy gm RAS, RASIS, v ng cong bathtub Cc im cn lu trong thit k tnh tin cy l kh nng chu li v kh nng mm do vi li.

C nhiu mc tin cy c yu cu i vi h thng thng tin ph thuc vo mc ch s dng ca h thng. i khi phi chp nhn cc yu t v kinh t t c tnh tin cy cao. Trong mt vi tnh hung khc, khng ch yu t tnh tin cy i vi cc hot ng ca h thng m cc thng tin c iu khin bi h thng cng cn phi m bo tin cy.

Cc ch s tnh tin cy
Tnh tin cy l cp trong h iu hnh hot ng n nh. Trng hp l tng l h thng khng b li, nhng khng c h thng no m khng b bt c mt li g. RAS/RASIS C 2 thut ng RAS v RASIS u l vit tt ca nhng yu t gip cho cc h thng my tnh hot ng trong mt trng thi n nh. RAS l vit tt 3 ch ci u tin ca RASIS:
R A S I S

R: Reliability (Tnh tin cy - t li) A: Availability (Tnh sn dng - Kh nng sn dng cp cao108) S: Serviceability (Kh nng dch v - D dng pht hin cc phn b li) I: Integrity (Tnh ton vn - Nht qun d liu) S: Security (S an ton - Ngn cn cc truy cp khng c php)

(Gi ) Mt v d v ch s benchmark trong tnh ton k thut l SPECmark, v mt v d v ch s benchmark giao dch l TPC. TPC-C l ch s benchmark thng c s dng trong nhm TPC, p ng trc tip cc ng dng kinh doanh trn thc t. 108 Availability: Tnh sn dng c bit n nh l kh nng m h thng duy tr cc chc nng (hoc ng) ti bt k thi im no hoc phn trm lng thi gian m cc chc nng c duy tr trong sut mt khong thi gian no . Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

107

111

2. Cc h thng my tnh

ng cong Bathtub ng cong Bathtub c s dng minh ha cho khi nim vng i phn cng. Phn cng c th b li trong thi gian u ca qu trnh vn hnh do mt s b phn b hng hc, nhng xc sut xy ra cc li khi s gim dn do vic sa cha v thay th. Sau , do hao mn v hng hc ca nhiu b phn, xc sut xy ra li li gia tng, v thm ch vng i ca n s kt thc. ng cong ny c ch ra nh di y.109
T l li

Thi k li sm110

Thi k n nh111

Thi k li hao mn112


Thi gian

Cc im lu trong thit k tnh tin cy


Mt h thng tin cy cao c th tip tc vn hnh thm ch ngay c khi mt vi phn ca h thng b li, h thng nh vy c gi l mt h thng chu li (fault-tolerant). Cc k thut ph bin cho cc cu hnh h thng tin cy cao bao gm k thut mm do vi li (fail-soft), chc nng cho php h thng tip tc hot ng ca n vi hiu nng thp hn hoc t chc nng hn khi mt li xy ra; v k thut an ton vi li (fail-safe), chc nng cho php h thng hot ng an ton bng cch trnh cc iu kin ri ro khi c mt li xy ra. K thut mm do vi li (Fail-soft) y l chc nng trong khi c mt li xy ra, b phn b li c ngt khi h thng v h thng tip tc hot ng vi mt mc hiu nng thp hn (fall back113). Trong mt h thng d phng, thng thng c 2 h thng cng x l d liu c lp, nhng nu mt h thng b li, cu hnh s chuyn x l sang h thng cn li v s tip tc x l. Ngoi ra, khi mt li xy ra trong h a b x l, h thng tip tc cc dch v bng cch ngt b x l b hng ra khi h thng. y cng l mt cu hnh h thng mm do vi li. K thut an ton vi li (Fail-safe) y l mt chc nng trong khi c mt li xy ra, h thng s kha cc chc nng ca n trong mt ch an ton thit lp chuyn n iu khin khu vc nh hng ca li114. iu ny cng ging nh l phng php tt c cc n bo ca ng st u bt khi c mt tai nn xy ra. Trong cc cu hnh h thng m c 2 h thng so snh cc kt qu x l vi nhau, nh trong mt h thng song hnh, khi cc kt qu so snh khc nhau, h thng m c xc nh xy ra li s b ngt trong khi hot ng vn c tip tc.

(Gi ) ng cong bathtub c t tn nh vy l v th ch ra mi quan h gia xc sut li v thi gian ging vi hnh dng ca ci bn tm (bath-tub). 110 Thi k li sm (Early failure period): Thi k ca cc li ti thi im bt u s dng ca cc khi. Cc li s xut hin t hn theo thi gian. 111 Thi k n nh (Stable failure period): Cc khi n nh trong sut thi k ny, t xut hin cc li. 112 Thi k li hao mn (Wear-out failure period): Mt khong thi gian no tri qua, cc li tr nn xut hin nhiu hn trong thi k ny. 113 Fall-back: Trong mt h thng my tnh mm do vi li, vic x l vn tip tc vi cc chc nng mc thp hn; iu ny gi l fall-back. 114 (Gi ) Mm do vi li (Fail-sofe) v an ton vi li (fail-safe) l cc t tng t nhau, trnh nhm ln chng. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

109

112

2. Cc h thng my tnh

Fool-proof Thut ng ny l mt phng php ngn chn mt cng dng khng nh trc ca mt chng trnh gy li, c bit khi nhiu ngi s dng cng s dng mt chng trnh. Nu mt c nhn ang s dng mt chng trnh c th, cch m chng trnh thc hin khng gy ra vn g nhng khi c nhiu ngi cng s dng, chng trnh c s dng nh th no s rt kh d on.115

2.4.3 Tnh sn dng


im chnh
MTBF l thi gian h thng hot ng ng n, v MTTR l thi gian h thng c sa cha. Tnh sn dng l t l thi gian khi h thng hot ng ng n.

Mt trong nhng ch s trong RASIS l A vit tt ca Availability, c ngha l t l hot ng, c tnh s dng MTBF v MTTR nh sau: Availability: A = (MTBF) / (MTBF + MTTR)

MTBF v MTTR
Gi s trng thi hot ng ca mt h thng my tnh c ch ra nh trong hnh sau: Thi gian
Hot ng Sa cha Hot ng Sa cha Hot ng Sa cha Hot ng Sa cha

T1

D1

T2

D2

T3

D3

Tn

Dn

MTBF (Thi gian trung bnh gia cc li - Mean Time Between Failures) y l thi gian trung bnh m h thng tip tc hot ng khng c li. Gi tr MTBF cng ln, h thng cng tin cy. V th, n c s dng nh mt ch s nh gi tnh tin cy (R trong RASIS) 116 MTBF = (T1 + T2 + T3 + Tn) / n (Trong , n l s khong thi gian h thng hot ng khng c li.)

(FAQ) C nhng cu hi thi lin quan n ngha ca cc ch ci RASIS l g khi n l mt ch s tnh tin cy ca h thng my tnh. 116 (Gi ) Cc chc nng ci tin MTBF gm pht hin li, t n sa li 1 bit, th li lnh, v.v l cc chc nng ngn chn h thng khng b dng. Cc chc nng ci tin MTTR gm a ra nht k hot ng (log). Bng cch tm cc nht k hot ng (logs), c th xc nh c nguyn nhn ca li. Vic bo tr t xa cng gip pht hin li nhanh chng, ci tin MTTR. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

115

113

2. Cc h thng my tnh

MTTR (Thi gian trung bnh sa cha - Mean Time To Repair) y l khong thi gian trung bnh cn sa cha khi mt li xy ra. Thi gian sa cha cng ngn, h thng cng tt. V th, n l mt ch s nh gi kh nng dch v (S trong RASIS). MTTR = (D1 + D2 + D3 + Dn) / n (Trong n l s khong thi gian h thng hot ng khng c li.)

nh gi tnh sn dng
tnh ton tnh sn dng, cc kt ni tun t v kt ni song song phi c tnh ton khc nhau. tng c bn c m t nh sau117 Tnh sn dng trong mt h thng kt ni tun t Tnh sn dng ca ton b h thng kt ni tun t c ch ra y l tch s tnh sn dng ca mi khi. y, P1, P2, v P3 l tnh sn dng ca cc khi tng ng nh trong hnh v. Unit 1 P1 Unit 2 P2 Unit 3 P3

Tnh sn dng ca ton b h thng = P1 * P2 * P3

Tnh sn dng trong mt h thng kt ni song song Gi s rng c mt h thng kt ni song song nh hnh di y, trong h thng hot ng min l t nht mt trong cc khi 1, 2, 3 hot ng. y, tn sn dng c tnh ton s dng lp lun rng xc sut ca ton b khng gian mu l 1. Unit 1 P1 Unit 2 P2 Unit 3 P3
Tnh sn dng ca ton b h thng = 1 (Xc sut tt c cc khi cng hng ng thi) = 1 (Xc sut khi 1 hng) * (Xc sut khi 2 hng) * (Xc sut khi 3 hng) = 1 (1 P1) * (1 P2) * (1 P3)

117

(FAQ) y lun l mt cu hi lin quan n tnh ton sn dng. Bn cn chc chn hiu cch tnh n.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

114

2. Cc h thng my tnh

Tnh sn dng trong mt h thng kt hp c kt ni tun t v song song Gi s rng c mt h thng hot ng nu khi 1 hot ng v t nht mt trong s cc khi 2 v 3 hot ng. Trong trng hp ny, khi 1 v cm khi 2 v 3 l kt ni tun t. Unit P2 Unit P3

Unit P1

Tnh sn dng = (Tnh sn dng ca khi 1) * {1 (Xc sut khi 2 v 3 cng hng ng thi)} = (Tnh sn dng ca khi 1) * {1 (Xc sut khi 2 hng) * (Xc sut khi 3 hng)} = P1 * {1 (1 P2) * (1 P3)}

Xem xt cc cu hnh phc tp hn118. Mc d 2 h thng di y c th xut hin ging nhau nhng tnh sn dng ca chng l khc nhau. y, tnh sn dng c biu din bng ch trong hnh. [Cu hnh 1] C 2 cm kt ni song song (bn trong ng nt t) c kt ni tun t.

Tnh sn dng = {1 - (1 - )2} * {1 - (1 - )2} = 2 (2 - )2 [Cu hnh 2] C 2 khi kt ni ni tip (bn trong ng nt t) c kt ni song song.

Tnh sn dng = 1-(1 - 2) * (1 - 2) = 2 (2 - 2)

118

(Gi ) Ch rng cc cu hnh tng t nhau c tnh sn dng khc nhau.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

115

2. Cc h thng my tnh

Cu hi nhanh
Q1 Gii thch ngha ca cc thut ng: MIPS, thi gian p ng, thng lng, v thi gian xoay vng (turn-around time.) Gii thch ngha ca RASIS. Gii thch ngha ca MTBF v MTTR. Biu din tnh sn dng s dng MTBF v MTTR. Tnh tnh sn dng ca ton b h thng ch ra nh hnh di. A v B l 2 khi, mi khi c tnh sn dng l 0.97. Ton b h thng c xem l hot ng nu t nht mt trong 2 khi hot ng.
A

Q2 Q3 Q4 Q5

A1 MIPS:

Vit tt ca million instructions per second. Ch ra s lnh c th c thc hin trong 1 giy, biu din theo n v triu lnh (106). y l mt ch s hiu nng phn cng.

Thi gian p ng: L lng thi gian trong khong t khi truyn d liu i n khi tr v kt qu x l. y l mt ch s hiu nng ca mt h thng trc tuyn. Thng lng: L mt phng php nh gi kh nng x l cng vic ca mt h thng trong mt lng thi gian. y l mt trong nhng ch s nh gi hiu nng ca h thng my tnh.

Thi gian xoay vng: L lng thi gian trong khong t khi c mt yu cu cng vic n khi hon thnh u ra. Ch yu c s dng trong x l theo khi, y l mt ch s nh gi h thng bao gm hot ng ca n.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

116

2. Cc h thng my tnh

A2 RASIS l vit tt ca cc yu t gip cho cc h thng my tnh vn hnh trong mt trng thi n nh.
R A S I S

R: Reliability (Tnh tin cy t li) A: Availability (Tnh sn dng) S: Serviceability (Kh nng pht hin cc b phn li) I: Integrity (Tnh nht qun ca d liu) S: Security (Ngn cn nhng truy cp khng cho php)

A3

MTBF: (Mean Time Between Failures) l lng thi gian trung bnh m h thng tip tc hot ng khng c li. MTTR: (Mean Time To Repair) l lng thi gian trung bnh sa cha khi c li xy ra.
Availability (Tnh sn dng): A = (MTBF) / (MTBF + MTTR)

A4 A5

Ch rng 2 khi c kt ni song song. Availability = 1 (1 0.97) * (1 0.97) = 1 0.03 * 0.03 = 1 0.0009 = 0.9991.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

117

2. Cc h thng my tnh

2.5

ng dng h thng

M u
Hin nay c kh nhiu h thng khc nhau c pht trin da trn c s d liu v mng my tnh. D thy nht l Internet v cc dch v c s d liu (thng c gi l c s d liu thng mi). ha 3 chiu cng l mt th d v ng dng ca h thng a phng tin.

2.5.1 Cc ng dng mng


im chnh
S dng h tng Web, Internet, mng ni b, mng ni b m rng. Cc h thng ng dng bao gm mua bn qua internet, phn mm nhm v th tn dng.

Ngy nay, chng ta c mt h thng mng thng tin khng l tri rng khp th gii. C rt nhiu h thng s dng mng ny v nhng ng dng trn tng i phong ph. y l lnh vc kh mi, do vy s khng c nhiu cu hi trong ch ny, chng cng kh d. Phn ln cu hi s ch yu cu kin thc mc khi nim, v vy cn nh nhng khi nim c bn t kt qu tt nht.

Cc ng dng c s h tng
C s h tng c ngha l c s hoc nn tng. Trong cc h thng my tnh, t ny m ch n cc thnh phn c s bao gm phn nhng mm v phn cng cu thnh nn h thng . Vi d, trong mt cu trc mng, cc thnh phn khc nhau nh dy cp, cc thit b truyn thng tin, v h thng qun l cc dy dn l cc b phn ca mt c s h tng truyn thng. Web (WWW: World Wide Web):H thng cup cp thng tin dng siu vn bn, c pht trin bi cc nh nghin cu CERN. Thng tin phn b trn khp th gii c lin kt li nh s dng siu vn bn v mng Internet. WWW l c ch lu tr thng tin di dng mt trang ch trn mi my ch phc v. Phn mm truy cp WWW v hin th ln mn hnh gi l Web browser hoc n gin trnh duyt web browser. Internet L mt tp hp ca cc mng trn ton th gii kt ni vi nhau thng qua giao thc TCP/IP. Khng c mt t chc chnh ph no hoc mt t chc c ch nh no qun l tp trung ton b Internet. Thay vo , vic h tr k thut v qun l ti nguyn trn Internet c thc hin bi cc t chc tnh nguyn. Mng ARPANET119, c thnh lp bi b quc phng M, chnh l tin thn ca Internet. Intranets Mng ni b
119

ARPANET (Advanced Research Project Agency Network): y l mng my tnh quc gia c pht trin di s ti tr ca Advanced Reseach Project Agency Network ( D n mng h tr nghin cu cao cp) ca b quc phng M..

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

118

2. Cc h thng my tnh

Mng ni b l mng trong phm vi ca mt cng ty ng dng cng ngh ca Internet. Thng thng mt bc tng la120 s dc thit lp gia Internet v mng ngn chn r r thng tin ca cng ty ra ngoi. Internet Tng la Mng cng ty

Extranets Mng ni b m rng Extranet l mt mng intranet m rng ca nhiu cng ty. Ni chung, extranet c xy dng bi vic kt ni nhiu intranet vo Internet Mng nt b ca cng ty A Mng nt b ca cng ty B

Internet

Truyn thng di ng Truyn thng di ng121 l mi trng mng m ngi dng c th truy cp c t bt c ni no. Ngy nay truyn thng l xu hng ch o, chng ta c th gi v nhn th in t trn Internet v tm kim c nhiu thng tin a dng ch vi mt chic in thoi. Lin lc v tinh Lin lc v tinh l mt h thng truyn dn khng dy s dng cc v tinh truyn thng. Mt trm pht truyn i (ng ln) mt lng ln thng tin n mt v tinh truyn thng cch xa khong 36000km trn qu o tri t, thng tin sau c pht tr li (downlink) ti nhiu trm thu trn tri t. Bng cch , mt lng ln thng tin c th truyn ti nhiu im cng mt lc. CATV Nhiu loi hnh dch v s dng CATV (truyn hnh cp) ang c xem xt v tho lun a vo thng mai ha, nh l kt ni Internet, dch v in thoi, cc th nghim lin quan n PHS (Personal Handy-phone System), v VOD ( Video theo yu cu). CATV c mong i s l thnh phn chnh ca h tng thng tin trong k nguyn a phng tin.

Cc h thng ng dng
Mt h thng ng dng mng l tp hp cc h thng s dng mng thng tin, bao gm cc ng dng sau: Mua sm qua Internet - Internet shopping y l h thng m ngi dng c th mua hng cc ca hng o trn cc trang web. thc hin thanh ton, ngi mua hng c th s dng th tn dng hoc i n mt ca hng gn tr. Phn mm nhm - Groupware
Tng la - Firewall: L mt thit b t gia Internet v mng ni b cng ty qun l d liu vo ra v bo v mng ni b khi nhng tn cng t bn ngoi v nhng truy cp khng hp l. Bn thn tn ca thit b cng bao hm chc nng ca thit b. 121 Thit b di ng/in ton di ng - Mobile/mobile computing: Thit b di ng" m ch bt k thit b thng tin no c th cm i c bao gm in thoi di ng, h thng in thoi cm tay c nhn (PHS), my tnh xch tay..."in ton di ng m ch n ch s dng ca cc thit thng tin truy cp vo mng cng ty t xa. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng -120

119

2. Cc h thng my tnh

y l phn mm lin lc bn trong mt t chc hoc chia s thng tin. Mt vi chc nng ca phn mm nhm: th in t, chia s lch lm vic, ti liu v dng cng vic. Th tn dng - Debit cards y l dch v cho php ngi dng c th thc hin thanh ton thng qua mt chic th tn dng c ngn hng pht hnh. Tin thanh ton s c tr ngay vo ti khon ngn hng.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

120

2. Cc h thng my tnh

2.5.2 Cc ng dng c s d liu


im chnh
Th d v mt ng dng c s d liu data warehouse. ng dng ca c s d liu trong thng mi bao gm k ton doanh nghip, qun l ti sn, qun l ti liu v h tr bn hng.

Mt kiu h thng c s d liu ng dng l trung tm d liu (Data Warehouse). H thng ng dng m c s d liu c s dng trong thng mi bao gm h thng k ton doanh nghip122, h thng qun l ti sn,123, h thng qun l ti liu124, v h thng h tr bn hng125.

Trung tm d liu - Data Warehouse


Trung tm d liu l mt c s d liu ln ca ton cng ty h tr trong vic ra quyt nh. tng ca n l t chc lu tr mt lng ln d liu s dng tr gip trong vic ra quyt nh kinh doanh. i khi trung tm d liu c gi l c s d liu thng tin (informational database).

Khai ph d liu - Data Mining


Thut ng ny lin quan n mt cng ngh, phng php phc tho ra cc xu hng, s tng quan, cc m hnh d liu cn cho qun l v tip th, thng qua vic nghin cu mt lng ln d liu th. Trung tm d liu thng phn tch cc d liu khc nhau da trn mt vi gi thuyt cn khai ph d liu thng pht hin ra nhng xu hng v m hnh t lp ra gi thuyt.

Ch d liu - Data Mart


Ch d liu l c s d liu lu tr d liu c trch ra t trung tm d liu. D liu lu trong ny c la chn v thng k ty theo mc ch ca tng nhm ngi s dng. Khc vi trung tm d liu, ni cha ton b thng tin ca cng ty, ch d liu c kh t thng tin p ng nhu cu ca ngi s dng ch.

H thng k ton doanh nghip - Corporate accounting system: L h thng m cc th tc k ton ca cng ty c t ng ha lm cho vic tnh ton thng k hiu qu v nhanh chng hn. H thng qun l ti sn - Inventory management system: L h thng theo di cn i sn xut v nhu cu sn phm, qun l ti sn nh sn phm, nguyn liu ca cng ty mc ti u. Trong cc ca hng bn l nh siu th , thng tin bn l nhp vo thit b POS c thu thp li v phn tch sau d on nhu cu v t hng t ng, m bo hng mc an ton v ti u khi mua thm. 124 H thng qun l ti liu - Document management system: l h thng h tr cng ty trong vic qun l nhiu loi ti liu; tm kim ti liu t nhiu ngun lu tr khc nhau hoc t ni dung ca ti liu . Mc tiu ca h thng l lm cho vic qun l ti liu v chun b ti liu hiu qu hn, th d : trnh c vic chun b li mt ti liu c sn trong h thng. 125 H thng h tr bn l - Sales support system: l h thng h tr cc k hoch bn l sn phm da trn cc thng tin bn l tch ly c.
123

122

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

121

2. Cc h thng my tnh

OLAP
OLAP (X l phn tch trc tuyn - OnLine Analytical Processing) l ng dng phn tch trong ngi dng cui pht hin ra cc vn v gii php ca vn bng cch trc tip tm kim v t chc mt c s d liu; mc ch l nhanh chng truy cp ti d liu v cung cp mt chc nng h tr cho vic phn tch d dng hn126.

OLTP
OLTP (X l giao dch trc tuyn - OnLine Transaction Process) l ch x l m thng ip c gi n my tnh ch x l t nhiu thit b cui, thng ip s c x l thng qua vic truy cp n hng lot c s d liu v tr li kt qu ngay lp tc. C s d liu s dng bi OLTP c gi l c s d liu doanh nghip (business databases), hoc i khi c s d liu trc tuyn (operational databases). Nhng khi nim ny khc vi c s d liu thng tin (informational databases) Bng di y so snh hai loi c s d liu trn:
Tiu ch so snh Tc v Thm d liu ? Cp nht d liu ? Ch x l Ngi s dng chnh Loi hnh thng mi Thi gian duy tr d liu C s d liu thng tin Informational databases Tr gip quyt nh C Thng khng h tr OLAP Ngi qun l Cc tc v khng theo chn127 Di C s d liu trc tuynOperational databases Cc tc v doanh nghip chung C Thng c h tr OLTP Nhn vin Cc tc v chun Ngn

Cc h thng ng dng
Nhiu h thng c pht trin da trn c s d liu. Ngy nay, s khng l qu ng nu ni phn ln cc h thng u hot ng trn c s d liu. C th k ra mt vi u im ca vic s dng c s d liu nh sau: D liu c th d dng tch ly li. D liu c th thao tc mt cch thng nht, tch hp. D liu c th c x l d dng. D liu c th c tm kim d dng.

(FAQ) c nhng cu hi lin quan n trung tm d liu trong cc bi thi. Hy c gng nm chc ngha ca trung tm d liu, OLAP v OLTP. 127 Tc v chun/khng chun - Standard/non-standard tasks: Cc tc v chun l nhng cng vic m th tc x l c nh v d nh cc th tc kinh doanh hng ngy v nhp d liu bn hng hng ngy. Cc tc v khng chun v nhng cng vic m th tc x l thay i theo tng trng hp. Th d to ra mt ti liu phn tch, cn cc qu trnh khc nhau ty thuc vo mc ch s dng, v vy n c coi l tc v khng chun. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

126

122

2. Cc h thng my tnh

2.5.3 H thng a phng tin


Ch im
Cc th d v ng dng ca a phng tin, bao gm AI, 3DCG v nhn dng m hnh. Cc h thng ng dng a phng tin, bao gm qung b Internet v VOD(Truyn hnh theo yu cu).

a phng tin - Multimedia lin quan n vic x l khng ch k t v vn bn, m cn l hn hp ca hnh nh, video, m thanh v cc phng tin truyn thng khc. Khi nim ny cng m ch ti cc thit b v phn mm s dng trong truyn thng a phng tin.

Tr tu nhn to (AI)
Tr tu nhn to l h thng c th thc hin cc qu trnh suy din nh h chuyn gia hoc h thng dch my. Mt my tnh chun thng khng lm g hn ngoi thao tc vi s hc v thc hin cc php ton logic. AI, ngc li, thc hin cc qu tnh suy din trn cc xu k t. Hin ny Lisp v Prolog l nhng ngn ng ph hp nht pht trin phn mm s dng cng ngh tr tu nhn to.

ha 3 chiu (3D Computer Graphics, 3DCG)


ha 3 chiu trn my tnh128 bao gm to ra khng gian o 3 chiu trong my tnh, t cc m hnh vo khng gian ny, v di chuyn chng. Cng ngh ny cng c s dng trong cc b phim, tr chi v hot hnh. VRML129 c s dng pht trin 3DCG. Bng sau y so snh thc ti nhn to (artificial reality) v thc ti o (virtual reality).
Loi Thc ti nhn to (AR) Thc ti o (VR) Gii thch Cng ngh to ra mt th gii o bn trong my tnh, vi cm nhn ca thc ti. Khng cn cng c c bit no tri nghim thc ti nhn to ny. Cng ngh to ra mt th gii tng tng, c cm nhn con ngi v cm gic th gii nh l c tht. Cn c mn hnh 3 chiu ring v thit b nhp liu c bit. Th d : phu thut o t xa, m phng bay

128 ha my tnh - Computer graphics (CG): Cng ngh to nh s dng my tnh. C nhng cng c cho my tnh x l nh c sn hoc l my tnh t to nh mi (CGI computer generated images). 129 Ngn ng m hnh ha thc ti o - VRML (virtual reality modeling language): ngn ng c t chun 3DCG trn Internet.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

123

2. Cc h thng my tnh

Cc h thng ng dng a phng tin


C nhiu h thng ng dng cng ngh a phng tin. Nh s tr gip ca WWW, chng ta c th d dng truy cp n mt mi trng ha, cc ni dung a phng tin phong ph, sn sng s dng. Truyn hnh Internet - Internet broadcasting Cng ngh ny ng dng a phng trn nn Internet. Bng vic s dng cng ngh truyn pht theo dng130(streaming distribution technology), cc chng trnh c pht i trong thi gian thc. So vi cc phng php truyn thng, chi ph cho thit b t hn nhiu v hn na c th truyn i ton th gii. Dch v theo yu cu131 cng c th trin khai trn nn cng ngh ny v vy chng ta c th xem bt c khi no, v chng trnh g chng ta mun. Truyn hnh Internet c nhiu nh dng khc nhau. Truyn hnh theo yu cu lu tr ni dung trn mt my ch phc v v phn pht chng theo yu cu ca ngi dng . Truyn hnh trc tip (Internet Live) pht cc chng trnh trc tip nh cc bui ha nhc mt cch ng thi ti nhiu ngi dng. Bin tp video phi tuyn - Non-linear editing y l phng php bin tp video trong cc hnh nh c s ha v sp xp vo on video mt cch ty vi s tr gip ca my tnh. Vic chnh sa nh, thay i trt t xut hin v to ra cc phin bn khc nhau kh d dng. Theo phng php bin tp tuyn tnh truyn thng, cc hnh nh, on video phi c sp xp theo ng th t nh khi on phim hon tt. Truyn hnh theo yu cu - Video on demand Dch v ny gi ngay mt on video qua mt knh truyn no khi ngi xem c yu cu, th d thng qua truyn hnh cp hai chiu(bidirectional CATV). Nh cung cp dch v lu tr nhiu chng trnh trn my ch phc v ca h v phn pht theo yu cu ngi xem. Mt my ch phc v truyn hnh theo yu cu c th p ng c nhiu truy cp ng thi ca nhiu ngi xem, chng trnh c yu cu s c pht li t u vi tng yu cu truy cp . Do vy, nh cung cp cn phi thit lp mt c s d liu hnh nh v kt ni n cc thit b di ng cui, cc thit b thu hnh gia nh qua mt knh truyn bng thng rng nh dy cp, khng dy,

Truyn theo dng - Streaming: Cng ngh truyn d liu cho php nhn d liu v v hin th ngay lp tc. Streaming cho php truyn hnh Internet pht ni dung i v bn nhn hin th ngay m khng phi i thi gian tr. streaming hot ng tt, bng thng ca ng truyn phi cao hn lu lng thng tin truyn i/nhn v; tuy vy, kt ni Internet thng chm, do vy d liu thng c nn li m bo thng tin c truyn pht theo thi gian thc. Vic xem mt chng trnh theo cng ngh truyn thn thng mt thi gian v d liu phi ti v ton b trc khi n c th c hin th. Vi cng ngh streaming, vic hin th thng tin v ti d liu s c thc hin cng mt lc. 131 Theo yu cu - On-demand: L mt tnh nng ca h thng cho php cung cp thng tin no bt c khi no c yu cu. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

130

124

2. Cc h thng my tnh

Cu hi Q1 Q2 Intranet l g? Trung tm d liu l g?

A1

L mng trong mt cng ty ng dng cng ngh ca Internet. Thng thng mt bc tng la c thit lp gia Internet v mng ca cng ty phng chng vic r r thng tin ca cng ty ra bn ngoi. l mt c s d liu ca ton b cng ty, h tr vic ra quyt nh. Khi nim ny b bao hm vic lu tr mt lng ln thng tin mt cch c t chc tr gip cc quyt nh kinh doanh. i khi n cn c gi l c s d liu thng tin.

A2

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

125

2. Cc h thng my tnh

Cu hi 1
Q1. C mt h thng qun l tp tin theo n v l cc khi. Mi khi c tm cung v mi cung lu c 500 byte. Cn bao nhiu cung lu tr hai tp tin, mt tp kch thc 2000 byte v tp kia c kch thc 9000 byte? B qua cc cung s dng bi cc cu trc thng tin qun l, nh th mc. a) 22 b) 26 c) 28 d) 32

p n cu 1
p n ng: d
Tp tin c lu li theo n v kch thc l tm cung. Tm cung lu c: 8 * 500 = 4,000 (byte) Do vy nu mt khi t hn 4000 byte, c 4000 byte s c s dng. Tip theo chng ta tm s cung cn thit lu tr cho mi tp tin 2000-byte v 9000-byte. Dung lng cn cho tp tin 2000-byte l = 2,000 / 4,000= 0.5(khi) cn 1 khi (= 8 cung) Dung lng cn cho tp tin 9000-byte l = 9,000 / 4,000=2.25 (khi) cn 3 khi (= 24 cung) Vy lu hai tp tin trn , tng s cung cn cp pht l 8 + 24 = 32 cung.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

126

2. Cc h thng my tnh

Cu hi 2
Q2. Thut ng no di y ch qu trnh chia nh d liu v lu tr trn nhiu a cng(xem hnh di)? y, b0 to b15 tng trng cho th t d liu c lu vo a, theo n v l bit, p0 n p3 biu din cc bit parity s dng pht hin li a. n v iu khin b0 b4 b8 b12 a d liu 1 a) Striping c) Blocking b1 b5 b9 b13 a d liu 2 b2 b6 b10 b14 a d liu 3 b3 b7 b11 b15 a d liu 4 p0(b0 n b3) p1(b4 n b7) p2(b8 n b11) p3(b12 n b15) a parity

b) Disk caching d) Mirroring

p n cu 2
p n ng: a
Stripping l k thut phn phi mt khi d liu ln trn hai hoc nhiu a ng thi. Nh stripping, mi khi d liu c th c v ghi song song trn nhiu a, v vy tc vo/ra tng ln. Stripping l mt cng ngh ca RAID. Nh trn hnh, cu hnh ny c cha mt a cng ring bit cho vic kim tra parity; nhng cu hnh nh vy gi l RAID2, RAID3 hoc RAID4. b) B m a - Disk cache: L b nh m c t gia a cng v b nh chnh ci thin ng k tc ca a cng. c) Blocking l c ch x l mi tp cc bn ghi lun l nh mt bn ghi vt l (khi). d) Mirroring l chun b nhiu a cng v ghi mt cng d liu ln ng thi cc a. Nu mt a b hng, thao tc vo ra vn c tip tc vi nhng a cn li. Cu hnh ny c gi l RAID1.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

127

2. Cc h thng my tnh

Cu hi 3
Q3. Th t no di y l t nhanh nht n chm nht theo ngha tc truy cp b nh hiu dng.? B nh cache C cache hay Thi gian khng c cache? truy cp (ns) Khng c cache Khng c cache C cache C cache 20 10 T l trng (%) 60 90 b) A, D, B, C d) D, C, A, B B nh chnh Thi gian truy cp (ns) 15 30 70 80

A B C D

a) A, B, C, D c) C, D, A, B

p n cu 3
p n ng: b
B nh cache ( b nh m) l b nh t gia CPU v b nh chnh iu tit s chnh lch tc gia hai thnh phn trn. Tc truy cp hiu dng c th tng ln bng vic thm vo mt b nh m tc cao v thc hin c ghi ln b nh m nhiu nht c th. Gi s tc l tc truy cp ca b nh cache, tm l tc truy cp ca b nh chnh, v h l t l trng. Tc truy cp b nh hiu dng c tnh nh sau: Tc truy cp b nh hiu dng = tc * h + tm * (1 - h)

T l trng l xc sut d liu cn c c sn trong cache. T l trng cng cao th tc truy cp b nh hiu dng cng nhanh. T A n D, chng ta cn tnh thi gian truy cp b nh hiu dng. Vi trng hp A v B, khng c b nh cache, v vy thi gian truy cp b nh chnh cng l thi gian truy cp hiu dng. y chng ta c th coi h = 0. Di y l kt qu theo th t t nhanh nht n chm nht ( thi gian truy cp hiu dng ngn nht n di nht) A: 15 (ns) (1) B: 30 (ns) (3) C: 0.6 * 20 + (1 0.6) * 70 = 40 (ns) (4) D: 0.9 * 10 + (1 0.9) * 80 = 17 (ns) (2) Vy nu ta sp xp t A n D theo th t nhanh nht n chm nht, th t s l A,D,B,C.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

128

2. Cc h thng my tnh

Cu hi 4
Q4. Hin tng phn mnh file xy ra khi sao chp mt vi file t th mc ny sang th mc kia trn mt a cng trong mt my tnh c nhn. Pht biu no di y l ng trong tnh hung ny. a) Hin tng phn mnh c c loi b bng cch thc hin kt xut ton b a vt l v sau phc hi li a. b) Thi gian truy cp thm ch s cn lu hn cho mt vi file khc file b phn mnh. c) Nu file b phn mnh c sao chp ln na, tnh trng phn mnh ni sao chp n s cn ti t hn, n s khng bao gi b loi b. d) Ngay c khi phn mnh xy ra, kch thc ca tp cng khng b thay i so vi tp gc ban u.

p n cu 4
p n ng: d
Phn mnh ngha l tp khng c ghi ln mt vng lin tc ca a, m vo cc vng khc nhau trn a. Khi c yu cu n tp b phn mnh, nhiu vng khc nhau trn a s phi truy cp, do gim hiu sut x l. Tuy vy kch thc tp khng b thay i, ch n thun b chia nh ra v lu li. a) Nu a c sao chp mt cch vt l (ngha l tng bit thng tin trn a ging ht nhau c v gi tr v v tr trn a), th hin tng phn mnh vn xy ra. N phi c sao chp mt cch lun l. b) Nu mt tp c sao chp ln a cng m c cc tp khc th khng tp no b nh hng tr tp ang c sao chp. Cc tp khc khng b nh hng mt cch vt l. c) Hin tng phn mnh s c gii quyt nu tp c sao chp n ni mi c kch thc vng trng lin tip ln hn kch thc tp.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

129

2. Cc h thng my tnh

Cu hi 5
Q5. Bng di y ch ra thi gian x l cho mt CPU v cc thit b vo ra thc hin 5 tc v c lp. Tc v no (a,b,c,d) c th thc hin ng thi vi tc v c mc u tin cao thi gian ri ca CPU t lc bt u thc hin n lc kt thc tc v l 0 ? y mi tc v s dng mt thit b vo ra khc nhau v thc hin song song. Ti nguyn dnh cho h iu hnh c th b qua. n v: ms Mc u tin Cao a) b) c) d) Thp Thp Thp Thp Thi gian x l cc tc v ring r CPU (3) I/O (3) CPU (3) I/O (3) CPU (2) CPU (2) I/O (5) CPU (2) I/O (2) CPU (3) CPU (3) I/O (2) CPU (2) I/O (3) CPU (2) CPU (3) I/O (2) CPU (3) I/O (1) CPU (4) CPU (3) I/O (4) CPU (2) I/O (5) CPU (2)

p n cu 5
p n ng:c
Chng ta kim tra hot ng ca mi tc v c mc u tin thp xem ci no s dng CPU trong khi tc v c mc u tin cao khng s dng CPU. Cc thit b vo ra l khc nhau vi cc tc v khc nhau, do vy khng phi i thao tc vo ra. Tc v c mc u tin cao s dng vo ra hai ln, mi ln 3ms. Nu CPU c s dng bi tc v c mc u tin thp chnh xc 3ms, CPU s khng c thi gian ri. Th d, xem xt tc v (a). Trong thi gian 3ms khi tc v c mc u tin cao s dng vo ra ln th nht, tc v c mc u tin thp s s dng CPU trong 2m. Trong 1 ms cn li, c 2 u i cho thao tc vo ra hon tt, do vy CPU s khng lm g thi gian ny. Tng t nh vy, cc tc v c mc u tin thp nh (b) hay (d), c thi gian s dng 2ms, s dn ti CPU nhn ri. Ngc li, tc v (c) s dng 4ms cui cng, ngay khi tc v c mc u tin cao hon tt, do vy s khng c thi gian nhn ri cho CPU. Vy tc v c mc u tin thp c th chy cng vi tc v c mc u tin cao thi gian ri ca CPU l bng 0 l CPU (3), I/O (2), CPU (3), I/O (1) , CPU (4) .

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

130

2. Cc h thng my tnh

Cu hi 6
Q6. Biu di y m t qu trnh chuyn trng thi ca mt tc v (tin trnh) trn mt h thng a nhim. Khi no th tc v chuyn t trng thi thc thi sang trng thi sn sng ?

Thc thi

Sn sng

a) b) c) d)

Mt tc v c mc u tin hn chuyn sang trng thi sn sng. B lp lch to ra mt tc v mi. Mt thao tc vo ra hon tt. Mt thao tc vo ra va c yu cu.

p n cu 6
p n ng: a
Khi mt tc v (tin trnh) c to, n c chuyn sang trng thi sn sng v xp vo hng i. Sau , n c chuyn sang trng thi thc thi hay khng ty thuc vo mc u tin ca tc v, hoc chuyn sang trng thi i khi c mt thao tc vo ra xy ra. Qu trnh thay i nh vy c gi l qu trnh chuyn trng thi ca tc v. (1)
Tc v c to

(3)
Trng thi thc thi

(5) F
Tc v kt thc

E D

Trng thi sn sng

Trng thi i

(4) (2) C th gii thch cc trng thi v qu trnh chuyn trng thi nh sau. STT Trng thi (1) Tc v c to (2) Sn sng (3) Thc thi
Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

Gii thch Mt tc v mi c ng k v xp vo hng i Tc v i c cp pht ti nguyn CPU Tc v c s dng ti nguyn CPU v ang thc hin tnh ton
131

2. Cc h thng my tnh

(4) (5)

i Tc v kt thc

Tc v i mt s kin hon tt, th d, thao tc vo ra. Tc v hon tt v n khng cn cn thit na, s c xa khi hng i.

Qu trnh A B C D E F

Gii thch Mt tc v c to, n c a vo hng i Ty theo mc u tin m tc v c chuyn sang trng thi thc thi Do mt s kin no (i vo ra,), tc v c chuyn sang trng thi i Chuyn sang trng thi sn sng sau khi mt s kin hon tt. Chuyn sang trng thi sn sng do tc v khc c mc u tin cao hn chun b thc thi. Tc v ang thc thi hon tt.

Nh vy vic chuyn trng thi t thc thi sang sn sng l E. iu ny xy ra khi mt tc v c mc u tin cao hn chuyn sang trng thi sn sng. b) y l qu trnh chuyn trng thi A trong hnh. c) Mt thao tc vo ra xy ra. Khi thao tc ny hon tt, tc v c chuyn sang trng thi sn sng. y l qu trnh chuyn trng thi D trong hnh. d) Mt thao tc vo ra va c tc v yu cu. Nu iu ny xy ra, tc v s gi supervisor thc hin vo/ra sau n c chuyn n trng thi i ch thao tc hon tt. y l qu trnh chuyn trng thi D trong hnh.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

132

2. Cc h thng my tnh

Cu hi 7
Q7. Pht biu no di y ph hp vi mi hnh h thng khch/ch phc v ? a) My khch v my ch phc phi chy cng loi h iu hnh. b) My ch phc v gi cc yu cu x l d liu, my khch x l cc yu cu . c) Mt my ch phc v c th cho php my khch gi yu cu x l n my ch phc v khc nu cn thit. d) Cc chc nng phc v khc nhau phi t trn nhng my tnh khc nhau, th d my tnh phc v tp tin, my tnh phc v in n

p n cu 7
p n ng: c
M hnh h thng khch/ch phc v gm cc thnh phn gi l khch, ch phc v. My khch ch thc hin vo ra d liu, cc qu trnh khc thng qua my ch phc v, trong khi my ch phc v iu khin tt cc cc thao tc vo/ra ty theo phn cng v kiu my ch. Thng thng, Thnh phn khch l cc thit b c kh nng x l d liu nh my tnh c nhn, trm lm vic c th t chy ng dng. Thc t, n cng thc hin nhng cng vic m ch my khch c th lm c, nh l hin th vn bn, v hnh. Ngc li, my ch phc v truy cp c s d liu hay thc hin in n theo cc yu cu ca my khch. Hn na, nu mt my ch phc v khng th p ng c yu cu, n c th gi yu cu n my ch phc v khc. Lc ny, my ch phc v u tin li tr thnh my khch v n yu cu my ch khc thc hin yu cu. a) Cc h iu hnh khc nhau s khng gy ra vn g, min l chng chy cng giao thc. Mt my ch phc v chy h iu hnh UNIX c th lm vic tt vi cc my khch chy Windows. b) Th t phi l: my khch gi yu cu x l, my ch x l yu cu . d) Trong mt h thng quy m nh, mt my ch phc v v my khch c th chy trn cng mt my tnh, th d : X Windows ca UNIX. Ngoi ra, s khng c hn ch g nu my khch v ch phc v c xy dng trn cng mt nn tng (H iu hnh) v c th ni vi nhau qua mng.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

133

2. Cc h thng my tnh

Cu hi 8
Q8. Khi so snh mt h thng x l phn tn (bao gm nhiu my tnh trn mt din rng) vi h thng x l tp trung, u l tnh nng ni bt nht ca h thng x l tp trung ? a) Trong trng hp thm ha hoc hng hc, cng vic phc hi c th tin hnh tp trung ti mt ni, trnh c nguy c phi dng h thng trong mt thi gian di. b) Khi h thng c qun l tp trung, s d dng hn trong vic thm hoc thay i cc tnh nng ca h thng, him khi cng vic b n tc tr tr. c) D liu nht qun v d dng c qun l, bo tr thng qua vic ci t tp trung trung tm. d) Mc d vn hnh v qun l ti nguyn phn cng, phn mm tr nn phc tp, nhng vic m rng tn dng nhng u im ca cc ngh mi kh d dng.

p n cu 8
p n ng: c
tng ca mt h thng x l tp trung l mt my tnh a nng c ln. Cc thit b c tp trung ti mt ni nn vic qun l tr nn d dng. Tuy vy nu my tnh trung tm b hng, h thng s c th dng hot ng mt thi gian di. a) V my ch thc hin tt c cc x l, h thng s b ngng hot ng n khi my ch c khi phc. Nu y l li trm trng, thi gian ngng phc v ca h thng s c th kh di. b) Trong h thng x l tp trung, my ch mt mnh phi x l tt cc cc yu cu. Nu ni dung ca cc yu cu khc nhau ng k, my ch c th khng p ng c tt c nhng yu cu , dn ti hin tng nh tr. d) Mt h x l tp trung x l tt c cc tc v ti my ch, v vy s kh nng nhc cho my ch khi x l nhiu tc v doanh nghip ring bit. Hn na, khi chng ta mun m rng h thng, s c nhng tc v quan trng khng c php dng. Cng vi s gii thiu ca cng ngh mi, mt vi tc v c th s khng c x l lu hn.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

134

2. Cc h thng my tnh

Cu hi 9
Q9. Cho mt cng vic, cng thc no sau y biu din xp x mi quan h gia thi gian quay vng, thi gian CPU , thi gian Vo/Ra, v thi gian i ca tin trnh ? y cc loi thi gian ph khc c b qua. a) Thi gian i ca tin trnh = Thi gian CPU + Thi gian quay vng + Thi gian Vo/Ra. b) Thi gian i ca tin trnh = Thi gian CPU - Thi gian quay vng + Thi gian Vo/Ra. c) Thi gian i ca tin trnh = Thi gian quay vng - Thi gian CPU - Thi gian Vo/Ra. d) Thi gian i ca tin trnh = Thi gian Vo/Ra - Thi gian CPU - Thi gian quay vng.

p n cu 9
p n ng: c Thi gian i ca tin trnh l thi gian tnh n n khi CPU bt u x l hoc bt u mt thao tc Vo/Ra. Thi gian quay vng(Turn-around time TAT) l thi gian tnh t lc bt u gi cng vic cho n khi nhn c kt qu. Khi nim ny ch yu dng trong x l theo l. TAT bao gm c thi gian CPU x l l thi gian Vo/Ra. Vy thi gian i ca tin trnh c th tnh bng cch ly TAT tr i thi gian CPU x l v thi gian Vo/Ra.
Trong hnh di y, vng mu xu din t thi gian i ca tin trnh. Cng vic bt u CPU x l X l Vo/Ra CPU x l X l Vo/Ra Cng vic hon tt

Thi gian quay vng

Nh vy, i vi mt cng vic, cng thc biu din mi lin h gia gia thi gian quay vng, thi gian CPU , thi gian Vo/Ra, v thi gian i ca tin trnh l : Thi gian i ca tin trnh = Thi gian quay vng - Thi gian CPU - Thi gian Vo/Ra .

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

135

2. Cc h thng my tnh

Cu hi 10
Q10. Cc mng LAN c ci t nh hnh di y. My ch phc v kt ni ti LAN3, my khch trn mng LAN1 ang thc hin cc ng dng doanh nghip. Vic truyn d liu gia cc mng thng c thc hin qua Router 1. Nu c h hng Router 1, Router 2 v 3 s c s dng truyn gia mng LAN1 v LAN3. T l sn sng ca thit b LAN kt ni LAN1 v LAN3 l bao nhiu ? y, t l hng hc ca mi b nh tuyn l 0.1, khng tnh thi gian chuyn i gia cc thit b khi b h hng v gi nh khng c hng hc no trong LAN ngoi tr cc b nh tuyn..
Server LAN 3 Router 3 Router 1 LAN 2 Router 2 LAN 1 Client

a) 0.729

b) 0.981

c) 0.990

d) 1.000

p n cu 10
p n ng: b
rng Router 1 v kt ni ni tip gia Router 2 v Router 3 mc song song. T l hng ca mi b nh tuyn l 0.1 nn t l sn sng ca chng l 0.9. Do vy, cu hnh mng c v li nh sau. Cc gi tr trong hp l t l sn sng ca mi thit b. Cu hnh 1

Router 2 0.9 Router 1 0.9

Router 3 0.9 My ch phc v

My khch

T l sn sng ca cu hnh 1 = 0.9 * 0.9 = 0.81 T l sn sng ca ton h thng = 1 (1 0.81) * (1 0.9) = 0.981.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

136

2. Cc h thng my tnh

Cu hi 11
Q11. Pht biu no di y ph hp vi khi nim thc ti o (VR Virtual Reality)? a) S dng cng ngh nh CG ( ha my tnh), thc ti o biu din th gii bn trong my tnh nh th l th gii tht. b) Vi mc ch ci thin giao din ngi dng, n khng hin th mt bc nh dn dn t trn xung, m u tin hin th mt bc nh m, kiu nh khm, ri r nt dn dn. c) Thc ti o xc nh cc kt qu gi thuyt c th t c hay khng thng qua m phng my tnh .Th d: ng ng gi s dng trong cc thit k t v my bay. d) Cc kh nng nh nhn dng ngi, suy din c th thc hin c trn my tnh nh thc ti o.

p n cu 11
p n ng: a
Thc ti o (VR) dng to ra cc cm nhn thc t mt cch nhn to bng vic kt hp ha my tnh v hiu ng m thanh. ging vi thc t, ngi ta c th s dng mt mn hnh c bit nh head-mounted (Head-mounted Display) cho vic hin th hnh nh 3 chiu v thit b nhp c bit nh gng tay d liu. Hn na, cc tc ng ti hnh nh cng c phn hi li ti ngi xem, nng cao tnh thc t ca hnh nh. b) Pht biu ny m t k thut xen k - interlace. c) Pht biu ny m t k thut m phng. d) Pht biu ny m t cng ngh AI (Tr tu nhn to).

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

137

Pht trin h thng

Mc ch
Pht trin h thng l vic to nn phn mm vn hnh my tnh. Thng thng, cng vic ny c thc hin ln lt t phn tch yu cu, thit kt ngoi, thit k trong n lp trnh v kim th. Tuy vy, cng c nhiu phng php lun c xut ty thuc vo tng ng cnh pht trin h thng. Trong phn 1, chng ta s hc v cc phng php lun cho vic pht trin h thng cng cc yu t h tr nh: cc ngn ng lp trnh, cc nhm cng c v nh gi cht lng phn mm. Trong phn 2, chng ta s hc v nhng th tc c th ca vic pht trin h thng v cc phng php kim th.

3.1 3.2

Cc phng php pht trin h thng Cc cng vic trong cc qui trnh pht trin h thng

[Cc thut ng v khi nim cn nm vng] Ngn ng lp trnh, trnh bin dch, chng trnh con, qui, ng s dng, CASE, ERP, m hnh thc , m hnh ch th, phng php im chc nng, DFD, biu E-R, kim im, kim th hp trng, kim th hp en, s c lp ca cc m-un

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

138

3. Pht trin h thng

3.1

Cc phng php pht trin h thng

M u
pht trin h thng, chng ta cn bit n cc phng php lun ca vic pht trin h thng. Nhng phng php lun ny c th c phn loi theo cc m hnh qui trnh v cc m hnh chi ph. M hnh qui trnh l phng php ca cc th tc pht trin trong khi m hnh chi ph l phng php ca vic nh gi chi ph. p dng nhng phng php ny, trc ht chng ta cn bit v mi trng pht trin h thng. Mt mi trng pht trin h thng l mt nhm cc cng c h tr cho vic pht trin h thng, bao gm cc ngn ng lp trnh v CASE.

3.1.1 Cc ngn ng lp trnh


im chnh
Cc loi ngn ng lp trnh bao gm: hng th tc, hng chc nng, hng logic v hng i tng. Cc ngn ng tiu biu bao gm COBOL, C, Java v SGML.

Ngn ng lp trnh l ngn ng m t cc tin trnh (chng trnh) m ta mun my tnh thc hin. Chng ta chn cc ngn ng lp trnh thch hp ty thuc vo tng ng dng.

Phn loi cc ngn ng lp trnh


Di y l mt cch phn loi cc ngn ng lp trnh v mt s ngn ng tiu biu.
Loi c im Cc th tc c biu din di dng cc thut ton c th. Mi th tc c vit ra s c thc thi bi my tnh, mt lnh ti mt thi im. Cc bc tin trnh c biu din bng cch kt hp ca cc chc nng c bn (x l lit k - list processing) Cc mi quan h c nh ngha bi cc hm logic c bn (x l suy din - inferential processing) Thao tc c kim sot bi cc i tng. Chng kt hp d liu vi cch thc x l. Cc ngn ng lp trnh COBOL, C, Fortran, Pascal, Lisp, Prolog, Java, C++, Smalltalk,

Hng th tc (Procedural1) Hng chc nng (Functional) Hng logic (Logic) Hng i tng (Object- oriented)

Cc ngn ng lp trnh
c im ca cc ngn ng lp trnh thng dng c m t nh di y.

1 Phi th tc (Non-procedural): C mt s ngn ng lp trnh khng theo hng th tc v c gi l cc ngn ng lp trnh phi th tc. Chng c nhn bit bi tnh cht l th t cc lnh c vit ra trong chng trnh khng ng vi th t thc thi. Thng thng cc tham s s c a ra v cc tin trnh s c thc thi theo ni dung ca cc nh ngha tham s.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

139

3. Pht trin h thng

Hng th tc/chc nng/logic/i tng Ngn ng c im


COBOL C Fortran Pascal Lisp Prolog C++ Java Smalltalk Mt ngn ng x l thng mi (business-processing language) c t v ngn ng ny c to nn bi CODASYL. c pht trin bi AT&T2 vit nn h iu hnh cho UNIX3 C tnh kh chuyn (portability) d dng c pht trin bi IBM nh l mt ngn ng tnh ton cho khoa hc v cng ngh Mt ngn ng lp trnh cu trc c pht trin vi mc ch ging dy cho sinh vin Mt ngn ng x l lit k c pht trin ti MIT4 c s dng cho vic nghin cu trong lnh vc tr tu nhn to, Mt ngn ng c c ch suy din c pht trin ti i hc Marseille ca Php Mt ngn ng hng i tng v l s m rng ca C Hon ton tng thch mc cao hn vi C c pht trin bi Sun Microsystems, da trn C++ Chy trn bt k h iu hnh no c pht trin bi Xerox ti phng th nghim Palo Alto Theo kiu i thoi v lp trnh c

Cc ngn ng nh du (cc ngn ng nh dng vn bn) y l cc ngn ng m thng tin v b cc, c phng, nh dng v cc c t khc c gn trc tip vo hin th ln mn hnh hoc phc v vic in n. Vic chn thm cc biu tng (tag th) nh <TITLE> v </TITLE> trong mt on c gi l gn th (tagging). Bng di y minh ha cc ngn ng nh du chnh:
Ngn ng SGML
HTML XML

c im Standard Generalized Markup Language (Ngn ng nh du tng qut ha chun) Cu trc logic v cu trc ng ngha ca vn bn c biu din vi cc du n gin. HyperText Markup Language (Ngn ng nh du siu vn bn) y l ngn ng c s dng trong vic to cc trang web trn Internet. eXtensible Markup Language (Ngn ng nh du c kh nng m rng) y l mt s m rng ca chc nng siu lin kt HTML, c m rng ti mc SGML c th c gi v nhn qua mng. Cc th khng c nh m c th c nh ngha t do.

Cc ngn ng lp trnh khc Bng di y m t v cc ngn ng lp trnh khc Ngn ng c im PostScript L mt ngn ng m t trang5 c pht trin bi Adobe Systems ca M. Visual Basic L mt ngn ng lp trnh cho Windows, c pht trin bi Microsoft ca M. Perl L mt ngn ng kch bn m t vic truy cp cc b m v CGI6 ca cc trang web.

Cc ngn ng kch bn (Script languages)


Ngn ng kch bn l ngn ng s dng vn bn (k t) m t cc th tc c thc thi bi
AT&T: American Telephone and Telegraph, mt cng ty in bo lu i nht th gii v ln nht ti M. (Ch ) C l ngn ng lp trnh c pht trin vit nn h iu hnh cho UNIX, nhng v n d s dng nn ngy nay c mt lng ln cc chng trnh c vit bi C, bao gm cc ng dng thng mi v cc h iu hnh. 4 MIT: Massachusetts Institute of Technology. 5 Ngn ng m t trang: y l ngn ng c s dng nh ngha nh in ra cho my in khi in vn bn s dng my in trang. Cc nh c th c in ngay c khi cc my in c nhng phn gii khc nhau.. 6 CGI (Common Gateway Interface): y l nguyn l ly cc yu cu t mt trnh duyt WWW, gi mt chng trnh bn ngoi c yu cu v tr v cc kt qu thc thi cho trnh duyt WWW.
3 2

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

140

3. Pht trin h thng

my tnh. Cc th tc x l c biu din bi mt ngn ng kch bn c gi l cc script. Phn ln chng nm trong cc phn mm c s d liu cng nh phn mm bng tnh v c s dng nh cc macro. Theo cch nhng ngn ng ny m t cc th tc th chng ging nh cc ngn ng lp trnh hng th tc; tuy nhin, cc script ny c c trng l iu khin theo s kin (event-driven)7. Ngoi ra, mt mi trng pht trin s dng GUI thng c h tr cho ngi dng cui gip h vit cc chng trnh mt cch d dng.8

3.1.2 Cu trc chng trnh v chng trnh con


im chnh
Cc cu trc chng trnh bao gm cc loi: ng s dng (reentrance), ti s dng v qui. Cc chng trnh con c th l cc chng trnh con m hoc ng.

Cc tin trnh c s dng thng xuyn trong mt chng trnh hoc cc tin trnh chia s c duy tr nh nhng chng trnh ring r v c chia s cho nhiu chng trnh. Nhng chng trnh nh vy c gi l chng trnh con, cc chng trnh con khc nhau c s dng tun theo cc iu kin s dng.

Cu trc chng trnh


Theo cu trc, cc chng trnh c th c phn loi nh di y: Cu trc chng trnh qui Ti s dng ng s dng Ti s dng tun t Khng dng li c qui Mt th tc c gi l qui nu nh ngha ca n tham chiu ti chnh n. Chng trnh trong nh ngha ca mt chng trnh con hay mt hm s dng chnh chng trnh con hoc hm c gi l chng trnh qui. Mi tham chiu nh vy c bit n nh mt li gi qui. Li gi ny c th c s dng trong hu ht cc ngn ng lp trnh ngoi tr COBOL v Fortran. Cu trc gi li chnh n C th c s dng lp i lp li m khng cn np li Nhiu tc v9 c th s dng chng trnh cng mt thi im Nhiu tc v c th s dng chng trnh mt cch tun t Phi np li mi khi s dng

iu khin theo s kin: L chng trnh c kch hot bi mt s kin v khi ng p ng v x l s kin. Mt s kin l bt k mt s thay i c iu kin no, chng hn nh vic nhn vo bn phm. Cc chng trnh khi ng khi ngi dng nhp chut vo mt biu tng l chng trnh iu khin theo s kin. 8 (FAQ) C cc cu hi tng hp v phn loi cc ngn ng ph bin. Chng hn, ta bit rng COBOL l hng th tc, Lisp l hng chc nng, v Java l hng i tng. 9 Tc v: L mt n v x l c c khi cc tin trnh c chia nh rt chi tit. Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

141

3. Pht trin h thng

Ti s dng (reusable) Thut ng ny ni ti loi cu trc chng trnh cho php nhiu chng trnh (hay tc v) chia s vic s dng chng trnh ny m khng cn np li vo b nh chnh mi thi im. Nu chng trnh c th c s dng ng thi bi nhiu tc v th n c gi l ng s dng10 (reentrant); nu khng, n c gi l ti s dng tun t (serially reusable).

Chng trnh con


Chng trnh con l mt phn ca chng trnh c s dng lp i lp li bn trong chng trnh thc thi cc th tc chung. Nu c nhiu chng trnh cng thc thi mt s th tc th nhng th tc ny c th gom li nh mt chng trnh v nhng chng trnh khc c th chia s vic s dng n. Nhng chng trnh nh vy cng c gi l chng trnh con. Chng trnh con m Mt chng trnh con m11 l mt chng trnh con c nhng vo bt k ni no chng trnh cn vi s ln ty thch. Chng trnh con ng Mt chng trnh con ng c to ra c lp vi cc chng trnh cn ti n. Nu mt chng trnh cn chng trnh con ny, n thc hin mt li gi chng trnh con (thng l cu lnh CALL) chuyn iu khin ti chng trnh con. Hnh di y minh ha khi nim v mt chng trnh con ng. Cc tin trnh c thc thi theo th t (1), (2), (3), Bng cu lnh CALL, chng trnh nhy ti li vo chng trnh con, v bng cu lnh RETURN, n tr v v tr ca cu lnh CALL (im tr v).12
(1)
Cu lnh CALL (im tr v) (5) Cu lnh CALL (im tr v)

(2)
Lnh gi

(6)
Lnh gi

(9)
(Li vo)

(4)

(8)

(3) (7)
Cu lnh RETURN
(lnh tr v)

Chng trnh con

(Ch ) Trong mt chng trnh ng s dng, cc phn khng th thay i (ch yu l cc phn th tc) v cc phn c th thay i (ch yu l d liu) c phn tch sao cho cc chng trnh c th s dng n cng thi im nh chia s vic s dng nhng phn khng th thay i v gi li nhng phn c th thay i theo chng trnh gi chng trnh ng s dng. Thng thng, hu ht cc chng trnh x l trc tuyn u l cc chng trnh c cu trc ng s dng. 11 Chng trnh con m: C th c thc thi nh mt macro trong hp ng, mt th vin sao chp trong COBOL, v %include trong C. 12 (FAQ) V cu trc chng trnh, gn y c nhiu cu hi lin quan n qui v ng s dng. qui l gi li chnh n cn ng s dng l c gi ng thi bi nhiu chng trnh. Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

10

142

3. Pht trin h thng

3.1.3 Cc b x l ngn ng
im chnh
Cc b x l ngn ng bao gm cc trnh bin dch, cc trnh thng dch Cc m-un np c to ra bi cc b son tho lin kt.

Mt ngn ng lp trnh s dng cch biu din tng t nh nhng ngn ng thng ngy c th vit cc chng trnh mt cch d dng. Tuy nhin, my tnh khng th hiu cc cu lnh ca bt k ngn ng lp trnh no. Do , cn phi chuyn i nhng chng trnh c vit bi cc ngn ng lp trnh thnh nh dng m my tnh c th hiu c. Vic chuyn i ny c thc thi bi b x l ngn ng.13

Cc b x l ngn ng
Mt b x l ngn ng l mt chng trnh dch (chuyn i) cc chng trnh ngun thnh ngn ng my. Cc b x l ngn ng c trnh by di y:
B x l ngn ng

Assembler Compiler Generator Interpreter

Trnh dch hp ng: Dch chng trnh hp ng thnh ngn ng my. Trnh bin dch: Dch ngn ng bin dch 14 thnh ngn ng my (COBOL, Fortran, C,) Trnh sinh m: To cc chng trnh bng cch a ra cc tham s (RPG,) Trnh thng dch: Thc thi khi dch cc cu lnh (BASIC, APL, LOGO,)

Ngoi ra, cng c nhng b tin x l15 chuyn i chng trnh ngun thnh mt ngn ng bin dch, khng phi ngn ng my.

Cc th tc ca trnh bin dch


Mt ngn ng bin dch c dch thnh ngn ng my theo th t di y. Chng trnh c dch thnh ngn ng my th c gi l chng trnh ch (hay m-un ch).
Phn tch t vng

Phn tch chng trnh ngun thnh cc bin v cc token (cc n v ngn ng nh nht)
Phn tch ng ngha

Phn tch c php

Phn tch chng trnh theo c php ca ngn ng Xc nhn khng c li ng ngha trong chng trnh To ra m mc ngn ng my Loi b nhng phn khng cn thit chng trnh ch Php nhn c thay th bi php cng lin tip Nhng bin khng cn thit vng lp c a ra ngoi vng lp Mi lnh c thay th bi lnh khc vi tc x l cao hn
Sinh m Ti u ha

(FAQ) C nhiu cu hi v vic la chn u l c im ca thng dch v bin dch. Hy chc chn rng bn hiu y nhng c im . Cc cu hi lin quan n th tc ca trnh bin dch cng thng c hi trong cc k thi. 14 Ngn ng bin dch: L mt ngn ng lp trnh to ra cc chng trnh ch t chng trnh ngun nh s dng trnh bin dch. N cng c gi l mt ngn ng cp cao hn v bao gm COBOL, Fortran, Pascal, PL/I, v C. Ngn ng bin dch s dng cch biu din ging nh trong i sng thng ngy ca con ngi. V vy chng d hiu v d hc. 15 B tin x l: L chng trnh ly chng trnh ngun trc khi chng c trnh bin dch dch sang ngn ng my v bt chng thc thi vi nhiu tin trnh. Chng hn, mt b tin x l cho ngn ng C h tr cc hm nh nh ngha cc gi tr s c tm thy trong chng trnh ngun di dng cc chui k t v ly cc tptp th vin c tham chiu bi chng trnh ngun. Chng c nh du bng t kha include. Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

13

143

3. Pht trin h thng

To m-un np
My tnh ch c th c v thc thi ngn ng my, do vy bt k chng trnh c vit bng ngn ng no khc cn phi c dch thnh ngn ng my. Mt cch thc hin vic l s dng trnh bin dch.16 Dch Chng trnh ngun
B x l ngn ng

Son tho lin kt Chng trnh ch


B son tho lin kt

M-un np

Cc m-un np l cc chng trnh c th thc thi. Cc chng trnh ch (c dch bi mt b x l ngn ng) khng th thc thi c. Qua mt chng trnh son tho lin kt (b son tho lin kt), nhng g cn cho vic thc thi s c b sung vo chng trnh ch. Trong vic lin kt hai hay nhiu chng trnh ch, b son tho lin kt s gi cc hm v cc chng trnh con m chng trnh ch s dng t th vin phn mm v lin kt chng vo chng trnh ch. B son tho lin kt cng c gi l b lin kt. Cc trnh thng dch khng c chng trnh ch. Ni ng hn, chng thc thi cc cu lnh ging nh vic dch tng cu lnh. Cc trnh sinh m to trc tip cc m-un np bng cch a ra cc tham s.

Thc thi chng trnh


thc thi mt chng trnh, cn phi lu chng trnh trong b nh chnh hoc trong mt b nh o. Chc nng ny c thc hin bi mt b np. B np lu mt m-un np trong b nh chnh v sau mi thi im, my tnh s ly mt lnh t m-un np, dch v thc thi n.

3.1.4 Cc mi trng pht trin v cc gi phn mm


im chnh
Cc cng c CASE v cng c h tr kim th s h tr cho pht trin h thng. ERP l mt gi phn mm c thit k to nn cc qui trnh kinh doanh hiu qu hn.

Mi trng pht trin bao gm cc phn cng cn thit xy dng h thng v cc phn mm chng hn nh cc cng c h tr pht trin h thng.

16 (Ch ) Vic lin kt mt chng trnh con trong khi to m-un np c gi l lin kt tnh. Ngc li, nu cn cng c th lin kt mt chng trnh con trong khi chng trnh c thc thi. Phng php ny c gi l lin kt ng.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

144

3. Pht trin h thng

Cc cng c CASE (Computer Aided Software Engineering)


CASE l mt nhm cc phn mm h tr vic pht trin h thng v t ng ha trong cng vic bo tr. CASE bao gm cc c s d liu chia s - ni lu tr nhng thng tin cn thit cho vic pht trin chng hn nh cc yu cu v thng tin thit k cho vic pht trin h thng. N cng thc hin vic qun l mt cch thng nht ton b qui trnh pht trin h thng. Hn na, cc kt qu thit k c th c minh ha bi nhng hnh v d hiu. CASE c th (H tr cc qui trnh c th)

CASE thng lu

H tr tt c cc tin trnh

Xc nh yu cu Thit k ngoi

H tr cc qui trnh thit k

Thit k chng trnh Lp trnh Kim th Vn hnh, bo tr18

CASE thng dng

CASE tch hp17

Thit k trong

H tr ti liu, qun l d n,

CASE h lu

H tr cc qui trnh pht trin

CASE bo tr CASE cung cp nn tng pht trin Kho cha19

H tr cc qui trnh bo tr

Xc nh s ghp ni cc CASE hin c

CASE tch hp: L nhng cng c h tr ton b qui trnh pht trin h thng. Ban u, tng ca CASE tch hp l c mt CASE bao ph c tt c cc qui trnh; tuy nhin, thc t l CASE tng phn c s dng v tng tt hn ht l s dng nhng cng c c sn ny tr nn ph bin. V vy, ngy nay CASE tch hp c pht trin nh mt cch to nn s ghp ni gia cc cng c CASE m nh , cc thng tin thit k c th c trao i tt hn. 18 (Gi ) Mt s CASE thng dng c nhng chc nng h tr ton b qui trnh pht trin. Tuy nhin, chng c phn bit vi CASE tch hp. CASE thng dng qun l cc lnh vc bn ngoi thng tin thit kt, chng hn nh h tr ti liu (bng, th, hnh v), qun l d n, qun l cu hnh h thng. 19 Kho cha: L mt c s d liu bn trong cc cng c CASE lu tr nhiu loi thng tin, n cng c bit n nh mt c s d liu cng ngh phn mm hay mt thit b lu tr. Vi vic qun l thng tin thit k mt cch thng nht nh s dng kho cha, ta c th kim tra tnh nht qun v ton vn cng nh t ng ha cc qui trnh pht trin. Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

17

145

3. Pht trin h thng

Cc cng c h tr kim th
Cc cng c h tr kim th phn tch mt chng trnh v gim st s vn hnh ca chng trnh khi thc thi. Nhng cng c chnh v chc nng ca chng c trnh by nh bng di y.
Cng c Kt xut b nh Kt xut snapshot Ln vt To d liu kim th M phng Hn tp Chc nng a ra ni dung ca b nh ngay sau khi chng trnh b ngt bt thng. a ra ni dung ca b nh trong khi chng trnh ang thc thi a ra cc lnh thc thi v ni dung ca cc thanh ghi tng thi im. T ng to nhiu loi d liu kim th M phng cc chc nng khng th thc hin c lp; m phng trc tuyn, m phng n v, Cng c bt iu khin, cng c chuyn i phng tin, gim nh20 21

EUC (Tnh ton ngi dng cui)


EUC (End User Computing) l tng v vic ngi dng cui c th t mnh thc hin cc qui trnh nh thit k, pht trin, vn hnh v bo tr h thng thng tin. Nng cao nng sut my tnh c nhn, gim thiu chi ph, pht trin x l phn tn da trn mng lm vic v ph bin cc gi phn mm tt c u ng gp cho tin trnh ca EUC. Trc y, b phn ngi dng thng yu cu rng vic pht trin v qun l vn hnh phi c thc hin bi cc b phn h thng thng tin; tuy nhin, cng vic ca cc b phn h thng thng tin ngy cng tng v kh c th cung cp nhng dch v ring bit cho ngi dng cui. Sau , trong gii hn bi cc b phn v cc nhm, ngi dng cui bt u t thc hin vic vn hnh v qun l h thng. Do ngi dng cui t vn hnh, thit k, pht trin v tch hp nn h c th iu chnh h thng ph hp vi nhng mc ch ring. Tch hp v pht trin h thng bi ngi dng cui c gi l EUD (End User Development), tuy vy trong thc t, s khc bit gia EUC v EUD khng c xc nh r rng.

Cc gi phn mm
Gi phn mm l phn mm mc ch chung m nhng ngi dng thng thng c th s dng mt cch ph bin. Trong s nhiu loi gi phn mm, cc gi thng mi nhn c nhiu s ch hn trong thi gian gn y v chng h tr cc qui trnh nghip v mt cch hiu qu. ERP ERP (Enterprise Resource Planning Lp k hoch ti nguyn doanh nghip) l khi nim v vic lp k hoch cho s ti u ha trong qun l ti nguyn nh vic hiu thng tin kinh doanh ca ton cng ty.22 Phn mm c tch hp t c mc ch ny c gi l mt gi ERP. Gi ERP l gi phn mm tch hp tt c tc v chung trong mt c s d liu m khng quan tm n kiu tc v, chng hn nh qun l sn phm, k ton, qun l bn hng, nhn s v tin lng.
Gim nh: s dng bng hi thoi thay i cng bc d liu v xem ni dung trong qu trnh thc thi chng trnh. 21 (FAQ) Cc cu hi v cng c h tr kim th c trong cc k thi. Hy nh chnh xc cc chc nng ca kt xut snapshot v ln vt. 22 (FAQ) Gn y, cc cu hi v cc gi phn mm thng xut hin. c bit, cu hi v ERP l ni bt nht. Cn phi hiu c cc tnh cht ca ERP. thc hin ERP, cn xem xt v cc qui trnh kinh doanh. Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng -20

146

3. Pht trin h thng

CRM CRM (Customer Relationship Management Qun l quan h khch hng) l khi nim trong tt c cc phng ban c c hi lin lc vi khch hng phi chia s, qun l thng tin cng nh lch s lin lc vi khch hng bt k cu hi no t khch hng cng c tr li thch ng nht. Cc cng ty c gng y mnh vic m rng khch hng ca h bng vic kt hp tt c cc knh truyn thng nh in thoi, fax, Web, e-mail, cng c mi quan h vi khch hng v cung cp nhng dch v m tng khch hng ring l cn. SFA SFA (Sales Force Automation T ng ha lc lng bn hng) l khi nim c bn ca h thng thng tin gip ch cho vic t chc li ton b hot ng bn hng nh nng cao li nhun ca t chc bng vic s dng cng ngh thng tin. V d, nhiu hot ng bn hng c th c to ra nh qun l cc bn ghi lin lc vi mi khch hng trn my tnh. Hn na, vic trao i cng vic vi nhn vin mi cng c thc hin tt hn. CTI CTI (Computer Telephony Integration Tch hp in thoi my tnh) l cng ngh cung cp cc dch v in thoi cao cp nh vic kt hp cc chc nng x l thng tin ca my tnh v cc chc nng truyn thng ca in thoi.

3.1.5 Cc phng php pht trin


im chnh
Cc m hnh qui trnh bao gm m hnh thc , m hnh ch th v m hnh xon c. Cc m hnh chi ph bao gm m hnh COCOMO v m hnh FP.

M hnh qui trnh l m hnh ca phng php pht trin h thng c nhn nhn theo kha cnh cc qui trnh lin quan; m hnh chi ph l m hnh theo kha cnh chi ph.

Cc m hnh qui trnh


M hnh qui trnh l m hnh tru tng ha tin trnh pht trin h thng. Vi vic thit lp mt m hnh qui trnh, cc th tc ca pht trin h thng s c c s ch o hoc hng dn. Bng di y m t nhiu loi m hnh v cc c im ca chng.
Tn M hnh thc (Waterfall model) c im Mi pha ca qui trnh pht trin s xui t trn xung di (thng lu xung h lu) m khng quay tr li. Mi pha s c xem xt li thi im hon thnh ca n phc v cho vic qun l cht lng. Kh c th lm r c tt c cc yu cu thi im ban u ca qu trnh pht trin. S lun c nhng hot ng cn lp li. Mt bn mu ca giao din ngi dng s c pht trin lc ra cc yu cu. Cc yu cu c lm r trong cc giai on sm. Giai on cui cng s c t s hiu chnh v xem xt li. Cc h thng con c pht trin mt cch c lp. Cc mc pht trin ng thi c th c kim sot. Nhn vin pht trin c m bo trong trng thi n nh.

M hnh ch th (Prototyping model) M hnh xon c23 (Spiral model)

23 M hnh xon c: L m hnh qui trnh m cc phng php ca c m hnh thc v m hnh ch th c kt hp cht ch. Nu nh mt ng dng ln c chia thnh cc thnh phn c tnh c lp cao vi nhau th vi mi thnh phn, cho c m hnh thc v m hnh ch th, u c p dng.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

147

3. Pht trin h thng

Hnh di y m t v d v cc pha pht trin s dng m hnh thc v m hnh ch th. Cc ni dung v cng vic trong qui trnh pht trin m hnh ch th hon ton ging nh m hnh thc . Vi giao din ngi dng, vic phn tch yu cu v kim th c lp i lp li cho n khi cc chi tit hon thnh. Vi nhng phn khc, m hnh thc c s dng. 24
Phn tch yu cu Kim im

Xc nh yu cu ca h thng Xc nh yu cu ca phn cng v phn mm Lp k hoch cho cu trc v chng trnh pht trin
Thit ngoi Kim im k

Thit k h thng khng quan tm n my tnh Thit k mn hnh, thit k biu mu (form),
Thit trong Kim im k

Thit k h thng, c quan tm n my tnh T chc tp, thit k tp,


Lp trnh

Bn mu
M hnh ch th25

Kim im

Thit k cu trc ca chng trnh Thit k giao din gia cc chng trnh Vit m, kim th n v,
Kim th Th vn hnh

Xc nhn chng trnh Kim th n v/tch hp/h thng


Vn hnh Bo tr Xc nhn li

Cc m hnh chi ph
Chi ph phn mm l chi ph phi chu trong mi qui trnh ca vng i pht trin phn mm (Software Development Life Cycle: SDLC). M hnh chi ph l m hnh nh lng chi ph chng hn nh o lng hiu qu v cht lng phn mm. Cc m hnh chi ph v cc c im tng ng s c trnh by trong bng di y.
Tn M hnh COCOMO
Phng php im chc nng (Function Point FP)

c im Khi lng cng vic lp trnh vin phi lm c tnh ton trong chi ph da trn mt cng thc ton hc, s dng mt m hnh thng k v gm cc mc c bn, trung bnh v nng cao (chi tit). Nhm 5 phn t - u vo, u ra, yu cu, tp logic v giao din c thu thp v c cng li c trng s. Da trn gi s rng tng c trng s tng quan vi cc mc pht trin phn mm, kch thc ca vic pht trin s c c lng. Cch nhn nhn theo phng php ny chnh l vic coi th ngi dng thc s cn khng phi l chng trnh m l chc nng.

24 (FAQ) C nhiu cu hi v m hnh thc v m hnh ch th. Hy chc chn rng bn hiu ng tt c cc c im ca mi m hnh ny. 25 (Gi ) V tng ca m hnh thc rt r rng v d hiu nn c nhiu d n p dng phng php ny. Do cc cng vic thc hin theo tng bc mt nn m hnh ny c s dng cho nhng d n kh ln. Mt khc, m hnh ch th li cho thy s hiu qu trong vic pht trin cc ng dng qui m nh.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

148

3. Pht trin h thng

3.1.6 Cc phng php phn tch yu cu


im chnh
Biu DFD v E-R c s dng biu din cc kt qu ca qu trnh phn tch yu cu. Nhng iu lin quan ti hng i tng bao gm ng gi v k tha.

Phn tch yu cu l vic nhn ra v t chc cc yu cu ca h thng mt cch cn thn. Cc kt qu ca vic phn tch yu cu c m t bng cc biu DFD v E-R. Mt phng php phn tch khc theo cch nhn nhn khc l phn tch hng i tng.

DFD (Data Flow Diagram Biu lung d liu)


DFD l mt biu ch ra lung ca d liu. Lung ca cc vt liu (cc i tng) v tin khng nm trong . DFD l cch tip cn hng d liu. Trong DFD, h thng c biu din bng cch s dng cc k hiu trong bng di y.
K hiu Tn Thc th ngoi Tin trnh Lung d liu Kho d liu Gii thch Ni to d liu (ngun), ni n (b cha, ni thu) X l d liu: iu chnh hoc chuyn i. Lung d liu Ni lu tr d liu (tp)

Tin trnh c biu din trong DFD c c trng l khng ch c lung d liu vo m c c lung d liu ra a ra kt qu x l. Khng c tin trnh no xut hin mt mnh.26 Thng tin t hng

Khc hng

Chp nhn t hng

Hng dn chuyn hng Thng tin tin hnh

Thng tin phn pht

Khch hng

Thng tin t hng Tp t hng Thng tin nhn t hng

Thng tin chuyn hng

Tp chuyn hng Thng tin chuyn hng Kim k hng

26 (FAQ) Cc cu hi lin quan n DFD thng xut hin trong cc k thi. C nhiu cu hi v ngha ca cc biu tng, v vy t nht hy hiu v ngha ca tng biu tng. Nhng cu hi khc bao gm cc cu hi lin quan n cch biu din ca DFD. Mi tin trnh c u vo v u ra, v vy mt biu lun lun c mt lung d liu vo v mt

lung d liu ra, ging nh Ti liu n thi Tp 1

. Nu bt k lung no thiu th DFD c li.

149

-- Phn1. n tp phn thi bui sng --

3. Pht trin h thng

Biu E-R (Entity-Relationship Diagram Biu thc th lin kt)


Biu E-R l biu m t mi quan h gia cc thc th. Mt thc th c th l ngi, i tng, s kin hay khi nim cn c qun l trong cc qui trnh nghip v, mi thc th u c cc thuc tnh. Di y l mt v d v biu E-R. Ch l b qua cc thuc tnh ca gim c chi nhnh v cc nhn vin.
V d Gim c chi nhnh Nhn vin Sn phm Tn sn phm Gi Kch c Tn thc th Thuc tnh 1 Thuc tnh 2

: 1-n-1 : 1-n-n (1-nhiu) : n-n-m (nhiu-nhiu)27

Biu trn ch ra mt gim c chi nhnh (1) qun l mt s nhn vin (n). Mi nhn vin li ph trch mt s (m) sn phm v mi sn phm c th c ph trch bi mt s (n) nhn vin. Mi sn phm c cc thuc tnh l tn sn phm, gi v kch c.

Hng i tng
Hng i tng tc l m hnh ha d liu v cc thao tc (tin trnh) bn trong. Vic tch hp d liu v thao tc c gi l ng gi. Cc thuc tnh c chia s bi d liu s c trch xut ra, v d liu c t chc thnh cc lp trong cu trc phn cp. Cc lp mc thp hn k tha cc thuc tnh ca cc lp mc cao hn trong cu trc ny, v do cc thuc tnh c k tha theo cch nh vy gi l k tha.28 V d, ta quan tm n mi quan h gia t v xe but. Nu t c nh ngha nh mt phng tin, v xe but c nh ngha nh mt phng tin ch ngi, th thuc tnh l phng tin s l chung ca c hai loi ny, v vy t l lp cha trong khi xe but l lp con. Khi y, s dng chc nng k tha, xe but c th c nh ngha n gin l ch ngi.29 t Phng tin Xe but Ch ngi Xe ti Ch hng : Lp cha : Lp con

27 (Ch ) Mi quan h gia cc thc th c gi l s tng ng. Mi quan h gia gim c chi nhnh v nhn vin l 1-n-n (1-nhiu), v mi quan h gia nhn vin vi sn phm l n-n-m (nhiu-nhiu). Mi quan h gia gim c chi nhnh v nhn vin ch ra rng mi nhn vin ch c mt gim c chi nhnh nhng mi gim c chi nhnh c th c nhiu nhn vin. Nu mt nhn vin c chn, gim c chi nhnh ca nhn vin l duy nht, nhng khi chn mt gim c chi nhnh th khng phi c duy nht mt nhn vin lin quan n ng ta. Ngc li, trong mi quan h gia nhn vin v sn phm, khng th chn duy nht mt sn phm theo mt nhn vin cng nh khng th chn duy nht mt nhn vin ph trch mt sn phm. 28 (Gi ) Trong hng i tng, ta ch cn thit k cc phn c thm vo. Chng hn, thm lp xe ti, ta ch cn thm phn ch hng. Tuy nhin, trong thc t, kh c th nhn bit c nhng thuc tnh chung v nhng thuc tnh c thm vo. 29 Lp cha/Lp con: Lp cp cao hn c gi l lp cha (superclass) cn lp cp thp hn c gi l lp con (subclass)..

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

150

3. Pht trin h thng

3.1.7 Qun l cht lng phn mm


im chnh
Vic kim im bao gm i xuyn qua (walk-through) v xt duyt (inspection). T l pht hin li ca phn mm ging nh ng cong tng trng.

Qun l cht lng phn mm l ni n qu trnh nh gi v qun l cht lng phn mm tha mn cc yu cu ca ngi dng. Cc phng php cho vic qun l ny bao gm kim im (review), d bo tin cy,

Cc phng php kim im


Kim im l vic hp tho lun c tin hnh cui mi tin trnh trnh mang nhng vn ang tn ti vo tin trnh tip theo trong qu trnh pht trin h thng. Nhng im cn ch ca mt bui kim im l: Nn c t 4 n 6 thnh vin (nu c qu nhiu, s khng th c c s nht tr). Ti liu cn c phn pht trc. (Cc vn nn c lit k ra trc.) Mc ch l tm li. (Cc bin php loi tr chng s c tho lun sau.) Bui hp nn gii hn trong 1 n 2 gi (nu cn hp lu hn th s hp thm vo ngy khc). Ban qun l khng nn tham d bui hp (iu ny c th dn n nhng nh gi mang tnh c nhn). C nhiu loi kim im, ty thuc vo mc p dng:30
Loi Kim im thit k (Design review) i xuyn qua (Walk-through) Xt duyt (Inspection) Chc nng p dng cho mi tin trnh thit k (thit k ngoi, thit k trong, thit k chng trnh) ca pht trin h thng. c dng cho vic nh gi cc vn bn thit k v xc nhn cc giao din, Dng cho tt c cc tin trnh ca pht trin h thng. Trong cc pha sm, khng ch i pht trin m c ngi dng cng tham gia vo . Dng cho tt c cc tin trnh ca pht trin h thng. N c thc hin thc hin mt cch c h thng di s hng dn ca ngi iu tit.31 Nhng vn a ra nn c thng bo ti ton b d n. Ring vic xt duyt trong pha lp trnh c gi l duyt m.32

(FAQ) ngha ca thut ng kim im v s khc nhau gia i xuyn qua v xt duyt thng c hi trong k thi. Ngi iu tit: ngi iu tit l ngi qun l c o to sp t, ch o cc bui kim im v c th x l cc li pht hin. Ngi iu tit chn cc kim im vin c gi l thanh tra vin l nhng ngi c kh nng v kinh nghim thm nh cc sn phm bn giao mi tin trnh. 32 Duyt m: Duyt m l vic xt duyt trong chng trnh ngun. Trong khi duyt m, chng trnh ngun c kim tra v thng qua trn c s tng dng lnh.
31

30

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

151

3. Pht trin h thng

ng cong tng trng


Trong pha kim th, mi quan h gia s lng tch ly ca cc li tm ra v thi gian c coi nh ging vi ng cong tng trng. Cc tnh cht ca ng cong tng trng c trnh by di y. ng cong tng trng i khi cn c gi l ng cong hnh ch S (S-shape curve). S lng li tch ly giai on u, tng t t. S lng li tng t bin mt thi im c th. Cui cng, n t n trng thi bo ha.

Thi gian

ng cong tng trng ch ra rng cc li khng d dng pht hin thi gian u, do vy s lng li s tng t t v s gim dn phn cui (mt cch l tng).33 34

M hnh gieo li (Error-Planting Model)


M hnh gieo li cn c gi l m hnh pht tn li (error-spreading model) hay m hnh gn li (bug-embedding model). m hnh ny, cc li s c c tnh t vo chng trnh. Khi y t l gia s li c gieo v s li c tm ra s c dng trong vic phn phi li cho ph hp c lng c tng s li ca chng trnh. Ngy nay, m hnh ny c ci tin khng a li vo chng trnh na. Thay vo , hai nhm kim th c lp s c thc hin trn cng mt chng trnh, v s lng li c tm ra bi mi nhm s c dng c lng tng s li.

Cc c trng cht lng phn mm


Cc c trng cht lng phn mm l cc chun m nh cht lng ca phn mm c nh gi. ISO/IEC9126-1 bao gm cc chun quc t ca cc c trng cht lng phn mm, n gm 6 c trng c lit k trong bng di y.
33

(FAQ) C cc cu hi la chn ng cong tng trng ng. V d, c th c vi th trong nhm cc cu tr li, v cu hi c th l: ng cong no trong s cc ng cong di y minh ha vic kim th c thc hin theo ng k hoch? Hy nm r cc c im ca ng cong hnh ch S. 34 (Gi )
Accumulated number of errors

Period

th A ch ra rng s lng li ln hn ng cong li chun. Ta c th hiu rng d liu kim th rt tt nn c nhiu li c tm ra. Tuy nhin, cng c th thy rng li c tm ra t rt sm v cht lng ca phn mm l km. th B, s li tch ly khng n nh, v vy c th thy cht lng phn mm l rt km. Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

152

3. Pht trin h thng

Cc c trng cht lng nh ngha Chc nng Cc chc nng v mc ch tng xng vi nhau tin cy Cc chc nng xc nh lm vic di cc iu kin xc nh v vic phc hi li sau khi c li l d dng. Tnh tin li Mc ch v chc nng r rng, vn hnh d dng. Hiu qu Thi gian thc thi nhanh, s dng cc ti nguyn mt cch hiu qu. Kh nng bo Thay i v sa cha d dng. tr Kh nng di D dng chuyn sang mi trng khc. chuyn

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

153

3. Pht trin h thng

Cu hi nhanh
Q1 Q2 Q3 Q4 Q5 A1 Lit k cc ngn ng lp trnh c phn loi l hng th tc, hng chc nng, hng logic v hng i tng. Gii thch ng s dng. Cc loi b x l ngn ng? Lit k 3 m hnh qui trnh in hnh v gii thch cc c im ca chng. Lit k hai s khc bit gia xt duyt (inspection) v i xuyn qua (walk-through). Hng th tc: COBOL, C, Fortran, v Pascal Hng chc nng: Lisp Hng logic: Prolog Hng i tng: Java, C++, and Smalltalk Thut ng ny ni n cu trc chng trnh mt chng trnh c th c s dng bi nhiu tc v cng mt thi im; l mt kiu ca cu trc chng trnh dng li c, cu trc chng trnh ny cho php nhiu chng trnh (tc v) chia s vic s dng chng trnh m khng phi np li chng trnh vo b nh chnh. Trnh bin dch (compiler), trnh dch hp ng (assembler), trnh sinh m (generator), v trnh thng dch (interpreter) M hnh thc : Mi pha ca qui trnh pht trin s i t trn xung di (thng lu xung h lu) m khng quay li. M hnh ch th: Mt bn mu ca giao din ngi dng s c pht trin lm r yu cu. M hnh xon c: Cc h thng con c pht trin c lp. C xt duyt v i xuyn qua u l cc phng php kim im v tng t nhau; tuy nhin, chng khc nhau phng thc vn hnh v cc tin trnh phi theo: Xt duyt l thc hin di s hng dn ca ngi iu tit, l ngi c o to sp t v ch o cc bui kim im. Cc li c tm ra trong xt duyt c thng bo ti ton b d n.

A2

A3 A4

A5

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

154

3. Pht trin h thng

3.2 Cc cng vic trong cc qui trnh pht trin h thng


M u
Phng php in hnh nht trong pht trin h thng l m hnh thc . y, chng ta s theo cc pha ca m hnh thc v t chc ni dung ca cc hot ng ca tng pha.

3.2.1 Thit k ngoi


im chnh
Thit k ngoi bao gm thit k mn hnh, thit k biu mu v thit k m. Trong thit k m, kh nng m rng l cn thit v tnh d hc l rt quan trng.

Thit k ngoi ni n vic thit k h thng m khng quan tm n my tnh. Kt qu ca cc hot ng s c tng hp li trong cc c t thit k ngoi phc v cho vic kim im.35

Th tc ca thit k ngoi
Thit k ngoi l cc hot ng thu thp v phn tch cc yu cu h thng c a ra bi ngi dng v thit lp cc chc nng h thng da trn nhng kt qu trc . Do khng quan tm n cc c t ca my tnh, thit k c thc hin theo cc chc nng ng dng di cch nhn nhn theo quan im ca ngi dng. y, cc hot ng chnh bao gm thit k mn hnh, thit k biu mu v thit k m. Lung thit k ngoi c m t di y.
Kim tra vic phn tch yu cu nh ngha v trin khai cc h thng con Thit k mn hnh, thit k form Thit k m Thit k d liu logic Chun b cc c t thit k ngoi Kim tra cc yu cu ca ngi dng Phn chia h thng thnh cc chc nng n v Thit k nh dng u vo, u ra Cc cu trc ca m nhn vin, m sn phn, Xc nh d liu, cu trc d liu v cc mc Tng hp

35 (Gi ) Trong cc k thi K s Cng ngh thng tin, hot ng ny gi l thit k ngoi nhng mt s sch tham kho c th gi l thit k chc nng, thit k tng th hay thit k phc tho. Ni dung ca cc hot ng ny ging nhau.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

155

3. Pht trin h thng

Nhng im cn nh trong thit k mn hnh


Trong thit k mn hnh, iu quan trng l phi thit k vi suy ngh l to ra giao din ph hp vi ngi dng (giao din con ngi). Do , cn phi quan tm n vic n gin ha u vo v c mt mn hnh d thao tc. Chi tit hn, nhng im di y cn phi quan tm ti:36 Quan tm n ngun d liu, lng d liu, s phn t v cc con s, thuc tnh, t cc phn t u vo sao cho chng c t t trn xung di, t tri qua phi. C gng chun ha b cc v thao tc mn hnh. Gi c tnh nht qun trong vic biu din thng ip. Quan tm n cc kh nng b d thao tc gia chng hoc khi ng li t mn hnh trc.

Nhng im cn nh trong thit k u ra


Thit k u ra l vic thit k nh dng u ra ca h thng, bao gm vic hin th mn hnh v in n. Trong , in n (bo co) l trung tm. Vi thit k mn hnh, cn phi quan tm n giao din ngi dng v lm cho cc bn bo co d c. Chi tit hn, nhng im di y cn phi quan tm ti: Thit lp th t v cc v tr c quan tm n mi lin h gia cc mc. m bo rng tiu c biu din thch hp vi ni dung c in ra. Phn bit r rng cc ngy khc nhau nh ngy chun b, ngy bo co v ngy ph chun. t cc mc vi khong cch thch hp. B tr ton b bo co c khng gian trng. Quan tm n thit k sao cho cc phn t ch cht cn c nhn ra ngay.

Thit k m
M cn c cc chc nng c lit k trong bng di y. Khi thit k, ta phi quan tm n nhiu thuc tnh nh tnh ph bin, tnh h thng, tnh m rng v tnh r rng.37
Chc nng Nhn dng Phn loi Lit k Kim tra Gii thch L chc nng phn bit d liu. M c th phn bit hai ngi c cng h v tn. L chc nng gom nhm; phn loi bi vic sp nhp m, L chc nng sp xp: Nu cc con s c canh l th d liu cn c sp xp theo ngy sinh. L chc nng kim tra gi tr u vo; v d, b sung thm vic kim tra s.38

(FAQ) Kiu cu hi sau thng c hi trong cc k thi: u l m t thch hp cn nh trong thit k mn hnh v thit k biu mu? Hy c k cc m t tr li chng. 37 (Ch ) Cc v d v m bao gm m lin tc v m c cc s c th. M lin tc l cc s lin tc c gn cho d liu theo th t t u. N c ch khi lng d liu l c nh. Trong m c cc s c th, d liu c phn loi thnh cc lp ln, lp trung bnh v lp nh vi nhng tiu chun c th trong cu trc phn cp, v mi nhm li c cc m lin tc. Cc con s c th di, nhng chng ph hp cho vic x l ny tnh. H thng m bu in l mt v d v loi m ny. 38 Kim tra s: M mt ch s (1-digit) c c nh thc hin mt tnh ton no c xc nh trc trn mi s ca mc s. Khi mt m c nhp vo, mt tnh ton nh th c thc hin thu c s c mt ch s, sau s ny s c so snh vi s kim tra. Nu chng ging nhau, m c coi l hp l; ngc li, n c coi l khng hp l. y l mt phng php pht hin li. Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

36

156

3. Pht trin h thng

3.2.2 Thit k trong


im chnh
Thit k trong bao gm phn r chc nng, cu trc ha, thit k tp, v thit k chi tit vo/ra. Thit k chi tit vo/ra c trng tm l phng php kim tra d liu u vo.

Thit k trong l vic thit k h thng c quan tm n vic my tnh s c s dng. Kt qu ca cc hot ng ny s c tng hp trong bo co thit k trong phc v cho vic kim im.

Th tc ca thit k trong
ng trn quan im ca ngi pht trin h thng, mt h thng ti u s c thit k da trn cc c t v my tnh. Lung thit kt trong c trnh by di y.
Phn r chc nng, cu trc ha Thit k tp Thit k chi tit vo/ra Chun b cc c t thit k trong Tng hp Quyt nh phng tin, phng thc, phng php kim tra u vo/u ra. Quyt nh mt cch c th v phng tin, cch t chc, b cc, ca tp Xc nh cc chc nng v gom nhm li da vo ni dung x l.

Thit k tp
T chc v phng tin ca cc tp cn phi c quyt nh theo mc ch s dng ca chng. phc v cho vic sao lu, nhiu loi phng tin c s dng, bao gm cc a t (MO), a mm (FD), CD-R, CD-RW, DVD_R, DVD-RAM, DAT,39 Ty theo mc ch s dng, phng php t chc tp s c chn t nhng phng n bao gm tun t, trc tip, tun t c nh ch mc v phn r.40 Nu lng ln cc bn ghi tn ti
39 (Gi ) Mt phng tin thch hp c la chn ty thuc vo ci g s c sao lu. Dung lng gn ng ca mi phng tin c trnh by di y: MO: 128, 320, 540, 640 MB/ 1.3 GB FD: 1.2/ 1.44 MB CD-R: 640/700 MB CD-RW: 700 MB DVD-R: 4.7/ 8.5 GB DVD+R: 4.7/8.5 GB DVD-RAM: 4.7 GB DVD-RW: 4.7 GB DVD+RW: 4.7 GB DAT: Ti a 24 GB 40 (Gi ) T chc phn r t khi c s dng trong cc tp d liu. N hu nh lun c s dng trong cc tp th vin.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

157

3. Pht trin h thng

v hu ht trong s chng c c v cp nht th cch t chc tun t l ph hp. Cn vi vic x l ngu nhin, cch t chc trc tip li ph hp hn.

Cc phng php kim tra


Trong s cc phng php c dng cho vic kim tra d liu u vo, mt s phng php in hnh c trnh by trong bng di y. Phng php Kim tra s Kim tra nh dng Kim tra gii hn Kim tra khong Kim tra hp l Kim tra th t Kim tra cn bng Kim tra phn loi Ni dung kim tra Phn t s c thc s l mt s khng? N c nm trong nh dng nh xc nh trc hay khng? Cc s c khng c canh l khng? Gi tr c nm trong khong gii hn trn v gii hn di hay khng? Gi tr c nm trong khong ng khng? (y c th c coi nh mt kiu kim tra khong) Gi tr c hp l khng? (V d, ngy 29 thng 2 ch c nm nhun) Cc gi tr kha c c t theo th t khng? Cc mc theo cp c tng xng khng? (V d, ngi thu nh v ch nh) Gi tr m c nm trong tp ch (master file) hay khng?

Phng php s kim tra


y l phng php xc nh liu c li u vo hay khng khi mt m c nhp vo bng vic thc hin thc hin tnh ton ging nh khi m c to ra v so snh kt qu tnh ton vi m. Thng thng, mt ch s (s kim tra) s c thm vo cui m c s to ra m. XXXXX Y M c s S kim tra XXXXXY M

Phng php s kim tra thng s dng modulus (chia ly d) 11. Trong modulus 11, cc trng s 2, 3, c gn vo mi s ca m c s t s nh nht. Tch ca trng s v gi tr s ca mi s sau c tnh ton v tnh tng cc tch. Cui cng, tng ny c chia cho 11, v s d chnh l s kim tra. Nu mt tch thu c l s c 2 ch s th cc ch s ny s c tch ra. Di y l v d vi m c s 12345.
[M c s] 14 / 11 = 1 d 3 [Trng s] Tch (nhn cc kt qu) Tch thnh cc ch s 12345 M c s 123453 M 3

V chia cho 11 nn phng php ny c gi l modulus 11. Chia mt s cho 11 c th d 10. Trong trng hp ny, s kim tra c nh ngha l 0. Bn cnh , cng c mt phng php c gi l modulus 10.41

41 Modulus 10: tng v vic tnh ton s kim tra bi phng php modulus 10 hon ton ging vi tng ca phng php modulus 11 ngoi tr vic tng c trng s c chia cho 10 thay v 11. C phng php modulus 11 v modulus 10 u c th pht hin ra hu ht cc li u vo.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

158

3. Pht trin h thng

3.2.3 Cc phng php thit k phn mm


im chnh
Cc phng php thit k phn mm bao gm thit k c cu trc v thit k theo cu trc d liu. Thit k c cu trc l phng php thit k hng qui trnh.

Trong khi phn mm c m hnh ha thnh cc qui trnh v d liu mt cch ring r th thit k c cu trc li l k thut hng qui trnh. Ngoi ra, c mt k thut khc m cc hot ng thit k c thc hin vi s tp trung vo cu trc d liu. Cc k thut thit k c cu trc bao gm cc biu bong bng, phng php phn r STS, v phng php phn r TR. Cc k thut tp trung vo cu trc d liu bao gm phng php Jackson v phng php Warnier.42

Cc k thut thit k c cu trc


Thit k c cu trc l k thut thit k da trn cch tip cn ca vic cu trc ha. Biu cu trc c s dng cho phng php ny. Trong m hnh ny, cc hot ng thit k thc hin t nhng tng tng qut n chi tit, v vy c khi n c gi l ci tin bc thang (cch tip cn trn-xung (top-down) hay phn r m-un43).

Biu bong bng (Bubble chart) Nhng biu ny s dng cc bong bong (cc hnh trn) biu din cc qu trnh chuyn i d liu u vo thnh d liu u ra, chng tng t nh DFD. Vi mi h thng, ch c mt bong bng khi u, nhng khi n v ra (cu trc ha li) th cc bong bng to thnh v cc lung d liu li phc tp hn. Di y l mt v d v vic phn r h thng qun l bn hng.
Tn d liu Tn d liu

Qun l bn hng

t hng

Chp nhn t hng

Thng tin chuyn hng Chuyn


hng

n hng

Thng tin n hng

Phn phi n hng

Thng tin phn phi

Ging nh DFD, biu bong bng c s dng phn r cc chc nng ca h thng. N cng c dng phn r cc chc nng ca chng trnh to nn mt phn cp.
(FAQ) Cng vi cc k thut thit k c cu trc v phng php Jackson, cc cu hi bao trm tng quan ca cc phng php thit k phn mm cng thng xut hin; chng bao gm cc cu hi nh La chn no di y l mt v d v? v nhm cu tr li thng lit k ra cc thut ng. 43 Phn r m-un: y l qui trnh trong cc chc nng chng trnh c tho lun, c chia thnh cc n v chc nng, v t vo trong mt phn cp chc nng. Mi n v chc nng sau khi c phn r c gi l mt m-un. Do mt chng trnh bao gm nhiu m-un. Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng -42

159

3. Pht trin h thng

Phn r STS (source, transform, sink ngun, bin i, b cha) Trong k thut ny, cu trc chng trnh c chia thnh ngun (u vo), bin i (cc tin trnh) v b cha (u ra), v mi thnh phn c nh ngha nh mt chc nng. Mt khi phn r STS c thc hin th cc k thut khc nh DFD hay biu bong bng cng c s dng.
Ngun
Chc nng 1 Chc nng 2

Bin i
Chc nng 3 Chc nng 4

B cha
Chc nng 5

im u vo tru tng ln nht44 M-un iu khin M-un ngun M-un chuyn i

im u ra tru tng ln nht

M-un b cha

Trong phn r STS, sau khi chia thnh 3 m-un, ta b sung thm mt m-un iu khin iu khin nhng m-un . Phng php ny c dng khi vit chng trnh cho x l theo l. Phn r TR (Transaction Partitioning Phn r giao dch) Trong k thut ny, cc giao dch c phn r bi chc nng i vi lung ca d liu, v chng c nh dng thnh cc m-un. V d di y l mt phn ca chng trnh tin lng. Nu chc nng cp nht tp c 3 chc nng cp nht lng c bn, cp nht tin tr cp (tin lng), v cp nht trit khu th mi chc nng to thnh mt m-un:
Cp nht tp Cp nht lng c bn Cp nht tr cp Cp nht trit khu

Phn r TR c s dng thng xuyn trong cc chng trnh ca cc h thng trc tuyn. V d, trong mt h thng t ch, cc giao dch xy ra thng xuyn theo mi chc nng, chng hn nh yu cu thng tin v s lng ch cn trng hoc xut v.

im tru tng ln nht: y l khi nim trong phn r STS m chng trnh c phn r thnh 3 m-un. Ranh gii gia ngun v bin i c gi l im u vo tru tng ln nht, ranh gii gia bin i v b cha c gi l im u ra tru tng ln nht. im u vo tru tng ln nht l ni d liu u vo c tru tng ha nhiu nht, d liu c chuyn i v dng li tr thnh d liu u vo. im u ra tru tng ln nht l ni d liu u ra c tru tng ha nhiu nht, d liu c t chc li hnh thnh d liu u ra. Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

44

160

3. Pht trin h thng

Cc k thut thit k da trn cu trc d liu


Vi tng l vic lm r bn cht cu trc d liu vo/ra s xc nh cc tin trnh, nhng k thut ny s so snh cu trc d liu u vo vi cu trc d liu u ra a ra cu trc ca cc tin trnh. Mt phng php in hnh l phng php Jackson (Jackson Structured Programming: JSP). Trong phng php Jackson, cu trc d liu v cu trc chng trnh c biu din nh cu trc cy. Bng di u m t cc k hiu c s dng trong phng php Jackson v ngha ca chng.
K hiu
A A B A B* A B C C

Tn ngha Phn t c Mt phn t trong cu trc d liu; mt n v x l trong bn cu trc chng trnh. Trnh t A gm c B v C; B v C c thc thi theo th t . Mi phn t ch xut hin mt ln trong th t . Bn trong A; B c lp li t nht 0 ln (c th khng lp). K hiu * c ngha l s lp li. C B v C u c chn bi A (mi thi im ch c mt phn t).

Lp li

La chn

Phng php Jackson c s dng thng xuyn trong cc chng trnh ca cc h thng x l thng mi. Mt phng php khc cng da trn cu trc d liu l phng php Warnier.45

45

Phng php Warnier: Ging nh phng php Jackson, y l k thut thit k da trn cu trc d liu. N c m t bng cch v biu Warnier, tng t nh lu .

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

161

3. Pht trin h thng

3.2.4 Tiu chun phn r m-un


im chnh
c lp m-un c s dng cho cc tiu chun phn r m-un. bn v mc ni (c kt) m-un c s dng cho cc tiu chun ca c lp m-un.

Trong thit k c cu trc, tt c m-un c phn r cui cng s c nh gi da trn nhiu tiu ch nh gi nh cu trc hoc c lp.

nh gi tnh cu trc
phc v cho vic phn r m-un, nhng tnh cht di y cn phi quan tm ti: Chng c qu nh hay qu ln khng? (Cc tiu chun cn phi c thit lp.) Kch c thch hp s khc nhau ty theo ngn ng c s dng (khong 300 bc vi COBOL). Chc nng: C chc nng no khng cn thit hay khng? C chc nng no phc hp hay khng? (Nu c cc chc nng phc hp, cn phi tip tc phn r chng.) Giao din: C qu nhiu tham s khng? (Trong trng hp nh vy, cn xem li qu trnh phn r.) Kch c:

nh gi c lp
nh gi c lp gia cc m-un, cho hai o bn ca m-un v mc ni ca m-un. Vic phn r c coi l tt nu cc m-un c c lp cao. mc ni m-un46 cng yu hoc bn ca m-un47 cng cao th c lp gia cc m-un cng cao.
Loi bn bn trng khp bn logic bn phn loi bn th tc bn trao i bn thng tin bn chc nng bn Yu c lp Thp mc ni Mnh Loi mc ni Mc ni ni dung Mc ni chung Mc ni ngoi Mc ni khin Mc ni nhn Mc ni d liu Mnh Cao Yu iu

46 mc ni m-un (module coupling): L tiu chun nh gi cc m-un lin h vi nhau mc no; mc ni m-un cng yu th chng cng c lp vi nhau. 47 bn ca m-un (module strength): L tiu chun nh gi cc thnh phn bn trong m-un c mi quan h vi nhau mc no; nu bn ca m-un cng cao th chng cng c lp vi nhau.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

162

3. Pht trin h thng

bn ca m-un c 7 mc c ch ra trong bng di y. . bn ca Ni dung m-un Chng trnh c chia ra hoc cc chc nng ging ht nhau s c loi tr. bn Khng c mi quan h c bit gia cc chc nng trong m-un. trng khp M-un c nhiu chc nng lin quan v la chn vic x l da trn cc iu bn kin tham s (i s). logic M-un hp nht nhiu m-un c thc thi mt thi im xc nh v thc bn thi nhiu chc nng mt cch tun t. M-un thit lp ban u l mt v d. phn loi M-un thc thi nhiu chc nng tun t; mi quan h bn trong m-un l bn cht ch, v nhiu chc nng khng th c thc thi c lp vi nhau. th tc M-un thc thi cc chc nng tun t ng nh trong bn th tc, nhng bn d liu c trao i gia cc chc nng. trao i M-un hp nht cc chc nng x l cng cu trc d liu, c mt im u bn vo v mt im u ra cho mi chc nng, v c th gi mi chc nng mt thng tin cch ring r. M-un ch gm mt chc nng, v tt c cc lnh l thc thi chc nng , bn v vy chng c mi lin h rt cht ch. chc nng

mc ni m-un c 6 mc nh di y.48
mc ni m-un Mc ni d liu Mc ni nhn Mc ni iu khin Mc ni ngoi Mc ni chung Mc ni ni dung Ni dung Ch c d liu cn cho vic x l mi c truyn vo. C cc m-un ang gi v m-un s c gi u khng c cc mi quan h chc nng. Chnh cu trc d liu c truyn vo nh cc tham s. M-un sp c gi s s dng mt phn ca cu trc ny. M chc nng c truyn vo mt chng trnh con nh mt tham s, v nh hng ti vic thc thi ca chng trnh con. D liu c khai bo bn ngoi s c chia s. S khc bit so vi mc ni chung ch l trong mc ni ngoi, d liu cn thit c khai bo bn ngoi. D liu c nh ngha trong lnh vc chung s c chia s. Mt m-un tham chiu trc tip m-un khc v thay i n.

3.2.5 Lp trnh
im chnh
Cu trc ho logic s ci thin tnh hiu qu v kh nng bo tr. Chng trnh ch c vit vi cc cu trc iu khin c bn.

Vic lp trnh yu cu logic c cu trc. Vi vic cu trc ho logic, mc phc tp c th c gim i v cc chng trnh c th c vit mt cch d hiu. iu ny gip nng cao hiu qu v ci thin kh nng bo tr trong qu trnh pht trin.

48 (FAQ) C nhiu cu hi thi v c lp ca cc m-un. Hy chc rng bn hiu ng ni dung v bn v mc ni m-un.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

163

3. Pht trin h thng

nh l cu trc
Trong mt chng trnh hp l, trong c mt cp li vo v li ra, khng c lp v hn v khng c lnh no khng c thc thi, ta c th vit logic chng trnh bng cch ch s dng 3 cu trc iu khin c bn: tun t, la chn (quyt nh), v lp. y c gi l nh l cu trc. N rt quan trng trong vic gi tnh cu trc khi vit chng trnh. Nguyn l c bn l vit mt chng trnh t goto (chng trnh khng s dng cu lnh goto).

Cc cu trc iu khin c bn
nh l cu trc a ra 3 cu trc iu khin c bn, nhng trong thc t, 6 cu trc iu khin c bn di y u c s dng.49
Tn Tun t La chn (Kiu if- then-else) Nhiu nhnh (Kiu case) Lp Do-while (Lp kim tra trc) Lp Repeat-until (Lp kim tra sau) Lp s ln c nh Gii thch Chng trnh bao gm cc cu lnh c thc thi tun t m khng c cu lnh goto v cc quyt nh logic. Hm c thc hin ph thuc vo vic c theo mt iu kin c th no hay khng. Nhiu nhnh c ch nh ph thuc vo gi tr ca mt bin hay mt kt qu x l. iu kin c quyt nh khi bt u qu trnh lp (lp khi tha mn iu kin); ph thuc vo iu kin, qu trnh lp c th khng xy ra ln no. iu kin c quyt nh khi kt thc mt qu trnh lp (vng lp s dng li nu tho mn iu kin); d l iu kin no th qu trnh lp cng xy ra t nht mt ln. Tin trnh c lp li vi s ln thc hin vng lp xc nh.

Di y l tp cc lu biu din cc cu trc iu khin c bn trn mt cch chi tit.50


Tin trnh 1 Tin trnh 2 Tin trnh 3 Sai ng iu kin Tin trnh 2 1 iu kin Tin trnh 2 Khc

Tin trnh 1

Tin trnh 1

Tin trnh 3

(Tun t)

(La chn)

(Nhiu nhnh)

Sai iu kin ng Tin trnh

Lp iu kin = Sai

Tin trnh Sai iu kin

Lp

Lp S ln lp

Tin trnh
Lp

Tin trnh
iu kin = Yes Lp

Tin trnh
Lp

ng
(K hiu quyt nh)

(K hiu quyt nh)

(K hiu lp)

(K hiu lp)

(Lp s ln c nh)

(Lp do-while)
49

(Lp repeat-until)

(Gi ) Ba cu trc iu khin c bn l tun t, la chn, v lp. Tun t v la chn nh trnh by trong bng, cn v lp, c a ra u tin c ngha l lp do-while.
50 (Gi ) K hiu lp cho bit iu kin kt thc vng lp. Ni cch khc, n l iu kin khi c tha mn th vng lp s dng li. Tuy nhin, trong mt vng lp do-while, tin trnh c lp li s c thc thi n khi no iu kin cn tha mn, v vy ta phi cn thn khi biu din iu kin s dng k hiu lp v k hiu quyt nh.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

164

3. Pht trin h thng

Cc kt qu ca thit k m-un c biu din bng cch s dng cc lu . Tuy nhin, c nhiu vn lin quan n cc biu ny, v mt s cng ty s dng cc phng php khc biu din. Tuy nhin, trong cc k thi K s Cng ngh thng tin, hu nh s dng cc lu .

Biu din ha cho thit k m-un


Bn cnh cc lu cn c cc phng php khc biu din kt qu ca thit k m-un nh c trnh by trong bng di y.
Phng php M gi (Ngn ng gi) Bng quyt nh Biu NS Biu cu trc Gii thch M gi tng t nh mt m chng trnh tht, nhng n cho php s dng ngn ng t nhin (chng hn nh ting Anh) vit tt cho cc hm. Mi quan h gia cc iu kin v ni dung ca vic x l c biu din di dng bng. Cu trc logic c biu din m khng cn s dng cc mi tn. V h tr trc quan nn biu ny rt d c. Mt cu trc cy c s dng biu din logic.51

3.2.6 Cc kiu v th tc kim th


im chnh
Cc kiu kim th bao gm kim th n v, kim th tch hp v kim th h thng. Th t ca vic kim th c th t trn xung (top-down) hoc t di ln (bottom-up).

Trong qu trnh pht trin h thng, cng vic thit k c thc hin t trn xung, nhng vic kim th li c thc hin t di ln. Ni cch khc, ta dng cch tip cn t chi tit i ln tng quan. Vic ny gi l tch hp bc thang. Trong kim th tch hp, thc hin vic kim th c hiu qu, ta phi chn th t kim th cc m-un mt cch cn thn.

Th t kim th
Vic kim th c t trong th t sau Kim th n v Kim th tch hp Kim th h thng Kim th mt m-un mt thi im Kim th trong n v chng trnh (lin kt cc m-un) Kim th ton b h thng (ton b chng trnh)

51 Biu cu trc: Biu ny cng c bit n nh mt biu cu trc cy. c c lp trnh c cu trc, nhng ngi pht trin v cc vin nghin cu xut ra nhiu loi biu . Mt vi v d ni ting l PAD (Hitachi), YAC (Fujitsu) v HCP (NTT).

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

165

3. Pht trin h thng

Kim th n v Kim th n v l mt php kim th cht lng ca cc m-un (cc n v nh nht trong chng trnh). Khi kim th ton b chng trnh, vic tm ra nguyn nhn gy li l kh khn, v vy kim th n v c thc hin cho mi m-un nh mt n v. Trong kim th n v, ta thc hin kim th chc nng52 v kim th cu trc.53 V cc m-un khng t hot ng nn ta phi chun b cc b iu khin (driver) v cc cung (stub). B iu khin (driver)54 M phng cc chc nng cc m-un mc cao. M-un c kim th M-un s c kim th Cung (stub) Kim th tch hp Vi nhiu m-un c lin kt vi nhau, ta kim th nhng chng trnh c lin kt (cc m-un ti). Mc ch chnh y l kim tra giao din gia cc m-un v u vo, u ra. Cc phng php ca kim th tch hp bao gm kim th t trn xung, kim th t di ln, kim th big-bang,55 v kim th hn hp (sandwich).56 Kim th h thng y l kim th cui cng c thc hin trong vic phn chia pht trin v c s dng kim tra cc c t yu cu c c tha mn hay khng. V d, ta t cu hi nh C vn v vic thc thi khng (kim th thc thi)? v N c th chu c cc ti nng khng (kim th ti)? Ta cng kim th cc phn t ngoi l v s o c a ra khi xy ra li. M phng cc chc nng ca cc m-un mc thp.

52 Kim th chc nng: y l mt loi kim th thm nh da trn cc c t ca m-un xc nhn rng tt c cc chc nng c a ra cho m-un u tha mn. 53 Kim th cu trc: y l mt loi kim th thm nh, da trn cc c t ca m-un v chng trnh ngun xc nhn rng logic ca m-un l hp l. 54 (Gi ) B iu khin l mt chng trnh m phng cc chc nng ca mt m-un mc cao, v cung (stub) l mt chng trnh m phng cc chc nng ca m-un mc thp. Thng thng, cung (stub) s tr v mt gi tr v do n d dng thc hin, trong khi b iu khin s iu khin cc li gi v v vy thng phc tp. 55 Kim th big-bang: y l php kim th trong mi cc kha cnh ca cc m-un hon thnh kim th n v c lin kt li v kim th. Nu chng trnh qui m nh, n c th gim s th tc kim th; tuy nhin, nu mt li xy ra, s kh nhn ra c li xy ra u. 56 Kim th hn hp (sandwich): L phng php kim th m cc m-un mc thp c kim th t di ln v cc m-un mc cao c kim th t trn xung. y l loi kim th c tnh thc t nht.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

166

3. Pht trin h thng

Th t ca kim th tch hp
Kim th tch hp c th c thc hin t trn xung hoc t di ln. c im ca mi kiu kim th ny c minh ha trong bng v hnh v di y.57
Kiu Kim th t trn xung c im Kim th t cc m-un mc cao xung cc m-un mc thp. Cn phi c cc cung (stub) m phng cc m-un mc thp cha c kim th. Giao din gia cc m-un c th c kim th mt cch y . Ban u, lm vic song song s kh khn. C hiu qu trong cc h thng mi c pht trin. Kim th t cc m-un mc thp ln cc m-un mc cao. Cn phi c cc b iu khin m phng cc m-un mc cao cha c kim th. Cc chc nng ca chng trnh c th c kim th mt cch y . Lm vic song song c th thc hin ngay t giai on u ca vic kim th. Hiu qu trong vic pht trin cc h thng mi bng cch chnh sa cc h thng c sn.

Kim th t di ln

M-un 1 M-un 2-1 M-un 3-1 M-un 2-2 M-un 3-2 M-un 2-3 M-un 3-3

3.2.7 Cc k thut kim th


im chnh
Cc k thut kim th bao gm kim th hp en v kim th hp trng. Kim th hp en khng c s dng trong kim th n v.

Mc ch ca vic kim th mt chng trnh l xc nhn rng chng trnh hot ng theo cc c t v loi tr li c trong chng trnh. Vi mc ch ny, mt s d liu gy li c th c c tnh nhp vo. C 2 k thut kim th c xut: kim th hp en v kim th hp trng.

Kim th hp en
Kim th hp en l phng php m nh cc trng hp kim th c thit k da trn cc c t bn ngoi ca chng trnh. Khng quan tm n logic ca chng trnh, d liu kim th c chun b ch da trn cc c t bn ngoi. Cc tiu ch kim th c a tra trong bng di y.
Tn Phn chia tng ng Phn tch gi tr bin Gii thch Khong ca cc gi tr u vo c phn chia thnh nhiu lp, v mt gi tr kim th s c chn ra t mi lp nh mt gi tr i din (v d, gi tr trung bnh ca lp). Khong ca cc gi tr u vo c phn chia thnh nhiu lp, v cc gi tr bin (gi tr gii hn) ca mi lp c chn ra v tr thnh gi tr kim th.

57 (FAQ) Thng c nhng cu hi nh u l m t thch hp cho kim th t trn xung? v u l m t thch hp cho kim th t di ln? Hy chc rng bn hiu s khc nhau gia cc phng php kim th t trn xung v t di ln cng nh vai tr ca cung (stub) v b iu khin (driver).

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

T trn xung

T di ln

167

3. Pht trin h thng

V d, gi s rng trong mt mc s (gi tr nguyn), t 0 n 30 l cc gi tr d liu hp l cn cc s nguyn khc l sai v a ra mt thng bo li. Hn na, gi s rng cc gi tr t 26 n 30 a ra li cnh bo s c hin th nh nhng gi tr cnh bo. Chng hn nh y, di tiu ch phn chia tng ng, c th chn ra tp d liu kim th l (-5, 15, 27, 50). Di tiu ch phn tch gi tr bin, c th chn ra tp cc gi tr bin ca cc lp l (-1, 0, 25, 26, 30, 31).
Lp tng ng khng hp l58 Lp tng ng hp l Lp tng ng khng hp l

Khong d liu li Gi tr - Phn chia tng ng Phn tch gi tr bin59 -5


-1 0

Khong d liu ng Khong d liu cnh bo


25 26 30 31

Khong d liu
+

15 -1 0 25 26

27 30 31

50

Kim th hp trng
Kim th hp trng l phng php m nh cc trng hp kim th c thit k da trn cc c t bn trong ca chng trnh. Di y l mt s tiu ch kim th: bao ph lnh, bao ph iu kin quyt nh (bao ph nhnh), bao ph iu kin (bao ph iu kin nhnh), bao ph quyt nh/iu kin, v bao ph a iu kin. Cc tiu ch ny c lit k theo chiu tng ca tnh kht khe (tnh nghim ngt).60
Tn Bao ph lnh Bao ph iu kin quyt nh (bao ph nhnh) Bao ph iu kin (bao ph iu kin nhnh) Bao ph quyt nh/iu kin Bao ph a iu kin Gii thch Cc trng hp kim th c thit k sao cho mi cu lnh c thc hin t nht mt ln. Cc trng hp kim th c thit k sao cho cc trng hp ng v sai trong quyt nh u c thc hin t nht mt ln. Cc trng hp kim th c thit k sao cho khi c nhiu iu kin, mi t hp cho cc trng hp ng v sai c tha mn. L kt hp ca bao ph nhnh v bao ph iu kin. Cc trng hp kim th c thit k sao cho mi t hp ca cc trng hp ng/sai trong mi iu kin u c kim th.

V d, gi s c mt chng trnh c cu trc nh hnh di y. D liu c chun b cho mi tiu ch kim th nh sau: Trong bao ph lnh, d liu i qua ng a, b, d c chun b v ng ny i qua tt c cc lnh. Ni cch khc, ch c d liu theo trng hp ng ca iu kin c chun b. Trong bao ph iu kin quyt nh, d liu cho cc trng hp ng v Sai, tc l d liu qua c hai ng a, b, d v a, c, d, u c chun b. a
iu kin
ng

Sai

b
Lnh

d
Lp tng ng hp l/ Lp tng ng khng hp l: Trong kim th hp en, khong ca cc gi tr d liu ng c gi l lp tng ng hp l, v khong ca cc gi tr d liu sai c gi l lp tng ng khng hp l. 59 (FAQ) C cc cu hi m bn cn chun b d liu kim th cho tiu ch phn chia tng ng v phn tch gi tr bin. Hy hiu mt cch y ngha ca cc thut ng , v chc rng bn c th chun b c d liu kim th. 60 (FAQ) Tt c cc k thi u c cc cu hi v ngha ca kim th hp en vo kim th hp trng. Hy chc rng bn bit nhng ngha . Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng -58

168

3. Pht trin h thng

Cc trng hp khc, bao ph iu kin, bao ph quyt nh/iu kin v bao ph a iu kin l cc k thut c s dng cho trng hp c nhiu iu kin. V d, gi s rng ta xem xt n a iu kin a v b y.
S (1) (2) (3) (4) a ng ng Sai Sai b ng Sai ng Sai a v b ng Sai Sai Sai Bao ph iu kin X X Bao ph quyt nh/iu kin X X X Bao ph a iu kin X X X X

Trong bao ph iu kin,61 cc s (2) v (3) s c kim th nh l cc t hp cho cc trng hp ng v sai trong a iu kin. Tuy nhin, a iu kin a v b l sai trong c hai s trn nn trng hp c hai cng ng s khng cn kim th. Trong bao ph quyt nh/iu kin, s c trng hp c hai cng ng, do vy c (1), (2) v (3) u c kim th. Trong bao ph a iu kin, mi t hp (1), (2), (3) v (4) u c kim th.

61 (FAQ) Lin quan n bao ph lnh vo bao ph iu kin quyt nh, cc cu hi thng hi d liu c th. Tt nht l hy thc s chun b d liu kim th ra kim tra.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

169

3. Pht trin h thng

Cu hi nhanh
Q1 Q2 Q3 Lit k cc kiu cng vic c thc hin trong thit k ngoi. Lit k cc kiu cng vic c thc hin trong thit k trong. tng mc c lp ca cc m-un, cn phi lm g vi bn ca m-un v mc ni m-un? K tn loi bn v mc ni c ni n y. M t ngn gn mi phng php kim tra sau: kim tra s, kim tra nh dng, kim tra gii hn, kim tra khong, v kim tra tun t. Q5 Q6 M t cc c im ca kim th hp en. M t cc c im ca kim th hp trng.

Q4

A1
Kim chng phn tch yu cu (Kim tra cc yu cu ca ngi dng) Xc nh v pht trin cc h thng con (Chia h thng thnh cc n v chc nng) Thit k mn hnh, thit k biu mu (Thit k nh dng u vo, u ra) Thit k m (Cc cu trc m nhn vin, m sn phm,) Thit k d liu logic (Xc nh d liu; quyt nh cu trc d liu v cc mc) Chun b cc c t thit k ngoi

A2
Phn r, cu trc ha chc nng (Xc nh cc chc nng v gom nhm chng da trn cc ni dung x l) Thit k tp (Quyt nh c th phng tin, t chc, b cc, ca tp) Thit k chi tit vo/ra (Quyt nh phng tin, phng thc v phng php kim tra u vo/u ra) Chun b cc c t thit k trong

A3 Cn tng bn ca m-un ( bn chc nng) v gim mc ni m-un (mc ni d liu)

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

170

3. Pht trin h thng

A4
Kim tra s: Kim tra phn t s c thc s l mt s hay khng Kim tra nh dng: Kim tra d liu c ng nh dng khng v cc con s c ng th t hay khng Kim tra gii hn: Kim tra gi tr c nm trong gii hn trn v gii hn di khng Kim tra khong: Kim tra gi tr c nm trong ng khong hay khng Kim tra tun t: Kim tra cc phn t kha c c lit k theo th t hay khng

A5 y l phng php m nh cc trng hp kim th c thit k da trn cc c t bn ngoi ca chng trnh. Khng quan tm n logic ca chng trnh, d liu kim th c chun b da trn cc c t bn ngoi. A6 y l phng php m nh cc trng hp kim th c thit k da trn cc c t bn trong chng trnh. C mt s tiu ch kim th, xp theo chiu tng ca tnh kht khe (tnh nghim ngt): bao ph lnh, bao ph iu kin quyt nh (bao ph nhnh), bao ph iu kin (bao ph iu kin nhnh), bao ph quyt nh/iu kin, v bao ph a iu kin.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

171

3. Pht trin h thng

Cu hi 1
Q1.

kh: **

Tn sut: **

Pht biu no di y l thch hp khi quan tm ti vic ti u ha mt trnh bin dch? a) b) c) d) N to ra m trung gian cho trnh thng dch thay v to ra m ch. N to ra m ch chy trn mt b my khc, khng phi my tnh m trnh bin dch chy. N to ra m ch hin th tn ca chng trnh con m vic iu khin c a ti hoc ni dung ca mt bin thi im c th khi chng trnh c thc thi. N phn tch chng trnh ngun v to ra m ch, nh vy vic x l c th hiu qu hn trong qu trnh thc thi.

p n cu 1
p n ng: d
Vic ti u ha mt trnh bin dch c ngha l loi b nhng phn d tha ca chng trnh ch. a) Ti u ha l loi b cc phn d tha; trnh bin dch to ra m trung gian. V vy, pht biu ny khng phi l mt li gii thch cho s ti u ha. b) y l li gii thch cho cc trnh bin dch cho. c) y l li gii thch cho cc b d vt. d) Vic ti u ha lm tng hiu qu x l trong qu trnh thc thi, c ngha l n bao gm vic loi b cc du ngoc n khng cn thit v cc thao tc trc tnh ton ch lin quan n cc hng s.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

172

3. Pht trin h thng

Cu hi 2
Q2. trong vic to nn mt vn bn XML? a) b) c) d)

kh: **

Tn sut: ***

Pht biu no di y l thch hp cho phng php nh ngha mt phn t - n v nh nht Mt th m v mt th ng lun i i vi nhau trong cu trc, khng c thiu bt k th no. Mt phn t d liu c to ra sao cho n c th c t gia mt th m v mt th ng. Tuy nhin, trong mt s trng hp, khng tn ti d liu. Trong mt ti liu XML, nhiu phn t gc c th c nh ngha biu din cu trc phn cp. Thng tin ch thch c thm vo biu din kiu ca phn t. N c nh ngha nh tn ca phn t.

p n cu 2
p n ng: b
XML (eXtensible Markup Language Ngn ng nh du m rng) m rng cc chc nng ca HTML, loi b cc chc nng khng cn thit ca SGML v c ti u ha s dng trn Web. Ging nh HTML, XML cng c s dng trn Web; im khc bit l trong khi cc th ca HTML l c nh th cc th ca XML c th nh ngha bi ngi dng thng qua vic nh ngha DTD (Document Type Definition nh ngha kiu ti liu). a) ng l cu trc c d liu c bao quanh bi th m v th ng, nhng khi khng c d liu, biu din mt phn t trng, mt th c bit ging nh <tn phn t/> c th c s dng v c phn bit vi th m. V d, c th m t ging nh <img SRC=tn tp/>. Do vy, th m v th ng khng nht thit phi i i vi nhau. b) Theo nguyn tc, d liu c bao quanh bi mt th m v mt th ng. Nu khng c d liu, iu ny cng c th chp nhn c. c) Trong XML, tt c cc phn t c t trong cu trc lng nhau. Mt phn t c th cha nhiu phn t khc, nhng khng c phn t no c cha trong nhiu phn t. y, phn t cha cc phn t khc c gi l cha, v phn t c cha bn trong gi l con.
Vn bn XML

Phn t 1

Phn t 2

Phn t 3

Phn t 21

Phn t 22

Phn t 23

d) Thng tin ch thch khng c cha trong d liu v trong thc t c th b qua. Cc ch thch c bao quanh bi cc th <!-- v -->.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

173

3. Pht trin h thng

Cu hi 3
Q3. trin h thng? a) b) c) d)

kh: *

Tn sut: ***

Pht biu no sau y m t tnh cht ca m hnh thc m bo tnh nht qun ca pht

Theo nguyn tc, khng cho php i ngc li qua cc pha pht trin. Pht trin h thng c chia thnh nhiu pha qun l. Nht nh cn to ra mt t chc d n. Cc hot ng pht trin trong pha tip theo da trn kt qu c a xung t pha trc .

p n cu 3
p n ng: d
M hnh thc l mt m hnh qui trnh trong vic pht trin h thng thc hin t pha trn (thng lu) xung pha di (h lu) theo th t: lp k hoch c bn thit k ngoi thit k trong thit k chng trnh lp trnh kim th ci t, vn hnh, bo tr. V lung qui trnh pht trin c chia thnh cc pha nn d dng nm c tng quan ca ton b d n. Vic qun l d n cng c coi l d dng hn v cng vic i t trn xung di mt cch tun t. Tuy nhin, v khng c quay ngc li, n c nhc im l hiu qu ca vic pht trin s gim xung nu qui trnh i hi s hi qui. Trong m hnh thc , vic kim im c thc hin cui mi pha cc li khng c mang sang pha tip theo. Nu c mt li c tm ra trong mt pha h lu (pha sau pha lp trnh), chi ph cho vic iu chnh h thng (chi ph cho vic hi qui) l rt ln. V vy, cc li phi c tm ra mt pha thng lu (mt pha thit k gia lp k hoch c bn v thit k chng trnh). a) y l mt trong nhng c im ca m hnh thc , nhng ch n gin l m t tin trnh thc hin ra sao; n khng m bo s nht qun ca pht trin h thng. b) y l mt trong nhng c im ca m hnh thc , nhng n m t vic phn loi ni dung ca cc hot ng; n khng m bo s nht qun ca pht trin h thng. c) Mt i d n c t chc cho vic pht trin h thng ni chung, khng ch trong m hnh thc . d) Pha thit k ca m hnh thc l s ci tin bc thang. Ni dung ca pha trc c a vo pha tip theo; iu ny m bo s nht qun ca pht trin h thng.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

174

3. Pht trin h thng

Cu hi 4
Q4.

kh: *

Tn sut: ***

Pht biu no di y thch hp vi m hnh ch th, mt phng php pht trin phn mm? a) V cc hot c thc hin tun t t lp k hoch c bn, thit k ngoi, thit k trong, thit k chng trnh, lp trnh, v kim th nn c th c c ci nhn tng quan v ton b d n v d dng quyt nh lch trnh cng nh cp pht ti nguyn. b) V mt m hnh th nghim c to ra pha sm ca pht trin h thng nn n c th loi b s khng chc chn v s khc bit trong suy ngh ca b phn khch hng v b phn pht trin. c) Cc c im ca phn mm c chia thnh nhm m cc c t l c nh, khng yu cu thay i v nhm m cc c t yu cu thay i. Sau , qui trnh cho vic to ra, kim im v thay i m theo nhng c t s c lp li. d) Mt ng dng ln c chia thnh cc thnh phn c tnh c lp cao; sau cc qui trnh ca vic thit k, lp trnh v kim th c lp li cho cc thnh phn , v dn dn m rng phm vi ca vic pht trin chng trnh.

p n cu 4
p n ng: b
Ch th l mt phng php m bn mu (m hnh th nghim) c lm thnh cc phn c th thy r rng t ngi dng h thng (mn hnh, biu mu,) v cc h thng c pht trin da trn phn hi ca ngi dng nhng ngi kim tra bn mu. Do , pht biu b) l thch hp. a) gii thch m hnh thc , v d) gii thch m hnh xon c.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

175

3. Pht trin h thng

Cu hi 5
Q5. Mi quan h no di y c a ra bi biu E-R? a) b) c) d) Mi quan h gia cc thc th

kh: *

Tn sut: ***

Mi quan h gia cc kiu thc th v cc th hin ca chng Mi quan h gia d liu v cc tin trnh Mi quan h gia cc tin trnh

p n cu 5
p n ng: a
Biu E-R ch ra mi quan h gia cc thc th (cc i tng thc s), biu th mt thc th vi mt hnh ch nht ( ) v cc quan h tng ng gia cc thc th vi mt ng ni ( , , ). Di y l mt v d ca biu E-R. Khch hng m khch hng tn khch hng
V d Tn thc th thuc tnh 1 thuc tnh 2

t hng s n t hng m khch hng ngy t hng : 1-1 : 1- nhiu : nhiu-nhiu

Chi tit t hng s n t hng m sn phm s lng

Sn phm m sn phm tn sn phm n gi

Thuc tnh c gch chn l mt thuc tnh kha chnh. Kiu thc th l mt thc th c d liu qun l. Thng thng, cc thc th c biu din bng cc danh t nh khch hng v sn phm. Cc th hin (Instances) l cc thc th mang gi tr. Khch hng M khch hng 1011 1021 Tn khch hng George Bush William Clinton a ch khch hng Crawford, Texas Hope, Arkansas Kiu thc th Th hin Th hin

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

176

3. Pht trin h thng

Cu hi 6
Q6.

kh: **

Tn sut: ***

Hnh di y ch ra mt mc c th ca mt biu lung d liu (DFD) phn cp. u l phng php ph hp nht m t DFD ca mc ngay bn di? Gi s rng cc tin trnh trong mc ngay bn di Tin trnh n l cc tin trnh c nh theo dng n-1, n-2,
2 1 3

a)
1 1

1 2

b)
1 1 1 3 1 2

1 3

c)
1 1

1 2 2 1 2 2

d)
1 1

1 3

1 2

p n cu 6
p n ng: b
Trong biu lung d liu, cc tin trnh (cc vng trn) c phn r ra theo th t. V vy, khi chng c phn r, nhiu tin trnh mc cao hn khng th hp nht vi cc tin trnh mc thp hn. Trong biu lung d liu c a ra trong cu hi ny, ch rng Tin trnh 1 c 2 lung d liu vo v 2 lung d liu ra. a) Trong khi Tin trnh 1 c 2 lung d liu vo, mi tin trnh con ca n li ch c mt lung d liu vo. b) Tin trnh con 1-1 c mt lung d liu vo v Tin trnh con 1-2 cng vy. Tng cng l 2. V lung d liu ra, c mt lung t Tin trnh con 1-1 v mt lung t Tin trnh con 1-3, tng cng l 2. Do , y c th l mt biu lung d liu c phn r trong cu hi ny. c) V biu lung d liu phn r mt tin trnh, cc t hp nh {(1-1), (1-2)} v {(2-1), (2-2)} c chp nhn, trong khi t hp nh {(1-1), (1-2), (2-1), (2-2)} th khng, nhiu tin trnh mc cao hn cng c kt hp vo. d) S lng lung d liu vo v lung d liu ra l ng, nhng mi tin trnh phi c t nht mt lung d liu vo v t nht mt lung d liu ra. y khng c lung d liu vo cho Tin trnh 1-2.
Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

177

3. Pht trin h thng

Cu hi 7
Q7.

kh: **

Tn sut: ***

Bng di y a ra s lng cc phn t theo nhm v trng s cho cc chc nng ngi dng ca mt chng trnh ng dng. Thng tin da trn phng php im chc nng. Chng trnh ng dng ny c bao nhiu im chc nng? y, h s hiu chnh ca phc tp l 0.75. Kiu chc nng ngi dng u vo t bn ngoi u ra bn ngoi Tp logic bn trong Tp giao din bn ngoi Yu cu t bn ngoi a) 18 b) 24 S lng phn t 1 2 1 0 0 c) 30 Trng s 4 5 10 7 4 d) 32

p n cu 7
p n ng: a
Trong phng php im chc nng, s im chc nng thu c nh sau: - Nhn s lng chc nng (s phn t) vi trng s tng ng - Tm tng ca cc kt qu trn - Nhn tng vi phc tp (h s hiu chnh ca phc tp) c c cu tr li Do s im chc nng c tnh nh di y: S im chc nng = (1 * 4 + 2 * 5 + 1 * 10 + 0 * 7 + 0 * 4) * 0.75 = 18

Cu hi 8
Q8.

kh: ***

Tn sut: ***

Th tc no di y c u tin ci thin tin cy v kh nng bo tr trong thit k m-un phn mm? a) Tng c bn v mc ni m-un b) Tng bn m-un trong khi gim mc ni c) Gim bn m-un trong khi tng mc ni d) Gim c bn v mc ni m-un

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

178

3. Pht trin h thng

p n cu 8
p n ng: b
Trong thit k m-un, vic tng c lp m-un nn c xem xt n ci thin tin cy v kh nng bo tr. Nu cc m-un c lp cao, chng s khng b nh hng bi cc m-un khc, nh nng cao tin cy. Hn na, kh nng bo tr cng c th c ci thin v vic chnh sa mt m-un s khng nh hng n cc m-un khc. Cc tiu ch nh gi o lng c lp ca cc m-un bao gm bn m-un v mc ni m-un. bn m-un o mc lin kt bn trong mi m-un. Mi lin kt bn trong m-un cng mnh th m-un cng c c lp cao. mc ni m-un o mc lin kt gia cc m-un. Mi lin kt gia cc m-un cng yu th c lp m-un cng cao.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

179

3. Pht trin h thng

Cu hi 9
Q9.

kh: *

Tn sut: ***

Pht biu no di y l ph hp vi kim th hp trng? a) Vic kim th c thc hin tun t kt hp cc m-un t mc thp ln mc cao. b) Vic kim th c thc hin tun t kt hp cc m-un t mc cao xung mc thp. c) Vic kim th c thc hin c ch ti cu trc bn trong ca m-un. d) Vic kim th c thc hin kim tra cc chc nng c lm vic theo cc c t hay khng, v khng quan tm ti cu trc bn trong ca m-un.

p n cu 9
p n ng: c
Kim th hp trng l phng php tp trung vo lung iu khin chng trnh, chun b d liu kim th i qua cc con ng ch cht trong chng trnh, v thc hin vic kim th. V cu trc bn trong v logic ca chng trnh c kim tra k lng, chng ta c th kim th cc chc nng chi tit theo quan im ca lp trnh vin, tuy nhin cc chc nng c trong c t nhng cha c thc hin trong chng trnh th khng c chn l d liu th nghim. a) y l gii thch v kim th t di ln. b) y l gii thch v kim th t trn xung. d) y l gii thch v kim th hp en.

Ti liu n thi Tp 1
-- Phn1. n tp phn thi bui sng --

180

Cng ngh mng

Mc ch
Ngy nay ang xut hin nhiu kiu mng nh cc mng LAN, WAN v mng Internet. Trong chng ny, chng ta s hc v cng ngh mng c bn lin quan ti cc mng truyn thng. Trong phn 1, chng ta s tho lun v cc giao thc. Bng cch thit lp cc giao thc, cc loi my tnh khc nhau c th giao tip vi nhau. Trong phn 2, chng ta s hc v cc cng ngh truyn thng c th, bao gm vic gi v nhn d liu nh th no,...Trong phn 3, chng ta s hc v cc cu trc v cch dng ca cc loi mng nh LAN v Internet.

4.1.Cc giao thc v s kim sot s truyn 4.2.Cng ngh truyn 4.3.Cc h thng mng

[Cc thut ng v khi nim cn nm vng] TCP/IP, m hnh tham chiu c bn OSI, a ch IP, cc th tc c bn, HDLC, kim tra chn l, s ng b ha bit (s ng b ha start-stop ), s ng b ha k t, LAN, s ng b ha khi, Internet, CSMA/CD, th truyn, cc cng c kt ni trong mng LAN.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

181

4. Cng ngh mng

4.1 Giao thc v kim sot truyn


M u
ngi gi v ngi nhn c th giao tip c vi nhau, th cn thit phi t ra nhng nguyn tc v lut l chung. Nhng lut l ny bao gm cc quy c trun thng v kim sot truyn c gi l cc giao thc.

4.1.1 Kin trc mng


im chnh
M hnh tham chiu c bn OSI v TCP/IP l cc giao thc c trng. TCP/IP c s dng trong mng Internet..

Kin trc mng l hnh thc t chc c h thng ca cc cu trc logic v cc giao thc truyn thng1 c c xem nh chun trong mt h thng mng.

M hnh tham chiu c bn OSI


M hnh tham chiu OSI (M hnh kt ni cc h thng m) l mt m hnh ca mt b cc giao thc, trong mt mng c chia thnh 7 lp c lp theo quan im2 chc nng.
Tng ng dng Tng trnh din Tng phin Tng giao vn Tng mng Tng lin kt d liu Tng vt l H thng m cui
Thng tin gia cc tc v Thng tin biu din khun dng d liu Qun l ch hi thoi
Bo m cht lng dch v cho cc tin trnh

Tng ng dng Tng trnh din Tng phin Tng giao vn Tng mng Tng lin kt d liu Tng vt l H thng m cui
Gi tin Khung tin

Network layer Khung tin


Tn hiu in (ng truyn vt l)

Data link layer Physical layer

H thng m trung gian

Tn hiu in (ng truyn vt l)

Cc giao thc: L mt tp cc nguyn tc (quy c) cho vic truyn thng.Mt giao thc quy nh cc kiu, cc ng

ngha, biu din cc nh dng, v cc th tc trao i ca cc th iu khin cho vic truyn thng. Cc giao thc c trng bao gm TCP/IP v OSI. Vic quan st 1 giao thc chung gip ta c th giao tip gia cc loi my tnh khc nhau.
2

Vai tr ca mi lp trong m hnh tham chiu c bn OSI hu nh lun lun c trong cc k thi. c bit l cc chc

nng ca lp mng, lp vn chuyn v lp phin thng xut hin trong cc k thi. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

182

4. Cng ngh mng

Tng 7

Tng ng dng

Quyt nh nh dng kiu d liu v ni dung gia cc ngi s dng Quyt nh cc c tnh v tp hp, nh dng d liu v nh dng biu thc d liu cho vic m ha v gii nn Quyt nh cc phng thc iu khin nh vic kt ni hay ngt cc ng truyn gia cc users, bao gm vic bt u v kt thc lin lc. Tip thu s khc nhau gia truyn thong cc mng v hon thnh mt hm thong ti lin lc c tin cy cao v kinh t. Qui nh vic iu khin pht hin cc li truyn v sa li trn ng truyn. La chn cc relays v cc route trn mng kt ni cung cp cc dch v mng gia cc phn cui Qui nh vic pht hin li truyn, cc ng b ha v iu khin vic gi li d liu d liu c th c truyn mt cch chnh xc. Qui nh cc m hnh/ kiu cc terminal c th c kt ni vi ng truyn, cng nh cc iu kin v in hay cc c tnh vt l cho vic truyn d liu

Tng 6

Tng trnh din

Tng 5

Tng phin

Tng 4

Tng giao vn

Tng 3

Tng mng

Tng 2

Tng lin kt d liu

Tng 1

Tng vt l

M hnh TCP/IP
TCP/IP l mt giao thc c s dng rng ri trn Internet v nhiu mng khc. Cc my trm UNIX c trang b cc giao thc nh l mt t tnh tiu chun. Cc chng trnh c s dng trong Internet, nh FTP, s dng cc dch v c cung cp bi TCP/IP Hnh minh ha sau y s ch ra s tng ng gia m hnh tham chiu OSI v TCP/IP
M hnh Tng ng dng Tng trnh din Tng phin Tng giao vn Tng mng Tng lin kt d liu Tng vt l M hnh TCP/IP Telnet, FTP SMTP POP, etc. TCP IP LAN Ethernet, etc. Tng ng dng Tng giao vn Tng mng Tng giao tip mng

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

183

4. Cng ngh mng

a ch IP
Mt a ch IP c 32-bit a ch mng c s dng trn Internet v c th c phn loi thnh cc lp da vo di network. Mi lp c xc nh bi cc bit mu ca 1-3 bt. Phn network l duy nht v phn host c th c nh ngha mt cch c h thng bi mi mng ring bit. Di u l biu minh ha ca cu trc a ch IP. Lp A c bit u tin bng 0, lp B c 2 bit u tin l 10 v lp C c 3 bt u tin l 110.
32 bits

Lp A Lp B Lp C

0 10 100

Phn mng, 7 bits Phn mng, 14 bits

Phn my trm, 24 bits ng dng cho cc mng ln Phn mng, 16 bits bnh
ng dng cho cc mng trung

Phn mng, 21 bits

Phn mng, 8 bits ng dng cho cc mng nh

Khi a ch IP c xc nh cho tt c cc my tnh trong Internet s dng 32 bit, s lng cc a ch IP s dng c khng p ng nhu cu. Bi vy, a ch IP 128-bit ( IPv6 ) dn c thay th IPv4 m rng.

4.1.2 Kim sot truyn


im chnh
Th tc c bn dng truyn cc k t. HDLC c th truyn mi dng mu bit (truyn trong sut).

Kim sot truyn cp n vic iu khin vic truyn d liu gia cc thit b kt ni qua mt ng truyn. C th hn, n bao gm ng iu khin, ng b ha, kim sot li v kim sot lin kt d liu. Kim sot truyn c thc hin theo cc bc sau.
Thit lp ng truyn Thit lp knh truyn Truyn tin Hy b knh truyn Ngt ng truyn

Thit lp mt lin kt d liu ng ngha vi vic thit lp mt ng kt ni v xc nh ch ca vic truyn. Thng tin lin lc 2 chiu s c thc hin sau khi thit lp mt lin kt d liu. Cc th tc c trung bao gm cc th tc c bn (BSC) v cc th tc HDLC

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

184

4. Cng ngh mng

Hm nguyn thy (Hm iu khin cch thc truyn d liu c bn)


Hm nguyn thy3 l hm c chc nng iu khin s dng 10 k t kim sot truyn. V c bn n truyn nhng k t, v thng tin c truyn gi l thng ip. Mt thng ip cha mt chui bit c bit gi l k t kim sot truyn trc, gia hoc sau. Di y l mt v d ca d liu c truyn. on Text l d liu, cha tp hp m 8-bit k hiu. Mi k t iu khin cng cha 8 bit.

S S S S Y Y Y T Text N N N X

E S S S SYN: SYNchronous idle (thi gian ng T Y Y Y b ha)4 X N N N STX: Start of TeXt (m u text) ETX: End of TeXt (kt thc text)

Trong hm nguyn thy, qu trnh ng b ha vi ch truyn d liu c thc hin bi vic gn nhng k t kim sot truyn (di 8 bit) gi l SYN vo u ca on text. Sau , bn nhn s c chng theo tng 8-bit mt. kim sot truyn cho ng, nhiu phng thc c s dng, bao gm phng thc tranh chp v phng thc thm d/la chn. D liu c truyn thnh cc n v khi trong khi qu trnh nhn v truyn c kim tra

Phng thc tranh chp


Phng thc ny hot ng nh sau: gia 2 my tnh kt ni im-ti im,10 mt my mun truyn d liu gi yu cu c truyn. Khi nhn phn hi tch cc t bn kia th bn truyn c trao quyn truyn d liu v d liu bt u c truyn.

Phng thc thm d/la chn


Phng thc ny c s dng trong h thng a im cui.5 My ch s thm d xem cc im cui theo th t c yu cu c truyn d liu khng. Nu c, th im cui s c trao quyn truyn d liu v d liu s c nhn t my ch. Tip , my ch s hi cc my u cui xem c sn sng nhn d liu khng. Nu my u cui tr li tch cc (hoc l my u cui c chn) th d liu s c gi.

(FAQ) Hm nguyn thy c hiu l BSC (Binary Synchronous Communication, truyn thng ng b nh phn). C ng b ha. iu cn thit khi d liu c truyn v nhn trong n v truyn thng l phi kt hp chnh xc thi H thng a im cui: Nhiu my cui c kt ni thng qua ch 1 ng truyn. Trm iu khin s qun l vic

rt nhiu cu hi v ngha ca thm d v la chn trong hm nguyn thy. Hiu ngha ca nhng t ny l cn thit.
4

gian truyn v nhn tn hiu.


5

truyn d liu vi my cui, v trm ny s iu khin nhng trm con t trung tm. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

185

4. Cng ngh mng

Giao thc HDLC (High-level Data Link Control)


HDLC l giao thc kim sot truyn vi mc ch l c c hiu qu cao v d liu tin cy gia cc my tnh. Qu trnh truyn c thc hin bi khi d liu gi l khung tin. Cu trc c th hin nh di:

F 01111110 F

A 8 bits

C 8 bits

Khung tin I Bt k

FCS 16 bits

F 01111110

C chui: mt chui bit bo hiu bt u v kt thc ca 1 khung Trng a ch: a ch ca ch A Trng iu khin: cha nhiu thng tin iu khin C Trng thng tin: d liu cn truyn I FCS Chui kim tra khung: kim tra bit bng phng php CRC6 s dng A qua I

HDLC c nhng c tnh sau:7 nh hng bit (c th truyn mt phn bit ty )148 Truyn lin tc (c th truyn m khng cn nhn phn hi trong gii hn s lng nht nh cc khung) Kim tra li chnh xc (s dng CRC) Truyn thng song cng (trong phn 4.2.3) c th thc hin c ngay c trong h thng a im cui.

6 7

CRC (Cyclic Redundancy Check): l on m ha dng pht hin li trong mt khi d liu (Ch thch) Trong HDLC, bit 0 c chn vo mi khi c t nht 1 chui 5 bit 1 lin tip. Lm nh vy, s m bo

rng khng c phn bit no nhm ln vi c chui. V d nh, nu chui d liu l 01111110, bit 0 s c chn vo nn chui tr thnh 011111010.
8

(FAQ) C nhng cu hi v vai tr ca mi trng trong HDLC v c tnh ca HDLC. Nm chc rng HDLC l nh

hng bit (mi th u c th c gi) Ti liu n thi FE Tp 1


-- Phn 1. n tp phn thi bui sng --

186

4. Cng ngh mng

Cu hi nhanh
Q1 Q2 Hy ch ra nhng im tng ng trong m hnh OSI v TCP/IP. K tn nhng c tnh ca HDLC.

A1
Tng ng dng Tng trnh din Tng phin Tng giao vn Tng mng Tng lin kt d liu Tng vt l

TCP IP

A2

nh hng bit (c th truyn mt phn bit ty )14 Truyn lin tc (c th truyn m khng cn nhn phn hi trong gii hn s lng nht nh cc khung) Kim tra li chnh xc (s dng CRC) Truyn thng song cng c th thc hin c ngay c trong h thng a im cui.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

187

4. Cng ngh mng

4.2 Cng ngh truyn


M u
Cc cng ngh truyn c s dng truyn d liu tc cao, hiu qu v cht lng. c bit hn n cung cp nhng cng ngh nh iu khin li, kim sot ng b v truyn song cng.

4.2.1 Kim sot li


im chnh
Cc phng thc iu khin li bao gm cc phng thc kim tra chn l v m CRC CRC l mt phng thc pht hin li hiu nng cao s dng trong HDCL v cc giao thc khc.

Kim sot li c vai tr ci tin cht lng ca qu trnh truyn d liu thng qua vic pht hin cc li trong qu trnh truyn d liu v trong mt s trng hp c th sa li. Nhng phng thc kim tra li in hnh bao gm kim tra chn l v CRC.

Phng thc kim tra chn l


Kim tra chn l l phng thc pht hin li bng cch kim tra tng s bit mt l chn hay l bng cch thm mt bit kim tra v d liu truyn i dc hoc ngang, phng php ny dng truyn cc k t nh phn. To ra mt s lng bit 1 l chn gi l even parity check, cn to ra mt s l bit 1 gi l odd parity check Hng truyn (Tnh chn l ca hng (LRC)9

c trng ca vic kim tra chn l kt hp LRC v VRC nh sau; 1 Bit li c th c pht hin v sa. 2 Bit li c th c pht hin nhng khng th sa.

1 k t

Chn l ca ct (VRC)

LRC/VRC S kim tra chn l p dng cho mi xu k t ca cc bit cng t th nm ngang ca mi k t c gi l LRC; s kim tra chn l p dng cho mi k t theo hng thng ng gi l VRC. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

188

4. Cng ngh mng

Trong hnh di, nhng bit t m l nhng bit sai v tnh chn l. Bnh thng, s lng 1 l l, nhng y l chn, ch ra l mt li.16

Nu 2 bit cng c li nh di, s lng bit 1 l chn trong khi thc t n l l c theo chiu ngang v chiu dc. Tuy nhin, c ti 2 v tr l sai dn ti khng th sa li.

Mt m trong mt bit c b sung nhm pht hin li c gi l m Humming.17

CRC (M vng)
CRC l mt phng thc s dng phn d ca kt qu php chia cho mt a thc xc nh lm bt kim tra. Vi mi n v truyn, chui bit c coi nh l mt s nh phn. Ly mt a thc cho trc (X16 + X12 + X5 + 1 c gii thiu bi ITU-T )18, chia s nh phn cho a thc ny ri ly phn d, phn d ny c s dng nh bit kin tra v c thm vo phn cui ca n v truyn.Chia s nh phn cho a thc . Ly phn d,v n c coi nh l bit kim tra, c thm vo phn cui n v truyn.B n nh n chia nhng thng tin c chuyn bng cng mt a thc,nu phn d bng 0 th khng c li. Phng thc ny c hiu qu trong vic pht hin li ca mt khi, li chm (cc bit lin tip nhau), v cc li ngu nhin.

FAQ: Cu hi lin quan n vic kim tra chn l nh v d sau Ct bit no c cha d liu li nu x dng tnh chn l l? C rt nhiu cu hi c s dng khi m cc bt 1. 17 Humming Code: l cch pht hin li bng cch thm cc bt kim tra vo d liu.N khng ch pht hin c cc bit li m cn c th sa c chng.Kim tra chn l l mt trng hp ring ca m Hamming 1 ITU-T (Hip hi vin thng quc t - Ban chun ha vin thng): l mt ban quan trng ca ITU, t chc ny xem xt cc cng ngh, hot ng, chi ph lin quan n vin thng, chun b v ban hnh cc chun vin thng.

16

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

189

4. Cng ngh mng

4.2.2 Kim sot ng b


im chnh
C 2 kiu ng b: phng php khng ng b v phng php ng b. Trong phng php khng ng b, c nhiu hn 2 bit cho mi k t.

gi v nhn d liu chnh xc, ngi nhn v ngi gi iu chnh thi gian truyn; iu ny c hiu nh l cch thc ng b. Cc my tnh hoc thit b u cui ca ngi gi v ngi nhn phi thc hin ng b theo cc ni dung d liu. C mt vi phng php ng b, ph thuc vo n c thc thi th no.
Phng php ng b

ng b bit ng b k t ng b theo khi

ng b theo n v bit ng b theo n v k t (ng b bng m SYN) ng b theo n v khi s dng chui cc

ng b theo bit (khng ng b)


ng b theo bit l mt phng php ng b m xc nh 1 bit bt u ch ra im bt u ca d liu (mt k t) v bit dng ch ra im kt thc ca d liu.10 N cn c gi l phng php ng b bt u - kt thc. Bi v c 2 bit thm , mi k t s cn 10 bit, hn 2 bit so vi nh dng thng thng. Bit bt u c biu din bi "0" v bit kt thc c biu din bi 1. Tin trnh thng thng biu din trong iu kin bit 1, xc nh bit dng. Khi bit bt u 0 c nhn, qu trnh nhn s c tin hnh theo 1 xung nh trc.Do vy, xung ny phi c xc nhn gia ngi gi v ngi nhn. Di y l 1 v d khi 8 bit k t 01001001 c nhn.

ST
Khng c kt ni

SP
Khng c kt ni

ST: Bit bt u SP: Bit kt thc

1 k t

xung Bit ng b thm vo mt bit bt u v 1 bit kt thc cho mi k t, v vy hiu sut truyn ton th l kh chm, nhng n c s dng trong cc thit b u cui tc chm bi v c cu kh n gin.
10

Truyn trc tip

Ch thch : ng b theo bit thnh thong c gi l phng php khng ng b hoc ng b bt u-kt thc. Nh

mt cch thc ng b, phng php ny c gi l phng php khng ng b, iu khng c ngha l n khng ng b. Phi cn thn khng hiu sai cc khi nim ny. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

190

4. Cng ngh mng

ng b theo k t (ng b)
ng b k t l phng php dng m SYN (10010110)2 t trc mt khi d liu trong vai tr m ng b11. M SYN c gi i nhiu ln lin tip m bo n c ch. Ti im ch, khi m SYN n th cc bit theo sau c chia lm cc n v d liu 8-bit, mi n v l mi k t.
V tr bt u ca d liu truyn

S S S Y Y Y N N N
Hng truyn

ng b theo khi (ng b)


Trong phng php truyn d liu theo khi, mt chui bt c bit s c chn vo v tr bt u v kt thc ca chi cc khi d liu.12 Chui bit ny c gi l chui c, ch ra v tr u tin v kt thc ca khi d liu truyn. Do , bt k s gii hn v k t, d liu c th c truyn vi s bit ty . ng b theo khi hiu qu hn nhiu so vi ng b theo k t, do n c s dng trin khai truyn d liu tc cao, nh trong HDLC
V tr u tin ca d liu V tr kt thc

Chui c
Hng truyn13

chui c

11

(Ch ) ng b k t hay cn c gi l ng b lin tc hoc ng b SYN. T lc m SYN c thit lp vi 8 bit,

mt s tng t i vi k t, d liu theo sau m SYN c nhn theo n v 8-bit. H thng c s dng trong cc thit b u cui tc va v cao. Phng php ng b ny c s dng trong cc th tc n gin.
12

(Ch ) ng b theo khi cn c gi l ng b c hay ng b frame. Trong HDLC, on bit 01111110 c (FAQ) Cc cu hi v ng b bit rt hay c hi trong cc bi kim tra. Nh rng bit u tin l "0" v bit cui cng

dng lm chui c.
13

l "1" cho mi k t. Thm vo , c nhng cu hi a ra s byte (s k t) ca d liu, tc ng truyn v hi bao nhiu giy truyn xong lng d liu . Trong trng hp ng b bit, mt bit bt u v mt bit kt thc c thm vo mi k t, vy mi k t chim c thy 10 bit. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

191

4. Cng ngh mng

4.2.3 Dn knh v truyn thng


im chnh
FDM v TDM l nhng phng php dn knh c bn C 3 phng thc truyn thng c bn: n cng, bn song cng, song cng

Dn knh l cp n vic truyn thng gia nhiu my tnh qua mt ng truyn ti cng mt thi im. Ta c th gim gi thnh truyn thong bng cch s dng ng truyn tc cao s dng phng php ghp knh t nhiu ng truyn tc thp. C 3 phng thc truyn thng: n cng, bn song cng, song cng, iu ny ph thuc vo dng ca lung d liu.

Phng thc dn knh


C 2 kiu dn knh l FDM v TDM.

FDM - Dn knh theo phn chia tn s


FDM l phng thc dn knh bng cch phn chia tn s, mi knh c phn phi vo mt bng tn xc nh v s dng mi knh nh mt knh giao tip c lp. V d: mt ng truyn c di thong 48kHz c th chia thnh 12 knh, mi mt knh c di thong 4kHz. Ta c th s dng nh 12 ng thoi. Mi knh c chia c th dung truyn c tng t v s. Trong di ng s v truyn hnh s, truyn thng s c thc hin trong cc knh truyn thng c thit lp t cc di tn s

TDM - Dn knh theo phn chia thi gian


TDM l s phi hp ca vic chia mt ng truyn s thnh nhiu knh c tc thp . Chng hn: 1 ng truyn c tc 64kbps kt ni vi 16 thit b u cui, v th, mi thit b u cui c tc ti a 4 Kbps Trong TDM, Mt ng truyn s cj chia thnh cc khe thi gian, cc knh c cng tn s c truyn nhng mi knh c phn chia nhng khong thi gian

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

192

4. Cng ngh mng

ng truyn cui Thit b cui (1) Thit b cui (2) Thit b cui (3) Thit b cui (4)

WDM - Dn knh theo phn chia bc sng


Trong khi cp quang cho php truyn tc cao(vi Gbps), th tn hiu quang ti mt bc sng c nhc im ch cho php truyn mt chiu. WDM gii quyt nhc im ny; n l phng php truyn nhiu tn hiu quang c bc sng khc nhau trn cng mt ng cp quang.14 V d, nu mt knh truyn tc 2.5Gbps cho mi bc sng c phn phi trn 4 knh ghp th tc truyn tng c th t c l 10Gbps.15

Cc phng thc truyn


Vic truyn d liu c th phn loi thnh 3 phng thc da trn dng d liu; l n cng, bn cng v song cng. Mt tuyn truyn thng gm 1 cp 2 phng tin truyn thng, gi l h dy kp. Mt s h thng gi l h bn dy vi 2 tuyn truyn thng (4 phng tin truyn): mt cp cho vic gi, cp kia cho vic nhn. Ni chung, h bn dy thng dng cho phng thc truyn song cng v h dy kp c dng cho phng thc truyn bn song cng. 16

Dn knh phn chia thi gian

Dn knh phn chia thi gian

Cc knh lgic (1)

Khi kim sot truyn

Khi x l

(4)

(3)

(2)

(1)

(4)

(3)

(2)

(1)

ng truyn tc cao

Hng truyn

n cng
Cc phng thc truyn

Truyn thng vi lung d liu theo mt hng Truyn thng vi vic gi v nht lun phin nhau Truyn thng vi vic gi v nhn c th xy ra ng thi

Bn cng Song cng

14

DWDM: K thut DWDM (Dense WDM) l mt mng ang c nghin cu; l cch truyn d liu mt

cao bng cch tng s bc sng ca k thut WDM hoc thu hp chnh lch gia cc knh ghp. S dng DWDM, truyn d liu thng lng cc ln, c th thay th tc Gbps bng tc Tbps.
15

(FAQ) C v l khng c cu hi st hch no mi v FDM v TDM nh cc k st hch trc y. Mi cu hi v

TDM u c th tr li min bn bit rng cc knh logic c th c s dng nh s phn chia thi gian trn mt ng. Nhng cu hi trong tng lai c nh bao hm WDM.
16

(Ch ) Dn knh cho php 1 h dy kp c s dng truyn song cng.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

193

4. Cng ngh mng

4.2.4 Chuyn mch


im chnh
Hai kiu chuyn mch: chuyn mch knh v chuyn mch lu-v-chuyn tip. Chuyn mch lu v chuyn tip li c 2 kiu: chuyn mch gi v chuyn mch thng bo.

Chuyn mch knh


Cc loi ng truyn tin khc nhau ph thuc vo vic hai u truyn tin c c nh hay khng. Nu c, chng ta ang s dng mt knh truyn dnh ring, 17 nu khng l mt chuyn mch knh i din l mng in thoi cng cng Phng php chuyn mch Chuyn mch knh Mng in thoi cng cng Chuyn mch gi Chuyn mch lu-chuyn tip Chuyn mch bn tin Mng chuyn mch gi Trao i th in t, Giao dch vi bn ngoi

Trong chuyn mch knh, mt b truyn s thc hin cuc gi bng cch thit lp mt knh vt l, i din bi dch v thoi. iu ny cho php d liu c truyn ti nhanh v cht lng tuy nhin cc bn tham gia phi s dng cng mt tc truyn v cng mt h thng kim sot truyn.

Chuyn mch lu-chuyn tip


Trong lu v chuyn tip, d liu chuyn n trc ht s c lu tm trong thit b chuyn mch trc khi chuyn n thit b nhn (mt b chuyn mch tip theo hay mt DTE18). Mc d cht lng truyn v tc khng tt bng chuyn mch knh nhng iu ny gii phng thit b nhn v thu khi gii hn tc truyn nh nhau v cng mt h thng iu khin. Phng php ny thch hp khi chuyn mt lng d liu nh v lu lng thi im khng ln Dng chuyn mch ny li c 2 loi, l chuyn mch gi cc tin c chia thnh gi c kch thc c nh v truyn i, v chuyn mch tin thng tin truyn i di dng cc bn tin.. Trong chuyn mch thng bo, ni chung ni dung cc gi tin khng b thay i khi truyn i. V d, phng php ny c s dng chuyn th in t trn mng v trao i thng tin giao dch gia cc ngn hng.

17

Knh truyn dnh ring: Mt ng truyn tin c quyn gia 2 hay nhiu im s dng. Ni chung ph cho knh

dnh ring tnh theo thng, xc nh da vo khong cch v tc ng truyn. C knh truyn xung dnh ring (phn nh da vo tn s) v knh truyn s dnh ring (phn nh da vo tc truyn d liu).
18

DTE (Data Terminal Equipment): Thit b m trch nhim v truyn, nhn hoc c hai. Ni chung DTE bao gm

cc my tnh v thit b u cui c th ni vi modem. Ti liu n thi FE Tp 1


-- Phn 1. n tp phn thi bui sng --

194

4. Cng ngh mng

Trong chuyn mch gi, d liu c chia thnh cc gi19 vi mt kch thc no (mt khi d liu), sau vi mi gi, a ch chuyn tip, thuc tnh d liu v m kim tra li c thm vo trc khi gi c truyn i trn phng tin truyn thng. Do cc ng truyn khng dnh ring cho bt k ngi dng no ngoi tr khi d liu c truyn hoc nhn, cc knh c th c dn v do cc ng truyn c s dng hiu qu20. Mng chuyn mch gi
Lu Gi tin Lu/phn B chia
C B A

Lu/tp hp
C B A

Dng s
C C A A

Gi tin lu

Cu hi nhanh
Q1 Q2 A1 A2 K tn cc phng php kim sot ng b ha. M t cc c tnh ca chuyn mch gi. ng b ha theo bit ng b ha theo k t ng b ha theo khi y l phng php trong d liu c chia thnh cc gi v gi i trn cc phng tin truyn thng .

19

Gi:

Trong truyn d liu, l mt khi d liu vi cc thng tin kim sot c thm vo chng hn nh a ch

chuyn tip. Vi vic truyn v nhn d liu bng cch chia chng thnh nhiu gi,ngi ta c th trnh c vic cc ng truyn trung gian gia hai a im c s dng theo kiu dnh ring, n n vic s dng hiu qu hn cc mch truyn thng.Hn na, do cc tuyn c th c chn mt cch linh hot, khi mt phn ng truyn gp li, tuyn khc c th c s dng thay th.
20

(FAQ) Cc cu hi v trao i gi s c trong cc bi thi. Cn bit rng vn c th truyn thng gia cc my tnh v

cc thit b u cui c tc khc nhau . Ti liu n thi FE Tp 1


-- Phn 1. n tp phn thi bui sng --

195

4. Cng ngh mng

4.3 Mng my tnh


M u
Mng l mt tp cc thut ng ni n mt t chc kt ni. Mt mng truyn thng tin gm cc ng truyn thng truyn d liu v cc nt lin kt cc ng truyn ny li vi nhau. LAN l mt mng quy m nh trong khi Internet l mt mng quy m ln.

4.3.1. Mng cc b (LAN)


im chnh Cu trc kt ni ca mng cc b gm : sao, trc v vng. Cc phng php kim sot truy cp ca mng cc b gm CSMA/CD v truyn th bi.

LAN v vit tt ca Local Area Network. .N l mt mng lin kt cc n v khc nhau tri ra trn mt vng kh nh, nh trong mt ta nh hay mt khu vc.

Cu trc kt ni ca mng cc b
T Cu trc kt ni y nhm ni n cu hnh kt ni ca mt mng. Cc cu trc kt ni in hnh ca mt mng bao gm sao, trc v vng.21
u cui/My ch u cui/my ch u cui /my ch

u cui

n v iu khin

(Mng sao)

(Mng vng)

(Mng trc)

Kim sot truy cp trong mng cc b


Cc phng php kim sot truy cp trong LAN c th c phn loi nh di y. Cc mng trc v vng ch c mt knh truyn , do cn kim sot truyn thng trnh xung t gia cc tn hiu truyn.

21

(Ch )

Mng sao: Cc u cui c ni vi n v kim sot truyn thng. Mng vng: Cc u cui c ni to thnh vng. Mng trc: Cc u cui c ni n cc tuyn truyn gi l cc trc.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

196

4. Cng ngh mng

CSMA/CD (a truy nhp s dng sng mang c pht hin xung ) My tnh truyn d liu s kim tra xem d liu c c truyn i hay khng trn knh truyn v sau truyn d liu. Nu d liu c truyn i, my tnh s i mt thi gian sau s li gi d liu. Kiu truyn d liu c dng l truyn theo trc (dng trc) hoc truyn theo mng hnh sao (dng sao). Nu trong khi mt tp hp d liu c gi m mng ang bn (ang c s dng) th s c xung t xy ra. Truyn vi th bi Trong phng thc ny, thng tin iu khin gi l th bi c truyn i theo mt s iu khin no trong mng LAN. My tnh nhn c th bi s c quyn c bit trong vic truyn d liu, thm vo du hiu a ch ch v d liu, v gi chng i. Kiu truyn l truyn theo dng trc hoc truyn theo dng vng 33.

c t v truyn thng trong mng cc b


Lin quan n truyn thng trong LAN, c vi c t bao gm 10BASE c thit lp bi IEEE802 Committee v FDDI (Fiber Distributed Data Interface) thit lp bi ANSI.
Chun LAN 10BASE2 10BASE5 10BASE-T 10BASE-F 100BASE-T 100BASE-FX 1000BASE-X Mi trng Cp gy Cp chun Cp xon i Cp quang Cp xon i Cp quang Cp ng truc Cp quang 1000BASE-T FDDI Cp xon i Cp quang 100Mbps Ring Tc truyn 10Mbps M hnh Chiu di Phng thc Ch truyn ln nht iu khin Bus CSMA/CD 185m LAN c nh Star34 100Mbps 1000Mbps (1Gbps) 500m 100m 2km 100m Ti 20km 25m Ti a 5km 100m 200km Token passing Mng trc Ti a 4 tng Ti a 22 tng T2, T4, TX a Cht lng cao 1000BASE-CX LX, SX Ti a 2 tng Mng trc

Chiu di ln nht l chiu di cp gia 2 im ch trong m hnh truyn thng ca LAN theo kiu bus, kiu vng, v khong cch truyn ln nht trong m hnh sao ca LAN. Chiu di ln nht theo FDDI l 200km, nhng trong mng LAN, nhiu khi cable thng gp i iu kin bnh thng trnh hng hc. Trong trng hp ny chiu di ln nht ch l 100km.

Mng cc b khng dy
Mng khng dy LAN s dng knh truyn thay cho cp v d nh sng radio, hoc tia hng ngoi. Hu ht dy cp b loi tr, nhng tn kh nhiu cng sc trong vic ci t v di chuyn cc thit b u cui. Tuy vy, vn c nhng hn ch v tc v khong cch truyn, v c th b nh hng bi cc nhiu in t t cc thit b khc. Mt nhc im na l gi thnh ca cc thit b u cui 35.
33 (Note) Khi phng php th bi p dng cho mng LAN dng vng, ta gi l vng vi th bi, khi p dng cho mng LANdng bus, ta gi

l mng bus vi th bi. Trong phng php chuyn th bi, cn phi xc nh th t m th bi c chuyn 34 (Hints & Tips) Trong mng 10BASE-T, etc. l mng LAN hnh sao. thit b iu khin c gi l b chia - hub. 35 (Note) c t ca LAN khng dy, a ra bi y ban IEEE802 , bao gm cc chun IEEE802.11a, IEEE802.11b, etc

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

197

4. Cng ngh mng

4.3.2. Mng ton cu (Internet)


im chnh
Mng Internet l mng bao gm cc mng c trong mi quan h qua li vi nhau TCP/IP l giao thc c s dng trong mng Internet

Thut ng Internet c ngha l mng ca cc mng v l mng ton cu. V giao thc, s dng TCP/IP, v truyn thng da trn a ch IP. Mng ni b v mng ni b m rng s dng cc cng ngh Internet cng c s dng rng ri.

WWW (World Wide Web)


Thut ng ny c nh ngha bi lng thng tin khng l c truyn qua bi cc thnh phn ca mng Internet nh mt li nhn. Cc kt ni thng tin trn web c hon thnh di dng siu vn bn. Vi mi kt ni trong vn bn, s c nhiu thng tin hn c tm kim v nghin cu, v theo cc my tnh trn th gii c th truy cp. WWW cung cp mt c cu nh siu vn bn cp trn. Mun xem ni dung ca chng cn cc trnh duyt web v d nh IE (Internet Explorer) hay Firefox.

Dch v Internet
Internet s dng giao thc TCP/IP , v c rt nhiu dch v s dng giao thc ny trn mng Internet. Di y l cc dch v chnh: Tn Telnet Ch thch Giao thc chun cho cc thit b u cui o S dng vi cc my tnh c th iu khin t xa File Transfer Protocol Giao thc chun truyn tp C tp vn bn v nh phn u c th truyn i Chc nng cho php ngi dng gi (nhn) tin nhn n (t) mt hoc nhiu ngi Vic truyn d liu vn thc hin khi mt trong cc bn khng kt ni. Tuy nhin, truyn v nhn thng ip, cn phi c mt a ch th. Cc giao thc c s dng l SMTP v POP3.

FTP

Th in t

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

198

4. Cng ngh mng

Mng ni b
Mng ni b l mng trong cc t chc s dng cng ngh Internet. Thng thng, gia mng bn trong v mng Internet c bo v bng mt h thng bo v c gi l tng la (firewall), c ci t nhm ngn chn s r r thng tin. Vi s ph bin ca Internet v ng dng duyt web, c th xy dng ln mt h thng chia s d liu, nhng thng bo, hay th in t vi gi r.

My ch Web Mng con Internet Tng la Mng ca cng ty Mng con My ch Web

Mng Extranet

Intranets

Extranet l s m rng ca Intranet gia cc cng ty. Ni chung, Intranet c kt ni vi Internet thng qua vic xy dng Extranet. Extranet Internet

Intranet cng ty A

Intranet cng ty B

HTTP (Giao thc truyn siu vn bn)


HTTP l mt giao thc truyn thng trong vic nhn v gi cc ti liu dng HTML gia cc my ch Web v my khch. yu cu, my khch s gi mt URL40 di dng HTML41 n my ch. tr li, my ch cng gi mt ti liu dng HTML ti my khch.

40

URL (Uniform Resource Locator): Dng nh danh mt ti nguyn trn web, bao gm giao thc, tn min, ng dn n ti nguyn

HTML (HyperText Markup Language): Dng to ra cc ti liu dng siu vn bn. Cc t t trong < v > gi l cc th dng nh dng vn bn, ch cc ng dn, khai bo cc kch bn. nu c m trong mt trnh duyt, trnh duyt s bin dch v hin th ni dung. xc nh a ch my ch WWW, ta dng a ch URL.

41

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

199

4. Cng ngh mng

4.3.3 Cc thit b truyn thng


im chnh Kt ni gia cc mng LAN bao gm: b nh tuyn, cu, b chuyn tip, gateways. Modem c s dng cho cc ng truyn tng t trong khi DSU v TA s ng cho cc giao tip bng s.

S a dng ca cc thit b giao tip l cn thit cho vic tin hnh cc giao tip trn mng. kt ni nhiu mng LAN vi nhau, cc thit b ci t tu theo mc ch ca n. Cc thit b c chn ny khng ph thuc vo h thng s dng tn hiu tng t hay tn hiu s.

Cc thit b trong mng LAN


Thit b kt ni trong mng LAN l cc thit b kt ni qua li trong cc mng Lan hoc gia cc mng c cc giao thc khc nhau. Sau y l hnh biu din s ph hp ca cc thit b vi cc tng trong m hnh chun OSI22:
M hnh OSI Thit b ni kt trong LANs
LAN B chia LAN

Tng ng dng Tng phin Tng trnh din Tng giao vn Tng mng Tng lin kt d liu Tng vt l

Gateway B nh tuyn Cu B chia B chuyn tip

Cu/B nh tuyn B chia LAN nhnh

LAN LAN LAN trc

Tn thit b Gateway

B tuyn Chc nng lc da trn a ch MAC 24 Cu B chuyn M rng khong cch truyn tn hiu bng cch khuych i tn hiu, etc. tip Tp trung cc mng con li26 v kt ni chng vi mng (dng cho mng LAN B chia25 hnh sao)

Gii thch Chc nng chuyn i giao thc trong cc tng (ch yu l tng giao vn v cc tng trn n) nh La chn ng i tt nht,chc nng lc23 da trn a ch IP

22 (FAQ) S tng ng gia m hnh OSI v cc thit b kt ni trong LAN hay c cp trong cc k thi. Nh rng router ng vi tng mng, bridge ng vi tng lin kt d liu v repeater ng vi tng vt l. 23 Chc nng lc: Hm ca h thng, da trn a ch, quyt nh xem gi tin c chp nhn hay loi b. Vi chc nng ny, rt nhiu gi tin khng cn thit s b ngn khng cho i vo LAN 24 a ch MAC: Mt s 48 bit gn cho thit b giao tip mng. V mt nguyn l, khng tn ti hai card mng trn th gii c cng a ch MAC. 25 (Hints & Tips) Mt b chia c chc nng chuyn tip cc gi tin tng lin kt d liu th gi l b chia chuyn mch. Trong khi , nu ch c chc nng chuyn tip tn hiu vt l th gi l b chia chuyn tip. 26 Backbone LAN / Branch LAN: Mng trc cp ti phn ng truyn ch yu trong mt t chc. Thng thng mng cp quang c s dng cung cp bng thng v tc cao. Mng trc dng kt ni cc mng LAN nhnh. Mt nhnh mng thng c s dng cho mt chi nhnh hoc mt b phn. N l mng LAN c va v nh, dng kt ni cc my trm, my ch, my in.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

200

4. Cng ngh mng

Thit b truyn thng cho ng truyn tng t


Thit b truyn thng cho ng truyn tng t c dng trong h thng truyn d liu s dng mng in thoi cng cng (tng t) lm ng truyn. Bi v my tnh l s v mng in thoi cng cng l tng t nn cn c cc thit b chuyn i gia chng. L mt mch chuyn i, cc thit b c chc nng quay s l cn thit. Cc n v truyn thng cho mch tng t c biu din trong hnh di y. My tnh
Thit b cui iu ch Gii iu ch modem NCU

ng truyn tng t

iu ch CCU Gii iu ch

trung tm

NCU

modem

Tn hiu s

Tn hiu tng t

Tn hiu s

Unit name Modem NCU CCU

Explanation MODEM (MOdulation DEModulation): L mt thit b chuyn i tn hiu tng t thnh s v s thnh tng t Network Control Unit: L thit b c chc nng to cc cuc gi ti cc thit b khc trong mng Communication Control Unit: L thit b dung iu khin qu trnh truyn thng, iu khin li, phn tch v tp hp cc tn hiu truyn/nhn

Thit b truyn thng cho ng truyn s


Thit b truyn thng cho ng truyn s l mt h thng giao tip s dng mch s lm ng truyn tn hiu. Khng ging nh mch tng t, modem l khng cn thit. Thay vo cn thm 1 thit b DSU (Digital Service Unit), lm nhin v chuyn tn hiu s trong my tnh vo cc khun dng vic giao tip trn mch s d dng hn. Hnh di y th hin cc n v truyn thng cho mch s.
My tnh

Mng s
TA DSU DSU TA

My tnh

Tn hiu s

Tn hiu s, d dng truyn trong mng truyn thng

Tn hiu s

Mt thit b gi l TA (B thch hp u cui) c th c yu cu gia DSU v thit b u cui.27 TA cho php cc my in thoi, my fax v my tnh, nhng thit b giao tip s hot ng trn ng ISDN. Hu ht cc trng hp u cn c TA.

27

(Hints & Tips) DSU thng c ci t vo bn trong TA v khng thy c trc tip.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

201

4. Cng ngh mng

4.3.4 Cc dch v vin thng


im chnh
Cng ngh ATM truyn v nhn mt gi tin c di 53 bytes

ISDN (Mng tch hp dch v s)


ISDN l mt giao thc mng hp nht trong cc nhm phc v nh: in thoi, dch v d liu v fax. N c y nhng ci chung v tc c bn v nhng ci ring v tc . Tc c bn c s dng gn ging nh tc ca cc ng in thoi, nh tc ring l cc ng cp quang. Cc c im c trnh by bng di y.28 Tn Tc c bn Tc c s Gii thch Gm c hai knh B v mt knh D (2B+D); Ti a l: 144Kbps Gm c nhiu knh B a l: 1,536Kbps 29 v mt knh D (23B+D, 24B, 4H0, etc.); Ti

C rt nhiu knh gia c th la chn gia cc ng truyn. v d, trong tc c bn, c hai knh B chng c th s dng hai ng trong 64kbps hoc mt ng 128kbps. Chi tit cho bi bng di y: . Name Knh D Knh B Knh H Explanation Knh tn hiu cho vic iu khin thng tin Tc c bn: C th s dng ging knh B trong gi chuyn Tc c s: mch Knh thng tin ngi s dng 64Kbps Knh ngi s dng vt tri 64Kbps H0 (384Kbps) H11 (1,536Kbps) H12 (1,920Kbps)31 16Kbps 64Kbps30

32

ATM (Asynchronous Transfer Mode)


ATM phn mnh cho mi thng tin trong cc phn t trong vic s cc di (53 bytes) cho vic chuyn v nhn, nh mang li mt cht lng cao trong cc ng s dng, trong cc thnh phn kin trc ca tc cao trong cc giao thc n gin ging nh l iu khin li v hiu nng s l
(FAQ) Thng xuyn c cc cu hi v tc ca cc giao din ISDN. Nh rng c hai knh B v mt knh D v tc mt knh D l 16kbps. 29 (Hints & Tips) Tc truyn ti a l tng tc ca tt c cc knh. Trong giao din c bn, tc l 144kbps bi v c hai knh B tc 64kbps v mt knh D tc 16kbps 30 (Hints & Tips) Trong giao din c s, knh D l khng bt buc, chng hn 24B. Tuy nhin, khi thu knh th mt knh D l cn thit, do cu trc thng l mt giao din 24B v mt 23B+D. 31 (Hints & Tips) Trong giao din c s, tc s l 1,536kbps s dng knh H11. H12 c s dng chu u cn H11dng M v Nht. 32 bps (bits per second): lng bit truyn c trong mt n v thi gian. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng -28

202

4. Cng ngh mng

cc phn mnh ca phn cng.

ADSL
ADSL (Asymmetric Digital Subscriber Line) l cng ngh truyn d liu tc cao s dng cng vi ng in thoi. Trong c th s dng vic kt ni thng qua modem ADSL thng thng. Tc Upload t 0.5Mbps n 1Mbps v tc download t 1.5Mbps n 40Mbps. Vic khc bit gi tc ti xung v ti ln l do khng ng b trong ng truyn s. n c th c thy trong vic ti t d liu ging nh nhu cu VIDEO v cc gi video trn cc trang Web d liu video.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

203

4. Cng ngh mng

Cu hi nhanh
Q1 Q2 Q3 Trnh by phng thc CSMA/CD Trnh by danh sch ba dch v c bn ca mng Internet M t cu trc knh trong giao din c bn ISDN.

A1

My tnh mun truyn kim tra ng truyn xem c d liu hay khng khng v sau gi d liu. Nu ng truyn bn, n s i cho sau mt khong thi gian no v sau gi li d liu. Phng thc ny c s dng chnh trong cc kiu LAN dng trc Telnet: FTP: Th in t: Giao thc chun cho u cui o S dng giao tip vi my xa Giao thc truyn tp, l giao thc chun cho vic tryn. C hai loi l tp vn bn v tp nh phn cc th truyn c Th tc cho php ngi s dng c th gi/nhn th n/t nhiu ngi khc. Vic truyn th c th thc hin ngay c khi ngi nhn khng kt ni vo mng. Mc d vy, cho vic gi hoc nhn th, mt a ch mail l phi c.

A2

A3

Hai knh B v mt knh D (2B+D)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

204

4. Cng ngh mng

Cu hi 1

kh: **

Tn sut: ***

Q1. Cu no m t ng trng thi trong m hnh OSI v tng mng a) Tng mng thc thi l trnh v s chuyn tip cho php d liu c th truyn qua cc h thng cui. b) Trong cc tng, tng mng gn vi ngi s dng nht cung cp cho h cc phng thc nh truyn tp v th in t c) Tng mng thu ht s khc nhau vt l tiu biu ca truyn thng v cung cp l trnh truyn trong sut n cc tng cao hn d) Cung cp cc giao thc kim sot truyn thng (kim tra li, kim sot truyn thng li,) gia cc nt lin k.

p n cu 1
p n : a OSI (Open Systems Interconnection) c xy dng bng cch chia cc chc nng trong mt h thng truyn thng ra lm 7 tng c lp n gin ha vic ni kt cc m hnh my tnh v mng khc nhau. OSI ch yu cung cp mt m hnh c bn; 7 tng trong m hnh tham chiu OSI c s dng nh mt hng dn. Tin trnh A Tng ng dng Tng trnh din Tng phin Tng giao vn Tng mng Tng lin kt d Tng vt l
Transmission medium

D liu ca ng dng Ni dung biu din Hi thoi Khi truyn d liu D liu D liu Tng mng Khung tin Khung tin Tng lin kt Tn hiu in Tn hiu in Tng vt l Nt trung gian
H thng m trung gian

Tin trnh B Tng ng dng Tng trnh din Tng phin Tng giao vn Tng mng Tng lin kt d Tng vt l
ng truyn

Trm A (H thng m cui)

Trm B (H thng m cui)

Tng mng m hnh cc chc nng chn ng v chuyn tip d liu. N m hnh ha mt mng my tnh, t a ra cc chc nng chn ng v chuyn tip d liu. Cc chc nng ny c ci t trong cc giao thc tng mng, chng hn X25, trong cc mng chuyn mch knh v c chuyn mch gi. Do , chc nng ca tng mng l tm ng i n mt my tnh khc b) c) d) Gii thch tng ng dng. Gii thch tng vt l. Gii thch tng lin kt d liu.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

205

4. Cng ngh mng

Cu hi 2

kh: *

Tn sut: ***

Q2 . Giao thc no sau y c pc s dng t ng thit lp a ch IP trong ln u tin kt ni vi LAN ? a) DHCP b) FTP c) PPP d) SMTP

p n cu 2
Tr li: a DHCP (Dynamic Host Configuration Protocol) l mt giao thc t ng thit lp thng s ca mng. Khi thit b u cui (my khch) sn sng, mt a ch ip ng c xc nh cho mi my client, v khi qu trnh kt thc a ch ip xc nh c t ch. b) FTP (File Transfer Protocol) l giao thc truyn tp trn mng TCP/IP c) PPP (Point-to-Point Protocol) l giao thc cho WAN s dng kt ni mng, khng c thit da trn TCP/IP. Thng thung PPP c s dng cho kt ni dial-up n internet, ngoi dng khng cn tn ti a ch ip SMTP (Simple Mail Transfer Protocol) l giao thc gi v nhn th in t gia hai dch v th in t trn mng TCP/IP . N lun lun s dng khi mt th in t c gi t thit b du cui (my khch) n my ch th in t

d)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

206

4. Cng ngh mng

Cu hi 3
Q3.

kh: **

Tn sut xut hin: *

K t T (m ASCII l 1010100) c gi thng qua cch truyn d liu s dng ng b bt u-kt thc vi s pht hin li trng thi chn. Nu k t nhn c l ng, dy bit no s nhn c? y, cc bit gi c gi theo th t sau : bit bt u (0); m k t, t bt d liu thp nht n bit d liu cao nht; bit chn l; v bit dng(1). Cc bit c vit trong chui theo cch m chng nhn c, bt u t bn tri. a) 0001010101 b) 0001010111 c) 1001010110 d) 1001010111

p n cu 3
Tr li: b Bi v di k t l 7 bit v 1 bit kim tra chn l c thm vo, mt k t s c di l 8. Bit bt u 0cng c thm vo trc chui bit k t, v bit dng 1 cng c thm vo cui.V vy, cng vi nhau, k t s c di l 10 bit. Bi v bit kim tra chn c s dng, s ca bit u tin trong 8 bit(i vi bn thn k t) s l chn (ngha l 0).

XXXXXXXX

1 Bit dng (gi tr 1) k t (kim tra chn) Bit bt u (gi tr 0)

a) b) c)

0001010101 s u tin trong nhm l 3kim tra l. 0001010111 s u tin trong nhm l 4kim tra chn. 1001010110 Bit dng l 0. Bit bt u l 1.

d)

1001010111 Bit bt u l 1 s 1.

V vy, chui bit, khi nhn c chnh xc, l 0001010101, p n l (b).

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

207

4. Cng ngh mng

Cu hi 4

kh: **

Tn sut: **

Q4. m thanh c ly mu 11000 ln/giy, mi gi tr c ly mu c ghi li dng d liu ly 8 bit. Trong h thng ny, mt a mm dung lng 1.4 x 106 byte c th ghi c trong bao nhiu giy? a) 15 b) 127 c) 159 d) 1,272

p n cu 4
Tr li: b V m thanh c ly mu 11000ln/giy, mi ln ly mu dng 8 bit d liu, lng d liu c truyn trong 1 giy l: S lng bit c truyn trong 1 giy = 11,000 (ln/giy) 8 (bit/ln) = 88,000 (bit/giy) Dung lng ca a l 1.4 106 byte, cng n v tnh, chng ta s chuyn s bit d liu trong 1 giy thnh byte nh sau: S byte d liu c truyn trong 1 giy =

88,000 (bit/giay) 8 (bit/byte)

= 11,000 (bytes/sec) C 11000 byte c truyn trong 1 giy trn mt a mm dung lng 1.4 106 byte, thi gian d liu m thanh ghi ln a =

1.4 106 11,000

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

208

4. Cng ngh mng

Cu hi 5

kh: **

Tn sut: **

Q5. Ba b nh tuyn IP c kt ni vi nhau bng cc ng thu bao nh hnh v bn di. Pht biu no di y ph hp nht vi hot ng ca router A trong vic chuyn mt gi tin terminal A sang terminal B?
Leased line Terminal Router Router

Terminal

Leased line Router Terminal

a) b) c) d)

Router A chuyn tt c cc gi tin n c router B v C Router A chuyn cc gi tin n router B ch theo ng c ch nh trong gi tin Router A chuyn cc gi tin n router B ch da trn a ch IP ch ca gi tin Router A bit c v tr ca terminal B t a ch MAC ca ch trong gi tin v chuyn cc gi tin n router B

p p cu 5
Tr li: c Mt router kim tra a ch IP ca bn nhn (nhn gi tin c chuyn n), xc nh ng i ph hp, v phn pht gi tin n ch. Trong tng lin kt d liu ca m hnh OSI, d liu c th c truyn ch gia cc im lin k hoc cc phn on ging nhau, nhng mt b nh tuyn gi gi tin n mt b nh tuyn c ch nh chuyn d liu qua cc tng mng . a) b) d) Nu phng thc truy cp ng truyn trong LAN l ging nhau th cu s lm chc nang ny. B nh tuyn ni cc mng LAN vi cc phng thc truy cp c th khc nhau, c th chuyn gi ti da trn a ch ch c ch nh. ng i ca mt gi tin khng c xc nh trc. N ch c xc nh ti cc b nh tuyn khi gi tin ti b nh tuyn. ng i tt nht s c la chn. Chc nng chuyn tip da trn a ch MAC l ca thit b cu.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

209

4. Cng ngh mng

Cu hi 6

kh: *

Tn s: ***

Q6. Nhng phng php iu khin truy cp no di y trong mng LAN cung cp chc nng pht hin mt s xung t trong khi truyn? a) CSMA/CA c) Bus vi th bi b) d) CSMA/CD Vng vi th bi

p n cu 6
Tr li: b Mt phng php iu khin trung gian l mt phng php gi khung tin (n v truyn) trong mng LAN. Nh quy nh, khi u cui gi mt gi tin, cc u cui khc cn phi nm gi tt c cc ng truyn cho n khi khung tin t n ch. CSMA/CD (Carrier Sense Multiple Acces with Collision Detection- a truy nhp s dng sng mang c pht hin xung t) l phng php iu khin truy nhp cho cc mng LAN dng bus hoc sao. u cui mun kim tra xem bt k truyn thng c thit lp bi cc u cui khc xong cha trn ng truyn ; u cui s gi d liu nu khng c truyn thng no xy ra. Nu c truyn thng xy ra , u cui i trong mt khong thi gian xc nh ri c gng truyn li d liu a) CSMA/CA (truy nhp a sng mang c trnh li ) l phng php iu khin truy nhp cho cc mng Lan tc trung bnh t 1Mbps n 2 Mbps . c) Bus vi th bi l mt ng dng ca vic truyn vi th bi trn mng LAN dng bus. Th bi l mt phng php iu khin truy nhp cho mng LAN dng vng v dng bus. D liu nhn thc qu trnh truyn, c gi l th i vng quanh mng LAN mt cch lin tc, v u cui nhn c th s nhn thc cho vic truyn d liu. Mt u cui mun truyn d liu phi nhn c th v truyn d liu m n mong mun truyn. Mi khi qu trnh truyn kt thc, th li c gii phng cho mng d) Vng vi th bi l mt ng dng ca th bi cho mng LAN dng vng.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

210

4. Cng ngh mng

Cu hi 7

kh: *

Tn s: **

Q7. Cu no di y miu t chnh xc nht chc nng ca my ch proxy? a) My ch proxy chuyn a ch IP o dng trong mng Intranet sang a ch IP ton cc v ngc li. b) My ch proxy t ng gn a ch IP cho my khch khi my khch kt ni vi mng. c) Khi my khch c kt ni vi mt mng Internal truyn thng vi mt mng bn ngoi, my ch proxy ng vai tr nh vt trung gian v thay mt cho my khch kt ni n my ch bn ngoi. d) Mt my ch proxy c bng tng ng cha tn my v a ch IP,v n thng bo cho my khch a ch IP ca tn my tng ng khi my khch gi yu cu.

p n cu 7
Tr li: c Proxy l my ch ci t duy tr bo mt v t tc truy nhp cao khi to kt ni n Internet t mt mng bn trong. N ngn chn vic truy cp khng c nhn thc vo ni mng, v n cng qun l vic truy cp t ni mng ra ngoi Internet. a) Chc nng chuyn a ch IP a phng sang a ch IP ton cc v ngc li l chc nng gi lp a ch IP hay NAT (Network Address Translation). Nhng chc nng ny thng c h tr trn cc b nh tuyn (gateways). b) y l s gii thch v DHCP (Dynamic Host Configuration Protocol). d) y l s gii thch v DNS (Domain Name System).

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

211

Cng ngh c s d liu

Mc ch
C s d liu l mt tp c t chc bao gm cc d liu c thu thp li nhm mc ch chia s d liu, qun l tp trung v c mc c lp cao. Cc c s d liu c nhiu loi nhng hin nay cc loi chnh bao gm: c s d liu phn cp, c s d liu mng v c s d liu quan h. Trong c s d liu quan h ang l xu hng chnh hin nay. Trong phn 1 chng ta s tm hiu v l thuyt cc c s d liu, tho lun cc cu trc ca chng v cc phng php pht trin. Trong phn 2, chng ta s hc cch s dng SQL ngn ng lp trnh c dng thao tc c s d liu quan h. Cui cng, trong phn 3, chng ta s tm hiu DBMS phn mm phc v vic s dng hiu qu cc c s d liu.

5.1 5.2 5.3

Cc m hnh d liu Cc ngn ng c s d liu Thao tc c s d liu

[Cc thut ng v khi nim cn nm vng] Lc 3 lp, c s d liu phn cp, c s d liu mng, c s d liu quan h, biu E-R, chun ha, php chn, php chiu, php kt ni, DDL, DML, SQL, y thc 2 pha, nhn bn
212

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

5. Cng ngh c s d liu

5.1 Cc m hnh d liu


M u
M hnh d liu l s m t khi qut cc i tng d liu c lin quan n nhau theo mt s lut no . to ra mt c s d liu u tin phi a ra mt m hnh d liu sau chun ha n bng cch loi b cc thng tin khng cn thit v cc i tng trng lp. Tip theo, c s d liu phi c thit k sao cho c th tm kim, cp nht v xa d liu mt cch hiu qu. Cc loi m hnh d liu bao gm: cc m hnh d liu khi nim, cc m hnh d liu logic v cc m hnh d liu vt l. Cc lut thc thi cc m hnh trn gi l: lc khi nim, lc ngoi v lc trong.

5.1.1 Lc 3 lp
im chnh
Khung (nh ngha) ca mt c s d liu c gi l lc 3 lp. Lc 3 lp bao gm: lc khi nim, lc ngoi v lc trong.

Vic tru tng ha v t chc cu trc cc thng tin th gii thc (i tng to thnh mt c s d liu) sau x l chng c gi l m hnh ha d liu (data modeling). Mt m hnh d liu c th l m hnh khi nim, logic hay vt l. Mi lin h gia chng c ch ra trong hnh v di y. 1

i tng trong th gii thc

(tru tng ha)2 M hnh E-R3 M hnh quan h, m hnh mng, m hnh phn cp C s d liu quan h, c s d liu mng, c s d liu phn cp (La chn DBMS) (Thao tc d liu)

M hnh d liu khi nim

M hnh d liu logic M hnh d liu vt l

1 (Ch ) Mt m hnh d liu l mt s biu din khi nim (m hnh) ca d liu; n c th cng dn n cc lut biu din.

Tru tng ha: Ly ra nhng thnh phn m t quan trng nht ca i tng v loi b nhng ci khc. Chng ta c th to ra mt c s d liu chia s nu nh: khi to mt m hnh d liu u tin phi tm ra tt c cc thnh phn ph bin trong tt c cc thao tc t cc thao tc gia cc d liu n cc thao tc cn c h thng ha. 3 (Gi ) Cc m hnh khi nim bao gm c m hnh E-R s c tho lun trong phn 5.1.3. Cc m hnh d liu logic trong c m hnh quan h, m hnh mng v m hnh phn cp. Hn na, nu chng ta chn mt m hnh d liu logic v to mt c s d liu t n, ta c th c c mt m hnh d liu vt l. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

213

5. Cng ngh c s d liu

c lp d liu
S c lp d liu c th hiu l Mt chng trnh s khng thay i khi d liu thay i. T khi nhiu chng trnh c th chia s mt tp hp d liu chng ta khng cn phi to ra nhiu tp d liu ng vi cc chng trnh ring l. Bi th d liu cn phi c t chc mt cch h thng. Mt loi phn mm nhm t c s c lp d liu l h qun tr c s d liu (DBMS). DBMS m bo s c lp d liu bng cch s dng lc 3 lp.

Lc 3 lp
Mt lc 3 lp l s m t khung ca mt c s d liu. Trong ANSIX3/SPARC,4 cc lc c chia thnh lc khi nim, lc ngoi v lc trong. Chng c gi l lc 3 lp. Quan h gia chng c biu din trong hnh v sau y: Chng trnh Lc ngoi Ngi dng cui Lc ngoi Lc khi nim Lc trong C s d liu Mt cch tng qut, ngi dng s dng c s d liu qua lc ngoi. Tn Lc ngoi
5

Ngi dng cui Lc ngoi

Lc khi nim Lc ngoi

Gii thch nh ngha ci nhn c s d liu t chng trnh hoc ngi dng. N s dng mt phn ca lc khi nim. Trong cc c s d liu quan h n gi l mt khung nhn cn trong cc c s d liu mng gi l lc con. N tn ti cho mi chng trnh v ngi s dng. y l d liu c cha trong c s d liu, nh ngha da theo m hnh d liu; mt nh ngha ca d liu thc ni chung. N c gi l bng trong c s d liu quan h v lc trong c s d liu mng. y l nh ngha cho vic thu c mt lc khi nim cho s lu tr ngoi. N bao gm cc thng tin nh l ti thiu, cc phng php t chc v di b m.

Lin quan n c s d liu quan h v c s d liu mng, xem phn 5.1.2 Cc m hnh d liu logic.

4 ANSI/X3/SPARC: ANSI (American National Standards Institute) l mt t chc phi li nhun a ra cc chun cng nghip M. X3 l y ban trong ANSI tho lun cc chun lin quan n x l thng tin. SPARC (Standards Planning And Requirements Committee) l y ban lin quan n cc vn quc t. 5 (FAQ) Nhiu cu hi thi hi v cc loi lc v c im ca n. Cn hiu c r rng s khc nhau gia lc khi nim, lc ngoi v lc trong.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

214

5. Cng ngh c s d liu

5.1.2 Cc m hnh d liu logic


im chnh
Cc m hnh d liu logic bao gm m hnh quan h, m hnh mng v m hnh phn cp Mt c s d liu l kt qu ca vic thc thi mt m hnh d liu logic trong mt mi trng lu tr

M hnh d liu logic bao gm m hnh quan h, m hnh mng v m hnh phn cp. Cc m hnh d liu ny khi c thc thi s tr thnh c s d liu quan h, c s d liu mng v c s d liu phn cp. 6

C s d liu phn cp (c s d liu cu trc cy)


Mt c s d liu phn cp chia cc bn ghi thnh cc cha v con vi mi lin h c th hin qua cu trc phn cp. N c m t bi mi lin h mt-nhiu (1:n) gia cc bn ghi cha v cc bn ghi con. Ni cch khc, mt bn ghi cha c th c nhiu bn ghi con nhng mt bn ghi con ch c th c duy nht mt bn ghi cha. Tuy nhin, cc c s d liu phn cp c i x nh l mt trng hp c bit ca cc c s d liu mng, v th chng khng cn c s dng nhiu. Cu trc ca mt c s d liu phn cp c ch ra nh hnh di y:
Cu lc b bng r Cu lc b bi Cu lc b bng nm Cha

Billy

John

Susie

Bobby

Jerry

Tommy

Nancy

Con

C s d liu mng
Mt c s d liu mng khc mt c s d liu phn cp ch cc bn ghi cha v bn ghi con khng ch c cc mi lin h mt-nhiu (1:n) m chng cn c cc mi lin h nhiu-nhiu (m:n). Ni cch khc, mt bn ghi cha c th c nhiu bn ghi con v ngc li, mt bn ghi con cng c th c nhiu bn ghi cha.7 Mt c s d liu mng i khi c gi l mt c s d liu CODASYL.8 Cu trc ca mt c s d liu mng c ch ra nh hnh di y.
Cu lc b bng r Cu lc b bi Cu lc b bng nm Cha

Billy

John

Susie

Bobby

Jerry

Tommy

Nancy

Con

V d y Susie ch thuc v cu lc b bi nhng Tommy thuc c cu lc b bng nm v cu lc b bng r.


(Ch ) Cc c s d liu phn cp v c s d liu mng i khi c gi l cc c s d liu cu trc (together) (Gi ) Mt c s d liu cu trc l mt c s d liu mng trong mi nt con ch c duy nht mt nt cha 8 C s d liu CODASYL: C s d liu mng cp n bt k mt c s d liu no da trn ngn ng c trng a ra bi CODASYL; do vy, mt c s d liu mng cng c gi l c s d liu CODASYL. CODASYL l vit tt ca Conference On DAta SYstems Languages. T chc ny bao gm chnh ph M, cc nh sn xut my tnh v ngi dng. y l t chc pht trin v duy tr ngn ng lp trnh hng kinh doanh COBOL. N pht trin COBOL nm 1960 v sau mi nghin cu v c s d liu.
7 6

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

215

5. Cng ngh c s d liu

C s d liu quan h
C s d liu quan h l mt c s d liu trong d liu c biu din trong mt bng 2 chiu. Mi hng trong bng ng vi mt bn ghi v mi ct l mt trng ca bn ghi. Ct c gch chn ch nh kha chnh.9
Tn bng: BangNhanVien MaNhanVien 00100 00200 00300 00400 Ten Paul Smith Rick Martin Billy Graham John Wilson SoDienThoai 03-3456-0001 03-3456-0011 03-3456-0010 03-3456-0200 Hng (cp, bn ghi) Ct (khon mc, thuc tnh,)

Mi bng lun c t tn. Nh v d trn, tn ca bng l BangNhanVien. Cc ct l MaNhanVien, Ten, v SoDienThoai Mi ct l mt tp d liu nh 00100, Paul Smith, 03-3456-0001. Ni cch khc, chng ta c th ni rng BangNhanVien gm c 4 hng v 3 ct (4 by 3).

S Bachman
S Bachman m t mi quan h cha-con gia cc bn ghi trong mt c s d liu mng. Cha gi l ch (owner) trong khi con gi l thnh vin (member). Bn di, cc thut ng nh theo hc (enrollment) v thnh phn (component) m t cc quan h cha-con gi l cc kiu tp cha-con. Cc ni dung tht s (cc gi tr) trong biu Bachman c gi l th hin10 (occurrence).
Sinh vin
Theo hc

Bi ging
Thnh phn

Cha

Ging vin

Gio s

Bi

Con

9 Kha chnh: L mt ct hoc mt tp cc ct xc nh duy nht mt hng trong bng. Trong cng mt bng, cc gi tr kha chnh khng th trng nhau. y trong Employee table, Employee number l kha chnh. Nu gi tr ca mt bng khng n nht, c th nh ngha mt kha kt hp bng cch kt hp nhiu ct. 10 Th hin: L mt gi tr c th trong s Bachman. V d, nu A, B v C l 3 Sinh vin th A, B, C l 3 th hin.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

216

5. Cng ngh c s d liu

5.1.3 M hnh E-R v biu E-R


im chnh
Biu E-R (E-R diagram) l mt m hnh d liu m khng cn lin quan n DBMS. Cc thnh phn ca mt biu E-R l thc th (entities) v quan h (relations)

Cc m hnh phn cp, mng v quan h l tt c cc m hnh d liu m DBMS c s dng. 11 Tuy nhin, d liu v thng tin s dng trong th gii thc khng nht thit phi gii hn tng thch vi DBMS. Mt trong cc phng php biu din cc cu trc d liu th gii thc chnh xc n mc c th l m hnh thc th lin kt E-R (E-R model). M hnh E-R c biu din bng cch s dng mt biu E-R. Biu E-R l mt k thut s dng trong thit k cc tp v c s d liu, dng biu din cc kt qu nhn c bi vic thu thp cc i tng qun l v cc thnh phn d liu. Cc i tng cn qun l v phn tch l cc thc th, c lin kt vi cc thc th khc bi cc quan h. Cc yu t to thnh cc thc th v quan h gi l cc thuc tnh.

Cc quy tc ca biu E-R


Trong mt biu E-R, cc thc th c biu din trong cc hp hnh ch nht trong khi cc quan h c th hin bi cc on thng v cc mi tn ( , , ). Cc thuc tnh cng c biu din trong cc hp. Trong v d di y, cc Nhn vin v Phng ban c lin kt bi mi lin h c tn l Vn chuyn. Thc th Nhn vin c cc thuc tnh l M nhn vin, tn nhn vin v Ngy tuyn dng. Trong mt s trng hp cc kha chnh c gch chn.

Nhn vin M nhn vin Tn nhn vin Ngy tuyn dng

Vn chuyn

Phng ban M ngi qun l Tn phng

:Tn thc th :Cc tn thuc tnh

Cc quan h th t
Trong mt biu E-R, quan h 1- nhiu mt cng ty c nhiu nhn vin c ch ra trong s sau. Ch rng, i khi khng cn phi biu din cc thuc tnh. 12 Tuyn dng Cng ty Nhn vin y, Cng ty v Nhn vin c lin kt bi mi quan h tn l Tuyn dng. Quan h gia Cng ty v Nhn vin l 1- nhiu ( ) nn mt cng ty c nhiu nhn vin. Nu mt nhn vin c chn, ch c duy nht mt cng ty lin quan n anh ta. Tuy nhin, chn mt cng ty th khng ch c duy nht mt nhn vin. Bi th vi mt quan h 1 - nhiu, chiu 1
DBMS (H qun tr c s d liu): L phn mm c thit k duy tr v thi hnh cc c s d liu . (FAQ) C nhiu cu hi thi hi gii thch cc biu E-R. Chc chn rng bn c th nhn ra cc quan h 1- nhiu, 1-1 v nhiu-nhiu. Mi quan h gia cc nhn vin v cc phng ban trong mt cng ty vi rt nhiu nhn vin, mt s trong c th thuc v nhiu phng ban, l nhiu-nhiu.
12 11

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

217

5. Cng ngh c s d liu

l chiu xc nh c. Di y l mt biu E-R ch quan h nhiu nhiu. Cng ty


Nm gi c phiu

C ng

y c mt mi tn 2 chiu th hin mi lin h nhiu-nhiu gia Cng ty v C ng. N ch ra rng mt c ng c th s hu c phiu ca nhiu cng ty v mt cng ty cng c th c nhiu c ng. Ni cch khc, ta c th hiu hnh v trn nh sau: C nhiu cng ty, mi cng ty c nhiu c ng.

5.1.4 Chun ha v cc rng buc tham chiu


im chnh
Chun ha c ngha l ti thiu ha cc d liu d tha C 3 dng chun ha: dng 1, dng 2 v dng 3

S chun ha (Normalization) - chun ha d liu l vic duy tr tnh nht qun v ton vn d liu bng cch loi cc d liu d tha. C 3 dng chun ha: dng 1, dng 2 v dng 3. S chun ha l mt khi nim ch c s dng cho c s d liu quan h. Xu hng chnh hin nay ca c s d liu l c s d liu quan h nn chun ha cng l mt vn rt quan trng.

Dng cha chun ha


Dng cha chun ha l dng m cc khon mc ch c lit k mt cc n gin. Mt cch tng qut, cc khon mc trng lp cng vn c bao hm. Nh trong hnh v di y, mt t hp (M sn phm, S lng, n gi) c lp li. Khon mc c gch chn l kha chnh. y M ha n l kha chnh cho chng ta bit rng khng th c s lp li M ha n. 13
Thng tin sn phm (1) M ha n M khch hng Tn khch hng M sn phm S lng n gi Thng tin sn phm (2) M sn phm S lng n gi

13 (Gi ) Khng th c 2 bn ghi m kha chnh c cng gi tr. Trong v d ca dng cha chun ha ny, khi M ha n l kha chnh th y khng c s trng lp ca M ha n

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

218

5. Cng ngh c s d liu

Dng chun 1
Dng chun 1 khng cho php s lp li cc khon mc trong bng. chuyn mt dng cha chun ha v dng chun 1, chng ta tch ring t hp (M sn phm, S lng, n gi) trong dng khng tun theo chun. Sau , thy rng c nhiu bn ghi trong (M ha n, M khch hng, Tn khch hng) u ging nhau nhng Thng tin sn phm li khc nhau, bi vy M ha n bn thn n cha th lm thnh kha chnh. Do , chng ta c th thm M sn phm to thnh cp kha chnh vi M ha n. Trong v d v dng cha chun ha trn ch c duy nht 2 nhm khon mc nh di y:
Nu c nhiu Thng tin sn phm ni dung ca nhm ny c th c lp li

y ch c th c duy nht 1 Thng tin sn phm

M ha n

M khch hng

Tn khch hng

M sn phm

S lng

n gi

Dng chun 2
Trong dng chun 1, hai khon mc M ha n v M sn phm cng nhau lm thnh kha chnh. 14 Trong cc c s d liu, tt c cc thuc tnh khng phi l kha u phi ph thuc hm vo thc th kha chnh. Tuy nhin, n gi khng c quan h vi M ha n. Khon mc n gi ch ph thuc duy nht vo M sn phm. Do chng ta c th tch ring n gi. lm c iu ny do M sn phm v n gi phi c tng ng vi nhau chng ta s dng M sn phm nh l kha chnh. Hn na, M khch hng cng c th c xc nh duy nht nu chn M ha n, do Tn khch hng l khng cn thit. Lc ny xc nh S lng, chng ta phi c M ha n v M sn phm. Cho cc gii thch tip sau, chng ta t tn cc bng mi l Bng ha n, Bng chi tit v Bng sn phm. Kt qu ca vic chia 3 bng ny gi l dng chun 2. 15
M ha n M khch hng M khch hng Tn khch hng Tn khch hng M sn phm S lng n gi M sn phm M sn phm

M ha n

M ha n

S lng

n gi

(Bng ha n)

(Bng chi tit)

(Bng phm)

sn

(Ch ) Ph thuc vo kha chnh ngha l mi khon mc c th c xc nh bi cc gi tr kha chnh. Ph thuc hm y /Ph thuc hm b phn: Trong dng chun 1, s lng c xc nh cho kha chnh M ha n + M sn phm. Nh thy v d trn, s ph thuc vo kt hp ca cc kha chnh gi l ph thuc hm y . Bn cnh , n gi ch ph thuc vo duy nht mt trong cc kha chnh ( y l m sn phm); Khi mt khon mc ph thuc vo duy nht 1 kha chnh th gi l ph thuc hm b phn. Mt dng chun 2 c th c nh ngha Dng chun 1 m trong tt c cc thuc tnh khng kha u ph thuc hm y vo kha chnh.
15

14

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

219

5. Cng ngh c s d liu

Dng chun 3
Ch rng trong dng chun 2, trong bng ha n ni ring, M ha n xc nh duy nht M khch hng. Hn na, khon mc M khch hng cng xc nh duy nht Tn khch hng. Do , nh ch ra di y, chng ta tch ring Tn khch hng v chun b mt bng mi Bng khch hng, trong M khc hng l kha chnh. y chng ta khng cn thay i g vi 2 bng Bng chi tit v Bng sn phm.

(Bng ha n)
M ha n M khch hng Tn khch hng

(Bng chi tit)


M ha n Tn khch hng M sn phm S lng

(Bng sn phm)
M sn phm n gi

M ha n

M khch hng

M khch hng

(Bng ha n)

(Bng khch hng)

Bi vy khi cc b ca dng cha chun ha c sa i thnh dng chun 3, cc d liu c chia thnh 4 b: Bng chi tit, Bng sn phm, Bng ha n v Bng khch hng. c tnh ca dng chun 3 l khng c khon mc no c lp li ngoi tr cc khon mc lm kho chnh. 16

Cc rng buc tham chiu


Nu nh khng c s mu thun gia d liu lu tr trong mt c s d liu, chng ta ni rng c s d liu nht qun (consistent). Rt nhiu iu kin nhm kim tra s ton vn ca d liu gi l rng buc ton vn (integrity constraints). Cc rng buc nht qun bao gm rng buc tham chiu (reference constraints), rng buc tn ti (existence constraints), rng buc cp nht (update constraints) v rng buc nh dng (format constraints).17 18 Rng buc tham chiu l mt rng buc lin quan n s nht qun gia cc khon mc trng lp. Nu mt bng bao gm d liu c tra cu t mt bng khc th bng khc y phi c d
Ph thuc hm bc cu: Tn khch hng dng chun 2 c th c xc nh v kha chnh M ha n xc nh M khch hng do xc nh Tn khch hng. Ni cch khc M ha n xc nh gin tip Tn khch hng. Dng xc nh gin tip ny gi l Ph thuc hm bc cu. Ni mt cch cht ch hn, mt dng chun 3 c th c nh ngha nh sau: Mt dng chun 2 trong khng c thuc tnh khng kha no ph thuc bc cu vo kha chnh. 17 (FAQ) Mt s cu hi thi a ra cc bn ghi mt dng khng chun cng nh l mt vi gi nh sau hi bn tm dng chun 3 trong mt nhm cu tr li. Nu bn lm theo cc bc nh m t trong cun sch ny c c dng chun 3 bn s tm c p n ng nhng rt mt thi gian. V th, ta nn tm dng chun 3 bng trc quan. Bn c th th nhiu cu hi thc hnh nhng bn c th xc nh c dng chun 3 bng cc c im khng c s trng lp cc khon mc tr xc khon mc kha chnh. 18 Rng buc tn ti: N c ngha l s tn ti ca mt d liu n l yu cu s tn ti ca mt vi d liu khc. V d, mt bn ghi con khng th thm vo tr khi mt bn ghi cha tn ti. Rng buc cp nht: N c ngha l mt khon mc mi phi tha mn cc iu kin a ra c th ng k hp l. V d, gi tr 6 khng th ng k nu gi tr phi nm trong khong t 1 n 5. Rng buc nh dng: N c ngha l mt khon mc phi c mt nh dng tha mn cc iu kin a ra. V d, vn bn khng th ng k trong mt khon mc yu cu gi tr s. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng -16

220

5. Cng ngh c s d liu

liu ng k tham chiu nng cao. V d, trong dng 3 gii thch trn, ng k Bng ha n, trong Bng khch hng thng tin v vic m khch hng cn tng thch vi m khch hng trong Bng ha n nht thit phi c ng k. y, M khch hng trong Bng ha n l mt kha ngoi ca Bng Khch hng. (Bng ha n)
M ha n M khch hng
Tham chiu

(M khch hng trong Bng ha n l mt kha ngoi ca Bng Khch hng)

M khch hng

Tn khch hng

(Bng khch hng)

5.1.5 Thao tc d liu trong c s d liu quan h


im chnh
Thao tc d liu bao gm cc php ton quan h v cc php ton tp hp Cc php ton quan h gm cc php chn, chiu v kt ni

Trong rt nhiu loi cc php ton trn c s d liu quan h th cc php ton quan h v cc php ton tp hp l quan trng nht. Trong mt c s d liu quan h mt bng, mt hng v mt ct u c i x nh nhng tp hp c th trch rt ra cc gi tr. Cc qu trnh trch rt ra cc gi tr ny bao gm s thao tc nh chn, chiu v kt ni. Chng c gi l cc php ton quan h. Trong khi , c nhiu nhng php ton khc nh 2 bng trong c s d liu quan h c s dng to thnh 1 bng mi gi l cc php ton tp hp. Cc php ton tp hp bao gm php hp, giao v tr.

Cc php ton quan h


ngha ca cc php ton quan h c lit k trong bng di y. Rt nhiu d liu c trch rt bng cch kt hp cc php ton c bn. Php ton Chn Chiu Kt ni Chc nng Chn ra cc hng tha mn iu kin no Rt ra mt s ct c bit (cc thuc tnh) Lin kt cc bng c cc ct tng ng

Php chiu rt ra mt ct c bit no . V d trong hnh v di y, ch Phng ban c rt ra. Php chn chn ra mt s hng no , v d mi hng m Tui l 23 u c chn. Php kt ni lin kt cc ct tng ng, v d 2 bng c kt ni bi Tn 19 20
19 (Gi ) Cc kt qu ca cc php ton quan h v tp hp c biu din nh cc bng mi nhng khng tht s lu tr trong c s d liu. N n gin lu tr trong vng lm vic nh nhng kt qu tc thi. 20 (FAQ) Rt nhiu cc cu hi thi bao hm ngha ca cc php ton quan h. Chc chn rng bn bit php chn ly ra cc hng v php chiu ly ra cc ct. Chc chn rng bn bit php kt ni l mt php ton kt hp nhiu bng.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

221

5. Cng ngh c s d liu

Tn
Tommy Michael Billy

Phng ban Tui Chiu bi ct


General affairs Development Research 23 25 23

Phng ban

Phng ban
General affairs Development Research

Tn
Yamada Michael Billy

Phng ban
General affairs Development Research

Tn
Tommy Michael Billy

Tui
23 25 23

Tn
Tommy Billy

Chn bi Tui = 23 Phng ban Tui


General affairs Research 23 23

Kt ni bi Tn

Tn
Tommy Michael Billy

Phng ban Tui


General affairs Development Research 23 25 23

Php chn cng c th chn ra nhiu ct khc nhau.

Cc php ton tp hp
Cc php ton tp hp c da trn l thuyt tp hp. Bao gm: Php ton Hp Giao Tr
21

Chc nng Chn ra cc hng nm trong t nht 1 trong 2 bng Chn ra cc hng m ch cc gi tr nh nhau tt c cc bng Chn ra cc hng nm trong bng ny nhng khng nm trong bng khc

V d, php hp chn cc hng xut hin trong Bng A hoc Bng B; ch rng Billy xut hin trong c 2 bng nn n ch c chn duy nht 1 ln. Php giao chn ly cc hng m xut hin trong cc Bng A v Bng B. Trong trng hp ny, ch Billy c chn. Th t ca cc php ton khng thnh vn trong cc php hp v giao, nhng vi php tr th t li l vn . Cc th t khc nhau s a n cc kt qu khc nhau. A B a ra cc hng nm trong A nhng khng nm trong B. y, Billy b b qua nhng Susan v Henry c chn. Ngc li, B A a ra cc hng nm trong B nhng khng nm trong A, v th Billy li mt ln na b b qua, kt qu tr v l John v Nancy c chn.
[Bng A]
Tn Susan Henry Billy Phng ban General affairs Development Research Tn Billy John Nancy Phng ban Research Sales Accounting

[Bng B]

Hp
Tn Susan Henry Billy John Nancy Phng ban General affairs Development Research Sales Accounting

Giao
Tn Billy Phng ban Research

Tr (A - B)
Tn Susan Henry Phng ban General affairs Development

Tr (B - A)
Tn John Nancy Phng ban Sales Accounting

21 Sp xp/ 4 php ton c bn: Mt c s d liu quan h khng ch c cc php ton quan h v tp hp m c c cc php ton sp xp v 4 php ton c bn. Sp xp l hm sp xp d liu tng hoc gim dn theo mt ct no . 4 php ton c bn p dng cho cc thuc tnh s v ly kt qu bng vic thao tc cc biu thc ton hc (4 php c bn). V d, c th ly kt qu ca vic nhn gi tr ca mt ct no vi 10.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

222

5. Cng ngh c s d liu

Cu hi nhanh
Q1 Q2 Q3 Q4 A1 Lit k lc 3 lp v gii thch vai tr ca tng lc . Lit k cc m hnh d liu logic v gii thch ngn gn c im ca tng loi. M t cc c im ca dng chun 1, 2 v 3. Lit k cc loi php ton quan h v gii thch cch thc hin ca tng loi. Lc ngoi:

nh ngha ci nhn c s d liu t chng trnh hoc ngi dng. N s dng mt phn ca lc khi nim. Trong cc c s d liu quan h, y gi l mt khung nhn; trong cc c s d liu mng, gi l lc con. N tn ti cho mi chng trnh v ngi s dng.

Lc khi nim: y l d liu c cha trong c s d liu, nh ngha da theo m hnh d liu; mt nh ngha ca d liu thc ni chung. N c gi l bng trong c s d liu quan h v lc trong c s d liu mng Lc trong: y l nh ngha vic thu c mt lc khi nim cho s lu tr ngoi. N bao gm cc thng tin nh l ti thiu, cc phng php t chc v di b m.

A2

M hnh phn cp: Mi lin h gia cc cha v con l 1:n. M hnh mng: Mi lin h gia cha v con l m:n. M hnh quan h: C dng bng Dng chun 1: Dng chun 2: Dng chun 3: Cc trng lp c loi b. dng chun 1 v cc ph thuc hm b phn c loi b dng chun 2 v cc ph thuc hm bc cu c loi b Chn ra cc ct no (cc thuc tnh) Chn ra cc hng tha mn iu kin no Lin kt nhiu bng c cc ct tng ng

A3

A4

Php chiu: Php chn: Kt ni:

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

223

5. Cng ngh c s d liu

5.2 Cc ngn ng c s d liu


M u
Mt ngn ng c s d liu l mt ngn ng dng nh ngha, xa cc c s d liu, cc bng, ng thi tm kim v cp nht d liu.

5.2.1 DDL v DML


im chnh
Cc ngn ng c s d liu bao gm DDL v DML. SQL l mt ngn ng c s d liu dng cho c s d liu quan h.

Mt ngn ng dng nh ngha v t chc cc c s d liu gi l mt ngn ng nh ngha d liu (data definition language - DDL) trong khi mt ngn ng dng tm kim, cp nht, thm, xa d liu gi l mt ngn ng thao tc d liu (data manipulation language - DML). Tng qut, ngi qun tr c s d liu s dng DLL chun b c s d liu trong khi ngi lp trnh vin h thng li s dng DML pht trin cc h thng s dng c s d liu. Cc ngn ng c s d liu c trng bao gm: SQL dng cho c s d liu quan h v NDL22 dng cho cc c s d liu mng.

DDL (Ngn ng nh ngha d liu)


DDL l mt ngn ng h thng dng nh ngha cc lc da trn m hnh d liu. Chng c quy nh l SQL-DDL cho cc c s d liu quan h.

DML (Ngn ng thao tc d liu)


DML l mt ngn ng h thng dng cc thao tc cc c s d liu dnh cho cc ngi dng. Chng c quy nh l SQL-DML cho cc c s d liu quan h. Da theo cch s dng, cc DML c phn lp nh di y:

22 NDL (Ngn ng c s d liu mng): y l ngn ng c s d liu cho cc c s d liu mng, s dng nh ngha lc v thao tc cc c s d liu. NDL bao gm cc chc nng sau: ngn ng nh ngha lc nh ngha cu trc ca c s d liu; ngn ng nh ngha lc con nh ngha cc khung nhn; ngn ng thao tc d liu thao tc d liu trong c s d liu v ngn ng m-un thc thi cc th tc t nhiu ngn ng thao tc d liu.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

224

5. Cng ngh c s d liu

Ngn ng c lp
DML

Trc tip dng DML trong ch hi thoi Ngn ng m-un Cho cc th tc con23 Nhng vo cc chng trnh

Ngn ng ch Ngn ng nhng

Ngn ng c lp y ta cp n mt h thng cung cp mt ngn ng lp trnh khc vi cc ngn ng thng thng sao cho cc hm cung cp bi h thng qun l d liu c th c s dng trong phm vi ca cc hm trong ngn ng m n cung cp. N s dng SQL v NDL di dng i thoi nh nhng cu lnh. Ngn ng ch y cp n mt h thng thao tc d liu DML c nhng vo trong chng trnh vit bng ngn ng cp cao hn nh COBOL, Fortran, v C. Cc ngn ng cp cao hn gi l cc ngn ng ch. Cc phng php nhng DML vo trong mt chng trnh bao gm h thng ngn ng m-un v h thng nhng. Trong h thng ngn ng m-un, chng ta c th pht trin mt th tc con m to thnh cc phn thao tc c s d liu ca chng trnh, v chng trnh gi th tc con bng mt lnh gi. Khng ging nh th, ngn ng con nhng (embedded sublanguage) l ni DML c vit trc tip trong chng trnh.

Hm con tr
Hm con tr (cursor function) c s dng khi x l cc hng (cc bn ghi) ca mt c s d liu s dng mt ngn ng th tc. N xem kt qu truy vn (bng thu c) bi DML nh mt tp sao cho c th x l bng mt ngn ng lp trnh. Vi hm con tr, cc tp s dng bi chng trnh hin ti c th chuyn sang c s d liu d dng. Trong SQL, c cc cu lnh thao tc sau. 24 Cu lnh thao tc DECLARE CURSOR OPEN CURSOR FETCH CLOSE CURSOR ngha Khai bo ca hm con tr Bt u hot ng ca con tr c mt hng Kt thc hot ng ca con tr

23 Ngn ng m-un: L ngn ng dng vit trong mt ngn ng thao tc d liu; n x l cc c s d liu khi c gi t mt ngn ng cp cao hn chng hn nh COBOL. 24 (Ch ) Trong DECLARE CURSOR, tn con tr c nh ngha. Tip theo DECLARE CURSOR, mt cu lnh SELECT c vit (l mt cu truy vn vit bng DML). Th tc ny a ra mt bng kt qu. Sau , bng lnh FETCH, bng bt u c c t hng u tin.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

225

5. Cng ngh c s d liu

5.2.2 SQL
im chnh
Cu lnh dng trch rt d liu l SELECT. Trong cc cu truy vn con lm r SELECT bng cch s dng mt mnh WHERE

y chng ta xem xt mt cch chi tit SQL ngn ng c s d liu cho cc c s d liu quan h. Trong SQL, cc cu lnh SELECT dng trch rt d liu t mt c s d liu.

Cu trc ca cu lnh SELECT


Cu trc mt cu lnh SELECT nh sau: SELECT FROM WHERE
25

khon mc 1, khon mc 2, bng 1, bng 2, iu kin

Php chiu v php chn


Di y l mt v d ch ra kt qu ca vic trch rt d liu bng cc php chiu v php chn s dng mt cu lnh SELECT trong bng Nhn vin. Nu theo sau SELECT l * tt c cc hng trong bng u s c chn. Chng ta cng c th kt hp php chn v php chiu.

[Bng] NhanVien
Ten Jimmy Frank Billy Harry Josh Randy Steve PhongBan Sales Human Resources Sales Sales General Affairs Human Resources Sales QuocTich Japan USA France Italy Germany USA UK Tuoi 28 22 35 43 48 36 31 Ten Billy Harry Josh SELECT Ten, PhongBan FROM NhanVien WHERE Age>=35 Randy PhongBan Sales Sales General Affairs Human Resources Ten Billy Harry Josh Randy PhongBan Sales Sales General Affairs Human Resources QuocTich France Italy Germany USA Tuoi 35 43 48 36 SELECT * FROM NhanVien WHERE Tuoi >=35 Php chn (Chn ra cc hng c tui >=35) SELECT Ten, PhongBan FROM NhanVien Ten Jimmy Frank Billy Harry Josh Randy Steve PhongBan Sales Human Resources Sales Sales General Affairs Human Resources Sales Php chiu (chn ra tn v phng ban)

Chn v chiu

25 (Gi ) Trong mt cu lnh SELECT, mnh WHERE c th c b qua. Nu b qua, iu kin ly d liu l khng c nn tt c cc khon mc c yu cu trong SELECT u c chn.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

226

5. Cng ngh c s d liu

Kt ni
Vi cu lnh SELECT chng ta c th kt ni cc bng thng qua cc ct c bit no . Di y l mt v d v vic kt ni bng Nhn vin v bng Phng ban. Khng th c cc ct trng tn trong mt bng nhng nu c cc ct tn ging nhau trong cc bng khc nhau th chng c th phn bit bng cch dng dng TnBng.TnCt. NhanVien.PhongBan=PhongBan.PhongBan l kha kt ni 2 bng ny.

[Bng] NhanVien
Ten Jimmy Frank Billy Harry Josh Randy Steve Phong Sales Human Resources Sales Sales General Affairs Human Resources Sales QuocTich Japan USA France Italy Germany USA UK Tuoi 28 22 35 43 48 36 31

[Bang] PhongBan
Phong Human Resources General Affairs Sales TruongPhong Randy Josh Harry

SELECT Ten, NhanVien.PhongBan, QuocTich, Tuoi, TruongPhong, ViTri Headquarters FROM NhanVien, PhongBan Headquarters WHERE NhanVien.PhongBan ViTri Branch office =PhongBan.PhongBan26

Ten Jimmy Frank Billy Harry Josh Randy Steve

Phong Sales Human Resources Sales Sales General Affairs Human Resources Sales

QuocTich Japan USA France Italy Germany USA UK

Tuoi 28 22 35 43 48 36 31

TruongPhong Harry Randy Harry Harry Harry Randy Harry

ViTri Branch office Headquarters Branch office Branch office Headquarters Headquarters Branch office

IN v BETWEEN
Trong mnh WHERE chng ta c th kt hp nhiu iu kin vi AND v OR. IN ch ra mt iu kin OR trong khi BETWEEN ch ra mt iu kin AND. chn t bng NhanVien tn ca nhng ngi c Tuoi l 22, 28 v 35 c 2 phng php nh di y. C 2 phng php u a ra nhng kt qu ging nhau. SELECT Ten FROM NhanVien WHERE Tuoi IN (22, 28, 35) SELECT Ten FROM NhanVien WHERE Tuoi = 22 OR Tuoi = 28 OR Tuoi= 35

26 (Ch ) Nu cc ct c cng tn, cc bin s c s dng theo cch ch ra di y. y, bin X c gn n bng NhanVien, bin Y gn n bng PhongBan. SELECT Ten, X.Phong, QueQuan, TruongPhong, DiaDiem FROM NhanVien X, PhongBan Y WHERE X.Phong = Y.Phong

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

227

5. Cng ngh c s d liu

chn t bng NhanVien tn ca nhng ngi c Tuoi t 22 n 28 cng c 2 phng php nh di y. C 2 phng php u a ra nhng kt qu ging nhau. SELECT Ten FROM NhanVien WHERE Tuoi BETWEEN (22, 28) SELECT Ten FROM NhanVien WHERE Tuoi >=22 AND Tuoi<=28

ORDERED BY
ORDERED BY c dng chn ra cc d liu v sp xp chng theo th t tng dn hay gim dn theo mt ct no . Sau y l mt v d trong tn c sp xp t bng NhanVien theo th t tng dn v gim dn. ASC dng cho th t tng dn v c th b qua khng cn ghi. i vi th t gim dn dng DEST. SELECT Ten FROM NhanVien ORDERED BY Ten ASC SELECT Ten FROM NhanVien ORDERED BY Ten DESC27

Cc hm tp hp v GROUP BY
Trong bng BanHang di y, chng ta xem xt mt v d ca cu lnh SQL tm ra tng s lng bn hng trong cc hng m c cng mt MaSanPham. tnh tng khi lng s dng hm tp hp SUM. Hm GROUP BY hp nht tt c cc hng c cng gi tr trong 1 ct no . y , chng ta hp nht d liu bi MaSanPham. 28

[Bng] BanHang
MaSan Pham

KhoiLu ongBan

G01 G02 G03 G04

100 50 200 100

SELECT MaSanPham, SUM(KhoiLuongBan) FROM BanHang GROUP BY TenSanPham

MaSanP ham

KhoiLu ongBan

G01 G02

300 150

Tng G01 Tng G02

(Gi ) Cc tn ct trong ORDERED BY hoc GROUP BY phi c cha trong ct c tn ch ra bi SELECT. y l mt yu cu c php ca SQL. 28 Hm tp hp: y l hm ca phn mm c s d liu. N c th tm rt nhiu d liu nh tng cng v gi tr ln nht cho mt ct no . Cc hm tp hp nh: SUM (tng cng), MAX (gi tr ln nht), MIN (gi tr nh nht), AVG (gi tr trung bnh), and COUNT (s lng).

27

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

228

5. Cng ngh c s d liu

Cc truy vn con
Chng ta c th to mt cu truy vn trn mt bng v sau s dng kt qu ca cu truy vn to ra cc cu truy vn khc. Cu truy vn u tin gi l truy vn con, c thc thi bng cch dng IN. [Bang]DatHang
MaDatHang MaKhachHang

[Table]ChiTietDatHang
MaDatHang MaSanPham

[Table]SanPham
MaSanPham LoaiSanPham

100 101 102

A100 B200 C300

100 100 100 100 100 101

301 302 301 401 402 301

301 302 401 402

television television VCR VCR

Trc tin chng ta m t phng php khng dng truy vn con. Cu lnh SQL a ra LoaiSanPham ca sn phm c t hng bi khch hng c m A100 t bng DatHang, ChiTietDatHang v SanPham nh sau: 29 SELECT LoaiSanPham FROM DatHang, ChiTietDatHang, SanPham WHERE MaKhachHang = 'A100' AND DatHang.MaDatHang = ChiTietDatHang.MaDatHang AND ChiTietDatHang.MaSanPham = SanPham. MaSanPham y MaDatHang 100 t bi MaKhachHang A100 trong bng DatHang c kt ni vi MaDatHang ca bng ChiTietDatHang. Kt qu l 5 dng u tin trong bng ChiTietDatHang vi MaSanPham 301, 302, 301, 401, v 402 c tr v. Hn na, vi vic kt ni vi trng MaSanPham ca bng SanPham th LoaiSanPham cng c tr v. Tip theo chng ta s dng dng cu truy vn con vi IN. SELECT LoaiSanPham FROM SanPham WHERE SanPham. MaSanPham IN(SELECT ChiTietDatHang.MaSanPham FROM DatHang, ChiTietDatHang WHERE MaKhachHang = 'A100' AND DatHang.MaDatHang = ChiTietDatHang.MaDatHang ) Nh thy trn, chng ta c th to ra 1 cu truy vn v s dng kt qu ca cu truy vn to ra mt cu truy vn khc. 30 Cu truy vn c cha trong IN c gi l cu truy vn con. Cu lnh SELECT trong cu truy vn con c thc thi u tin v kt qu nhn c ChiTietDatHang.MaSanPham s kt ni vi SanPham.MaSanPham . y, cc m sn phm thu c bi IN l 301, 302, 301, 401, v 402, nhng 301 lp li nn s trng lp c b qua. Bi vy thu c 4 dng 301, 302, 401, v 402. 31
(Ch ) i khi EXITST c s dng trong cc cu truy vn con. IN v EXIST l cc hm khc nhau nhng cc kt qu thc thi hu ht ging nhau. 30 (Ch ) Chng ta c th vit NOT trc IN. Trong trng hp ny NOT IN (cu truy vn con) a ra ph nh kt qu ca truy vn con. 31 (FAQ) Mi k thi thng c nhiu cu hi v trch rt d liu t cu SELECT trong SQL. Cn thng tho cch s dng ca SELECT. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng -29

229

5. Cng ngh c s d liu

Hn na, cc trng lp c th c loi b. Nh ch ra di y, ta c th loi b cc loi sn phm trng lp bng cch dng DISTINCT trc loi sn phm. Television v VCR b lp li nn mi loi ny c loi b cc phn trng lp v ch xut hin 1 ln trong kt qu tr v. 32 SELECT DISTINCT LoaiSanPham FROM SanPham WHERE SanPham. MaSanPham IN(SELECT ChiTietDatHang.MaSanPham FROM DatHang, ChiTietDatHang WHERE MaKhachHang = 'A100' AND DatHang.MaDatHang = ChiTietDatHang.MaDatHang ) Bng di y s m t r hn kt qu: [Bng] ChiTietDatHang
MaDatHang MaSanPham

(JOIN)
MaSanPham

(IN)
LoaiSanPham

(DISTINCT)
LoaiSanPham

100 100 100 100 100 101

301 302 301 401 402 301

television television television VCR VCR

television television VCR VCR

television VCR

32 (Gi ) Ch rng s lng kt qu trch chn d liu thay i theo iu kin ca WHERE. IN cng ging nh iu kin OR v th cc gi tr ging nhau c loi b. DISTINCT cng loi b cc gi tr ging nhau nhng n c a ra ngay trc tn ct trong SELECT.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

230

5. Cng ngh c s d liu

Cu hi
Q1 Q2 Q3

nhanh

Gii thch vai tr ca DDL v DML

Gii thch hm con tr.


Cho bit kt qu tr v t bng BangDanhSachSinhVien sau khi thc hin cu truy vn sau: SELECT Ten FROM BangDanhSachSinhVien WHERE ChuyenNganh = 'Physics' AND Tuoi < 20 [Table] BangDanhSachSinhVien Ten ChuyenNganh Paul Newman Physics John Wayne Chemistry Tom Hanks Biology Robert Redford Physics Clint Eastwood Mathematics Tuoi 22 20 18 19 19

A1

DDL: Ngn ng nh ngha d liu: Mt ngn ng h thng s dng nh ngha cc lc da trn m hnh d liu. DML: Ngn ng thao tc d liu: Mt ngn ng h thng dng thao tc cc c s d liu c s dng bi ngi dng.

A2

y l hm s dng khi x l cc hng (bn ghi) ca mt c s d liu s dng mt ngn ng lp trnh. Khi cc kt qu truy vn ca DML bao gm nhiu hng, ta c th c tng hng mt ging nh x l cc tp vi ngn ng lp trnh. Xem xt cu lnh SQL chng ta thy ngha ca n l Ly t danh sch sinh vin tn ca cc sinh vin c chuyn ngnh l physics v c tui <20. Do vy, kt qu tr v l Robert Redford.

A3

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

231

5. Cng ngh c s d liu

5.3 Kim sot c s d liu


M u
chc chn tnh tin cy ca d liu rt nhiu cc iu khin c p dng vi mt h thng c s d liu. Trong mt c s d liu phn tn, iu ny l rt quan trng duy tr tnh nht qun.

5.3.1 Cc chc nng kim sot c s d liu


im chnh
iu khin truy cp dnh ring c a ra nhm duy tr tnh nht qun d liu. Cc phng php phc hi li bao gm quay lui (roll-back) v quay tin (roll-forward).

Cc chc nng iu khin c s d liu bao gm cc chc nng iu khin truy cp v qun l chia s ti nguyn. ng thi chng cng h tr vic phc hi d liu khi gp li.

iu khin truy cp
Ni chung, vi vic qun l truy cp nhm duy tr tnh ton vn ca mt c s d liu ta s dng iu khin truy cp dnh ring (exclusive access control) 33 iu khin truy cp dnh ring ngn chn vic nhiu ngi dng truy cp cng mt d liu ti cng mt thi im. Qua iu khin ny, nhiu ngi dng c th s dng cng mt c s d liu m khng gy ra cc xung t. Tuy nhin, nu tt c cc giao dch (transactions) 34 ch l c lin quan vi nhau, iu khin truy cp dnh ring l khng cn thit. Trong mt s trng hp, iu khin truy cp dnh ring c th gy ra mt kha cht (deadlock). Mt kha cht l tnh trng trong 2 giao dch u ang trong tnh trng ch trng thi kia gii phng. Hnh v mnh ha cho kha cht nh di y. 35 Giao dch A Kha X Ch Y D liu X D liu Y Giao dch B Kha Y Ch X

iu khin truy cp dnh ring: Phong ta mt vng ca c s d liu khi n c cp nht bi mt giao dch sao cho cc giao dch khc b ngn cm truy cp trn vng c s d liu y. 34 Giao dch: L mt n v x l d liu c chuyn t thit b u cui n my ch. N cng c gi l mt thng ip. 35 (Ch )Nu mi giao dch phong ta tt c cc ngun ti nguyn cn thit ti thi im n bt u x l v khng gii phng chng trong sut thi gian x l th c th trnh c mt kha cht. Hoc nu mi giao dch c mt th t khc nhau ca vic phong ta, kha cht cng c th trnh. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

33

232

5. Cng ngh c s d liu

Qun l chia s ti nguyn


C nhiu ngi dng truy cp c s d liu thng qua cc ng dng. y vic chnh sa, cp nht d liu cn c hon thnh bi ch 1 ng dng. V l do ny chc nng qun l giao dch (transaction management function) c gii thiu. Chc nng qun l giao dch nhm duy tr tnh nht qun d liu, trnh cc xung t bng cch chia d liu thnh cc n v giao dch sao cho c s d liu c th iu khin c vic cp nht t cc ngi dng khc nhau. N bao gm cc c im ACID (ACID characteristics).36 Tn A C I D Gii thch Khng c giai on trung gian on cui ca qu trnh x l. Hoc tt c cc x l u c hon thnh hoc khng c g c thc hin c. Nht qun Khng quan tm n iu kin hon thnh mt giao dch, cc ni dung (Consistency) ca mt c s d liu khng th c nhng mu thun. Cc kt qu x l khng th khc bit d cc giao dch c s l C lp ng thi hay tun t (Isolation) Bn vng Cc kt qu khng b ph hng bi li v cc nhn t khc khi cc giao dch kt thc. (Durability) Nguyn t (Atomicity)

Qun l phc hi
C nhiu phng php qun l phc hi, ph thuc vo tnh trng li ca c s d liu. Loi li Phng php phc Gii thch hi Li h Khi ng li Mt li h thng nh cc li vt l h thng (1) Quay li thi im khi m d liu c sao lu37 thng (2) Ghi li mt cch tun t s dng cc thng tin cp nht (post-update) trong nht k. 38 lui Li logic ca cc thc thi dn n chng trnh b li Li giao Quay (Roll-back) (1) Ch quay lui li cc thng tin li s dng cc thng tin trc cp dch nht trong nht k (2) Ti thc hin li giao dch Li mi Quay tin Vn vi i tng trung gian nh a t trng (Roll-forward) (1)Thay th i tng (2) Quay li thi im d liu c sao lu (3) Thc hin li tun t theo cc thng tin trc cp nht trong file nht k.
36 (FAQ) C nhiu cu hi thi v ngha v s cn thit ca iu khin truy cp dnh ring. Nh rng iu khin truy cp dnh ring l mt hm ngn cm truy cp vo cng 1 v tr (bn ghi) ti cng mt thi im. Cng phi hiu rng iu khin truy cp dnh ring c a ra nhm duy tr tnh ton vn d liu. 37 Back up: Sao lu: L s nhn i cc ni dung ca mt c s d liu vo trong mt i tng trung gian nh a t. Vic sao chp c thc hin ti nhng khong thi gian nh k. Thng thng cc ni dung sao chp l nhng d liu ngay trc khi ng hoc cc gi tr ngay trc khi tt ca mt h thng online. Nu mt h thng c thc thi 24h mt ngy, vic sao lu c thc thi khi cc giao dch l t nht chng hn nh na m. 38 File nht k: L bn ghi d liu trong cc iu kin ca c s d liu trc v sau cp nht c ghi li mi khi cc ni dung ca c s d liu c cp nht. Trong mt s h thng ch cc ni dung trc cp nht mi c ghi li.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

233

5. Cng ngh c s d liu

5.3.2 Cc c s d liu phn tn


im chnh
y thc 2 pha l cng ngh duy tr tnh ton vn ca mt c s d liu phn tn Nhn bn l cng ngh nng cao trnh din p ng ca mt c s d liu phn tn

C s d liu phn tn l cng ngh ly nhiu c s d liu khc nhau trn nhiu my tnh kt ni vi mt mng v khin cho chng xut hin nh mt c s d liu n nht. Do ngi dng khng nht thit phi bit c my tnh no thc s c d liu ngi cn.

y thc 2 pha
y thc 2 pha (Two-phase commitment) l c ch nhm m bo tnh ton vn ca mt c s d liu phn tn v rt quan trng khi cp nht c s d liu.39 y thc 2 pha c 2 pha khc nhau. Trong pha th 1, thnh vin yu cu s ng b ha to ra mt yu cu n tt c cc thnh vin khc v s m bo cho lnh cp nht. Ti thi im ny, tt c cc thnh vin u m bo.40 Sau mi thnh vin tr v hoc y thc (COMMIT) hoc quay lui (ROLLBACK) 41 cho thnh vin yu cu ng b ha. Trong pha th 2, thnh vin yu cu s ng b ha xem xt s phn hi t mi thnh vin v quyt nh COMMIT hay ROLLBACK. c bit, thnh vin yu cu s la chn ROLLBACK khi thm ch ch c mt thnh vin tr v ROLLBACK. Hnh v trong trang bn ch ra mt tin trnh x l trong cc trng hp thng thng. Chng ta s dng hnh v ny gii thch s y thc 2 pha. ACK trong hnh v l thng ip phn hi ch ra s hon thnh mt cch bnh thng. Site A v Site B l cc v tr t c s d liu phn tn. My ch l my tnh iu khin c s d liu phn tn ny. Khi c s d liu c cp nht, my ch chuyn mt lnh cp nht (1) n mi site. Mi site s tin hnh cp nht tm thi c s d liu. y l mt iu kin cho bit ti u c s d liu c th tin hnh cp nht ti bt c thi im no, nhng c s d liu cha tin hnh cp nht mt cch vt l. Hn na, mi site t n chun b cho vic cp nht v xa b ti bt c thi im no khi m n nhn c lnh m bo (2) t my ch. y l pha th 1. Nu c site no c vn trong pha ny vic cp nht s b hy b ti mi site. Bc tip theo, sau khi chc chn rng cc pha sn sng cho vic cp nht (ACK), my ch chuyn mt lnh y thc (3) cho tt c cc site mt cch tun t. Site A vi vic nhn c lnh y thc tin hnh cp nht tht s v thng bo s hon thnh bnh thng ca x l cho my ch (ACK). My ch sau chuyn lnh y thc sang site B. Tng t nh vy site B cng tin hnh vic cp nht tht s v thng bo s hon thnh bnh thng ca x l cho my ch (ACK). Sai my ch sau s xc nhn vic ton b c s d liu c cp nht tht s (4). y l pha th 2. 42
39

y thc: C ngha l kt thc mt cp nht c s d liu. Ch sau n, kt qu s l mi c lu gi. Khi mt ng dng thc thi mt lnh COMMIT, vic cp nht mi kt thc. 40 Tnh trng m bo: L tnh trng m c th hon tt mt x l hoc quay li tnh trng trc. 41 Quay lui: Dng x l v tr v cc thng tin lin quan n thi im trc x l. iu ny din ra khi c mt vi s c xy ra trong x l giao dch gy ra vic x l khng th hon tt mt cch bnh thng. Quay lui c th c thc hin vi h qun tr c s d liu nhng cng c th c thc thi bi lnh ROLLBACK qua mt ng dng. 42 (FAQ) Nhiu cu hi thi lin quan n li c s d liu vi quay lui (roll-back) v quay tin (roll-forward). Bn chc chn s gii quyt c nu bn hiu ngha ca quay lui v quay tin. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

234

5. Cng ngh c s d liu

Site A Pha 1 Cp nht tm thi

My ch

Site B

(1) Lnh cp nht

Cp nht tm thi

m bo

(2) Lnh m bo ACK Pha 2

m bo ACK

y thc
Cp nht tht s

(3) Lnh y thc


y thc
Cp nht tht s

ACK (4) Hon thnh cp nht tht s

ACK

Nhn bn
Nhn bn l c ch t ng tng ng cc ni dung c cp nht cho cc bn sao ca c s d liu trn mng. Mc ch ca vic nhn bn l nng cao s p ng ca qu trnh truy cp d liu trong mt mi trng c s d liu phn tn. Cc bn sao ca d liu ch c t trn cc my ch khc trn mng, khi d liu c cp nht s thay i s t ng c nh x n cc bn sao. Tuy nhin vic cp nht ca cc bn sao khng c tin hnh ng b cng vi d liu ch. Ni chung, vic cp nht c th ch c tin hnh trn my ch v cc bn sao ch c nh x nhm m bo s ton vn d liu.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

235

5. Cng ngh c s d liu

Cu hi nhanh
Q1 Q2 Q3 Q4 Gii thch vai tr ca DDL v DML. Gii thch cc c im ACID. Lit k nhng th cn thit khi phc li khi mt c s d liu gp li v li giao dch. Phng php phc hi gi l g? Gii thch y thc 2 pha.

A1 A2

DDL: Ngn ng nh ngha d liu DML: Ngn ng thao tc d liu Cc c tnh ACID l khi nim ca vic duy tr tnh nht qun d liu. Thut ng ACID l vit tt cho Nguyn t (Atomicity), Nht qun (Consistency), C lp (Isolation), v Bn vng (Durability). Cn c thng tin trc cp nht trong tp nht k. gi l phng php quay lui (rollback).

A3 A4

y l mt c ch m bo tnh ton vn ca mt c s d liu phn tn. Pha u l pha m thnh vin yu cu ng b ha to mt yu cu n cc thnh vin thc thi xin mt x l cp nht. Pha th 2 l pha m thnh vin c yu cu ng b cn nhc cc phn hi t mi thnh vin v quyt nh xem y thc (commit) hay quay lui (rollback).

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

236

5. Cng ngh c s d liu

Cu hi 1
Q1.

kh: *

Tn sut: ***

Trong s cc php ton sau y php ton no ly ra vi ct c bit no t cc bng trong 1 c s d liu quan h? a) Php kt ni b) Php chiu c) Php chn d) Php hp

p n cu 1
p n ng: b
Cc thao tc vi mt c s d liu quan h gm cc loi sau: Cc loi php ton Cc php Chn ton Chiu quan h Kt ni Cc php Hp ton tp hp Giao Tr Contents of operation Chn ra cc hng tha mn cc iu kin no Chn ra cc ct tha mn mt iu kin no Kt ni cc bng bng cc ct c cng gi tr Chn ra cc hng nm trong t nht mt bng (cc hng trng lp ch c tnh 1 ln) Chn ra cc hng nm trong tt c cc bng Chn ra tt c cc hng nm trong 1 bng v khng nm trong bng khc

Hot ng ca cc php ton quan h ch ra di y:


M Sn phm M t hng bi Company A Company B Company C Company D Company E t hng bi Company A Company B Company C Company D Company E

Chn

010 011 020 025 030

PC unit Display Printer Keyboard Modem

010 011 020 025 030

Chiu

Chn ra mt s hng no

Kt ni Chn mt s ct no (Kt ni bi m)
Sn phm M Sn phm t hng bi Company A Company B Company C Company D Company E

010 020 030

PC unit Printer Modem

010 011 020 025 030

PC unit Display Printer Keyboard Modem

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

237

5. Cng ngh c s d liu

Cu hi 2
Q2.

kh: **

Tn sut: ***

Hy cho bit u l dng chun 3 ca bng KyNang cha cc thng tin v k nng nhn vin? y cc trng gch chn l cc kha chnh.
KyNang(NhanVienID, Ten, {MaKyNang, TenKyNang, SoNamKinhNghiem}) Ch rng, cp ngoc { v } cho bit s lp li. a)

NhanVienID Ten

MaKyNang MaKyNang

TenKyNang

SoNamKinhNghiem

b) NhanVienID Ten MaKyNang c) TenKyNang

SoNamKinhNghiem

NhanVienID MaKyNang NhanVienID Ten MaKyNang TenKyNang

SoNamKinhNghiem

d) NhanVienID MaKyNang NhanVienID Ten MaKyNang TenKyNang SoNamKinhNghiem

p n cu 2
p n ng: c
Bng thng tin k nng khng i km cc li gii thch nhng chng ta cn xem xt d on kha chnh. y c th cho rng kha chnh l m nhn vin (NhanVienID). T cc phn b lp li ca bng thng tin k nng ta c th thy mi m nhn vin c th ng vi nhiu m k nng. iu ni ln rng mi nhn vin c th c nhiu k nng. Do s nm kinh nghim khng th xc nh c tr khi 2 trng (m nhn vin v m k nng) bit. Chng ta c th thy rng mt nhn vin khng th c cng mt m k nng nhiu hn mt ln. Mt khc nh gii thch pha sau th m k nng khng th t mnh lm kha chnh. u tin, loi b s lp li ca MaKyNang, TenKyNang, SoNamKinhNghiem trong bng. D liu sau c chia thnh nhiu bn ghi khc nhau, tuy nhin nu nhn vin ID t mnh lm kha chnh th s trng lp c th xy ra. Do chng ta cn phi kt hp nhn vin ID v m k nng lm thnh kha chnh. y l dng chun 1. KyNang(NhanVienID, Ten, {MaKyNang, TenKyNang, SoNamKinhNghiem}) KyNang (NhanVienID, Ten, MaKyNang , TenKyNang, SoNamKinhNghiem )

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

238

5. Cng ngh c s d liu

Tip theo, ch rng tn (Ten) ch ph thuc hm vo ring trng nhn vin ID (ph thuc hm b phn vo kha chnh), tn k nng ch ph thuc hm vo ring trng m k nng (ph thuc hm b phn vo kha chnh), v S nm kinh nghim ph thuc hm vo NhanVienID, MaKyNang (ph thuc hm y vo kha chnh) khi m mt nhn vin c th c nhiu k nng. By gi chng ta cn phi loi b cc ph thuc hm b phn. y l dng chun 2. Chng ta gn tn cho tng bng mi tch ra nh gii thch pha di. KyNang (NhanVienID, Ten, MaKyNang , TenKyNang, SoNamKinhNghiem ) NhanVien(NhanVienID, Ten) ThongTinKyNang (MaKyNang , TenKyNang) KyNang (NhanVienID, MaKyNang, SoNamKinhNghiem)

Sau s phn tch trn mi bng ch c duy nht 1 trng khng l kha, do khng th c cc ph thuc hm bc cu. Bi th y cng l dng chun 3. a) Dng chun 1 b) Ten ch c th xc nh n nht da vo NhanVienID nn l mt ph thuc hm b phn. y l dng chun 1. c) SoNamKinhNghiem ph thuc hm vo NhanVienID,MaKyNang. Do SoNamKinhNghiem khng ph thuc hm i vi kha chnh NhanVienID.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

239

5. Cng ngh c s d liu

Cu hi 3
Q3.

kh: *

Tn sut: ***

u l m t thch hp nht ca kha chnh trong c s d liu quan h: a) Cc hng khng th c tm ra tr khi iu kin tm kim l cho ct cha kha chnh. b) Nu mt ct no cha cc gi tr s c gn kha chnh th sau ct c khng th c s dng trong cc php ton s hc. c) Cc hng vi cc gi tr kha chnh ging nhau khng th xut hin trong cng 1 bng. d) Khng th to thnh kha chnh gm c nhiu ct khc nhau.

p n cu 3
p n ng: c
Trong mt c s d liu quan h, kha chnh c to ra bng cch kt hp 1 hoc nhiu trng nhm mc ch xc nh mt hng (bn ghi). Kha chnh khng th mang cc gi tr trng lp trong cng 1 bng. a) b) Cc hng c th c c t u theo th t. Mt kha chnh l mt trng hoc mt tp cc trng (ct) sao cho n khng c s trng lp gi tr ca bng v khng xc nh r cc thuc tnh ca d liu. Do vy, d liu c th c s dng cho cc php ton. Mt kha chnh c th to thnh bng cch kt hp nhiu ct khc nhau.

c)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

240

5. Cng ngh c s d liu

Cu hi 4
Q4.

kh: **

Tn sut: **

u l m t ng nht cho cc khung nhn c s d liu quan h?


a) b) c) d) Khng th nh ngha mt khung nhn t nhiu bng. Khi mt ct c thm vo mt bng khung nhn phi c nh ngha li. Nhng ngi dng khng ch bit cu trc ca khung nhn m cn bit cu trc ca bng gc. Cc khung nhn hu ch trong vic bo v d liu v ton vn d liu khi m cc d liu c s dng c th c hn ch.

p n cu 4
p n ng: d
Mt khung nhn (bng o) l s m t ci nhn c s d liu t quan im ca mt ng dng. N l mt bng tch bit nh ngha bng cch kt hp cc khon mc cn thit t cc bng khc nhau hay t mt bng duy nht. Vi vic ch duy nht cc khon mc cn thit vi ngi s dng c nh ngha cc d liu c th b s dng s c hn ch, cho php bo v v ton vn d liu. Hn na, mt khung nhn xut pht t mt bng c th c cp nht, nhng mt khung nhn xut pht t nhiu bng th khng th cp nht. Thm ch nu mt khung nhn xut pht t mt bng n l n khng th c cp nht nu s dng cc iu kin sau: DISTINCT: Trong DISTINCT, cc hng vi cc gi tr trng lp c kt hp li thnh 1 hng, v vy nhng hng bng gc cn c cp nht s khng th xc nh c. Cc hm tp hp, tnh ton: Gi tr thu c bi cc tnh ton (v d gi tr thu c bng php ton SUM nh l tng cng) khng th c cp nht. Trong trng hp ny gi tr gc nn c cp nht. Cc truy vn con GROUP BY, HAVING

Mt khung nhn gi l mt lc ngoi trong mt c s d liu quan h v mt lc con trong c s d liu mng. a) b) c) Mt khung nhn c th nh ngha bng cch kt hp nhiu bng. Mt khung nhn khng b nh hng khi mt ct c thm vo bng gc. Vi vic ch cc khon mc cn thit mi c chn v nh ngha t bng gc khung nhn khng lin quan n cu trc ca bng gc.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

241

5. Cng ngh c s d liu

Cu hi 5
Q5.

kh: *

Tn sut: ***

Cu lnh SQL no di y c th thu c bng B t bng A? [Bng] B


Ten
Lucy Brown Mike Gordon William Smith John Benton Tom Cage Mary Carpenter

[Bng] A MaNhanV ien


10010 10020 10030 10040 10050 10060

MaPhong
101 201 101 102 102 201

Luong
2,000 3,000 2,500 3,500 3,000 2,500

MaPhong
101 101 102 102 201 201

MaNhan Vien 10010 10030 10040 10050 10020 10060

Ten
Lucy Brown William Smith John Benton Tom Cage Mike Gordon Mary Carpenter

a) b) c) d)

SELECT MaPhong, MaNhanVien, Ten FROM A GROUP BY MaNhanVien SELECT MaPhong, MaNhanVien, Ten FROM A GROUP BY MaPhong SELECT MaPhong, MaNhanVien, Ten FROM A ORDER BY MaNhanVien, MaPhong SELECT MaPhong, MaNhanVien, Ten FROM A ORDER BY MaPhong, MaNhanVien

p n cu 5
p n ng: d
Bng B c th chn MaPhong, MaNhanVien, v Ten t bng A. iu ny c th vit nh sau:

SELECT MaPhong, MaNhanVien, ten FROM A Ch rng cc bn ghi c sp xp theo MaPhong v trong cng mt MaPhong th sp xp theo MaNhanVien. iu ny c thc hin vi cu lnh sau y. Nh rng ASC ngha l Theo th t tng dn; nu th t b b qua th mc nh s l ASC. ORDER BY MaPhong, MaNhanVien T thu c bng B t bng A chng ta s dng cu lnh SQL sau: SELECT MaPhong, MaNhanVien, Ten ; ly MaPhong, MaNhanVien, Ten FROM ; t bng A ORDER BY MaPhong, MaNhanVien ; Sp xp theo th t tng dn ca m phng v m nhn vin.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

242

5. Cng ngh c s d liu

Cu hi 6
Q6.

kh: **

Tn sut: *

Trong mt h thng c s d liu phn tn, phng php no sau y c s dng thm d xem nhiu site thi hnh mt lot cc x l giao dch c th c cp nht hay khng v c th thc hin mt x l cp nht c s d liu sau khi xc nhn rng tt c cc site c th c cp nht? a) y thc 2 pha (Two-phase commit) b) iu khin t chi truy cp (Exclusive access control) c) Quay lui (Roll-back) d) Quay tin (Roll-forward)

p n cu 6
p n ng: a
Mt c s d liu phn tn c kh nng truy cp v l thuyt nh mt c s d liu duy nht d n c kt ni vi nhiu my tnh trong cc v tr a l ring bit nh cc x nghip, cng s v cc trung tm nghin cu. Trong mt c s d liu phn tn, nu mt site kt thc qu trnh cp nht trong khi cc site khc hy b vic cp nht d liu s mt tnh ton vn. Do vy, cn c mt c ch chc chn tnh ton vn ca cc c s d liu ti cc nhiu a im. y thc 2 pha l mt c ch m nh n s ton vn ca d liu c m bo khi mt c s d liu b phn tn (v d c s d liu phn tn). N c 2 pha. Trong pha th nht mt thnh vin yu cu cp nht c s d liu s thm d cc thnh vin khc ca c s d liu phn tn nu s y thc c cho php. y, mi c s d liu phn hi bng y thc (COMMIT) hoc quay lui (ROLLBACK), nhng ti thi im ny cc c s d liu phn tn km gi vic cp nht. Tnh trng ny (COMMIT c th c thi hnh nhng vic cp nht tht s li b km gi) gi l tnh trng m bo. Trong pha th 2, thnh vin yu cu kim tra ni dung phn hi ca cc thnh vin khc v ch dn COMMIT hay ROLLBACK n mi c s d liu. Nu mt trong cc c s d liu phn hi ROLLBACK th thnh vin yu cu chuyn ROLLBACK n tt c cc thnh vin. Ni cch khc, nu tt c u phn hi COMMIT th sau thnh vin yu cu gi mt lnh COMMIT n tt c cc thnh vin. Lc ny cc c s d liu phn tn c cp nht tht s.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

243

Bo mt v chun ho

Mc tiu ca chng:
Khi thng tin c trao i qua mng, vn an ton v bo mt cn c m bo v nguy c r r v gi mo thng tin lun c th xy ra v vt khi tm kim sot ca ngi dng. Bn cnh , virus my tnh ngy cng lan trn; v th, vic bo v cc h thng my tnh v d liu khi nhng nguy c ny l rt cn thit. Trong phn 1, chng ta s hc mt s phng php m bo s an ton v bo mt. Ngoi ra, phn mm v d liu cn c chun ho c th trao i thng tin thng qua mng. Vic chun ho c ngha l thit lp cc nh dng v cu trc chung cho thng tin. Thng tin c th c trao i m khng cn thc hin thm bt k thao tc c bit no nu nh thng tin c tp hp theo ng vi cc chun nht nh. V vy trong phn 2, chng ta s hc v cc xu th trong vic chun ho.

6.1 6.2

An ton bo mt Chun ho

[Cc thut ng v khi nim cn nm vng] M ho, mt m kha cng khai, mt m kha ring, xc thc, virus my tnh, vc-xin, tng la, s gi mo, s ngy trang, ISO9000, MPEG, JPEG, Unicode, EDI, CORBA

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

244

6. Bo mt v chun ha

6.1 An ton bo mt
M u
An ton bo mt c ngha l duy tr tnh an ton ca cc h thng my tnh v cc h thng mng. Mt cch ngn chn nhng truy cp tri php l yu cu ngi dng nhp vo nh danh ngi dng (user ID) v mt khu ca ngi . Mt cch khc cng rt hiu qu l m ho d liu chng r r d liu cho bn th ba (third party).

6.1.1 Bo v s an ton
im chnh
Cc phng php bo v bao gm m ho, xc thc v qun l truy cp. Cc phng php m ho bao gm mt m kha ring v mt m kha cng khai.

M ho (Encryption)
M ho c ngha l trn thng tin theo mt mu no sao cho bn th ba khng th hiu ni dung ca n. y l mt phng php c hiu qu cao trong vic bo v thng tin lu trong h thng my tnh. Da trn s kt hp gia kha m ho v kha gii m, c hai loi l mt m kha ring (hay cn gi l mt m kha chung) v mt m kha cng khai. Khi nim v m ho c trnh by di y. 1
[Ngi gi] Kha m ha Vn bn thun Kha gii m Vn bn thun [Ngi nhn]

Vn bn m ha

Vn bn thun: d liu trc m ha Vn bn m ha: d liu sau m ha

M ha

Gii m

Mt m Mt m kha ring Mt m kha cng khai

Gii thch Cng mt kha c dng lm kha m ho v kha gii m (chuyn i i xng). Kha cn c gi b mt. DES v FEAL l nhng v d v h thng ny. Kha m ho l kha c cng khai trong khi kha gii m c gi b mt. Thng ip c m ho bi kha cng khai ca bn nhn v c gii m bi kha ring ca bn nhn (chuyn i bt i xng). RSA l mt v d cho h thng ny.2 3

(Gi ) M ha khng th ngn nga d liu khi b sai lch v n ch lm cho d liu khng th c c. Ngoi ra, c mt ri ro l mu m ho c th b b gy nu nh cng mt kha c s dng trong mt thi gian di. Cn phi bit rng m ho khng phi l mt bin php hon ho. 2 (Ch ) Cn bit rng trong mt m kha cng khai, m ho c thc hin bng cch s dng kha cng khai ca bn nhn. Kha cng khai sn c trn mng v ai cng c th c cn kha gii m c gi b mt. H thng ny c c im l vic chuyn i i xng gn nh khng th v vic gii m cng l khng th nu s dng kha m ho. 3 DES/RSA: DES (Data Encryption Standard) l v d v mt m kha ring. Cn RSA (Rivest-Shamir-Adleman) l v d v mt m kha cng khai. RSA c t tn theo cc ch ci u tin ca tn ca ba ngi pht minh ra loi mt m ny. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

245

6. Bo mt v chun ha

Xc thc
Xc thc c ngha l kim tra xem ngi dng c phi l mt ngi dng hp l hay khng. C nhiu phng php xc thc c lit k di bng sau: Phng php Xc thc thc th Gii thch L cng ngh xc nh t chc m chng ta ang giao tip c hp l hay khng. Thng thng ngi ta s dng s kt hp gia ID ngi dng v mt khu. Ngoi ra cn rt nhiu cc phng php khc bao gm call-back, 4 mt m kho ring, v mt m kho cng khai.

Xc thc ip Ch k s5

thng L cng ngh pht hin bt k s sai lch no c th xy ra trong khi truyn k t hoc vn bn. Nu nh c s sai lch, bit kim tra s c thit lp. L cng ngh m bo s hp l ca mt ti liu, thng thng s dng mt m kha cng khai.

i khi, mt khu s dng mt ln (ngn hn) c s dng tng cng s an ton v bo mt. ID ngi dng cng l mt bin php xc thc; thng thng, ngi qun tr h thng chu trch nhim n nh ID ngi dng cn mt khu c qun l bi ngi dng.

Qun l truy cp
Qun l truy cp c ngha l ngn cn nhng truy cp tri php ti ngun ti nguyn (v d nh d liu) trong mt h thng my tnh. thc hin mc ch ny, cc ID ngi dng v mt khu c ng k trc vi h thng, ngi dng c yu cu phi nhp ID v mt khu ca ngi c c quin truy cp ti cc ngun ti nguyn v mng. Quin c c kh nng truy cp vo ngun ti nguyn c gi l quin truy cp. Bng sau ch ra cc phng php qun l truy cp nhn dng tng c nhn. Kiu Tri thc c nhn S hu c nhn c im c nhn Gii thch Mt khu th ID, th IC, th quang Du vn tay, ging ni, hnh dng bn tay, mu vng mc, ch k

Qun l quin truy cp thng qua cc c im c nhn c gi l xc thc sinh trc hc.

Call-back: y l mt phng php m bn nhn ngt kt ni trao i v sau kt ni li bng cch gi bn gi tr li. Ch k in t: y l phng php m p dng mt m kho cng khai. C rt nhiu cch ng dng phng php ny, nhng cch n gin nht l s dng mt m kho cng khai nghch o. Bn gi m ho vn bn vi kho ring b mt ca anh ta/c ta v thm tn ca anh ta/c ta vo trong vn bn thun. Bn nhn, da vo tn thun , s ly c kho cng khai ca bn gi v s dng kho cng khai gii m vn bn. Nu thng ip c m ho m c c, bn gi s tin hnh kim tra li; mt khc, bn nhn s xc nh xem thng ip ny c phi l c gi bi ngi khc gi mo hay khng.
5

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

246

6. Bo mt v chun ha

6.1.2 Virus my tnh


im chnh
Virus my tnh l cc chng trnh thc thi cc hnh ng khng hp l. Tng la bo v vic truy cp khng c php t bn ngoi.

Cng vi s pht trin v ngy cng ph bin ca Internet, s xut hin ca ngy cng nhiu cc kiu hnh thc ph hoi thng qua mng ang dn tr thnh mt xu th. V vy, vn ngy cng tr nn cp thit l cn phi c bin php ngn chn cc virus my tnh v bo v ngn chn li nhng truy cp khng c php t bn ngoi. Chng ta s cng gii thch v vn ny mt cch chi tit hn, bao gm cc phng php c th c th p dng.

Virus my tnh
Mt virus my tnh, hay ch n gin, mt con virus, l mt chng trnh xm nhp vo h thng thng qua mng hoc cc thit b lu tr vi mc ch ph hoi, gy li, hoc nh cp d liu. Mt virus my tnh c th t ti sinh v sinh si thng qua mi trng mng v cc thit b lu tr. Hn na, bt k ai cng c th to ra mt virus macro6 rt d dng, v vy thit hi do virus gy ra cng lan rng. Thng thng, virus my tnh bao gm t nht mt trong nhng chc nng sau: Chc nng Chc nng t ly Chc nng n Chc nng th hin triu chng c tnh Virus gy nh hng bng cch t ti sinh bng chnh chc nng ca n hoc ti sinh trn mt h thng khc s dng chc nng ca h thng. Virus bao hm mt s iu kin xc nh tn cng, v d nh ngy gi, khong thi gian, hoc s lng tin trnh c th; khi virus t n giu cho n khi tin hnh tn cng. Virus c mt s chc nng ph hu cc tp tin nh cc chng trnh, d liu hoc thc thi mt s thao tc m ngi to ra khng mong i.

Vc-xin (Phn mm vc-xin, vc-xin my tnh)


Vc-xin l mt chng trnh c th tm ra v loi tr cc virus my tnh. V c bn, vc-xin cha mt c s d liu c sn (mt tp mu) m trong ng k cc mu v cc virus my tnh c pht hin, thc hin so snh nhiu loi d liu trn a v b nh vi cc mu ny, t pht hin ra cc virus my tnh. V l do ny, vic cp nht cc vc-xin vo bt k lc no cng l cn thit.7 8
6 Virus macro: y l mt loi virus my tnh li dng cc hm macro ca cc bng tnh v phn mm x l vn bn. Cc virus my tnh thng thng i hi mt kin thc nht nh v ngn ng my, v vy vic to ra chng i vi ngi dng l kh kh khn. Mc d vy, cc virus macro c th c vit bng cc ngn ng lp trnh, do chng c th c to ra mt cch kh d dng. Thng thng chng n trong cc tp tin v c gi km cng vi email. 7 (FAQ) Trong cc k thi trc, c rt nhiu cc cu hi lin quan n virus my tnh. Bn cn nm chc nh ngha v virus my tnh, cc phng php trnh nh hng ca virus, cc phng php p dng trong trng hp b nh hng, v cc vn lin quan n vc-xin. 8 (Gi ) Vc-xin ch c th nhn ra cc mu ca nhng virus tng c pht hin. Do n khng th x l c cc virus mi. V vy mt gi c bn l cn c s phng nga v thn trng sao cho my tnh khng b nh hng bi virus. Mt khi pht hin ra nh hng ca virus th cn thit phi ngay lp tc p dng cc thao tc ngn khng cho nh hng lan rng hn.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

247

6. Bo mt v chun ha

Cc bin php ngn chn virus


bo v my tnh khi b nh hng bi cc virus my tnh, nhng im sau y cn c ch : C phn mm vc xin Khng sao chp phn mm bt hp php Khng thc thi cc chng trnh kh nghi Thit lp mt khu v quin truy cp Thc hin sao lu nh k Khng chia s a cng (cn chn lc trong qun l) Khng m nhng th in t kh nghi Nu chng ta pht hin ra nh hng ca virus, cn lin h ngay vi ngi qun tr xin ch dn. Nhng hnh ng t c th khin cho tc hi ca cc virus my tnh cng tr nn trm trng.

Tng la
Tng la l mt h thng (c cu) bo v h thng mng ni b nh h thng mng LAN trong nh, khi truy cp tri php t bn ngoi. C th hn, tng la c ci t gia mt mng ni b v mng bn ngoi v d nh Internet. Tt c cc giao tip gia bn trong v bn ngoi c thc hin thng qua tng la. Tng la c kh nng gii hn cc dch v c sn cho mi ngi dng v xc nh quin truy cp t bn ngoi quit nh xem c cho php truy cp ti mng bn trong hay khng. i khi mt my tnh c ci t tng la, cng c trang b chc nng ca mt my ch i din9 (proxy server).

Mng Internet Tng la


Mng LAN trong nh

Cc my tnh

My ch i din: y l mt loi my ch c ci t bo v tnh an ton bo mt v truy cp tc cao khi mt mng bn trong kt ni vi Internet. My ch ny ngn chn nhng s xm nhp tri php vo mng bn trong v gy tr, qun l truy cp t mng bn trong ra ngoi Internet. Chc nng ny kh ging vi chc nng ca mt tng la, v v vy thng thng chc nng ca my ch i din c thc hin bi mt thit b tng la. Ngoi ra, mt my ch i din cn c chc nng u nhim: d liu gi n t Internet c th c lu li mt cch tm thi. Sau , khi chnh trang web c truy cp li, s truy cp s tr nn nhanh hn bng cch bt n my ch i din. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

248

6. Bo mt v chun ha

6.1.3 Ti phm my tnh


im chnh
Ti phm my tnh l hnh ng xm nhp vo h thng thng tin vi mc ch khng tt. Virus my tnh l mt loi ti phm my tnh

Ti phm my tnh l hnh ng xm nhp vo mt h thng thng tin vi mc ch khng tt v thc hin mt hnh ng no chng hn nh ph hu d liu. Cng vi s m rng ca cc h thng mng, nhng ngi dng khng c quin nhng c th truy cp vo cc mng bt u xut hin. Virus my tnh l mt phng tin ph bin ca ti phm my tnh. Ti phm my tnh bao gm vic thao tc trn mng ca cc h thng ngn hng, xm nhp vo trong mt my tnh c iu khin t xa thng qua mng, v t by trn cc phn mm tn min cng cng.

S sai lch (Falsification)


S sai lch cp n hnh ng c tnh lm thay i d liu hoc chng trnh trong mt my tnh v bao gm gi mo, chnh sa ti liu, thay th phng tin lu tr bng mt phin bn li c chun b t trc, ghi li d liu v xo d liu. Vic ngn chn gi mo l rt kh khn nhng mt phng php hiu qu pht hin ra gi mo l xc thc thng ip. Mt v d cho vic gi mo l phng php Salami. Phng php salami l mt cch nh cp dn dn t mt ngun ti nguyn c s lng ln. V d nh, mt ngi dng c th m mt ti khon ngn hng o v chuyn mt vi xu t cc ti khon khc ti ti khon ca anh ta/c ta.

S ph hoi (Destruction)
S ph hoi l hnh ng xo cc d liu quan trng hoc mt chng trnh c lu tr trong my tnh v v hiu ho cc thit b h thng hoc cc phng tin lu tr bng cch ph hu chng mt cch vt l. Nhng v d in hnh cho hnh thc ph hoi ny l Trojan horse, bom logic10 v bom th in t11. Mt phn mm trojan horse giu bn trong chng trnh mt lnh c bit khng gy nh hng ti qu trnh x l thng thng v sau thc thi cc chc nng khng c php trong khi vn chng trnh hot ng bnh thng. Mt khi tho mn mt iu kin nht nh no , n c th ph hu tt c cc tp tin trong my tnh hoc nh cp ID ngi dng v mt khu. ngn chn li Trojan horse, ngi dng cn phi cn thn lu li mt bn sao nh l bn sao gc v so snh chng trnh kh nghi vi vi bn sao pht hin ra virus. Mc d vy, khng c mt phng php no thc s hiu qu phng ngn chn Trojan horse bn cnh vic kim tra chng trnh ngun vo thi im chng trnh c ghi hoc chnh sa.12 13
Bom logic: y l mt chng trnh ng dng ca phng php c s dng bi Trojan horse. Chng trnh ny nhng bn trong h thng mt tin trnh gy ph hu h thng khi tho mn mt iu kin no (thi gian, tnh hung, tn sut ) 11 Bom th in t: y l hnh ng gi mt lng ln cc th in t hoc th in t c kch thc ln ti mt ngi xc nh trong mt khong thi gian ngn, dn n gy li cho h thng th in t. 12 (FAQ) Trong cc k thi trc, c xut hin cc cu hi lin quan n ti phm my tnh, bao gm cc vn v virus my tnh Cn hiu r v trojan horse v scavenging. 13 (Ch ) Mt loi ti phm my tnh khc l superzapping. y l hnh thc lm dng chc nng c bit ca h thng dng cho tnh trng khn cp (v d nh, mt chng trnh ng dng truy xut ti tt c cc tp tin v qua c th thay i ni dung ca cc tp tin ) Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng -10

249

6. Bo mt v chun ha

R r (Leak)
R r l mt thut ng chung cp n vic nh cp thng tin hoc bn sao t mt h thng thng tin. Cc phng php bao gm t phng tin truyn trn mt n v u ra, trn ln cc d liu b mt vo bo co u ra v lm cho cc d liu ni b ny c dng nh mt thng tin khc bng cch m ho n. Mt v d ca vic r r l scavenging (lng rc). Scavenging l hnh ng nh cp thng tin khi my tnh sau khi mt hnh ng c thc thi. Mt ngi c th nh cp thng tin t vn bn b b i (ging nh rc) hoc thng tin cn li trn a cng hay trong b nh. Mt phng php hiu qu ngn chn li scavenging l xo tt c cc thng tin trong b nh c s dng lu tr tm thi v trn a cng sau khi hon thnh cng vic. 14

Tapping
Tapping l hnh ng chn cc d liu trn mng mt cch phi php v nh cp thng tin hoc truy cp vo h thng my tnh mt cch tri php. i tng ca tapping khng ch gm d liu my tnh m cn cc d liu m thanh. M ho l bin php hiu qu ngn chn tapping.

Gi mo (Disguise)
Disguise is the act of stealing someone else's user ID and password and acting on a network using the stolen identity. By doing so, the unauthorized user steals confidential information that only the authorized user should access, or commits wrongdoing and blames the authorized user for what he or she has done. Digital signatures are effective in preventing disguise. Gi mo l hnh ng nh cp ID ngi dng v mt khu ca ngi khc v hot ng trn mng s dng cc thng tin nh cp y. Bng cch lm nh vy, ngi dng tri php c th n cp cc thng tin ni b m ch nhng ngi dng hp php c th truy cp, hoc c th thc hin cc hnh ng tri php v ti cho ngi dng hp php v nhng hnh ng . Ch k in t rt hiu qu trong vic ngn chn li gi mo.

14 (Ch ) Rt nhiu phng php khc nhau c s dng duy tr tnh an ton v bo mt trong giao tip, bao gm nhn din s gi v nhm ngi dng ng. Nhn din s gi l cch thng bo cho ngi nhn cuc gi v s in thoi ca ngi gi. Nhm ngi dng ng ng k a ch ca thit b u cui cho php to kt ni vi cc n v chuyn i in t v to kt ni ch vi nhng thit b u cui .

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

250

6. Bo mt v chun ha

Cu hi nhanh
Q1 in t thch hp vo trng trong bng sau
Kho m ho Mt m kho ring Mt m kho cng khai Q2 Thng thng, mt virus my tnh c nh ngha l c t nht mt trong ba chc nng. Lit k ba chc nng . Kho gii m

A1
Mt m kho ring Mt m kho cng khai Kho m ho Kho ring (kho chung) Kho cng khai ca bn nhn Kho gii m Kho ring (kho chung) Kho ring ca bn nhn

A2

Chc nng t ly lan, chc nng bnh v chc nng th hin triu chng

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

251

6. Bo mt v chun ha

6.2 Chun ho
M u
Chun ho c ngha l nh ra cc qui nh, yu cu, c t, cu trc, hoc/v cc nh dng chung. Cc i tng c chun ho c th s dng m khng cn phi iu chnh g thm. Nhng i tng chun y lin quan n x l thng tin bao gm phn cng, phn mm, cc qui trnh pht trin h thng v nhng qui c lp trnh.

6.2.1 Cc t chc chun ha v chun ho qu trnh pht trin v mi trng


im chnh
Cc t chc chun ha bao gm ISO, ITU, ANSI Cc chun bao gm ISO 9000, ISO 14000,

Chun ho cho cng ngh thng tin c thc hin ch yu bi ISO. S chun ho trong vin thng c thc hin bi ITU. Cc t chc khc bao gm ANSI, y l t chc ra cc chun ni a ca M. Cc chun c th bao gm ISO 9000 cho pht trin phn mm v chun ISO 14000 cho vic quan tm n iu kin mi trng. 15

Cc t chc chun ho
Bng sau l tp hp cc t chc chun ho ni ting:16 Tn ISO
17

ITU

Gii thch T chc chun quc t y l t chc quc t hot ng thng nht v qui nh cc chun trong cc lnh vc lin quan n cng nghip. Trong mi lnh vc, thng thng c y ban k thut (TC) v di u ban k thut l cc nhm tiu ban (SC) v cc nhm lm vic (WG). Lin on truyn thng quc t y l t chc quc t chun ho cc cng ngh vin thng cng nh chun ha v xut cc chun quc t cho tt c cc loi truyn thng. ITU-T18 chu trch nhim i vi vin thng trong khi ITU-R19 chu trch nhim vi cc h thng khng dy v v tuyn.

15 (Gi ) Trong s cc hot ng v vic chun ho ca t chc ISO, hot ng trong ngnh in t v in c phn no hon thnh cng vi IEC. Lm vic trong vin thng c phn no hon thnh bi ITU. i khi ISO c th kt hp vi cc t chc chun ho a phng nh l ANSI nu cn thit 16 IEC(International Electrotechnical Commission - Hi ng cng ngh in in t quc t): y l mt t chc c thnh lp vi mc ch nh ra cc chun quc t chung trong lnh vc in in t. T chc ny hin nay tr thnh b phn vin thng ca ISO (ISO/IEC), lm vic cng nhau nh mt t chc. 17 IEEE(Institute of Electrical and Electronics Engineers): Nhm ny c mt nh hng ln trong vic ra cc chun trong nhiu lnh vc nh LAN v cc giao thc khc 18 ITU-T (International Telecommunications Union Telecommunications Standardization Sector): y l b phn tho lun v cng ngh, giao tip v cc ph c lin quan n in thoi v in bo; b phn ny cng a ra cc chun ring ca h nh l nhng xut. Nhng xut chnh ca b phn ny bao gm lot I cho ISDN, lot V cho cc ng dy tng t v lot X cho cc ng dy k thut s.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

252

6. Bo mt v chun ha

ANSI

Vin chun ho quc gia M y l mt t chc phi li nhun tham gia trong vic lp ra cc chun cng nghip M v cc nc thnh vin ca ISO.

Lot chun ISO 9000


Lot chun ISO 9000 l tn chung cho mt lot cc chun quc t c thit lp bi t chc ISO quan tm n cu trc m bo cht lng ca cc doanh nghip. Lot chun ny c thit lp vo nm 1987, chnh sa vo nm 1994 v chnh sa thm vo nm 2000 hnh thnh ra phin bn hin nay. Chun cho vic xc thc l chun ISO 9001; cc chun khc ch ra cc iu khon c coi nh l hng dn t c tnh xc thc. Chun ISO 9001 qui nh nhng yu cu c lin quan n h thng qun l cht lng cho cc doanh nghip v t chc trong cc trng hp sau: Khi cn thit, phi kim tra rng cng ty c kh nng cung cp sn phm tho mn nhng yu cu ca khc hng hoc nhng chun c yu cu thch hp hay khng. Khi cng ty mun c c s hi lng ca khch hng V vy, y c coi l chun cho h thng qun l cht lng, ch khng phi l chun cho sn phm. T khi ISO 9001 c cng nhn ton cu, cc cng ty t c chun ny cng c c s tn nhim ca quc t. Cu trc ca lot chun ISO 9000 c trnh by tng phn nh di y: ISO 9000 ISO 9001 H thng qun l cht lng C bn v t vng H thng qun l cht lng Cc yu cu Trch nhim trong vic qun l (hng n khch hng, cc chnh sch cht lng, kim im,) Qun l ti nguyn (S phn chia ngun lc, ngun nhn lc, mi trng lm vic,) Hin thc ho sn phm (k hoch hin thc ho sn phm, cc qu trnh c lin quan n khch hng, thit k v pht trin,) o lng, phn tch v ci tin (iu khin v o lng, iu chnh cc sn phm khng ph hp,) Hng dn cho cc ci tin v hiu nng

ISO 9004

Lot chun ISO 14000


Lot chun ISO 14000 l mt nhm cc chun quc t c lp ra bi t chc ISO lin quan n qun l bo v mi trng. Cc chun ny t ra cc hng dn cho vic o lng m cc cng ty phi thc hin x l cc vn nh hng xu ti mi trng ton cu nh l s tiu th ngun nng lng v rc thi cng nghip. Cc chun ny tng ng vi phin bn v mi trng ca lot chun ISO 9000 v h thng ho cc chng ch tun theo bi mt t chc th ba. 20

19 ITU-R (International Telecommunications Union Radiocommunication Sector): y l b phn c giao cho cc tn s ca sng radio, cc h thng radio chun, cc thao tc giao tip v tinh, giao tip thng qua khng dy, giao tip di ng, pht thanh truyn hnh, 20 (FAQ) Mt s cu hi thi hi v vai tr ca cc t chc chun quc t bao gm ISO v ITU. Mc d vy, hu ht cc cu hi thi u gi thit l bn c nhng hiu bit trc v cc chun ny. Mt v d tiu biu cho nhng cu hi nh vy l nh dng nn nh no c chun ha bi c hai t chc ISO v IEC. Cn chc rng bn bit t nht l tn gi v vai tr ca cc t chc ra chun c cp n trong quin sch ny.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

253

6. Bo mt v chun ha

6.2.2 Chun ho d liu


im chnh
Cc m k t bao gm EBCDIC, Unicode Cc nh dng tp tin bao gm JPEG, MPEG, SGML, CSV,

Khi truyn d liu, mt trong nhng qu trnh sau y cn phi thc hin: gi d liu sau khi lm cho d liu tng thch vi nh dng ca bn nhn; hoc nhn d liu di mt nh dng khc v sau chuyn n v nh dng d liu ca bn nhn. Trong c hai cch, nu nh nh dng khng nht qun, cn phi chuyn chng cho nhng t chc khc. Mc d vy, vic thay i nh dng c th c loi tr nu nh c nhng nh dng chun v tt c mi ngi u s dng nh dng chun ny. D liu c chun ho y bao gm cc m k t v nh dng tp tin.

M k t
M k t l m c gn cho mi k t v k hiu vi mc ch x l k t v cc k hiu trn my tnh. Cc m k t c x l khc nhau ph thuc vo my tnh x l. M EBCDIC Gii thch M chuyn i nh phn thp phn m rng (Extended Binary Coded Decimal Interchange Code) y l m k t c IBM thit lp dnh cho cc my tnh vi mc ch chung. Mt tp hp gm 8 bit i din cho mt k t. Chun biu din mt k t c s dng trn ton th gii ch trong mt m k t hp nht. Tt c cc k t c biu din s dng 2 byte. y c coi l mt phn ca chun quc t c a ra bi ISO.

Unicode (UCS-2)

B sung thm vo danh sch cc m c lit k bng trn, c chun ASCII21 v EUC22 v cc chun khc.23

Tp tin hnh nh
Tp tin hnh nh l tp tin m trong mt nh tnh ging nh nh chp hoc nh k xo minh ho c s ho thnh mt tp tin. C rt nhiu nh dng tp tin c lit k di y.

ASCII (American Standard Code for Information Interchange): y l m k t c thit lp bi ANSI, to nn cc m cho cc k t ch ci, s, cc k t c bit, v cc k t iu khin nh l du xung dng, mi m s dng 7 bit. ASCII c coi l mt phn ca chun quc t ISO (ISO 646). 22 EUC (Extended Unix Code): y l m k t bt k, c s dng ch yu bi h iu hnh UNIX. N c th x l cc k t 2 byte cng nh l cc k t 1 byte. y l m chun c xut bi AT&T v EUC Nht Bn, EUC Hn Quc v EUC Trung Quc, 23 (Ch ) Sau chun u tin, Unicode c m rng s dng 3 byte hoc nhiu hn. V vy, ngy nay n c nh ngha cho mi k t c th s dng 4 byte trong Unicode (UCS-4). Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

21

254

6. Bo mt v chun ha

nh dng JPEG GIF BMP TIFF

Gii thch
Joint Photographic Experts Group: Mt t chc kt hp ca ISO v ITU-T nhm m ho mu sc trong nh tnh, hoc phng php nn/ gii nn c ra bi t chc ny. Graphic Interchange Format: nh dng nh c pht trin bi CompuServe, mt cng ty dch v trc tuyn ln M. N tng thch vi cc nh mu hoc nh n sc vi s mu l 256 hoc t hn. Format to save images as bitmap data, standard graphics format used by Windows. nh dng lu gi nh di dng d liu tng bit, nh dng ho chun c s dng bi h iu hnh Windows. Target Image File Format: biu din d liu s dng cc th t trong khi d liu trong tp tin. Bng cch s dng cc th, ta xc nh c nh dng ca d liu.

Nn nh ng
Mt h thng m cho nh ng l MPEG (Moving Picture Experts Group). MPEG l tn ca t chc nh ca JTC1, l t chc kt hp gia ISO v IEC. y l phng php nn/gii nn nh ng, c xut bi nhm ny.24

nh dng tp tin vn bn
Tp tin vn bn c chun ho vi mc ch l cc d liu vn bn v d liu c chun b s dng mt ng dng c th d dng c chuyn i. Mt cch qui c, cc tp tin vn bn c chuyn i di nh dng c gi l tp tin vn bn (*.txt). Mc d vy, cc tp tin vn bn ch c th biu din cc xu k t, khng th biu din cc inh dng vit a dng khc nh l dy ca ch, kch c, mu sc, v cu trc ca vn bn ti liu. Ngy nay, cc nh dng c chun ho bao gm c kiu ti liu. Bng cch chun ho cc nh dng tp tin ti liu, cc ti liu c x l theo cch hp nht v cn c th a c vo trong c s d liu. Bng sau ch ra cc nh dng tp tin ti liu chun: nh dng SGML XML HTML TeX CSV25 PDF Gii thch
Standard Generalized Markup Language Ngn ng nh du tng qut chun Mt loi ngn ng biu din cu trc ng ngha v logic ca ti liu cng cc k hiu; mt ti liu c th c s dng nh mt c s d liu. eXtensible Markup Language Ngn ng nh du m rng c Mt loi ngn ng ra i sau HTML, m cc chc nng m rng ca SGML c th c s dng trn Web. Ngi dng c th nh ngha cc th ring ca mnh. HyperText Markup Language Ngn ng nh du siu vn bn Mt loi ngn ng c dng to ra cc trang Web trn mng Internet. Cc th c bao trong cp < > thit lp ra kch c ch, mu sc, v cc siu lin kt. c pht m l tek hoc tef Mt chng trnh nh dng v hon tt ti liu c th thit lp v in ra cc ti liu vi cc cng thc ton hc, ho hc phc tp. Comma Separated Value Format nh dng gi tr c phn cch bi du phy Mi thnh phn ca d liu c i km bi mt du phy v c lit k. nh dng ny c s dng ch yu lu gi d liu t c s d liu ca phn mm v cc phn mm bng tnh. Portable Document Format nh dng vn bn di chuyn c Mt loi nh dng c pht trin bi Adobe System cho cc ti liu in t. Cc ti liu c th c trao i cho d trn bt k m hnh my tnh v nn tng no.

(Ch ) MPEG cng m ho c m thanh cng vi nh ng. MPEG c MPEG-1, MPEG-2, MPEG-3, MPEG-4 v nhiu hn th na. MPEG-1 dng cho cc phng tin lu tr nh CD-ROM v l chun cho ISO/IEC (ISO 9660). MPEG-2 l phin bn nng cp ca MPEG-1 v dng cho HDTV(TV c phn gii cao) cng nh l vic truyn ti nh s dng ng truyn bng thng rng ISDN. MPEG-4 l m ha hiu nng cao cho nh ng v m thanh c thit k cho mng Internet v giao tip truyn thng qua sng v tuyn (truyn thng di ng).

24

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

255

6. Bo mt v chun ha

6.2.3 Chun ha trao i d liu v phn mm


im chnh
Cc chun v trao i d liu bao gm EDI, STEP, CALS, Cc chun v phn mm bao gm CORBA, RFC, OMG,

thc hin nhng giao dch trao i d liu gia cc cng ty, cc d liu trao i cn phi c chun ho. Mt trong nhng khi nim chun ho ny l EDI. 26 Ngoi ra cn c STEP, y l mt trong nhng chun trao i d liu m hnh sn phm. Nu nh cc sn phm phn mm ti u c th c kt hp cng nhau, bao gm cc phn mm c vit bi nhiu hng sn xut phn mm, ta s c mt h thng tt hn. thc hin iu ny, phn mm cng phi c chun ho.

Chun ho trao i d liu


Mng Internet ngy cng tr nn ph bin v cng vi s pht trin , mt loi nh dng mi cng c ra i. Loi nh dng ny c ra i phc v cc giao dch trao i thng tin cch in t thng qua mng. V l do ny, vic chun ho trao i d liu cng c xem xt. Bng sau ch ra nhng phng php chun ho chnh. Loi chun EDI CALS Gii thch Trao i d liu in t (cc giao dch in t, trao i d liu in t) Commerce At Light Speed Tt c cc thng tin lin quan n sn phm c chia s, t c t, pht trin, thit k thu c, vn hnh, v bo tr. Chun ny c thit k nng cao hiu sut, rt ngn giai on pht trin v gim gi thnh. Thng mi in t Bun bn khng phi din ra trong cc ca hng, t hng qua th m din ra trn mng Internet. Tin in t 27 c coi l phng tin thanh ton in t. Chun trao i cc d liu m hnh sn phm (Standard for the Exchange of Product Model Data) chun ISO 10303 International standard for the exchange of product model data L chun quc t phc v vic trao i cc d liu m hnh sn phm

EC

STEP

Open Systems Cc h thng m


Mt h thng m l mt h thng my tnh c to nn theo cch m, bng vic chun ho cc c t, phn cng v phn mm, c th thc hin cc chc nng m khng gy nn xung t, khng quan tm n nh sn xut. Trong cc h thng x l phn tn, phn cng xut pht t rt nhiu nh sn xut khc nhau v thng c kt ni vi nhau hnh thnh nn mt h thng; v vy, phn cng v phn mm u phi c chun ho.
(Gi ) EDIFACT c p dng M v Chu u, c dng gip vic trao i d liu gia cc nc hiu qu hn. Tin in t: y l phng thc thanh ton s dng giao tip qua IC hoc PC, c c im l cc ha n thanh ton vt l v tin mt khng c s dng. Tin in t c s dng nh phng tin thanh ton trong thng mi in t qua mng, chng hn nh mng Internet. Ngoi ra, c nhng th IC, nh nh th thng mi, c trang b cc chp in t m trn lu tr mt lng tin nht nh, qua ngi dng c th mang i v s dng nh tin mt bnh thng.
27 26

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

256

6. Bo mt v chun ha

Chun ho phn mm
Phc v cho vic chun ho phn mm hng i tng, di y l cc phn mm, cc chun v cc t chc ra chun. Tn CORBA Gii thch Common Object Request Broker Architecture L nhng c t chung cc i tng c th trao i thng ip vi nhau trong mt mi trng h thng phn tn. c ra bi OMG (Object Management Group). Enterprise JavaBeans L cc c t chun cho vic hnh thnh nn nhng ng dng hng i tng phn tn ca Java. C th kt hp cc thnh phn s dng cc cng c t cc nh cung cp khc nhau. EJB c kh nng tng thch vi CORBA. Request for Comments Mt nhm cc ti liu v xut k thut v ch thch, c bin son bi IETF. Cc ti liu ny c sn trn mng Internet v c th c thu c nh FTP hoc email. Giao thc lin quan n TCP/IP c vit bng RFC. Object Management Group Mt t chc phi li nhun xut ra vic ph bin v chun ho cng ngh hng i tng. T chc ny xut ra chun cng nghip (OMA) trong lnh vc cng ngh hng i tng.

EJB

RFC

OMG

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

257

6. Bo mt v chun ha

Cu hi nhanh
Q1
Q2

M t ni dung ca lot chun ISO 9000


(1) nh dng nn cho cc nh mu tnh l g? (2) nh dng nn cho cc nh ng l g?

A1

Lot chun ISO 9000 l tp cc chun quc t cho cc cu trc m bo cht lng v nhng nguyn tc chng t kh nng ca mt cng ty hay t chc c th cung cp cc sn phm theo yu cu ca khch hng. Do lot chun ISO 9000 c cng nhn trn ton th gii nn cng ty no c c chun ny th cng s c c danh ting quc t v s ng tin cy.
(1) JPEG (2) MPEG

A2

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

258

6. Bo mt v chun ha

Cu hi 1
Q1. a) b) c) d)

kh: *

Tn sut: ***

Qui trnh no sau y m bo ngi gi gi mt ti liu c m ho cho ngi nhn bng cch s dng mt m kho cng khai? Ngi gi m ho ti liu bng cch s dng kho cng khai ca ring mnh v bn nhn gii m ti liu bng cch s dng kho ring ca anh ta. Ngi gi m ho ti liu s dng kho ring ca anh ta, bn nhn gii m ti liu bng cch s dng kho cng khai Ngi gi m ho ti liu bng cch s dng kho cng khai ca bn nhn, v bn nhn gii m ti liu bng cch s dng kho ring ca anh ta Ngi gi m ho ti liu bng cch s dng kho ring ca bn nhn, v bn nhn gii m ti liu bng cch s dng kho ring ca anh ta

p n cu 1
p n ng: c
Mt m kho cng khai l mt h thng m trong kho m ho c a ra cng khai trong khi kho gii m c gi b mt. Kho c a ra gi l kho cng khai, v kho c gi b mt c gi l kho ring. Khng ging nh mt m kho ring (mt m kho chung), ch c mt kho m ho v mt kho gii m l cn thit, v vy vic qun l cc kho l d dng hn. Hn na, do kha gii m c chia s cng khai, kho ny khng nht thit phi gi i. Nhng do kho cng khai khng th c s dng gii m vn bn, m ho v gii m c th gy tn thi gian. Trong mt m kho cng khai, bn gi m ho thng ip bng cch s dng kho cng khai ca bn nhn trong khi bn nhn gii m thng ip s dng kho ring ca anh ta/c ta. a) Trong mt m kho cng khai, nhng g c m ho bi kho cng khai, c gii m bi kho ring cng cp vi kho cng khai. Trong la chn (a), kho cng khai thuc v ngi gi trong khi kho ring thuc v bn nhn, do chng khng to nn mt cp. Cu ny m t v ch k in t. Mt kho ring c gi b mt. Cu tr li ni rng ngi gi m ho ti liu bng cch s dng kho ring ca bn nhn nhng ngi gi khng c kho ring ca bn nhn.

b) d)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

259

6. Bo mt v chun ha

Cu hi 2
Q2. Cu no sau y m t thch hp v virus my tnh? a) b) c) d)

kh: **

Tn sut: ***

Ngay c khi trong my tnh tn ti mt tp tin chng trnh m virus nm n trong , chng no m ngi dng cn cha c tnh khi ng tp tin , my tnh s khng b nh hng. Virus ph hu b nh chnh mt cch vt l v khi ng cc thao tc m khng theo ch ca ngi s dng. Mt my tnh c cp nht vi cc thnh phn mi nht v tp tin ch k mi nht pht hin v kim tra virus s khng b nh hng bi virus. Trong qu trnh kim tra virus, ngi dng c th trnh b nh hng t sector khi ng bng cch s dng a khi ng h iu hnh khng c virus.

p n ng:

Khi mt my tnh c bt, u tin m h thng c chng trnh c gi l a khi ng, v a cng hoc a mm c dng nh l a khi ng c gi l a khi ng. Mt a khi ng c chun b trc s dng trong trng hp khn cp. Khi vng khi ng b nh hng bi virus, h iu hnh s c khi ng t mt a khi ng khng c virus. a) Mt virus sector khi ng (gi n gin l virus khi ng) xm nhp vo sector khi ng m trong chng trnh khi ng (chng trnh khi ng h iu hnh t a cng) c lu tr v tn cng my tnh khi my c bt. V vy, nh hng ca virus c th xy ra ngay c khi ngi dng khng nhn thc c. V virus l mt chng trnh nn virus khng ph hu n phn cng mc d n c th gy ph hu phn mm.
Mt thnh phn (phn mm) pht hin v ngn chn li virus c gi l vc-xin (phn mm vc-xin, vc-xin my tnh). Mt tp tin ch k lu tr thng tin v cc virus c pht hin trc . Vc-xin pht hin v kim tra cc virus bng cch kim tra nhng chng trnh mc tiu v cc d liu trong tp tin ch k. Do , mt vc-xin khng th pht hin hoc loi b nhng virus mi cha c ng k trong tp tin ch k.

b) c)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

260

6. Bo mt v chun ha

Cu hi 3
Q3.

kh: *

Tn sut: ***

Pht biu no di y l m t ph hp vi chng ch ISO 9001:2000? a) b) c) d) Khi c chng nhn, cht lng phn no c m bo. Ch c mt hi ng chng ch cho mi quc gia. y l chng ch cho lnh vc cng nghip v khng c p dng cho lnh vc dch v. Chng ch chng nhn cc t chc m h thng qun l cht lng ph hp vi chun quc t.

p n cu 3
p n ng:
d Lot chun ISO 9000 l tp cc thut ng cp n mt lot cc chun quc t c ra bi t chc ISO lin quan n h thng qun l cht lng ca cc cng ty. Chun dng chng nhn l ISO 9001, v cc chun khc l cc mc ch ra cc nguyn tc t c chng ch ISO 9001. y khng phi l chun cho sn phm, hn th na, n chng nhn mt cch quc t l qui trnh cht lng ca cng ty hoc t chc l da trn nhng im sau: Cc cng ty hoc t chc c kh nng cung cp cc sn phm tho mn nhu cu ca khch hng hoc p ng c cc chun theo yu cu. H ang lm vic nng cao s tho mn ca khch hng. Mt cch tnh c, chun ISO 9001 c xem xt li vo thng 12 nm 2000. Cc mc c yu cu trc y b phn tn, nay c t chc li v chia thnh bn nhm: Trch nhim qun l, Qun l ti nguyn, Hin thc ho sn phm, o lng, phn tch v ci tin. Chun ny c c im l khi nim v h thng qun l cht lng v s ci tin khng ngng ca h thng qun l cht lng. Con s 2000 trong ISO 9001:2000 biu th l chun ny c xem xt li vo nm 2000. a) b) c) Mt cng ty c chng nhn cn phi c kim tra hng nm hoc mi su thng, v vic nh gi li mt cch y cn phi c thc hin mi 3 nm. V vy, nhng hot ng lin tc l rt cn thit. C rt nhiu t chc chng nhn. Mt t chc mong mun c chng nhn c th chn bt k t chc chng nhn no theo mnh. Mc d vy, mi quc gia ch c duy nht mt t chc c u nhim m c th kim tra v cng nhn cc hi ng chng nhn khc. Chun ny p dng cho tt c cc ngnh.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

261

Tin hc ha v qun l

Mc tiu ca chng
Trong x hi hin i, my tnh c s dng trong rt nhiu lnh vc. Hng ngy, chng ta s dng my tnh gia nh v cng s. My tnh c s dng trong cc h thng k ton doanh nghip, qun l sn xut, cc h thng t v tu. Trong chng ny, chng ta s tm hiu cc kin thc lin quan n vic pht trin cc h thng nh vy. Phn 1, chng ta s nghin cu cc chin lc thng tin c s dng bi cc cng ty. Phn 2 s tm hiu v h thng k ton doanh nghip. Phn 3 s tm hiu qun l doanh nghip, phn 4 s nghin cu mt s v d c th v cc h thng thng tin s dng my tnh.

7.1 7.2 7.3 7.4

Cc chin lc thng tin K ton doanh nghip K thut qun l S dng cc h thng thng tin

[Cc khi nim v thut ng cn nm vng] Gim c thng tin (CIO), phng php KJ, brainstorming, h tr gip ra quyt nh (DSS), h thng tin chin lc (SIS), BPR, bng cn i k ton (B/S), bo co ti chnh (P/L), khu hao, phn tch im ha vn, phn tch ABC, kim sot lp lch, qui hoch tuyn tnh, kim sot kho, phn phi chun, CAD, FA, POS

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

262

7. Tin hc ha v qun l

7.1 Cc chin lc thng tin


M u
Chin lc thng tin c nh ngha l chin lc tin hc ha nhm to ra s khc bit vi cc i th cnh tranh trn thng trng. thc hin c chin lc thng tin th rt nhiu hot ng cn phi c thc hin.

7.1.1 iu chnh qun l


im chnh
Lnh o qu trnh tin hc ha l gim c thng tin. Phng php KJ xc nh cc vn c bn t tho lun t do.

iu chnh qun l l mt hot ng nhm hp nht t chc chuyn sang mt phng php hot ng mi. Mt cng ty thng bao gm b phn nhn s, b phn sn xut, b phn ti chnh v b phn thng tin. iu chnh qun l lin quan n tt c cc b phn , phi hp cc b phn to ra gi tr cao hn thng qua cc ch o, hng dn c gi l chin lc qun l.

CIO
CIO (Chief Information Officer Gim c thng tin) l ngi chu trch nhim cao nht trong vic gim st cc h thng thng tin. Khng ging nh trng phng chuyn qun l cc h thng thng tin, CIO phi c trch nhim pht trin cc chin lc thng tin s dng hiu qu ngun ti nguyn thng tin phc v cho vic qun l doanh nghip. CIO c trch nhim gim st qun l cc b phn thng tin ca doanh nghip.1

Phng php KJ
Phng php KJ do Jiro Kawakida pht minh. Trong phng php ny, rt nhiu tng c to ra gii quyt mt vn , cc tng c nhm li v c lin h vi nhau. Khi mt h thng thng tin c thit k, vic u tin l phi phng vn xem quan im ca ngi s dng h thng. Rt nhiu kin v thng tin s c thu thp trong bc ny, bao gm khng t cc kin l mu thun, tri ngc nhau, c bit l khi s lng ngi tham gia phng vn ln. Phng php KJ l mt phng php hiu qu xc nh nhu cu chung t nhng kin tri ngc .

1 (FAQ) ngha v vai tr ca CIO tng l cu hi thi. Ngoi vic hiu bit r cc h thng thng tin th cc CIO cn phi nhn trch nhim i u trong chin lc thng tin. V vy, yu cu cc CIO hiu bit rt rng cc lnh vc khc nh cng nghip , nghip v kinh doanh v cc chc nng qun l.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

263

7. Tin hc ha v qun l

Cc th tc chung ca phng php KJ c ch ra trong hnh:


1. Xc nh ch 2. Thu thp thng tin 3. To ra cc th (card) 4. Gom nhm v t tn 5. Phn tch v nh gi Quyt nh xem ci g s c thc hin. To ra tht nhiu tng v quan im.2 Ghi li cc quan im v tng vo cc th. Phn nhm cc th. Tng hp (v cc th,vit ti liu)

Brainstorming
Brainstorming l mt phng php tho lun nhm, din ra di nguyn tc tn trng kin ca ngi khc, khng ch trch, ph bnh bt c kin no ca cc thnh vin. N hot ng trn bn nguyn tc l: Khng cho php ch trch, t do ng gp kin, s lng quan trng hn cht lng, khuyn khch tho lun v tng ca ngi khc v hon i v tr. Cc nguyn tc trn gip cho cc thnh vin c th t do din t kin v quan im ca c nhn m khng c bt c gii hn no. Trong sut cuc tho lun, rt nhiu tng mang tnh cch tn, i mi s c to ra.

OJT v Off-JT
OJT (On the Job Training) l vic o to gn lin vi mt tp cc cng vic rt c th. Mt gim st vin hay cp trn s trc tip hng dn cp di, nhng ngi m c t kinh nghim v k nng lin quan n cng vic c th, bao gm kin thc, k thut, quan im. OJT c tin hnh theo mt k hoch v mc tiu r rng. N khng ging nh cc loi hnh o to ln lp truyn thng, n lm hc vin v ging vin tr nn gn gi hn. Thm vo , OJT cng l mt phng php rt hiu qu gip ngi hc d dng hc tp, ci tin v pht trin kh nng ca mnh qua qu trnh lm vic ti cng ty. 3 Khc vi OJT l Off-JT (Off the Job Training), y l loi hnh o to theo phong cch ln lp truyn thng. Mc ch ca n l nhm o to nhng ngi mun tm hiu cc lnh vc khc vi nhng lnh vc hng ngy m h ang lm.

(Ch ) Mt phng php hc cch thu thp thng tin thng quan phng vn l th vai (ng vai). Mt nhm 4 ngi, trong mt ngi s ng vai tr l ngi phng vn, mt ngi khc l ng vin cn li ng vai tr quan st vin v s bnh lun nh gi v ng gp kin sau khi phng vn. 3 (Ch ) Mt d n l mt t chc c hnh thnh thc hin cc mc tiu c nh ngha trc bao gm lch biu, chi ph, v hiu nng di nhng gii hn thi gian c nh ngha trc. N s c gii tn khi hon thnh cc mc tiu ca n. N khng ging cc t chc doanh nghip hay tp on. Mt d n c mc tiu, im bt u v im kt thc. Trong hu ht cc trng hp, cng vic ny c thc hin bi mt nhm ngi. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

264

7. Tin hc ha v qun l

7.1.2 Cc chin lc tin hc ha


im chnh
DSS vit tt ca decision-support system c hiu l h tr gip ra quyt nh, SIS l strategic information system - h thng thng tin chin lc. BPR l ti cu trc li cc qui trnh nghip v.

Chin lc tin hc ha l vic thc hin tt hn i th cc cng vic mang tnh chin lc vi s tr gip ca my tnh bng cch s dng cc h thng thng tin chin lc nh ERP, CRM, SFA, v CTI. V cc vn ny cp n trong chng 3, trong chng ny chng ta s tip tc cp n cc vn khc.

Cc h thng thng tin phc v cc chin lc tin hc ha


C rt nhiu h thng thng tin c s dng cho cc chin lc tin hc ha. S dng hp l cc h thng thng tin ny c th mang li nhng li th cnh tranh cao. DSS DSS (Decision Support System) l mt h thng tr gip cho cc nh qun l, qun tr trong vic ra cc quyt nh gii quyt cc vn phi cu trc (l cc vn khng c khun mu gii quyt). i vi cc vn ny, rt kh c th tm thy cc thng tin cn thit c nh ngha sn, ng thi cng rt kh c th tm c cc m hnh gii quyt sn c. V vy, DSS yu cu phi c cc chc nng ca c s d liu4, cc chc nng da trn m hnh5, cc chc nng v giao din ngi dng6. Bng cch kt hp cc chc nng ny, ngi dng c th tm ra c cc quyt nh cho cc bi ton m mnh ang gp phi. SIS SIS (Strategic Information System) l mt h thng thng tin s dng cng ngh thng tin nh l mt phn ca chin lc doanh nghip thu c c hi cnh tranh.

Phn tch, thit k v ci tin cng vic


hnh thnh mt lung cng vic ti u, iu cn thit l phi xem xt v thit k li lung cng vic. BPR BPR l cng vic thay i ni dung kinh doanh thc t ca doanh nghip, ti cu trc li cc lnh vc kinh doanh, da vo phn tch ni dung v lung kinh doanh, thit k li mt cch ti u ha t c nhng mc tiu v li nhun cng nh s hi lng ca khch hng.
Chc nng c s d liu: cho php tm kim v phn tch cc d liu cn thit khi c vn xy ra. Chc nng da trn m hnh: la chn cc m hnh hp l gii quit vn , v d m hnh gi lp , m hnh ton. 6 Chc nng giao din ngi dng: Cho php s dng chc nng c s d liu v chc nng da trn m hnh mt cch d dng da vo tng tc.
5 4

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

265

7. Tin hc ha v qun l

Cc m hnh kinh doanh M hnh kinh doanh l mt nn tng to ra nhng khi nim kinh doanh c bn. Ni cch khc, n l nguyn mu thc hin kinh doanh mang li li nhun. N nhn c s quan tm ln hn ca cng lun cng nh xut nhiu s ring bit hn bng cch gn kt doanh nghip vi my tnh v Internet, thng qua s pht trin ca cng ngh thng tin.

a Internet vo doanh nghip


Vi s pht trin ca Internet, cc doanh nghip v cu trc doanh nghip mi cha tng xut hin c thnh lp ngy mt nhiu.7 e-business/ Dot com business e-business l mt cu trc doanh nghip mi, n tn dng cc li th do Internet v my tnh mang li. N l mt cu trc doanh nghip tin tin, kt ni s m rng v mi trng Internet vi s m rng ca cc giao dch, cc hot ng v hnh thc kinh doanh. N c th c thc hin bng cch nh ngha cc m hnh doanh nghip v to ra s thay i trong qui trnh nghip v, cc qui tc v t chc. Dot com business (.com business) l mt thut ng dng ch cc doanh nghip kinh doanh trn Internet. .com (company) l mt loi tn min c cp pht cho cc cng ty, doanh nghip. Cc cng ty ch ng kinh doanh trn internet c gi l cc cng ty dot com hay cc cng ty in t.8 SOHO SOHO (Vn phng nh, vn phng gia nh) l thut ng c to nn nh hai cm vn phng nh v vn phng gia nh. Thut ng vn phng nh ni n vic s dng cc ngun ti nguyn bn trong v bn ngoi doanh nghip mt cch hiu qu thng qua mng. Vn phng gia nh cp n hnh thc lm vic thng qua Internet, mi ngi vn c th lm vic hiu qu m khng cn phi n cng ty, h c th nh s dng Internet v lm vic. M hnh doanh nghip ny ang ngy cng ph bin cng vi s pht trin ca Internet.

Cng ty o: l mt loi hnh cng ty mi , cng ty c thnh lp thng qua mng v c qun l bi nhiu ngi. EC (Electronic Commerce - Thng mi in t): L mt phng php bn hng ha v dch v thng qua mng, thay th cho cc hot ng mua bn truyn thng. Vi thng mi in t, mt doanh nghip c th c thnh lp vi s vn rt nh, ng thi gim mt cch ng k chi ph iu hnh v bn hng. Mt khc cng xc nh v phn loi c khch hng, t gi cc thng tin cn thit n tng loi khch hng.
8

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

266

7. Tin hc ha v qun l

Cu hi nhanh
Q1 Q2 Q3 Q4 CIO l g? Cc th tc chnh ca phng php KJ l g? Lit k cc nguyn tc ca Brainstorming. Th no l BPR?

A1

CIO(Chief Information Officer - gim c thng tin) l ngi chu trch nhim cao nht trong vic gim st cc h thng thng tin. Khng ging nh mt trng phng chuyn qun l cc h thng thng tin, CIO phi c trch nhim pht trin cc chin lc thng tin s dng hiu qu ngun ti nguyn thng tin phc v cho vic qun l doanh nghip. CIO c trch nhim gim st qun l cc b phn thng tin ca doanh nghip. 1. Xc nh ch : quyt nh ci g s c thc hin 2. Thu thp thng tin: To ra tht nhiu tng v quan im 3. To ra cc th: Ghi li cc quan im v tng vo cc th 4. Gom nhm v t tn: Phn nhm cc th 5. Phn tch v nh gi: Tng hp (v cc hnh, to cc ti liu) 1. Khng cho php ch trch. 2.T do ng gp kin. 3. S lng quan trng hn cht lng. 4. Khuyn khch tho lun v tng ca ngi khc v hon i v tr.

A2

A3

A4 BPR l cng vic thay i ni dung kinh doanh thc t ca doanh nghip, ti cu trc li cc lnh vc kinh doanh, da vo phn tch ni dung v lung kinh doanh thit k li mt cch ti u ha t c nhng mc tiu v li nhun cng nh s hi lng ca khch hng.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

267

7. Tin hc ha v qun l

7.2

K ton doanh nghip

M u
K ton doanh nghip l th tc bo co tnh hnh hot ng ca doanh nghip ti cc bn lin quan trong v ngoi doanh nghip. K ton doanh nghip c chia thnh k ton ti chnh v k ton qun l.

7.2.1 K ton ti chnh


im chnh
Trong K ton ti chnh, cc ti liu c bn l B/S v P/L. V khu hao, c phng php s d gim dn v phng php khu hao ng thng.

K ton ti chnh l qu trnh cung cp cc thng tin k ton ti cc i tng lin quan bn ngoi doanh nghip nh cc c ng v ch n. Trong bo co ti chnh cn phi c bng cn i k ton (B/S) v bo co kt qu hot ng kinh doanh (P/L).

B/S v P/L
Bng cn i k ton (B/S) l mt bo co phn nh ton b tnh hnh ti chnh ca doanh nghip ti mt thi im, phn nh mi quan h gia ti sn, n phi tr v ngun vn ch s hu. Bo co kt qu hot ng kinh doanh (P/L) l mt bo co phn nh kt qu hot ng kinh doanh trong mt k k ton, phn nh mi quan h gia chi ph v thu nhp (doanh thu). Do , ti sn trn Bng cn i th9 c phn nh trn Bng cn i k ton (B/S), doanh thu c phn nh trn Bo co kt qu hot ng kinh doanh (P/L), v chnh lch doanh thu chi ph l li nhun rng. Li nhun rng trn Bng cn i k ton (B/S) phn nh vn ch s hu tng, v tng tng ng vi li nhun rng trn Bo co kt qu hot ng kinh doanh (P/L). Xem bng di.
{Bng cn i th} N phi tr Vn ch s hu Ti sn Chi ph N phi tr Vn ch s hu Li nhun rng [Bng cn i k ton] Doanh thu

Ti sn

Doanh thu Li nhun rng [Bo co kt qu hot ng kinh doanh]

Chi ph

H thng ti khon
Mt khon hnh thnh nn ti sn, n phi tr, hoc vn ch s hu trn bng cn i k ton v bo co kt qu kinh doanh c gi l mt khon mc. Mt s khon mc c phn nh theo bng sau:
9 Bng cn i th: L mt bng c lp s dng kim tra s pht sinh ng hay khng khi kha s k ton. Tng s d n v tng s d c lun bng nhau.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

268

7. Tin hc ha v qun l

Ti sn Ti sn lu ng

ton b ti sn thuc s hu v qun l ca doanh nghip Ti sn s c chuyn ha thnh tin trong mt khong thi gian ngn (1 nm hoc di 1 nm). Ti sn d chuyn ti sn c kh nng thanh khon cao tin mt, tin gi ngn hng, cc khon phi thu, cc khon tng ng tin. ha thnh tin thnh phm bn nguyn vt liu (raw material), hng Hng tn kho ha.. Ti sn c nh ti sn khng chuyn ha thnh tin Nh ca, quyn s dng t, bn quyn, trong thi gian ngn bng sng ch Khon cng n ca cng ty (khon tin vay phi c thanh ton trong thi gian xc nh). phi c thanh ton trong thi gian khon phi tr ngi bn, vay ngn hn, ngn khon phi tr khc c vay trong khon thi gian di vay di hn Vn cn thit cho hot ng kinh vn c phn doanh Li nhun ca cng ty 11 doanh thu thu c t cc hot ng doanh s bn hng kinh doanh ca doanh nghip.

N phi tr N ngn hn N di hn Vn ch s hu
10

Doanh thu Li nhun thun t hot ng kinh doanh Li nhun khc

doanh thu thu c t ngun khc Li cho vay ngoi cc hot ng kinh doanh nh: li phi thu, thu nhp khc. Chi ph Cc chi ph cn thit cho hot ng kinh doanh Gi vn hng bn chi ph cn thit mua hng ha chi ph ca hng mua Chi ph bn hng v cc chi ph cn thit cho cc hot tin lng nhn vin b phn qun l doanh nghip, tin cng, tin thng, Chi ph qun l doanh ng kinh doanh. cc khon ph cp, chi ph khu hao, chi nghip ph cng tc, chi ph bng tin khc.

Chi ph khc

chi ph cho cc hot ng khc ngoi hot ng kinh doanh

li tin vay tr, tin hoa hng

Khu hao 12
Khu hao ti sn c nh (TSC) l mt phng php lm gim gi tr TSC bng cch phn b gi tr phi khu hao ca TSC13 nh mt khon chi ph theo mt phng php nht nh. Theo bng di c cc phng php khu hao bao gm phng php khu hao ng thng v phng php khu hao s d gim dn.

10 (Gi ) Vn ch s hu (Capital): l ngun vn c hnh thnh t bn thn doanh nghip (vn t c) v c gi l vn gp. N phi tr vn c vay t bn ngoi v c gi l vn vay.Vn ch s hu v n phi tr (vn gp v vn vay) to nn tng ngun vn. 11 (Ch ) Li nhun bao gm: Li nhun gp (Gross profit) = Doanh thu thun Gi vn hng bn Li nhun thun t hot ng kinh doanh = Li nhun gp (Chi ph bn hng + Chi ph qun l doanh nghip) Li nhun trc thu = Li nhun thun t hot ng kinh doanh + Li nhun khc Chi ph khc. Ni chung, Li nhun trc thu l li nhun doanh nghip m c dng nh gi. 12 (FAQ) S c cu hi thi a ra mt ti khon v mt lng tin v yu cu bn tnh ton thu nhp kinh doanh cng nh thu nhp bnh thng. Hy tm hiu cc cng thc ca tng loi thu nhp. Cng c nhng cu hi m bn phi tnh ton chi ph khu hao. Hy hiu ngha ca cc cng thc tnh ton cho phng php khu hao ng thng v phng php khu hao s d gim dn. 13 Nguyn gi (Acquisition cost): S tin thanh ton khi mua ti sn.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

269

7. Tin hc ha v qun l

Phng php Phng php khu hao ng thng

Ni dung Xc nh chnh lch gia nguyn gi v gi tr thanh l (gi tr cn li) 14 ca TSC. Chia phn chnh lch chia cho thi gian s dng hu ch v mt s lng c nh c khu tr mi k k ton l khu hao TSC. Mc khu hao hng nm = (Nguyn gi - Gi tr thanh l c tnh)/Thi gian s dng hu ch.

Phng php khu Xc nh bng t l khu hao c nh nhn vi gi tr cn li (gi tr cha khu hao s d gim hao) ca TSC l chi ph khu hao cho k k ton. Mc khu hao hng nm = gi tr cn li (gi tr cha khu hao) t l khu dn15 hao c nh.

14 Gi tr cn li (Residual value): Gi tr ti sn c tnh thu c khi ht thi gian s dng hu ch ca ti sn. Thng thng, gi tr cn li bng 10% chi ph thanh ton c c ti sn. 15 (Gi ) T l khu hao cho phng php khu hao s d gim dn c xc nh theo thi gian khu hao. V d, nu my tnh c khu hao trn 6 nm, t l khu hao bng 0.319.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

270

7. Tin hc ha v qun l

7.2.2 K ton qun l


im chnh
im ha vn l im m ti li nhun hot ng kinh doanh bng 0. Cch nh gi mt cng ty bao gm h s kh nng thanh ton v h s n.

K ton qun l l trnh t cung cp thng tin k ton cho cc i tng bn trong doanh nghip. Thng tin qun l bao gm phn tch im ha vn, cc ch s ti chnh, phn tch chi ph, v nh gi hng tn kho.

Phn tch im ha vn
im ha vn l im m ti thu nhp (doanh thu) bng tng chi ph16 b ra (bin ph v nh ph), ngha l, im m ti li nhun bng 0. Doanh thu di im ha vn kt qu l l (mu ), v doanh thu trn im ha vn kt qu l li (mu en). Bng vic nhn bit c ha vn, chng ta c th xc nh c mc tiu th cn thit khng b l. Phng php phn tch qun l s dng im ha vn c gi l phn tch im ha vn.. Trong phn tch im ha vn s dng th minh ha mi quan h Doanh thu = Gi bn n v * sn lng tiu th bng cch nh du trn th sn lng tiu th trn trc nm ngang v Doanh thu trn trc thng ng. th ha vn (ng doanh thu) c ly tiu chun l ng 45 tng dn v bn phi. Mt khc, khi nh ph l chi ph khng thay i tng ng vi mc sn lng tiu th, nh ph c biu din l ng nm ngang. Bin ph c th c biu th theo cng thc Bin ph = Gi thnh sn xut n v * sn lng tiu th, do vy bin ph c biu din l mt ng (gi tr bng 0 nu khng c sn phm no c tiu th) cng tng dn v bn phi, theo sn lng tiu th. Tng ca nh ph v bin ph c biu din l ng tng chi ph. Theo th bn di, giao im gia ng doanh thu v ng tng chi ph l im ha vn.17

Doanh thu, chi ph

ng tng doanh thu Li nhun ng tng chi ph (nh ph + bin ph) Bin ph ng nh ph nh ph S lng bn Tng chi ph

nh ph: L chi ph thay i khng tng xng vi mc tiu th, bao gm chi ph nhn vin (tin lng), tin thu vn phng, v cc chi ph dch v. Bin ph: l chi ph thay i ph thuc vo mc sn lng tiu th, nh chi ph nguyn vt liu. 17 (Gi ) V nguyn tc, ng doanh thu v ng tng chi ph lun giao nhau. ng doanh thu l gi bn n v * sn lng tiu th trong khi ng tng chi ph l gi thnh sn xut n v * sn lng tiu th. Khi trong gi bn n v bao gm gi thnh sn xut n v v li nhun mc tiu, tc l, gi thnh sn xut + li nhun mc tiu = gi bn n v, dc ca ng doanh thu ln hn dc ca ng tng chi ph. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

16

Doanh thu ti im ha vn

im ha vn

271

7. Tin hc ha v qun l

i vi doanh thu ha vn, theo phng trnh sau: Doanh thu ha vn =

18

Tng nh ph 1- Tng bin ph/Doanh thu

Tng nh ph = 1- T sut bin ph = Tng nh ph 1- T sut li trn bin ph

Phn tch ti chnh


Phn tch ti chnh c thc hin nh gi cc bo co qun l v tnh trng ti chnh bng cch phn tch mc an ton v kh nng sinh li ca mt cng ty. Thng s dng cc s phn tch ti chnh, cc h s quan h.19 H s an ton. H s an ton l cc h s s dng nh gi kh nng thanh ton n ca doanh nghip. Cc h s c m t trong bng sau: H s H s kh nng thanh ton ngn hn H s kh nng thanh ton nhanh Ni dung T s ca ti sn lu ng, ti sn c kh nng chuyn i nhanh thnh tin, v n ngn hn. H s ny phn nh kh nng thanh ton ngn hn ca doanh nghip. H s ny 200% l tt. T s ca tin cng vi tng ng tin, cc khon c kh nng i nhanh thnh tin, v n ngn hn. H s ny phn nh kh nng thanh ton tc thi ca doanh nghip, m bo hn h s kh nng thanh ton n ngn hn. H s ny 100% l tt. T s ca ti sn c nh v vn ch s hu Ti sn c nh c m bo mua sm bng vn ch s, do vy t s ny cng nh cng c li. T s 100% l tt. T s ca n phi tr c bo m bng vn ch s hu. N cng thp so vi vn ch s hu tnh hnh ti chnh ca cng ty cng an ton, do , h s n c gi tr nh l an ton. H s n 100% l tt. T s ca vn ch s hu v tng ngun vn, phn nh tnh n nh. Vn ch s hu cng ln so vi tng ngun vn cng c li. Do vy, h s t ti tr c gi tr ln l tt. H s t ti tr 50% l tt.

T sut t ti tr TSC H s n H s vn ch s hu (h s t ti tr) 20

Ch rng li nhun s dng trong phn tch im ha vn l li nhun hot ng kinh doanh. H s quan h: l t s ca mt khon mc v mt khon mc khc, c biu din dng phn trm. So snh gia cc khon mc trong Bng cn i k ton c gi l phn tch tnh trong khi so snh gia cc khon mc trn bo co kt qu kinh doanh c gi l so snh ng. 20 (Ch ) Cng thc tnh h s an ton: H s kh nng thanh ton ngn hn = Ti sn lu ng / N ngn hn *100% H s kh nng thanh ton nhanh = Ti sn lu ng / N ngn hn *100% T sut ti tr TSC = Ti sn c nh / Vn ch s hu *100% H s n = N phi tr / Vn ch s hu *100% H s vn ch s hu = Vn ch s hu / Tng ngun vn *100%
19

18

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

272

7. Tin hc ha v qun l

Cc ch tiu sinh li
Cc ch tiu sinh li l cc ch tiu phn nh li nhun m doanh nghip kim c l bao nhiu. Cc ch tiu c phn loi theo bng di. Ch tiu T sut li nhun trn vn c phn T s li nhun trn doanh thu thun T sut chu chuyn (vng quay vn kinh doanh) Ni dung Ch tiu ny phn nh li nhun bng bao nhiu ln so vi vn ch s hu, tc l, phn nh tnh hiu qu ca ng vn s dng. Li nhun cng cao ng vn s dng cng hiu qu, do , ch tiu ny c gi tr ln l tt. Ch tiu ny phn nh li nhun bng bao nhiu ln so vi doanh thu thun. Li nhun cng cao hiu qu kinh doanh cng tt, do , ch tiu ny c gi tr ln l tt. Ch tiu ny phn nh mc m ti sn v vn c s dng trong mt k k ton. Vi mong mun thu c doanh thu ln vi ti sn v vn b ra t, ch tiu ny c gi tr ln l tt.

Mt s ch tiu c a ra di y. V vn c th thay i trong mt k, nn gi tr trung bnh ti thi im u k v cui k c s dng chung cho c k.21 T sut li nhun vn kinh doanh= (Li nhun / Tng ngun vn)*100% T sut li nhun trn doanh thu = (Li nhun / Doanh thu thun)*100% Vng quay ton b vn = (Doanh thu thun / Tng ngun vn)*100%

Chi ph
Chi ph l cc ph tn cn thit sn xut v tiu th sn phm. Ph thuc vo ni dung ca chi ph, chi ph c th phn loi nh sau: Li nhun bn hng Chi ph qun l doanh nghip Chi ph bn hng Chi ph sn xut gin tip Chi ph nguyn vt liu trc tip Chi ph sn xut Chi ph nhn cng trc tip trc tip Chi ph trc tip Chi ph sn xut Gi bn Tng chi ph

Ph thuc vo chi ph c gnh chu nh th no, chi ph c th c phn loi thnh chi ph nguyn vt liu, chi ph nhn cng, v ph khc. Chi ph nguyn vt liu l gi tr ca nguyn vt liu ang tiu dng. Chi ph nhn cng l chi ph v lao ng s dng. Ngoi chi ph nguyn vt liu v chi ph nhn cng l cc chi ph khc. Mt khc, nu chi ph c mi quan h vi sn phm, chi ph c th c phn loi thnh chi ph trc tip v chi ph gin tip. Chi ph trc tip l cc chi ph c th c tnh trc tip cho mt sn phm xc nh. Chi ph gin tip l chi ph khng th tnh trc tip cho mt sn phm xc nh, chi ph ny c phn b cho cc sn phm theo tiu chun nht nh.
(Gi ) Khi tnh cc ch tiu sinh li v s dng Tng ngun vn tnh ton, gi tr vn bnh qun thng c s dng. V Ngun vn (bao gm N phi tr) l khc nhau ti thi im u k v cui k. Gi tr vn bnh qun l trung bnh cng ca Tng ngun vn ti thi im u k v cui k k ton. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng -21

273

7. Tin hc ha v qun l

nh gi hng tn kho
Hng tn kho c xc nh nh ti sn m s c bin i thnh tin thng qua tiu th hoc c tiu dng cho sn xut sn phm. Xem xt gi tr thc t ca hng tn kho c gi l nh gi hng tn kho. Phng php Ni dung Phng php nhp Hng tn kho c nh gi vi gi thit sn phm no mi nhp kho s xut sau xut trc (LIFO) trc, cn li sn phm nhp u tin (hng tn kho gn thi im u k). Phng php qun lin hon bnh Gi n v c tnh s dng s lng tn v s lng nhp mi ti mi thi im sn phm c nhp kho. n gi bnh qun = (Tr gi tn kho + Tr gi nhp kho mi)/(s lng tn kho + s lng nhp kho mi)

Phng php nhp Hng tn kho c nh gi vi gi thit sn phm nhp kho trc s c xut trc xut trc trc, li hng tn kho mi (hng tn kho gn ti thi im cui k). (FIFO) Phng php bnh Tr gi v s lng hng tn kho c cng li xc nh n gi bnh qun, qun nh k khng quan tm ti thi gian, ti thi im u hoc cui k. (bnh qun gia quyn) Tr gi hng tn kho c thay i ph thuc vo phng php nh gi hng tn kho c s dng. Mi doanh nghip quyt nh phng php m mnh thc hin.22

22 (Gi ) Kt qu nh gi hng tn kho ph thuc vo tnh trng kinh t. Vi nhng sn phm m n gi mua ang tng dn, n gi l cao hn vi nhng sn phm nhp kho sau cng; trong trng hp ny, phng php nhp trc xut trc (FIFO) s cho kt qu nh gi cao nht. Mt khc, nu n gi mua gim dn, n gi l cao vi nhng sn phm nhp kho u tin. Do , s dng phng php nhp sau xut trc (LIFO) s cho kt qu nh gi cao nht. Phng php bnh qun gia quin v phng php bnh qun lin hon s cho kt qu gi tr trung gian gia kt qu ca phng php LIFO v FIFO.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

274

7. Tin hc ha v qun l

Cu hi nhanh
Q1

Khi kha s k ton vo cui k, theo bo co kt qu kinh doanh c lp. Tnh li nhun t hot ng kinh doanh cho k k ton.
n v: triu la Ch tiu S tin Doanh thu 150 Gi vn hng bn 100 Chi ph bn hng v Chi ph qun l doanh 20 nghip Thu nhp khc 4 Chi ph khc 3

Q2

a ra cng thc tnh h s kh nng thanh ton ngn hn.

A1

Li nhun t hot ng kinh doanh


=Doanh thu Gi vn hng bn Chi ph bn hng v chi ph qun l doanh nghip = 150 100 20 = 30(triu la)

A2

H s kh nng thanh ton ngn hn = (Ti sn lu ng / N ngn hn) * 100%

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

275

7. Tin hc ha v qun l

7.3 K thut qun l


M u
K thut qun l l h thng cc nguyn l v phng php dng tm ra gii php cho vn mt cch khoa hc. Cc vn bao gm: lp k hoch sn xut, k hoch bn hng, kim sot kho. N c phn ra lm hai loi chnh l IE (Industrial Engineering) v OR (Operations Research). OR bao gm kim sot kho, qui hoch tuyn tnh, lp k hoch, xc sut v thng k.

7.3.1 IE
im chnh
Cc phng php ph bin ca IE l phn tch ABC v 7 cng c kim sot cht lng. Phn tch ABC c s dng xc nh im ti hn nh qun l hng tn kho.

IE l h thng cc k thut v phng php nhm ti u ha vic thit k, iu hnh v kim sot ngun nhn lc, sn phm (my mc, trang thit b, nguyn vt liu v nng lng), ti chnh v thng tin, t cc mc tiu qun l v hin thc ha cc mc tiu . Bn cnh , m bo c s hi ha cc mi quan h trong x hi cng nh bo v mi trng. N xc lp mt tp cc hot ng lin quan n ton b qui trnh qun l sn xut.23

Qun l cht lng vi 7 cng c thng k


7 cng c thng k cho phn tch d liu c ch ra trong bng di
Cng c M t Biu nhn Biu th mi lin h gia cc c tnh mc tiu v cc yu t, nhng yu t dng nh qu c nh hng n cc c tnh, biu din bng hnh v ging xng c. S dng cc ct minh ho cc hin tng v nguyn nhn, nhm li cc dng nh Biu Pareto l cc khuyt tt, ti sn xut, sa cha, khiu ni, tai nn v hng hc. Cc ng gp khc c thm vo ch ra tn sut tch lu (ct) Biu phn L mt dng ca th ct trong cc yu t bin ng hay cc d liu c th c b chia thnh cc lp hoc thnh cc phn v c din t nh cc ct vi khong cch lp c biu th qua ng y v tn sut biu th qua chiu cao. Biu phn Biu phn tn ch ra mi quan h gia 2 bin trong phn tch bng s. gii quyt tn cc vn v xc nh iu kin ti u bng cch phn tch nh lng mi quan h nhn qu gia cc bin s.

(Gi ) C nhiu nh ngha v IE cng nh c nhiu phm vi p dng. V phm vi p dng, cch hiu v thng nht chung l IE bao gm cc phng php phn tch v qun l thc hin tp trung vo nghin cu qun l (khng ch xc nh cc phng php qun l hiu qu bng cch nghin cu v phn tch cc bin php qun l v iu kin lm vic, m cn bao gm 1 h thng phng php phn tch thit lp thi gian nh mc hp l). Tuy nhin, c mt vi kin, theo ngha rng, IE bao gm bt c hot ng g lin quan ti qun l kinh doanh, trong khi theo ngha hp, IE ch gii hn trong qun l sn xut. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

23

276

7. Tin hc ha v qun l

c s dng cho vic thu thp d liu, n s dng mt tp cc th v bng, n c s dng bng cch tch vo cc trng bn cnh cc cu hi v cu tr li. D liu thu c t cc bng kim l u vo cho cc cng c phn tch d liu khc. Do y l bc quan trng quyt nh tnh hiu qu ca cc cng c phn tch khc. Biu phn Phn vng thng thng tm ra nguyn nhn ca khuyt tt. vng Biu kim Biu kim sot l th ng gp khc biu din gi tr trung bnh ca cc c sot tnh, t l khuyt tt hoc s khuyt tt. Chng c s dng kim tra s bt thng ca qu trnh da trn s thay i ca cc c tnh (c tnh kim sot).

Bng k

[Biu nhn qu]

[Biu Pareto]

[Biu phn b ]

[Biu phn tn]

[Bng kim24]
Thi gian 9:00- 9:59 10:00- 10:59 11:00- 11:59 12:00- 12:59 13:00- 13:59 Tng Kim tra tn sut 30 24 17 36 18 125

[Biu phn vng]


100 80

T ch Nng nghip

S ngi

60 40 20 0
1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 (year)

Pha tp

[Biu kim sot] Gii hn kim sot trn ng trung tm ng gii hn di

Phn tch ABC


Hng ha trong kho c th c hp thnh nhm theo danh mc hng ha, v sau mi nhm c th c sp xp theo th t gim dn theo gi hng tn kho (Mc d tr hng tn kho) hoc theo doanh thu bn hng (T sut li nhun). Sau , s tng cng c th c biu din trn cng mt th phn loi v qun l hng tn kho thnh 3 nhm - Nhm A, B v C. Phng php ny c gi l phn
24 (Ch ) Bng kim v biu phn vng khng c nh dng c th. Chng ta c th s dng mt dng ph hp cho mc ch ca mnh. Cc th trong hnh l mt v d.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

277

7. Tin hc ha v qun l

tch ABC,25 chng ta s dng th Pareto biu din di y.

Gi lu kho hng nm H s tch ly Gi lu kho hng nm Kim sot mc thp Kim sot mc thp Kim sot mc cao

Sn phm lp A

Sn phm lp B

Sn phm lp C

Trong phn tch ABC, nhm sn phm A yu cu qun l cht ch (hoc mt mc cao) trong khi cc nhm sn phm B v C i hi qun l mc tng i thp. Nhm sn phm A tng ng vi khong 70% mc tn kho d tr, nhm sn phm B bng khong 70% n 90% v nhm sn phm C mc 90% hoc cao hn. Phn tch ABC l mt k thut phn tch v kim sot da trn nguyn l Pareto.26

7 Cng c kim sot cht lng mi


Trong khi by cng c kim sot cht lng c s dng trong phn tch nh lng v s liu, th by cng c kim sot cht lng mi cung cp mt phng php qun l s liu v cht lng nh l con s bit ni. Cc cng c ny c s dng a ra cc bin php gii quyt vn v lp k hoch chin lc ca cng ty. By cng c kim sot cht lng mi ny bao gm: Phng php biu kt hp, phng php biu tng ng, phng php biu cy, phng php biu ma trn, s qu trnh ra quyt nh (PDPC), v phng php biu mi tn.

25 (FAQ) C nhiu cu hi thi v phn tch ABC. Hy hiu quan im v ni p dng..Trong ng dng, bn c th thy iu ny kim th chng trnh. V d, ngun ca cuc tho lun v vic chng trnh no nn c qun l mc cao, s li ca mi chng trnh c th c ch ra biu Pareto.sd 26 Nguyn l Paretol: ch mt s yu t c nh hng ng k n kt qu trong khi hu ht cc yu t c nh hng nh. Da trn c s , nhm sn phm A c u tin hng u trong qun l trong phn tch ABC.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

278

7. Tin hc ha v qun l

7.3.2 Kim sot lch biu (OR)


im chnh
Biu mi tn c s dng cho vic kim sot lch biu. Cc hot ng ch yu c qun l l cc hot ng nm trn ng ti hn.

Mt phng php phn tch gi l k thut nh gi v kim nghim chng trnh c s dng to ra v qun l cc lch biu sao cho thi gian hon thnh d n l ngn nht c th. Trong phng php ny sau khi to biu mi tn (biu th hin mi quan h gia cc hot ng v s ngy c yu cu cho mi hot ng), rt nhiu phn tch s c thc hin ti u ha lch biu.

Biu mi tn
Biu mi tn ph hp cho qun l cc d n c ln, trong rt nhiu hot ng din ra ng thi. Mt v d biu mi tn c th hin trong hnh di.27

Hot ng

Nt S ngy yu cu

Hot ng dummy task28 gi

Trong biu mi tn ny hot ng A l cng vic khi to bt u ton b qu trnh, cng vic ny din ra trong 4 ngy. Theo sau hot ng A, cc hot ng B, C, v D c thc hin ng 6 thi. Ti nt , cc hot ng E v F li hp nhau li. iu ny cho bit rng hot ng H khng th bt u nu E v F cha hon thnh.

Gii php s dng biu mi tn


tnh ton s ngy yu cu ca d n t biu mi tn, phng php tnh ton hng ti c s dng tm ra thi gian nt sm nht v phng php tnh ton quay lui c s dng tm ra thi gian nt mun nht. S dng biu bn di, chng ta hy tnh ton s ngy yu cu. Trc tin, ti mi nt ta v mt hnh ch nht gm 2 ngn, v qui c n v thi gian tnh bng ngy.

(Ch ) Trong biu mi tn, Cc ch ci A, B, I, i km vi cc mi tn c gi l hot ng.Cc con s i km vi cc mi tn cp n thi gian yu cu, th hin khong thi gian din ra hot ng. n v thi gian c th l ngy, gi, pht... 28 Hot ng gi: l hot ng khng c ni dung. Ngi ta s dng mt ng nt t th hin s ng b. Khi C kt thc th hot ng F c th bt u ngay lp tc , nhng I khng th bt u cho n khi hot ng C v G cng hon thnh. Thi gian yu cu cho hot ng gi thng c xem l 0. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

27

279

7. Tin hc ha v qun l

Tnh ton hng ti


1 Chng ta tnh thi gian nt sm nht29 tnh t nt . Ti cc nt m bt u hot ng tip theo cn hon thnh nhiu hn mt hot ng trc , ta s ly s ngy ln nht c yu cu bi cc hot ng trc lm thi gian sm nht ca nt. Thi gian sm nht ca nt s c tnh ton v ghi vo ngn trn ca hnh ch nht. Tip n ,ta s tnh thi gian hon thnh ton b d n. 3 6 10+111 4 6 9+2=11

2 3

4+610 Thi gian sm nht ca nt bt u bao gi cng l 0

Ly s ngy ln hn

Nu s ngy ging nhau, ta ty chn mt s.

6 8 11+314 7 9+6=15 8

Ly s ngy ln hn. 15

1 2 0+44 2 5 4+26 2 4 4+59

4 7 9+09 5 6+1=7 7

Ly s ngy ln hn 9

V c bn, nu chng ta ly thi gian sm nht ca nt cng vi thi gian yu cu hon thnh hot ng tip theo, kt qu s l thi gian sm nht ca nt tip theo, ch tr trng hp nt tip theo yu cu nhiu hn mt hot ng phi c hon thnh. Trong trng hp ny, chng ta phi tnh ton v so snh i vi tt c cc hot ng. tm ra c thi gian ln nht yu cu. V l thi gian sm nht ca nt tip theo.
A
1 x

Hot ng
2 x+a 1 Thi gian sm nht ca nt + s ngy yu cu cho hot ng A = x + a

S ngy yu cu Trong tnh ton hng ti, chng ta t thi gian sm nht ca nt u tin l 0. Tip theo, v 2 hot ng A yu cu 4 ngy, cho nn thi gian sm nht nt l 4 ngy. Ni cch khc, cc hot 7 ng B, C, D c th bt u sau 4 ngy. Xt trng hp ti nt , hot ng G v hot ng gi hp li, ng A, C, hot ng gi mt 9 ngy hon thnh cn ti ng A, D, G ch mt 7 ngy 7 hon thnh. Nh vy, thi gian sm nht nt c tnh l 9. Hot ng I khng th bt u nu 7 nh hot ng gi v G cha hon thnh. Do , thi gian sm nht ti nt c th nhiu hn 9.

29 Thi gian sm nht ca nt: l thi gian m mt hot ng c bt u, khi m cc hot ng yu cu lm trc honh thnh nhanh nht c th.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

280

7. Tin hc ha v qun l

Tnh ton quay lui


8 By gi chng ta s tnh ton thi gian mun nht ca nt,30 bt u ti nt v tin hnh quay lui. Ti nhng nt m cc hot ng phn k (r nhnh), ly thi gian yu cu nh nht cho mi ng i tip theo t nt, thi gian ny s tr thnh thi gian mun nht ca nt . L do l v cc hot ng phn k ti nt , cho nn thi gian mun nht ca nt c xc nh bng cc hot ng bt u sm nht, thi gian mun nht ca nt c tnh ton v ghi vo ngn di ca hnh ch nht. 6 8 3 6 15-312

Thi gian mun nht cho nt bt u l 0.


1 2 4-4=0

12-111

Copy

9 8 11-6=5 2 4 9-5=4 2 6 8-2=6

5 7

Nh nht4

9-18

4 7 12-2=10 4 6 9-0=9

7 8 15-6=9

Nh hn9

V c bn, nu chng ta ly thi gian mun nht ca mt nt, tr i s ngy yu cu cho hot ng trc , chng ta c thi gian mun nht cho nt trc , tr trng hp nt trc c nhiu nhnh phn k.
1 2 Thi gian sm nht ca nt s ngy yu cu cho hot ng A

A a

2 Hot ng

x x-a S ngy yu cu

Bng cch tnh ton hng ti, chng ta xc nh s ngy yu cu hon thnh d n l 15 ngy. V ti nt cui cng, th thi gian sm nht v thi gian mun nht ca nt l ging nhau. S dng tnh ton quay lui, chng ta tnh ton c thi gian mun nht m mt nt phi bt u 8 d n hon thnh trong vng 15 ngy. V d, chng ta cn 15 ngy n c nt , hot ng H cn 3 ngy. Nh vy, hot ng H phi bt u mun nht l 12 ngy sau khi d n bt u. 4 Xem xt nt , nu chng ta xem xt ng F, H , chng ta thy hot ng H c th c khi to mun nht l 10 ngy (= 15-3-2) sau khi d n bt u. Tuy nhin, nu i theo ng hot ng gi, I th hot ng H phi c bt u 9 ngy (= 15 6) sau khi d n bt u. V vy, ti 4 nt , thi gian mun nht ca nt l 9.

30 Thi gian mun nht ca nt: l thi gian mun nht m nt c th bt u m khng nh hng n thi gian ca ton d n.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

281

7. Tin hc ha v qun l

ng gng
ng gng l ng ni cc nt m thi gian sm nht v thi gian mun nht ca nt l ging nhau. Cc hot ng trn ng gng u khng c php chm tr. Nu mt hot ng trn ng gng b tr th ton b thi gian yu cu cho d n cng s b ko di. Trong th trn th ng gng l
1 2 4 7 8 AC hot ng gi I ().

Khi nim rt gn lch biu


5 Trong th mi tn v d trn, xem xt nt , thi gian sm nht ca nt l 6 trong khi thi gian mun nht ca n l 8. iu ny c ngha l, hot ng G c th bt u sau 6 ngy bt u d n, tuy nhin cng c th chp nhn c nu hot ng G bt u sau 8 ngy. Ni cch khc, s c 2 ngy lng ph. Nh vy, thm ch hot ng G c th gim n 2 ngy, nhng thi gian ca ton b d n s khng gim.31

rt gn thi gian cho ton b d n, chng ta nht thit phi gim thi gian yu cu cho cc hot ng trn ng gng.

Cc hot ng gi
Mt hot ng gi l hot ng c biu th bng ng nt t. N c s dng ch ra mi quan h v thi gian gia hai hot ng. Nu hai hot ng gia hai nt c ch ra nh hnh di, th n khng ch ra mi quan h rng buc v thi gian gia hai hot ng, v vy ta thm vo mt hot ng gi th hin mi quan h ny.32
A
1 2 1

B
3

31 Nu thi gian yu cu cho mi hot ng c th gim i, th ng gng c th thay i. C mt v d l khi ta gim thi gian yu cu cho mt hot ng trn ng gng i 2 ngy, th thi gian yu cu ca ton b d n s gim i 1. Khi thi gian yu cu gim i mt s nt, thi gian sm nht v thi gian mun nht phi c tnh li. 32 (FAQ) C rt nhiu cu hi thi cho bn mt biu mi tn v yu cu bn tnh ton thi gian yu cu hoc tm ng gng. Nu bn ch cn tm thi gian yu cu, s dng tnh ton hng ti l phng php rt hiu qu. Tuy nhin, chng ta cng thng s dng phng php quay lui kim tra li kt qu tnh ton. Trong tnh ton quay lui, thi gian mun nht ca nt u tin bao gi cng bng 0, do nu kt qu khc 0, tc l bn tnh sai.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

282

7. Tin hc ha v qun l

7.3.3 Quy hoch tuyn tnh


im chnh
Mt bi ton qui hoch tuyn tnh c th c gii bng th nu hai bin s c cung cp. Khi nghim l mc sn xut hoc khi lng thc t, th kt qu khng th l s m (iu kin l khng m).

Qui hoch tuyn tnh(Linear programming (LP)) l phng php hiu qu tm ra gii php cho cc vn m iu kin rng buc cng nh hm mc tiu u l tuyn tnh. V d c th l n c s dng khi nguyn vt liu gii hn trong khi k hoch sn xut v chi ph vn chuyn cn phi c ti thiu ha.

Cc iu kin rng buc/Hm mc tiu


Xem xt tnh hung sau y:

33

sn xut 1 tn sn phm A, chng ta cn 4 tn nguyn liu P v 9 tn nguyn liu Q. i vi sn phm B, chng ta cn 8 tn nguyn liu P v 6 tn nguyn liu Q. Li nhun thu c khi bn 1 tn sn phm A, v B ln lt l 20,000 v 30,000 la. Tuy nhin, chng ta ch c 40 tn nguyn liu P v 54 tn nguyn liu Q. Vn l chng ta phi sn xut ra bao nhiu tn sn phm A v B tng ng thu c li nhun cao nht. Gi x, y ln lt l khi lng (tn) sn phm A v B cn sn xut, bng sau s tm tt cc thng tin trn: 1 tn sn 1 tn sn phm Khi lng nguyn phm A B liu cn trong kho 4 tn 8 tn 40 tn Cn bao nhiu tn 4x + 8y < 40 P? 9 tn 6 tn 54 tn Cn bao nhiu tn 9x + 6y < 54 Q Li nhun 20,000 la 30,000 la Hm mc tiu 2x + 3y cc i? T bng trn chng ta c: Cc rng buc: 4x + 8y < 40 9x + 6y < 54 x > 0, y > 0 Hm mc tiu: Z = 2x + 3y (iu kin khng m)34

33 Cc iu kin rng buc/Hm mc tiu: Cc iu kin rng buc l cc biu din lin quan n gii hn ca cc phn t, v hu ht c biu din bng cc bt ng thc. Hm mc tiu l biu din cc i ha li nhun, Qui hoch tuyn tnh l tm gi tr ln nht ca hm mc tiu tha mn cc iu kin rng buc. 34 (Gi ) iu kin khng m n gin l gi tr khng th m. y,do P v Q l khi lng nguyn liu tn kho nn n khng th m.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

283

7. Tin hc ha v qun l

Gii quyt vn
Trc tin,chng ta s chuyn cc bt ng thc rng buc thnh cc ng thc tng ng v v cc ng thng nh trong hnh ch ra.Cn ch thm hai iu kin qui nh gi tr khng m ca x v y: x > 0, y > 0. 4x + 8y < 40 9x + 6y < 54
y

4x + 8y = 40 9x + 6y = 54

1 x + 5. 2 2 y= x + 9. 3
y=

(0,9)

9x+6y=54

C (0,5)

B (4,3) Giao im ca 2 ng 4x+8y=40


O (0,0) A (6,0) (10,0) x

Nh vy, phn bn trong hnh t gic OABC l tp hp cc im tha mn tt c cc bt ng thc rng buc. V khng cn bit hm mc tiu l g, ta c nhn xt l ti mt trong cc nh ca a gic rng buc th hm mc tiu t gi tr cc i.35 Nh vy, ta ch vic nh gi gi tr ca hm Z ti cc nh ca a gic rng buc. O:Z A: Z B:Z C:Z =20+30 =26+30 =24+33 =20+35 =0 = 12 = 17 = 15

Gi tr ca Z ln nht ti B (x, y) = (4, 3). Vy, li nhun thu v s t cc i nu to ra 4 tn sn phm A v 3 tn sn phm B.36

35 (Ch ) Nghim ti u trong qui hoch tuyn tnh thng l giao im ca cc ng. Bn cn phi nm c gii h phng trnh tuyn tnh nh th no. 36 (FAQ) Tn s xut hin cc cu hi thi v qui hoch tuyn tnh l tng i cao.Nhng hu ht cc cu hi kim tra bui sng th tng i n gin,ch yu tp trung yu cu tm cc iu kin rng buc.Tuy nhin, cc cu hi bui chiu thng yu cu bn tm gii php.V vy, bn phi bit cc tm gii php thng qua th.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

284

7. Tin hc ha v qun l

7.3.4 Kim sot kho (OR)


im chnh
Cc phng php qun l hng tn kho bao gm phng php t mua theo chu k v phng php s lng t hng c nh. S lng ti u t hng khi c nhu cu khng thay i c th c thc hin theo cng thc t hng ti u (EOQ).

Kim sot kho l h thng qun l cc danh mc hng ha trong kho, bao gm sn phm v nguyn vt liu. Hot ng qun l kho bao gm hot ng t hng. C 2 phng php t hng: h thng t hng nh k v h thng t hng theo s lng c nh. Cng thc EOQ c s dng xc nh s lng hng ha cn mua da trn chi ph lu kho v chi ph t hng

Mc ch ca kim sot kho


Mc ch ca kim sot kho l tm ra phng php qun l lm ti thiu ha ton b chi ph kho, bao gm chi ph t hng v chi ph lu kho. Nu kho ln th gi lu kho s lm mt gnh nng. Tuy nhin nu chng ta thng xuyn phi t hng do khng lu kho th chi ph t hng c th tng. Chi ph t hng tng c nhiu nguyn nhn m trong c mt nguyn nhn l do bin ng v gi ca hng ha ti thi im hin ti.

Cc h thng t hng
C hai h thng t hng: h thng t hng nh k v h thng t hng theo s lng c nh. Trong h thng t hng nh k, chu k t hng c c nh v lng t hng thay i theo thi gian ty vo tnh hnh. Trong h thng t hng theo s lng c nh, s lng t hng l c nh cn chu k t hng s thay i. Bng di ch ra cc c im ca mi h thng.37 H thng t hng theo s lng c nh (H thng im t hng li) C nh Thay i Da vo d on nhu cu C nh Trng hp m n t hng Trng hp m n t hng khng theo khng theo qui lut khng th thc qui lut c th thc hin c hin c n gi cao n gi thp Cn qun l cht ch Khi lng trong mi n t hng ln C li ch trong t hng mt ln D dng kim sot hng tn kho (tit kim chi ph giao nhn) D dng ghi chp trn s ci hng tn kho. H thng t hng nh k

Chu k t hng S lng Mt Chu k hng


c im Qun l

37 (Gi ) H thng t hng nh k thng p dng cho lp A trong phn tch ABC. H thng t hng theo s lng c nh thng p dng cho lp cc sn phm B v C trong phn tch ABC.Gi ca cc sn phm lp A thng rt t, v vy phi gim gi thnh lu kho, do vic d on nhu cu phi c tin hnh rt cn thn.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

285

7. Tin hc ha v qun l

EOQ Cng thc lng t hng ti u


S lng ti u t hng khi nhu cu khng thay i c th c thc hin theo cng thc t hng ti u. t cc bin nh trong bng :

Bin M K P c x n

M t Nhu cu cho mt thi k c nh (hng nm) Chi ph t hng trn mt ha n n gi T l % chi ph tn tr38 S lng hng t trn mt ha n S lng n hng trong mt thi k c nh (hng nm)

Nu c n n hng c t trong mt nm v s lng hng ha trong mi n hng l nh nhau th ta c : Chi ph t hng = n K Nhu cu (M) = n x Nh vy, chi ph t hng = (MK) / x t x l s lng hng c t ti thi im chuyn hng. Mt ha n khc s c t khi hng ha trong kho tiu th ht. Vy lng hng tn kho trung bnh c th xem l x/2. Chi ph kho s l: Chi ph kho = (x / 2) P c = (xcP) / 2 Tng chi ph cho vic kim sot kho c tnh : Tng chi ph (T) = Chi ph t hng + Chi ph kho = (MK) / x + (xcP) / 2 Nu gi tr x = Q th T s nh nht, v vy gi tr ny c gi l lng t hng ti u. Trong th bn di, xem xt im m chi ph t hng bng chi ph kho, ti im ny lng hng ti u c tnh nh sau: (MK) / x = (xcP) / 2 x= Chi ph Chi ph kho Tng chi ph

2 MK / cP (x > 0)

Q: S lng t hng ti u
38

Chi ph t hng S lng t hng

T l % chi ph tn tr: L t l chi ph cn thit cho vic lu kho: n gi * t l chi ph tn tr = chi ph kho.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

286

7. Tin hc ha v qun l

7.3.5 Xc sut v thng k


im chnh
Phng sai v lch chun l o phn b d liu. Phn phi chun c s dng cho mc ch kim tra.

Xc sut l i lng c dng o kh nng xut hin mt s kin. V d, xc sut xut hin mt 1 khi reo mt con xc sc ng cht l 1/6. Thng k nghin cu tnh cht qui lut ca bi ton da trn cc d liu c th t tp cc mu th. thc hin thng k, vic cn thit l phi tnh cc s c trng, bao gm trung v, phng sai Khi tp mu th ca khng gian bi ton l ln th phi dng n phn phi chun.

Xc sut
Khi reo mt con xc sc ng cht, kt qu thu c s l mt mt vi s chm t 1 n 6. Cc s t 1 n 6 ny c gi l cc bin ngu nhin. Xc sut xut hin mt mt s l 1/6, tng cng s l 1. Xem xt v d sau y: Mt cng ty X mua cc sn phm t cc cng ty A, B v C, vi t l tng ng l 50%, 30% v 20%. Gi s rng t l xut hin sn phm li ca cc cng ty ln lt l 1%, 3% v 3%. Ly ngu nhin mt sn phm m cng ty X mua, v pht hin ra rng sn phm ny c li. Vy xc sut mua phi mt sn phm li ca cng ty A l bao nhiu? Gi s, cc sn phm mua t cng ty A chim 50%, t l sn phm li ca cng ty A l 1%. Nh vy t l xut hin sn phm c li ca cng ty A trong tng s sn phm mua ca cng ty X c tnh nh sau: T l sn phm li ca cng ty A trn tng s sn phm = 50% 1% ..(1) Tnh ton tng t,ta c: T l sn phm li ca cng ty B trn tng s sn phm = 30% 3% ..(2) T l sn phm li ca cng ty C trn tng s sn phm = 20% 3% ..(3) Tng (1), (2) v (3) l t l xut hin mt sn phm li trn tng s sn phm. Trong (1) l t l sn phm c li ca cng ty A trn tng s sn phm. Nh vy,xc sut xut hin sn phm c li trong tng s sn phm bng (50% 1%) / (50% 1% + 30% 3% + 20% 3%) = 50 / 200 = 0.25

Gi tr trung bnh, phng sai v lch chun


Nu xt mt mu th t khng gian mu, s c rt nhiu xu hng, qui lut c th c lng bng cch tnh ton cc c trng ca mu nh: gi tr trung bnh, phng sai v lch chun.39 V d, khi gi tr trung bnh ca mt mu c gi tr l 10, th chng ta c th c lng trung v ca khng gian mu cng l 10. t x l gi tr trung bnh ca mu x, V l phng sai v l lch chun.40 Ta c cc ng
39 Khng gian mu v mu th: Tt c cc tp d liu (b d liu) cn quan st bng phng php thng k c gi l Khng gian mu - Population, mt b d liu c ly t khng gian mu c gi l mt mu th. Khng gian mu thng rt ln v khng th quan st ht c, v vy phng php thng k da trn cc b d liu i din hay cc mu th. 40 K vng/Phng sai/ lch chun: Gi tr k vng hay k vng ton hc l gi tr trung bnh ca bin ngu nhin. Phng sai l o s bin thin ca bin ngu nhin. Nu phng sai l nh th gi tr d liu s tng i gn vi gi tr trung bnh (trung v). Cn bc hai ca phng sai c gi l lch chun.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

287

7. Tin hc ha v qun l

thc sau:
n x = 1 xi

n i=1

V=2= 1 {(xi- x )2} n i=1

hiu r hn cc cng thc trn chng ta hay lm mt v d: gi s cc gi tr ca 5 mu th c ly t khng gian mu c gi tr ln lt l : 3, 2, 7, 7, 6 Gi tr trung bnh = (3 + 2 + 7 + 7 + 6) 5 = 25 5 = 5 Phng sai = {(3 5)2 + (2 5)2 + (7 5)2 + (7 5)2 + (6 5)2 } 5 = (4 + 9 + 4 + 4 + 1) 5 = 22 5 = 4.4 = 4.4 = 2.0976 2.10 (lm trn n 2 ch s thp phn) 41

lch chun

Ngoi cc o trn, ngi ta cng dng cc o khc nh mode v trung v c lng cc vn lin quan n khng gian mu.42

Phn phi nh thc


Phn phi nh thc l phn phi xc sut ca bin ri rc, trong hm xc sut P(x) l xc sut s kin P xut hin ng x ln trong n ln th. R rng phn phi Bec-nu-li B(n,P) l mt trng hp c bit ca phn phi nh thc. Trong phn phi Bec-nu-li, mi php th ch c hai kt cc. K vng v phng sai V trong phn phi nh thc c tnh theo cng thc43: =nP V = n P (1 P)

Phn phi chun


Phn phi chun l phn phi lin tc, v n gn ging vi phn phi nh thc khi xc sut P nh v n ln. Phn phi chun k hiu l N( , 2), y l k vng, 2 phng sai. Tuy nhin trong thc t, ngi ta thng s dng phn phi chun rt gn hay phn phi chun chun tc. Mi phn phi chun u c th chuyn v phn phi chun rt gn bng mt php ton gi l php qui chun. Ta c : u = (x ) /
(Gi ) Tnh cht ca lch chun. lch chun khng thay i gi tr khi ta thm mt hng s a vo mi gi tr ca mt mu th. Khi nhn mi gi tr d liu ca mt mu th vi mt s a th lch chun cng tng gi tr ln a ln.. 42 Mode/Trung v: Mode l gi tr ca bin ngu nhin c tn sut xut hin nhiu nht trong mu th. Trung v l gi tr ng v tr gia khi cc mu th c sp xp. Nu s gi tr mu trong mu th l l th trung v chnh l phn t ng gia, nu s gi tr mu th l chn th trung v s l trung bnh cng ca hai gi tr ng gia. 43 (Ch ) Phn phi nh thc c s dng cho cc bin ngu nhin ri rc trong khi , phn phi chun l phn phi xc sut ca bin ngu nhin lin tc. Php qui chun s chuyn mt phn phi chun thnh mt phn phi chun chun tc. Bin ri rc l bin m gi tr ca n l ri rc, v d 2 mt ca mt ng xu (mt chn,mt l). Bin lin tc l bin c gi tr l lin tc, v d n v o di. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng -41

288

7. Tin hc ha v qun l

Trong , u l k vng ca phn phi chun rt gn, x l gi tr ca mu th. Chng ta hy xem mt v d v phn phi chun chun tc, v ch l phn phi chun chun tc c tch cht i xng. [Bng phn phi chun chun tc] u 0.0 0.5 1.0 1.5 2.0 2.5 3.0 P(u) 0.5000 0.3085 0.1587 0.0668 0.0228 0.0062 0.0013 [Phn phi chun chun tc]

P (u)

O u Trong phn phi chun chun tc, nu u = 2.0 th P(u) biu din phn din tch pha di ng cong tha mn 2.0 < u < . Nu u = 0.0 th n l din tch pha di ng cong tha

mn 0.0 < u < . V n chnh xc l mt na ca phn phi chun nn din tch l 0.5 (50%). Chng ta hy lm mt bi kim tra vi phn phi chun tc. Gi s kch thc ca mt sn phm c sn xut trong mt dy truyn sn xut c th l 200mm vi lch chun l 2mm. Chiu di ca mt sn phm t chun s l 200mm2mm. Chng ta hy tnh xc sut m mt sn phm b li. i vi loi sn phm ny, gi tr ca k vng ton l 200mm v lch chun l 2mm, phn phi chun N(200, 22). Bin ngu nhin c gi tr nm trong khong 2002 (chiu di sn phm trong khong 198mm n 202mm) c th chuyn sang phn phi chun chun tc nh sau : u(198) =

198 200 = 1.0 2

u(202) =

2002 200 = 1.0 2

Nh vy, mt sn phm c xem l tt nu kch thc nm trong khong -1.0 n 1.0 trong phn phi chun chun tc, v din tch gii hn bi ng cong phn phi chun vi gi tr bin ngu nhin nm trong khong t n 1.0 v t 1.0 n l xc sut sn phm c li. Trong bng phn phi chun chun tc gi tr ca P(u) ) = 0.1587 ng vi u = 1.0. Nh vy xc sut mt sn phm b li s l: 0.1587 2= 0.3174

H s tng quan.
Hai lc lng c gi l c mi tng quan vi nhau nu c mt xu hng lin kt hai lc lng vi nhau. Nu mt lc lng ny tng th lc lng kia cng tng, hoc lc lng ny tng th lc lng kia gim v ngc li. Mt gi tr xc nh mi tng quan gia hai lc lng c gi l h s tng quan. H s tng quan -1<r<0 0<r<1 r 0 r 1 Mc Tng quan m Tng quan dng Tng quan yu Tng quan mnh Gii thch Xu hng tri ngc nhau Xu hng tng t nhau Gn nh khng lin quan Lin quan rt gn gi.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

289

7. Tin hc ha v qun l

Cc biu bn di ch ra s khc nhau gia cc h s tng quan. r -1 -1 < r < 0 r 0 0<r<1 r 1

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

290

7. Tin hc ha v qun l

Cu hi nhanh
Q1 Q2 Gii thch phn tch ABC. T cc th sau y ch ra phn phi c phng sai ln nht? (a) (b) (c)

Tn s

Tn s

Lp d liu

Lp d liu

Tn s Lp d liu 291

A1

L phng php qun l kho m trong hng ha trong kho c nhm theo tng lp sn phm, trong mi lp li sp xp theo th t gim dn ca chi ph kho hoc doanh thu. Tng tch ly s c ch ra trn th kho c th c qun l thnh 3 nhm A, B v C. Cu tr li ng (c) (a) Tn sut gi tr d liu l gn ging nhau, do gi tr trung bnh cng gn vi trung v. Mt khc, tn sut d liu c gi tr sai khc nhiu gi tr trung bnh cao hn trong trng hp b, do phng sai trong trng hp ny ln hn trong trng hp b. Tuy nhin, tn sut d liu c gi tr sai khc nhiu gi tr trung bnh nh trong trng hp c, v th phng sai nh hn trong trng hp c. Trong trng hp ny, phn phi l phn phi chun, tn sut gi tr d liu tp trung gn gi tr trung bnh, v gim dn v c hai pha. Gi tr trung bnh cng gn trung v. Phng sai trong trng hp ny l nh nht. Tn sut gi tr khong gia thp, nhng phn phi l phn phi chun, gi tr trung bnh cng gn trung v. Tn sut gi tr v hai pha gi tr trung bnh cao hn so vi hai trng hp cn li, do phng sai trong trng hp ny l ln nht.

A2

(b) (c)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

7. Tin hc ha v qun l

7.4 S dng cc h thng thng tin


M u
Cc h thng thng tin a dng ang c s dng trong rt nhiu cng ty. Nhng h thng ny c th c phn loi thnh cc h thng sn xut c gii thiu thng qua FA, v cc h thng kinh doanh c gii thiu thng qua POS. .

7.4.1 Cc h thng sn xut


im chnh
FA vit tt ca t factory automation (t ng ho sn xut) CIM l mt h thng sn xut c tch hp bi my tnh. N l mt khi nim cha FA.

Mt h thng sn xut l mt h thng t ng ho qu trnh sn xut. Cc quy trnh sn xut thng thng c lung nh hnh v di y, v mt h thng sn xut h tr chng. MIS44
Lp k hoch qun l

CAP/MRP45
Lp k hoch sn xut

46

CAD
Thit k sn phm

CAPP47

Thit k quy trnh


CAM

iu khin quy trnh sn xut

CAP

CAE48

Lp lch FMS

FMC

Nghin c u v pht tri n

FA

By gi chng ta hy tm hiu cc thnh phn chnh

44 45 46 47 48

MIS: H thng thng tin qun l (Management Information System) CAP: Lp k hoch c h tr bi my tnh (Computer Aided Planning) MRP: Lp k hoch yu cu nguyn liu (Material Requirement Planning) CAPP: Lp k hoch quy trnh c h tr bi my tnh (Computer Aided Process Planning) CAE: Sn xut c h tr bi my tnh (Computer Aided Engineering)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

292

7. Tin hc ha v qun l

Thit k c h tr bi my tnh (CAD)


CAD cp n vic s dng mt nh dng tng tc thc hin cng vic thit k chi tit, bao gm hnh dng, kch thc nh ca mi b phn trong mt sn phm cng nh cc nguyn liu. N c s dng trong mt s lng ln cc lnh vc nh thit k my, thit k cu trc, v thit k bng mch in. Nhng phng php khc nhau cho vic thit k hnh dng ca i tng nh sau Phng php M hnh khung dy M hnh b mt M hnh c M t Phng php biu thc cho mt hnh dng 3 chiu, s dng cc nh v cnh. B mt c t gia cc ng. Biu din ng tng tc gia hai mt phng v cc mt ct i qua. Biu din phn c bn trong di cc b mt

CAD trong mt ngha rng c th cp n tt c cc tin trnh c h tr bi my tnh, nhng ni chung thut ng ny ch cp n h tr tnh ton lin quan n cc b mt v hnh dng ca cc b phn. r rng hn s khc bit ny, quy trnh ca vic thit k khi nim v nh gi phn tch c cp n CAE.49 50

nh gi phn tch

Thit k khi nim

CAE CAD trong ngha rng

Thit k quy trnh CAD

Thit k chi tit

V, ti liu

CAM

Sn xut c h tr bi my tnh (CAM51)


CAM l cng vic sn xut c s dng cc my tnh, c thc hin trong mt phm vi ln cc ng dng, t cc hot ng sn xut quy m nh n cc quy trnh sn xut quy m ln s dng cc ngi my. Bn cnh cc my tnh, cc my mc v thit b khc c yu cu trong cc quy trnh sn xut cng c xem xt bn trong phm vi ca CAM.

T ng ha sn xut (FA)
FA l mt h thng m tch hp v qun l hu c ton b cc h thng sn xut bao gm k hoch sn xut, t hng, sn xut, lp rp, kim tra, duyt, vn chuyn, lu tr v phn phi. Do
49 FMS H thng sn xut linh hot (Flexible Manufacturing System): N c ngha t ng ho cc dy chuyn sn xut ph hp vi a m hnh v m hnh linh hot, v cc sn xut s lng nh. N bao gm c cu sn xut, cc ngi my, ngi vn chuyn, phong tin vn chuyn t ng v thit b lu tr t ng. 50 FMC sn xut linh hot (Flexible Manufacturing Cell): N c ngha t ng ho cc qu trnh . Mt l mt n v nh nht ca sn xut v lp rp trong sn xut. 51 (Gi ) CAM nhn d liu t CAD ging nh chng tng tc vi cc thit b khc.CAM khi chun b d liu lnh sn xut. Trong thc t bi v CAD v CAM c quan h cht ch, chng c gi cng nhau l CAD/CAM.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

293

7. Tin hc ha v qun l

vy, FA bao gm tt c CAD, CAM v CAE, k c CAT52, lp rp, sn xut v iu khin quy trnh.

Sn xut c tch hp vi my tnh (CIM)


CIM l vic qun l v h tr s dng cc my tnh tch hp nghin cu v pht trin, thit k, sn xut, bn hng, v iu khin qun l. Trong khi FA l mt h thng lin quan n mt sn xut thc s, CIM bao gm cc iu khin khc nhau nh t hng, sn xut, gi cng; do vy n l mt khi nim khi qut hn FA.

7.4.2 Cc h thng kinh doanh


im chnh
POS c s dng nghin cu chiu hng bn hng mt sn phm n l; EOS c s dng cho cc t hng t ng. Ngn hng POS (Bank-POS) cho php mua sm s dng cc th tin.

Mt h thng kinh doanh l mt thut ng cp mt cch ton din n cc h thng ng dng qun l. N c s dng cho mc ch h tr cc hot ng chung, gia tng nng lc v hiu qu kinh doanh.

im bn hng (POS)
Mt h thng POS l mt h thng x l d liu mt cch trc tip (thi gian thc) ni d liu bn hng ging nh cc m sn phm v gi bn c a vo ti im bn hng thng qua mt thit b u cui c gi l u cui POS c t trong cc siu th v cc ca hng bn l. D liu c biu din thng qua cc k hiu OCR v cc m vch, cc thit b u cui POS c trang b vi mt u c OCR v mt u c m vch53.

H thng t hng in t (EOS)


Mt h thng POS c th thu c cc xu hng ca mi sn phm v da trn thng tin bn hng ny, mt EOS qun l mt cch ng n hng ha tn kho chc chn rng hng lu tr l v lng tn kho qu nhiu s c gim. Khi hng ha tn kho gim, d liu b sung lng hng trong siu th hay ca hng bn l c a vo thng qua thit b u cui, v c t hng trc tuyn trong thi gian thc n nh sn xut hoc tr s. Vic qun l t hng thng thng c cc vn nh sau:
52

CAT Kim tra c h tr bi my tnh (Computer Aided Testing): y l mt h thng trong cc my tnh c s dng qun l cc kim tra c im khc nhau trn cc b phn v sn phm trong sut qu trnh hon thnh ca sn phm. N c th cng cp n mt h thng trong cc my tnh c s dng duyt cc sn phm trong sut qu trnh sn xut. 53 (Gi ) Vic s dng mt h thng POS c th em li cc kt qu sau: thi gian ch i ngn hn ti im thanh ton, gia tng dch v khc hng, hiu qu bn hng tng ln, gim s nhn vin v t ng kim k. Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

294

7. Tin hc ha v qun l

Tn thi gian di t khi t hng n khi phn phi Chim thi gian di kim tra lng hng tn kho C kh nng xy ra sai st t hng i hi s hiu bit su v sn phm duyt sn phm.

EOS c xem l gii php ph hp nht gii quyt cc vn trn. Mi quan h gia cc h thng POS v EOS nh sau:
Nh cung cp

t hng t ng (EOS) Qun l kim k

Khch hng

H thng POS Qun l thu, tp hp thng tin

C s d liu

iu khin qun l

Qun l kho

Qun l khch hng

Ngn hng in t (Electronic Banking)


Ngn hng in t l mt h thng trong cc my tnh ca cc c quan ti chnh v cc my tnh hay thit b u cui ca cc c nhn hay cng ty c kt ni li thng qua cc ng truyn thng. Nh d liu nh chuyn khon v truy vn s d c thc hin. N bao gm cc dch v sau y. Tn Ngn hng cng ty (firm banking) Ngn hng gia inh (Home banking) Ngn hng Internet (Internet banking) M t Kt ni cc c quan ti chnh v cc cng ty. Chuyn khon nh chuyn gia cc ti khon v gi tin, Truy vn v vic gi v rt tin. Kt ni cc c quan ti chnh v cc c nhn Truy vn s d ti khon Chuyn khon nh chuyn gia cc ti khon v gi tin, ng dng cho gi thi gian c nh Cung cp cc dch v ngn hng trn Internet Cc my tnh c nhn c th c s dng kim tra s d, tr cc ha n s dng v chuyn tin..

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

295

7. Tin hc ha v qun l

Cc h thng th (Card Systems)


Cc h thng th gm nhng h thng c lit k trong bng di y. Chng c cung cp duy tr ti sn ca khch hng hay em li li nhun cho cc khch hng mi. Cc phng thc thanh ton v s cn thit mt ID ph thuc vo th. POS ngn hng (bank POS) c s dng nh cc th ghi n.54 Loi nh dng Mc ch Th POS ngn hng Dch v im Tr trc mt Tr sau, tr tt c Tr ngay lp tc. s lng tin, mt ln hay bi nhiu ln. khng tn. Gi ti sn Gi ti sn Thu ht khch Thu ht v gi ti sn khch hng khch hng hng khch hng Khng C C C C Khng Khng C C Th im Th tr trc Th tn dng

Chc nng nhn C dng55 Chc nng thanh Khng ton Chc nng bn ghi C

Phn mm nhm (Groupware)


Phn mm nhm l mt h phn mm c s dng giao tip v chia s thng tin mt cch hiu qu trong mt t chc v d nh mt cng ty56. Trong khi mt h thng kinh doanh qun l cc nhim v thng xuyn phm vi ln ca cng ty, phn mm nhm c s dng a ra quyt nh trong cc loi nhim v khng thng xuyn ging nh kim sot lp lch hp. thc hin cng vic cng tc trong mt nhm hiu qu hn, n s dng hiu qu cc my tnh c nhn v mng. V d mt nhm c th s dng mt PC-LAN gi v nhn cc th in t, qun l lch cng vic v lch hp, truyn thng trong mt nhm ly cc cng vic cng tc c lm. Cc cng c trong phn mm nhm bao gm: Cc cng c ca phn mm nhm
Th in t Bn tin in t Chia s d liu (cc ti liu, d liu) iu khin lch Lung cng vic Gi v nhn cc th ca cc c nhn Truyn thng trong mt s gii hn ngi Trao i cc kin gia nhiu thnh vin. C s d liu iu khin lung ti liu

Th ghi n (Debit card): L mt dch v m mt th tin mt c pht hnh bi mt ngn hng c th c s dng thanh ton khi mua sm. Lng tin gim c gim ngay tc thi trong thi gian thc t ti khon ngn hng. 55 (Gi ) Chc nng nhn dng l chc nng xc minh s ng nht c nhn. Chc nng thanh ton l kh nng thc hin thanh ton ging nh tin mt (chi phiu). V d mt th tr trc khng c chc nng nhn dng do vy th tr trc c th mua.Chc nng bn ghi lin quan n kh nng mt th c th lu gi mt bn ghi trn chnh n. 56 (Gi ) ngha gc ca phn mm nhm l mt cng vic c cng tc thng minh. Tuy nhin bn thn cng vic ca con ngi l mt phn mm nhm. Do vy n c nhn nhn li, thut ng ny gi cp n mt h thng m h tr cc cng vic cng tc trong mt t chc thng qua vic s dng my tnh, bng vic cung cp cc dch v khc nhau trn mng li bao gm th in t, bn tin in t, phng tho lun

54

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

296

7. Tin hc ha v qun l

Truyn thng PC (PC Communication)


Truyn thng PC ngha l vic kt ni cc PC li bi ng truyn thng n mt my tnh ch cung cp mt mng cc truyn thng PC, do cc PC c th truyn thng vi mt PC khc v nhn cc dch v khc nhau, bao gm th in t, bn tin in t, cc phng tho lun in t, v cc dch v thng tin57. Trong cc dch v cung cp thng tin, tt c loi thng tin c cung cp nh tin tc, d bo thi tit, cp nht tin th thao, cp nht tin th trng, thng tin hp tc v cc qung co rao vt.

Cc c s d liu thng mi (Commercial Databases)


Mt c s d liu thng mi l mt c s d liu cung cp vi l ph cc thng tin kinh doanh ging nh thng tin v mt cng ty, thng tin lin quan n khoa hc cng ngh, v thng tin sng ch. Ni chung, dch v ny s dng cc c s d liu thng qua mt ng truyn thng ging nh dch v truyn thng PC58l

Cu hi nhanh
Q1 Q2 Gii thch CAD. Tn ca h thng th trong vic thanh ton c th c thc hin bi mt ngn hng pht hnh th tin mt v tin c tr ngay lp tc.

A1

CAD l mt h thng m to thnh h thng FA. N l h thng s dng cc my tnh, cc my v t ng, hin th v nhng thit b khc thc hin cc nhim v thit k v v trong mt nh dng tng tc mt cch t ng. POS ngn hng bank POS (th ghi n - debit card)

A2

57 (Gi ) Truyn thng PC v Internet ging nhau trong vic chng u cung cp cc dch v thng qua cc ng truyn thng. Tuy nhin trong truyn thng PC, mt cng ty cung cp truyn thng PC c mt my ch c ci t v cc dch v c cung cp thng qua my ch ny. Trong khi Internet khng c mt my ch c ch nh. 58 (Gi ) Mt trong nhng phng tin truyn d liu gia cc cng ty l EDI (trao i d liu in t -Electronic Data Interchange). EDI l mt nh dng d liu c chun ha cho thng mi in t v cc th tc ca n.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

297

7. Tin hc ha v qun l

7.

Cu hi 1
kh: ** Tn sut: **

Q1.

p n no sau y m t ph hp s pht trin ca mt k hoch h thng thng tin tng th? a) b) c) d) CIO tp hp tt c cc yu cu h thng ha t mi b phn ngi s dng v cc xut pht trong s phi hp, bt u vi nhng th m c th c khi u ngay lp tc. CIO to ra cc iu chnh lin quan n k hoch kinh doanh, nghin cu cc xu hng cng ngh... v thit lp mt k hoch tng th ging nh mt k hoch thi gian trung bnh/di. Tip CIO thu c s tn thnh v h tr cho k hoch t qun l cp trn. Nhng ngi lnh o trong cc b phn ngi dng ring l lm vic nh nhng thnh vin kha (key member) v hp nht cc k hoch ring l thnh mt k hoch tng th. Cc chuyn gia trong cc lnh vc vin thng b phn cc h thng thng tin pht trin mt k hoch tng th, a ra s cn nhc cc cng ngh tin phong.

p n cu 1
p n ng: b
K hoch tng th ca mt h thng thng tin yu cu thit lp cc chin lc v cc mc tiu ca h thng thng tin v m t ton b phm vi i tng c bao gm trong h thng mt nh dng phc tho. Cc chnh sch ging nh t chc ca kin trc h thng, cc nhim v tng xng v cng ngh thng tin tr ln d hiu, ton b lch c thit lp v cc hiu qu u t tng xng c nh gi. CIO (Gim c thng tin) l nhn vin cp cao nht trong vic ph trch mt h thng thng tin. T quan im qun l mc cao nht, CIO thit lp mt k hoch t trung bnh n di. CIO cng qun l vic thi hnh k hoch vi s tn thnh v ch th t qun l cp cao nht CEO (Gim c qun l). Ni chung, nhn vin trong vic ph trch b phn cc h thng thng tin tr thnh CIO. CIO khng ch i hi c hiu bit v cc h thng thng tin m cng chu trch nhim trong vic xy dng cc chin lc tin hc ha; do vy ngi phi c s hiu bit phm vi rng v k ngh tng th, v kinh doanh ca cng ty, v cc chc nng qun l tng th. a) CIO c th tp hp yu cu cc h thng thit lp cc chin lc tin hc ha, nhng khng phi l nhim v chnh ca CIO c) K hoch tng th khng c hnh thnh bi vic tng kt cc k hoch ring l khc nhau n t di ln. Thay vo k hoch c thit lp t trn xung v c thi hnh. d) K hoch tng th c thit lp bi CIO. Cc chuyn gia trong cc cng ngh thng tin mi b phn thc thi k hoch di d qun l ca CIO.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

298

7. Tin hc ha v qun l

Cu hi 2
Q2.

kh: **

Tn sut: **

Gi bn tnh theo nghn USD cho k hin ti l bao nhiu nu gi nh gi sn phm trong kho bt u k l 20.000 USD, cc chi ph sn phm l 100.000 USD v gi nh gi sn phm trong kho cui k l 30.000 USD? a) 50 b) 70 c) 90 d) 110

p n cu 2
p n ng: c
Gi bn l chi ph phi gnh cho gi ca sn phm. Trong trng hp ny, n l tng cng cc chi ph phi tr cho sn phm c bn. Gi nh gi sn phm trong kho bt u k l gi tr nh gi cc sn phm trong kho ti thi im bt u k. Cc chi ph sn phm trong k l gi chi ph ca cc sn phm c mua trong sut k ny. Gi nh gi sn phm trong kho cui k l gi tr nh gi cc sn phm trong kho ti cui k. Do vy gi sn phm c bn trong sut thi k l gi nh gi sn phm ti u k cng vi cc chi ph sn phm tr i gi nh gi sn phm cui k. Do vy gi bn Gi bn = Gi sn phm nh gi u k + Cc chi ph sn phm trong k Gi sn phm nh gi cui k. = $20K + $100K $30K = 120 30 = 90 (nghn USD).

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

299

7. Tin hc ha v qun l

Cu hi 3
kh: ** Tn sut: **

Q3.

Pht biu no sau y m t ph hp vi mt im ha vn? a) b) c) d) Nu cc chi ph c nh khng thay i, im ha vn gia tng khi t s gi bin thin gim. Nu cc chi ph c nh khng thay i, im ha vn gim mt na khi t s gi bin thin gim mt na t mc ban u ca n. Gi bn ti im ha vn bng tng chi ph c nh v bin thin. Nu t s gi bin thin khng thay i, im ha vn gia tng khi chi ph c nh gim.

p n cu 3
p n ng: c
Mt im ha vn l mt im trong gi bn v ph tn l bng nhau, cho bit rng li nhun l 0. Nu gi bn trong sut mt thi k xc nh nh hn gi bn ti im ha vn, kt qu l l, nu chng ln hn, kt qu l li nhun. Trong phn tch im ha vn, trng tm c t mi quan h gia chi ph c nh v chi ph bin thin. Chi ph c nh l cc ph tn vi mt gi tr c nh khng lin quan n cc thay i trong gi bn. Chi ph ny bao gm t, hp ng cho thu, khu hao, ph bo him, ha n bt ng sn...Chi ph bin thin theo mt mt khc l cc ph tn m cc thay i c mi quan h vi gi bn, v d chng bao gm chi ph nguyn liu. Gi s S l gi bn, F l chi ph c nh, V l chi ph bin thin v P l li nhun (li nhun cui cng). Mi quan h nh sau: Li nhun = Gi (chi ph c nh + chi ph bin thin) => Gi = Chi ph c nh + chi ph bin thin + li nhun: S = F + V + P (1) Chi ph bin thin V l cc ph tn t l trc tip vi gi bn, do vy nu hng s t l l v, khi chng ta c biu thc sau: V = vS (v l t s gi bin thin) (2)

Thay (2) vo (1) chng ta c S = F + vS + P (3)

Ti (1) hay (3) chng ta c th tm ra gi bn S m to ra li nhun P bng 0, v s l im ha vn Gi bn im ha vn

Chi phi co dinh F = 1- V / S 1- chi phi bien thien / gia ban chi phi co dinh F = = 1- v 1- ti so gia bien thien
=
300

(4)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

7. Tin hc ha v qun l

Mt biu th hin im ha vn c gi l biu im ha vn. Trong biu , gi bn ti im m ng chi ph bin thin v ng gi bn ct nhau l im ha vn. Chi ph ng gi Li nhun im ha vn ng chi ph tng Chi ph bin thin ng chi ph c nh
L

Chi ph tng

Chi ph c nh Gi bn im ha vn Gi bn

Nh trong biu trn, nu gi bn thp hn gi bn im ha vn, khi l; ngc li nu gi bn ln hn gi bn im ha vn, s c li nhun. Gi bn im ha vn l gi bn m c li nhun bng 0, do vy li nhun trong biu thc (1) bng 0. Ni mt cch khc gi bn bng vi tng chi ph c nh v chi ph bin thin. a) Trong cng thc tm gi bn im ha vn, nu chi ph c nh khng thay i v t s chi ph bin thin gim, mu s tng (1-t s chi ph bin thin), do vy gi bn im ha vn gim. b) Thay 0.5 vo v trong biu thc (4) cho gi bn im ha vn, v sau so snh rng kt qu khi bng 0.25 (bng ca 0.5, t s chi ph bin thin u tin). Ch rng kt qu khng c chia u. Gi bn im ha vn (v = 0.5) S0.5 = F (1 0.5) = 2F Gi bn im ha vn (v = 0.25) S0.25 = F (1 0.25) 1.333F d) Trong mt biu thc tm gi bn im ha vn, nu chi ph c nh gim trong khi t s gi bin thin gi khng i, t s gim, gi bn im ha vn gim.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

301

7. Tin hc ha v qun l

Q4.

kh: ** Pht biu no di y l mt m t ph hp cho phn tch ABC?

Cu hi 4

Tn sut: ***

a) b) c) d)

D liu ging nh cc b sn phm c mua bi khch hng c phn tch da trn thng tin gi bn thu c thng qua mt h thng POS Mt vng c xc nh bi s phn chia thnh mt li vi kinh v v xc nh c phn tch mt cch chi tit bi vic tp hp v phn tch d liu khc nhau bao gm sc mua v dn c. Vi mt mc tiu xc nh, mt vng c chia thnh 3 ni v cc quan im chnh c la chn cho mi ni. Cc kho st c thc hin lp li xc nh xu hng v tnh hnh ca vng. Cc sn phm c sp xp bi gi bn hay li ch c c theo th t gim dn. Da trn t l tch ly chng, cc sn phm c phn loi thnh 3 hng, v phn tch sn phm c thc hin xc nh cc sn phm bn chy nht.

p n cu 4
p n ng: d
Phn tch ABC l mt phng php trong lng hng trong kho c nhm theo cc mc sn phm v sau mi nhm c sp xp theo th t gim dn bi gi trong kho ( t s cu hnh kho) hay tng thu bn hng (t s cu hnh tng thu bn hng); tng tch ly c tnh ton kho c th c qun l cho mi mc sn phm. Kt qu phn tch ABC c biu din trong mt biu Pareto. Trong phn tch ABC, kho c phn chia thnh 3 nhm: Nhm A c qun l chu o trong khi nhm B v C c qun l vi u tin thp hn tng i. iu ny l da trn nguyn tc Pareto, trong cc trng thi cho nhiu s kin, ch c mt s t cc nhn t c tc ng ng k, trong khi phn ln cc nhn t c tc ng rt t. 100% Mc 90% A Gi trong kho B C Mc 70% Tch ly %

Nh ch ra trn biu , cc nhm mc c lit k theo th t gim dn ca gi (t s cu hnh). Mt ng cong c v bi ni cc tng tch ly. Cc mc c nhm ging nh nhm A cu thnh khong 70% t s cu hnh, nhm B gia 70 - 90%,, v nhm C l phn cn li. Cc phng thc qun l khc nhau c thc thi cho mi nhm.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

302

7. Tin hc ha v qun l

Ni chung nhm A nhn c s quan tm qun l cht ch, v cc h thng t hng nh k c thc hin. Vi nhm B, cc h thng t hng s lng c nh s dng cng thc EOQ c thc hin. Vi nhm C h thng t hng s lng c nh trong mt t hng c thc hin khi kho i n mt mc no , hoc h thng 2-bin c s dng. a) y l mt gii thch cho phn tch gi (phn tch mua ng thi). Phn tch gi xc nh kh nng bn bng vic phn tch sn phm no v xu hng sn phm no c mua cng vi nhau (v d chng l mt quan h). V d quan h c bit: trong cc siu th bia v khn dng mt ln thng c bn ng thi. N c pht hin khi nam gii thng mua cc khn sau khi mua bia. Do vy khi mt ca hng t khn v bia gn nhau, vic bn hng gia tng. Bng vic tm ra cc quan h, s lng mt sn phm dng nh khng lin quan n sn phm chnh yu c th c m rng v lng bn gia tng. iu ny n t tng xem xt k n gi mua sm ca khch hng. tm cc quan h. Phn tch gi c s dng trong cc lnh vc khc nhau ging nh phn tch d liu mua hng trong kinh doanh bn l v s phn tch quan h trong cc yu cu la chn ca cc cng ty dch v in thoi. b) y l mt gii thch ca s trnh by thng qua bng. c) y l mt gii thch v phng php Delphi v cc cc kho st lp li c cp. Phng php Delphi l mt k thut lp k hoch logic c s dng trong lp k hoch tng lai di hn v lp k hoch cng ngh. N c phn loi di cc phng php trc gic. Cc phng php trc gic l cc phng php lp k hoch hoc d on da trn cc kinh nghim v hiu bit ca con ngi. Phng php Delphi c cc u im trong c tnh phn hi. Trong phng php ny, cc la chn ca mt s lng ln ngi c tp hp v phn tch thng qua bn cu hi, kt qu ca kho st c tng kt, c a ra cho ngi kho st v sau qu trnh kho st c lp li. Phng php ny c nhiu u im. u tin, n hiu qu khi k hoch khng th d on v s thay i cng ngh khng th tin hnh khi n thc hin mt phng php trc gic. N cng c th gip trnh cc nh hng bi tp cc thay i n t cc cuc gp i thoi chnh thc. Thm vo , khi mt kt lun t kho st khc vi quan im a s, cc quan im mi cha c gi tr.vn c th c s dng t cc l do c thm vo bi bn yu cu. Do vy s trnh by v la chn trong cc cu hi kho st l quan trng n s thnh cng ca phng php ny.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

303

7. Tin hc ha v qun l

Cu hi 5
kh: ** Tn sut: ***

Q5.

Bng di y ch ra s thay i thi tit mt khu vc c th. V d trong ngy sau ngy tri trong, c 40% kh nng thi tit l trong, 40% kh nng thi tit l my v 20% kh nng thi tit l ma. Nu s thay i thi tit l mt chu trnh Markov, kh nng thi tit trong 2 ngy sau khi ma l bao nhiu? n v: % Tri trong ngy Tri my ngy Tri ma ngy tip theo tip theo tip theo 40 40 20 30 30 b) 27 40 50 c) 30 30 20 d) 33

Trong My Ma a) 15

p n cu 5
p n ng: d
Chu trnh Markov c ngha xc sut mt s kin xut hin ti mt thi im xc nh ph thuc vo cc s kin xy ra trc . Trong mt chu trnh Markov, tm ra xc sut ca mt s kin trong tng lai da trn cc xc sut ca cc s kin trong qu kh, chng ta cn quay lui li thc hin mt s hu hn bc. Trong chu trnh Markov n gin ny, chng ta ch cn quay lui li mt bc. Xc sut thi tit trong hai ngy sau mt ngy ma nh sau: ma ma ma ma trong my trong: 0.2 0.3 = 0.06 trong: 0.3 0.4 = 0.12 trong: 0.5 0.3 = 0.15

Do vy xc sut cn tnh bng 0.06 + 0.12 + 0.15 = 0.33 33(%)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

304

7. Tin hc ha v qun l

Cu hi 6
Q6.

kh: **

Tn sut: ***

Trong biu sau y, sau khi xem xt li tng hnh ng th ngi ta thy rng ch c hnh ng D c th c gim xung thnh 3 ngy. Nh vy c th gim xung tt c bao nhiu ngy nu hon thnh tt c cc hnh ng (t A n H)? ng chm chm di y biu din mt hot ng gi.
E (3 ngy)

B (3 ngy) 1 A (5 ngy) 2

G (3 ngy) 7

D (10 ngy) F (12 ngy)

C (5 ngy)

H (6 ngy)

a) 0

b) 1

c)

d) 3

p n cu 6
p n ng: b
Ta tnh thi gian sm nht ti mi nt trc v sau khi rt ngn. Gi s rng hnh ng gi ch chim 0 ngy. 1. Thi gian sm nht trc khi rt ngn Mi con s biu din sau y th hin thi gian sm nht ti nt tng ng:
20
B (3 ngy)

E (3 ngy)

23
5
G (3 ngy)

0
1

A (5 ngy)

2
C (5 days)

D (10 days) F (12 ngy)

7
H (6 ngy)

5
3 6

10

23

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

305

7. Tin hc ha v qun l

2. Thi gian sm nht sau khi rt ngn Bng cch gim s ngy thc hin hnh ng D xung 3 ngy (t 10 xung 7 ngy), thi gian sm nht ti cc nt c t m thay i.

17
B (3 ngy) A (5 ngy)

E (3 ngy)

20
5
G (3 ngy)

0
1

2
C (5 ngy)

D (10 ngy) F (12 ngy)

7
H (6 ngy)

5
3 6

10

22

V th, xt tng qut th thi gian c th gim khi hon thnh ht cng vic l 1 ngy.

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

306

7. Tin hc ha v qun l

Q7.

kh: * Tn sut: *** Khi nim no sau y cung cp s h tr ton din cho mt lot cc tc v lin quan n sn phm thng qua vic s dng my tnh?

Cu hi 7

a) CIM

b) EOS

c)

OA

d) POS

p n cu 7
p n ng: a
a) CIM (Sn xut tch hp my tnh) l khi nim v qun l tch hp, s dng my tnh trong mi phng din ca cng vic sn xut bao gm c qun l t hng nguyn liu, qun l sn xut, v qun l qui trnh. y l mt khi nim rng hn so vi FA v bao gm c cc thnh phn ca FA v CAD/CAM/CAE

b) EOS (H thng t hng in t): l mt h thng nhm h tr d tr hng ti kho mt cch hiu qu v gim cc mt hng tn kho d. H thng POS phn tch cc xu hng bn hng cho mi sn phm v thng tin ny c th c dng h tr d tr hng ti cc nh kho. c) OA (T ng ha vn phng): l tng s dng cc my v trang b vn phng chng hn nh cc my trm v cc b x l vn bn nhm nng cao hiu qu x l thng tin trong cc vn phng. POS (im bn hng): l mt h thng thu thp v phn tch cc thng tin bn hng mt cch trc tip (trong thi gian thc) ti cc im thu tin. Cc m vch c gn hoc c in ln sn phm c c bi my c m vch v thng tin c thu li mt cch t ng.

d)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

307

7. Tin hc ha v qun l

Q8.

kh: * Tn sut: *** H thng no sau y c dng trao i thng tin gia cc cng ty v c s dng trong Thng mi in t?

Cu hi 8

a) CA

b) EDI

c)

SET

d) SSL

p n cu 8
p n ng: b
EDI (Electronic Data Interchange) (Trao i d liu in t): xc nh nh dng d liu cho vic trao i d liu in t trn mng v cc th tc sao cho thng mi in t c th c thc hin gia cc cng ty khc nhau. a) CA (Certificate Authority) (T chc thm quyn cp bng): l mt t chc c quyn chng nhn mt kha cng khai l hp l trong thng mi in t khi m ch k s da trn phng php m ha kha cng khai c s dng. SET (Secure Electronic Transactions) (Giao dch in t an ton): L bn m t v vic x l cc thanh ton trn mng Internet mt cch an ton. Bn m t ny c pht trin bi t chc Visa International (H chiu quc t) hp tc vi MasterCard International (Th MasterCard quc t) ti M. SSL (Secure Sockets Layer) (Tng cm an ton) l mt giao thc an ton gia mt phc v WWW v mt trnh duyt WWW. N cho php xc thc v m ha bng vic kt hp m ha kha cng khai v kha c nhn.

c)

d)

Ti liu n thi FE Tp 1
-- Phn 1. n tp phn thi bui sng --

308

Bi thi th FE(Bui sng)

Phn 2

TP BI THI TH

Phn ny bao gm mt b y cc cu hi thi FE (Bui sng v bui chiu) bao gm cc cu hi c s dng trong cc bi thi trc y. Mi cu hi u c cu tr li v li gii thch tng ng.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

309

Bi thi th FE(Bui sng)

Bi thi th (Bui sng)


K s CNTT c bn

Cc cu hi cn c tr li theo quy nh di y:

S lng cu hi La chn cu hi Thi gian thi

Q1 - Q80 Tt c cc cu hi u bt buc phi tr li 150 pht

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

310

Bi thi th FE (Bui sng) p n v Gii thch -

Q1.

Trong cc s thp phn sau, s no c th biu din di dng du phy ng nh phn m khng c li lm trn s? a) 0.2 b) 0.3 c) 0.4 d) 0.5

Q2.

Cho mt s nguyn khc khng vi s ch s vit trong h thp phn l D, s ch s vit trong h nh phn l B. Trong cc biu thc sau, biu thc no th hin ng v mi quan h gia D v B? a) D c) D 2 log10 B B log2 10 b) D d) D 10 log2 B B log10 2

Q3.

Biu thc hoc gi tr s no sau y biu din mt s nh phn n ch s gm ton s 1, 1111111. y, s m c biu din theo dng b hai. a) (2n-11) b) 1 c) 0 d) 2n 1

Q4.

Khi cng hoc tr cc s nguyn c thc hin bng my tnh th cn phi ch n li trn s (overflow). T hp no sau y a ra tt c cc php ton c th gy trn s? Php ton x+y x+y x+y x+y xy xy xy xy b) B, C, E, H Ton t x Dng Dng m m Dng Dng m m c) B, E Ton t y Dng m Dng m Dng m Dng m d) C, E, H

A B C D E F G H a) A, D, F, G Q5.

Thi gian tnh ton tm ra li gii cho mt h phng trnh tuyn tnh trn my tnh t l vi ly tha bc ba ca s n s trong cc phng trnh . gii h phng trnh tuyn tnh gm 100 n s th mt my tnh cn thi gian l 2 giy, vy cn bao nhiu giy mt my tnh vi tc x l nhanh gp 4 ln c th gii mt h phng trnh tuyn tnh vi 1000 n s? a) 5 b) 50 c) 500 d) 5,000

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

311

Bi thi th FE (Bui sng) p n v Gii thch -

Q6.

Cho mt m gm 8 bit th bit quan trng nht l bit chn l. Trong cc php ton vi bit sau y, php ton no c s dng ly 7 bit thp cn li? a) AND vi s thp lc phn 0F b) OR vi s thp lc phn 0F c) AND vi s thp lc phn 7F d) XOR (loi tr OR) vi s thp lc phn FF

Q7.

Kt qu ca mt cuc gim nh 100 b phn nh sau: c 11 b phn gp s c A, 7 b phn gp s c B v 4 b phn gp s c C. Ngoi ra, 3 b phn gp c hai s c A v B, 2 b phn gp c hai s c A v C v khng b phn no gp c 2 s c B v C. Hi c bao nhiu b phn khng gp s c no? a) 78 b) 83 c) 85 d) 88

Q8.

Trong s nhng bng chn l di y, bng no biu din cng thc logic Z = X Y + X Y ? Trong , l php nhn logic, + l php cng logic v A l php ly ph nh logic ca A . a) X 0 0 1 1 c) X 0 0 1 1 Y 0 1 0 1 Z 0 1 1 1 Y 0 1 0 1 Z 0 0 0 1 d) X 0 0 1 1 Y 0 1 0 1 Z 1 0 0 1 b) X 0 0 1 1 Y 0 1 0 1 Z 0 1 1 0

Q9.

Cn t nht bao nhiu bit biu din duy nht cc ch ci in hoa ting Anh (t A n Z) v cc k t s (t 0 n 9) vi cng s bit? a) 5 b) 6 c) 7 d) 8

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

312

Bi thi th FE (Bui sng) p n v Gii thch -

Q10. Xu k t no trong s cc xu sau c on nhn bi automat hu hn trong biu di? K hiu nhn. ch trng thi ban u v k hiu ch trng thi c on

1 0 0 0 0

1 0,1 1

a) 01011 Q11.

b) 01111

c) 10111

d) 11110

Biu c php di y biu din mt c php nht nh. Cc biu din dng s nh -100, 5.3, +13.07 u tun theo c php ny.

Numeral

Numeral

Da trn k php ny, biu din dng s no sau y tun theo c php c th hin trong hnh di?

Numeral

Numeral

Numeral

a) .9

b) 5.2E07

c) 9.89E

d) +1.E4

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

313

Bi thi th FE (Bui sng) p n v Gii thch -

Q12. Khi duyt cy nh phn, c 3 phng php khc nhau ph thuc vo th t duyt. (1) Th t trc: Duyt theo th t ca nt, cy con tri, v cy con phi (2) Th t gia: Duyt theo th t cy con tri, nt, v cy con phi (3) Th t sau: Duyt theo th t cy con tri, cy con phi v nt Khi cy c minh ha di y c duyt theo th t trc, hy cho bit u l chui cc gi tr nt u ra?
a

b c h i d j f

e g k

a) abchidefjgk c) hcibdajfegk

b) abechidfjgk d) hicdbjfkgea

Q13. Hai thao tc vi stack c nh ngha nh sau: PUSH n : y d liu (s nguyn n) vo stack POP: Ly d liu ra khi stack Khi dy cc thao tc vi stack di y c thc thi trn mt stack rng, kt qu no s c to ra?
PUSH 1 PUSH 5 POP PUSH 7 PUSH 6 PUSH 4 POP POP PUSH 3

a) 1 7 3

b) 3 4 6

c) 3 7 1

d) 6 4 3

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

314

Bi thi th FE (Bui sng) p n v Gii thch -

Q14. La chn no di y m t c trng ca phng php bm c s dng trong qu trnh tm kim bng? a) Phng php bm l tn gi khc ca mt phng php s dng cy nh phn b) Phng php bm l mt phng php trong khng c s xung t trong vic tm kim v tr lu tr. c) Phng php bm quyt nh v tr lu tr da vo gi tr hm ca kha. d) Thi gian yu cu cho vic tm kim t l vi kch thc ca ton b bng. Q15. Gii thut sp xp no c minh ha trong lu di y?
Bt u S lng mc Lp

Tro i

Tro i

Lp Kt thc

a) Sp xp phn on c) Sp xp chn

b) Sp xp gim dn d) Sp xp ni bt

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

315

Bi thi th FE (Bui sng) p n v Gii thch -

Q16. Trong nhng cu sau, cu no m t ph hp v b nh flash? a) Khng yu cu lm ti theo nh k duy tr thng tin c lu tr, v tt c hoc mt phn thng tin c th b xa v ghi bng in. b) Tt c cc thng tin c lu tr c th b xa bng nh sng t ngoi v ghi . c) Do c th c d liu vi tc cao nn thng c s dng nh b nh cache. d) Yu cu lm ti theo nh k v c s dng rng ri nh l b nh chnh. Q17. Mch logic no di y vi 2 u vo v 1 u ra c th cho u ra X = 0 ch khi c 2 u vo A v B u bng 1 ?
A X B

a) Mch AND c) Mch OR

b) Mch NAND d) Mch XOR

Q18. Trong mt my tnh, mt lnh c thc thi theo th t t bc 1 n bc 6 nh trong bng di. Hi phi mt bao nhiu nano giy thc thi 6 lnh s dng x l ng ng lnh nh trong hnh di? Bit rng, thc hin mi bc mt 10 nano giy v khng c lnh no nh lnh nhy, lnh r nhnh b dng trong x l ng ng lnh.

Bng cc bc thc hin lnh


Bc 1 2 3 4 5 6 Nhn m lnh Gii m lnh Ly a ch Tnh a ch hiu lc Nhn d liu Thc thi lnh Lnh 1 1 2 1 3 2 1 4 3 2 5 4 3 6 5 4 6 5 6

Lnh 2

Lnh 3

Hnh. X l ng ng lnh thc thi cc lnh

a) 50

b) 60

c) 110

d) 300

Q19. Cng ngh no di y ph hp vi mt h thng a phng tin m cho php mt lnh thc thi thao tc nh nhau trn 2 hoc nhiu d liu mt cch ng thi? a) MIMD
Ti liu n thi FE Tp.1
-- Phn2. Tp bi thi th --

b) MISD
316

c) SIMD

d) SISD

Bi thi th FE (Bui sng) p n v Gii thch -

Q20. Thi gian thc hin lnh trung bnh ca mt my tnh l 0.2 sec. Hiu nng theo thut ng MIPS ca my tnh ny l bao nhiu? a) 0.5 b) 1.0 c) 2.0 d) 5.0

Q21. Ngt x l no di y c xp vo nhm ngt ngoi? a) Ngoi l thao tc (Operation exception) c) Li trang (Page fault) (Invalid instruction code) b) Ngt nh thi (Timer) d) M lnh khng hp l

Q22. C 2 CPU X v Y c cu hnh nh hnh di. C 2 u c nhng iu kin hon ton nh nhau ngoi tr thi gian truy cp b nh m v b nh chnh c ch ra nh trong bng di. Khi mt chng trnh chy trn c 2 CPU thi gian x l l nh nhau. Trong trng hp t l thnh cng (hit ratio) ca b nh m l bao nhiu? Bit rng khng c yu t no khc ngoi CPU nh hng n t l thnh cng . (T l thnh cng hit ratio l xc sut m phn chng trnh cn thc thi nm trong b nh m) CPU B nh m 32 Kbytes
Bng Thi gian truy cp n v: nano giy

B nh chnh 8 Mbytes

CPU X B nh m B nh chnh 40 400

CPU Y 20 580

Hnh. Cu hnh

a) 0.75

b) 0.90

c) 0.95

d) 0.96

Q23. Pht biu no di y l thch hp vi chin lc tr m kiu ghi xuyn qua (write-through) trong b nh m? a) b) c) d) D liu ch c ghi vo b nh m khi CPU thc hin thao tc ghi. D liu c ghi ng thi vo c b nh m v b nh chnh. Thay i d liu trong b nh chnh khi d liu c y ra khi b nh m. V tn s truy cp b nh tng i thp nn t l chim dng bus cng thp.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

317

Bi thi th FE (Bui sng) p n v Gii thch -

Q24.

Trong mt a cng, mt tp t chc tun t gm cc bn ghi c chiu di c nh khng ng. Mt chng trnh c v x l tun t tt c cc d liu trong tp . Khi t chc tp hoc phng php c thay i, gii php no di y l thch hp t c thi gian ngn nht chng trnh cn c d liu? Bit rng, khng tnh n h thng a x l. a) Phn chia v lu tr d liu vo cc tp ring bit v truy cp tun t cc tp . b) To ra mt tp t chc theo ch s v c d liu s dng kha cho mi bn ghi. c) To ra mt tp t chc trc tip v ch c d liu khi cn thit. d) To khi cc bn ghi v tng s lng bn ghi c yu cu trong mt thao tc c vt l.

Q25. Trong CD c hoc c/ghi, cng ngh no di y c th ghi d liu theo tng khi nh, ng nh khi ghi ln mt a cng? a) Ghi trn a (Disc at once) c) Ghi theo gi (Packet writing) b) Ghi tng track (Track at once) d) Ghi nhiu phin (Multi session)

Q26. M t no di y ph hp vi cc c im ca chun USB 1.1? a) USB 1.1 s dng phng thc truyn d liu tc cao ph hp vi d liu c phn pht thi gian thc nh m thanh, hnh nh. USB 1.1 cho php cc thit b kt ni theo cu trc daisy-chain hoc cu trc hnh cy, v cho php kt ni ngay c khi khng c mt PC hot ng nh mt my ch. b) Cc thit b ngoi vi c kt ni ti mt PC hot ng nh mt my ch. USB 1.1 h tr nhiu ch truyn d liu, nhn chung, my in hoc my qut s dng ch tc cao, bn phm v chut s dng ch tc thp. c) USB 1.1 l giao tip tun t ban u c thit k kt ni cc modem, nhng cng c s dng kt ni cc thit b ngoi vi vi PC. d) USB 1.1 l giao tip song song kt ni cc a cng, cc my in laser v cc thit b ngoi vi khc vi cc my tnh nh, bao gm PC. Q27. La chn no di y m t c trng ca mt mn hnh OLED so vi mn hnh LCD? a) OLED c vng nhn hp. b) OLED c tui th cao. c) OLED ta nhit t. d) OLED t pht sng.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

318

Bi thi th FE (Bui sng) p n v Gii thch -

Q28. Cn khong bao nhiu megabytes (MB) b nh hin th mt mn hnh kch thc 1024x768 pixels khi b nh hnh nh lu tr 24 bits thng tin mu cho mi pixel? Bit 1MB bng 106 bytes. a) 0.8 b) 2.4 c) 6.3 d) 18.9

Q29. Trong kin trc my tnh c bn, phng php no sau y m c chng trnh v d liu u c c trong thit b lu tr ca mt my tnh trc khi c thc hin? a) nh a ch c) iu khin chng trnh trc tip b) B nh o d) Chng trnh lu tr

Q30. Khi 3 nhim v chy c lp, th t u tin ca chng c ch ra nh trong bng di, chui cc thao tc v thi gian x l ca CPU v cc thit b vo/ra cng c m t nh trong bng. Thi gian ri ca CPU l bao nhiu mili giy t lc c 3 nhim v bt u thc thi cng mt lc n khi c 3 nhim v u c hon thnh? Bit rng, khng c xung t no xy ra trong cc hot ng vo/ra, v c th b qua chi ph ca h iu hnh. Th t u tin Cao Trung bnh Thp a) 2 Chui cc thao tc v thi gian x l trong ch c lp (n v: millisecond) CPU(3) I/O(5) CPU(2) I/O(5) CPU(2) CPU(2) I/O(6) CPU(2) I/O(5) CPU(2) CPU(1) I/O(5) CPU(2) I/O(4) CPU(1) b) 3 c) 4 d) 5

Q31. Biu thc no di y m t mi quan h gia thi gian xoay vng, thi gian CPU, thi gian vo/ra v thi gian ch x l? Bit rng tt c cc chi ph thi gian khc c th b qua. a) Thi gian ch x l = Thi gian CPU + Thi gian xoay vng + Thi gian vo/ra b) Thi gian ch x l = Thi gian CPU - Thi gian xoay vng + Thi gian vo/ra c) Thi gian ch x l = Thi gian xoay vng Thi gian CPU Thi gian vo/ra d) Thi gian ch x l = Thi gian vo/ra Thi gian CPU Thi gian xoay vng Q32. Cc chc nng no di y nm trong qun l nhim v ca h iu hnh? a) Phn phi CPU c) Thc thi vo/ra b) iu khin spool d) Bo v tp

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

319

Bi thi th FE (Bui sng) p n v Gii thch -

Q33. La chn no di y m t ph hp nht mc ch ca spooling? a) b) c) d) ghi li thng tin lch s vn hnh ca mt h thng my tnh. Cho php x l mt bn ghi logic m khng cn quan tm n bn ghi vt l. cung cp b nh o c kch thc ln hn b nh thc bng cch dng mt thit b lu tr th cp. tng hiu qu ca h thng giao tip vi cc thit b ngoi vi tc chm, bng cch dng mt thit b lu tr th cp. Q34. La chn no sau y m t ph hp nht v API (Application Program Interface) trong mt h iu hnh? a) y l mt k thut cho php cc chng trnh ng dng thao tc trc tip vi phn cng v thc hin cc chc nng khc nhau. b) y l mt k thut cho php cc chng trnh ng dng s dng cc chc nng khc nhau c cung cp bi h iu hnh. c) y l mt k thut cho php nhiu chng trnh ng dng giao tip vi nhau qua mng. d) y l mt k thut cho php chun ha mc chn menu ca mi chng trnh ng dng thun tin cho ngi dng. Q35. Trong h thng tp phn cp di y, khi th mc hin ti l B1, la chn no sau y l tn ng dn tng i ca tp C2? y, k hiu .. trong tn ng dn cho bit mt th mc cha. Du \ xut hin u tn ng dn c ngha l th mc gc, gia l phn cch gia cc th mc hoc cc tn tp. Hp ch nht trong hnh biu din th mc.

A1

A2

a) c)

..\A1\B2\C2 A1\B2\C2

C1

b) C2 d)

..\B2\C2 B1\..B2\C2

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

320

Bi thi th FE (Bui sng) p n v Gii thch -

Q36. Trong lp chc nng ca h thng client/server 3 lp, la chn no di y l kt hp ca hai chc nng c x l?

a) b) c) d)

u vo ca cc iu kin tm kim v tp hp cc iu kin x l d liu u vo ca cc iu kin tm kim v truy nhp d liu Tp hp cc iu kin x l d liu v thao tc d liu Truy nhp d liu v thao tc d liu

Q37. Trong cu hnh h thng my tnh, la chn no di y gii thch ph hp nht cho h a x l ghp cht? a) Nhiu b x l chia s mt cng chung, v mi b x l c iu khin bi h iu hnh ca chnh n. Kh nng x l c ci thin trn c s phn chia u khi lng cng vic. b) Nhiu b x l chia s b nh chnh v c iu khin bi mt h iu hnh. V nguyn tc, mt nhim v trong h thng c th c thc hin bi bt k b x l no, v th kh nng x l c ci thin bng cch phn chia khi lng cng vic thnh nhng phn nh. c) Bnh thng, mt trong s cc b x l trng thi standby. Khi mt li xut hin trong h thng ang hot ng, tin trnh c tip tc bng cch chuyn sang b x l standby. d) Hai b x l c kt ni song song ng thi thc hin cng mt tin trnh v so snh kt qu vi nhau. Nu mt trong hai b x l tht bi, n b loi b v tin trnh c tip tc. Q38. La chn no di y l pht biu ph hp nht khi quan tm n s nh gi hiu nng h thng? a) Trong OLTP (Online Transaction Processing X l giao dch trc tuyn), cc gi tr MIPS c dng nh gi hiu nng h thng. b) Thi gian p ng v thi gian chuyn i l thc o nh gi hiu nng h thng t quan im ca ngi qun tr h thng. c) Thng thng, thi gian p ng c ci thin khi t l tiu th ti nguyn h thng tr nn cao hn. d) S lng giao dch hoc cng vic c th x l trong mt n v thi gian l quan trng nh gi hiu nng h thng.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

321

Bi thi th FE (Bui sng) p n v Gii thch -

Q39. Trong h thng song song c ch ra di y, cn t nht bao nhiu h thng con (subsystem) tng kh nng sn sng ca ton h thng ln 99% hoc hn? y, kh nng sn sng ca mi h thng con l 70%. Ton h thng hot ng vi iu kin c mt h thng con ang hot ng.
Subsystem Subsystem

Subsystem

a) 3

b) 4

c) 5

d) 6

Q40. Trong m hnh DFD phn cp, mt phn ca m hnh DFD mt mc xc nh c ch ra di y. La chn no di y minh ha phng thc ph hp nht m t cp thp hn trc tip trong m hnh DFD? y, cc tin trnh trong cp thp hn ca tin trnh n c nh s nh sau: tin trnh n-1, tin trnh n-2,
2 1 3

a)
1 1

1 2

b)
1 1 1 3 1 2

1 3

c)
1 1

1 2 2 1 2 2

d)
1 1

1 3

1 2

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

322

Bi thi th FE (Bui sng) p n v Gii thch -

Q41. La chn no di y m t ph hp nht mt c trng ca chng trnh qui? a) Mt chng trnh qui c th gi chnh n trc tip hoc gin tip qua mt chng trnh khc. b) Mt chng trnh qui c th c nh v v c thc thi bt k a ch no trong b nh chnh. c) Mt chng trnh qui c th a ra cc kt qu chnh xc ngay c khi n b gi ng thi bi nhiu tc v. d) Mt chng trnh qui c th c thc thi lp li m khng cn np li. Q42. La chn no di y gii thch ph hp tnh ti u ca mt trnh bin dch? a) N to ra mt m trung gian cho mt chng trnh thng dch thay v to ra m ch. b) N to ra mt m ch chy trn mt loi my tnh khc t my tnh c dng bin dch. c) N to ra mt m ch xc nh cc tn chng trnh con c kim sot cng nh ni dung cc bin ti cc thi im c th trong qu trnh thc hin chng trnh.
d) N phn tch m chng trnh v to ra mt m ch c th c thc hin vi hiu qu x l c ci thin.

Q43. La chn no di y m t thch hp mt c trng ca ngn ng hng i tng? a) Trnh t tnh ton c xc nh bi lung d liu, khng phi bi lung iu khin. D liu dng bi mt lnh s khng c li dng bi lnh hoc cc lnh khc. b) S kim sot tnh ton c thc hin tun t qua cc lnh. Vic chuyn d liu gia cc lnh c thc hin gin tip bng cch tham chiu n b nh qua cc bin. Cc lnh v nh ngha d liu c tch bit. c) D liu c n vi th gii bn ngoi v c thc hin gin tip bi mt th tc gi mt phng thc. Mt chng trnh l tp hp ca cc ng gi d liu v phng thc. d) Mt chng trnh c xy dng bi d liu v lnh (biu tng ca thao tc) biu din cc biu thc quan h cu trc lng nhau v cc hm. Thc hin lnh ngha l tnh ton (c lng) cc biu thc hoc cc hm.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

323

Bi thi th FE (Bui sng) p n v Gii thch -

Q44. La chn no di y m t ph hp nht mt c trng ca mt ngn ng lp trnh? a) COBOL thch hp cho vic x l d liu doanh nghip v c thc hin bi mt b thng dch b) C l mt ngn ng m t h thng, v mt chng trnh vit bng C cn c dch trc khi thc hin. c) Cc c t ngn ng ca Java ph thuc vo nn tng, v Java c thc hin bng cch dng mt b thng dch e) Perl ph hp vi vic vit chng trnh chy trn mt my client, v mt chng trnh vit bng Perl cn c dch trc khi chy. Q45. La chn no di y nn tin hnh sau khi hon thnh thit k ngoi ca h thng? a) B tr mn hnh c) Lu b) K hoch pht trin h thng d) c t c s d liu vt l

Q46. La chn no di y gii thch ph hp nht cho k ngh ngc khi quan tm n phn mm? a) c t thit k c trch rt t mt chng trnh thc hin. b) Mt chng trnh c thit k theo trnh t u ra, x l, v u vo. c) Cc chc nng c thc hin bi phn mm c p dng nh l mt trong cc tnh nng ca phn cng.
d) Ngn ng pht trin v cc cng c pht trin c la chn theo ni dung x l ca cc chng trnh.

Q47. Trong mc ni m un c dng nh mt o ca c lp ca m un, mc ni m un cng yu (hay cng thp) th s c lp ca cc m un cng mnh (hay cng cao). mc ni m un no no c s c lp m un mnh nht trong cc la chn no sau y? a) Mc ni chung c) Mc ni d liu b) Mc ni nhn d) Mc ni ni dung

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

324

Bi thi th FE (Bui sng) p n v Gii thch -

Q48.

La chn no di y l gii thch ph hp nht cho kim th hp trng, mt trong cc phng php kim th chng trnh? a) Cc m un mc thp nht trong cu trc chng trnh c kim th u tin. Sau , chng c tch hp thnh cc m un mc cao hn, v cc m un tch hp ny c kim th. Theo cch , phng php ny li lp li vic tch hp v kim th mc cao hn na. b) M un mc cao nht trong cu trc chng trnh c kim th u tin. Sau , cc m un mc thp hn c gi bi m un cao nht c tch hp v kim th. Theo cch , phng php ny li lp li vic tch hp v kim th mc thp hn na.
c) Phng php kim th ny tp trung n cc c t bn ngoi ca mt chng trnh, v tt c cc t hp c th ca cc gi tr u vo c kim th. Phng php ny bao gm cc k thut nh phn on tng ng, phn tch gi tr bin, v th nhn qu.

d) Phng php kim th ny tp trung vo cu trc bn trong ca mt chng trnh. Logic chng trnh c xem xt v kim th n khi tt cc c cc con ng u c thc hin. Phng php ny bao gm cc k thut nh bao ph lnh v bao ph iu kin. Q49. Khi s dng phng php tnh m kim tra di y tm m kim tra, sau ghp vo ui ca mt d liu cho trc, kt qu no sau y l ng. Cho gi tr ca d liu l 7394, trng s ng vi mi ch s l 1, 2, 3, 4, h s c s ca php chia 11 [modulo 11]. [Phng php] 1) 2) 3) Nhn mi ch s ca d liu vi trng s tng ng, sau ly tng. Chia tng trn cho h s c s ly phn d Ly phn d ca php chia h s c s trn, sau ghp vi d liu ban u c m kim tra. b) 73941 c) 73944 d) 73947

a) 73940

Q50. Trong mt mn hnh GUI, cung cp mt giao din hiu qu cho c nhng ngi thnh tho s dng bm phm v cha thnh tho, vn no sau y l trong trng nht? a) Hn ch ti a vic nhp liu trc tip t bn phm v cho php la chn danh sch s dng chut. b) t cc trng quan trng, chng hn cc trng bt buc ln pha trn m khng quan tm n nh dng ca biu mu nhp liu. c) Cho php s dng c hai giao din chut v bn phm i vi cc thao tc thng xuyn s dng. d) Cho php thc hin cc chc nng hay s dng bng cch kch p chut
Ti liu n thi FE Tp.1
-- Phn2. Tp bi thi th --

325

Bi thi th FE (Bui sng) p n v Gii thch -

.Q51.

M t no sau y l ng nht v XML?

a) XML c xy dng da trn HTML v thm vo mt s chc nng. b) Mun nhp mt vn bn XML phi dung mt trnh son tho vn bn c bit c) XML tch hp cu trc logic v hin th khun dng ca mt vn bn. d) XML cho php ngi s dng nh nghi cc thng tin v thuc tnh v cu trc logic ca mt vn bn bng cch s dng cc th ring ca h. Q52. Tnh cht no sau y m t ng nht vic lm th no s dng cc stub (cung) trong pha kim th? a) Stub c s dng kim tra qu trnh x l c ng hay khng bng cch a ra mt phn gi tr ca cc thanh ghi v b nh mi khi mt lnh xc nh no c thc hin. b) Khi mt chng trnh c kim tra theo phng php t trn xung, mt module cp thp tm thi (c gi l stub) c to ra v thc hin cng vi chng trnh chnh kim tra cc thao tc c) Trong qu trnh thc hin mt chng trnh, mt stub s kim tra v sa li cho ng ni dung cc thanh ghi nu cn, v sau tip tc kim tra cc tin trnh tip theo. d) Khi thc hin trong mt bc kim tra cho mt m-un ca mt chng trnh, mt module cp cao hn (l module thc hin gi module kim tra) s c cung cp kim tra li cc thao tc. Q53. Mt cng ty thng mi mun pht trin mt ng dng cung cp d liu cho cc nhn vin bn hng ti cc chi nhnh trn ton quc t mt my ch t tr s, s dng mng ring ca cng ty. Trong qu trnh kim th h thng trong mi trng mng LAN, vn no sau y l kh kim tra? Gi thit mng ni b ca cng ty bao gm mt mng LAN ti tr s v ti mi chi nhnh, c ni vi nhau bng ng truyn vin thng. a) Thi gian x l ca cc chng trnh ng dng. b) Thi gian p ng c) Cc thao tc kim sot khi server b qu ti d) S tin trnh chy trn my ch

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

326

Bi thi th FE (Bui sng) p n v Gii thch -

Q54.

Trong qu trnh kim th logic sau y, trng hp kim th no l cn thit kim tra lnh r nhnh ?

A OR B
False

True

Cu lenh

a) A
False

b) B
True

c) A
False True

d) A
False True

B
True False

B
False True

A
False True True

B
True False True

Q55. Trong mt d n php trin h thng, PERT c s dng to ra mt k hoch ci t v to ra mt on gng. M t no sau y l ng nht v on gng? a) Cc hnh ng cn s tp trung cao nht v cht lng h thng b) Cc hnh ng m qu trnh ci t n c th thay i c) Cc hnh ng lin h trc tip n tr ca ton b d n d) Cc hnh ng chi ph cao nht. Q56. Tnh cht no sau y m t ng nht phng php im hm (function point)? a) Cng kch thc ca tng dng lnh ca mi hm trong chng trnh, t nh gi c kch thc ca ton d n. b) Mi mc cng vic c chia nh mt cch chi tit, sau c lng ti ca mi mc. c) Kch thc d n c c lng da trn s lng v tnh cht ca vic vo/ra, cc file logic bn trong, cc giao din, yu cu t bn ngoi d) Kch thc ca d n c c lng bng cch tm kim cc trng hp tng t v phn tch, nh gi cc kt qu v s khc nhau hin c. Q57. M t no sau y l ng nht cho vic thm mt s kim tra vo m ca khch hng? a) b) c) d) pht hin li khi nhp m khch hng sp xp m khch hng theo th t u tin cho cc khch hng mi. c th on c khch hng l ai c th phn loi c khch hng theo cc tiu ch, v d theo vng

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

327

Bi thi th FE (Bui sng) p n v Gii thch -

Q58. Chi ph s dng mt h thng my tnh c xc nh da trn nhiu tiu ch, chng hn nh lng s dng ti nguyn v s lng ngi s dng. th no sau y m t mt h thng m chi ph gim dn theo s ngi dng. y trc honh ch lng s dng, trc tung ch chi ph s dng. a) b)

c)

d)

Q59. Thit b no sau y c s dng mt h thng my tnh khng b tt do li t xut mt ngun in bn ngoi? a) CVCF c) My pht in ring b) UPS d) Thit b nhn nng lng d phng

Q60. Trong bo tr phn mm, kim th no sau y c s dng bo m rng hiu ng ph ca vic x l li hay chi ph khng php sinh? a) Kim th hiu nng c) Kim th hi quy b) Kim th chu ng (Endurance test) d) Kim th ngoi l

Q61. M t no l ng cho cc giao thc tng phin trong m hnh OSI? a) L cc giao thc pht hin v hi phc li cho cc qu trnh v d liu truyn b mt, dn knh dliu. b) L cc giao thc truy cp d liu t xa, truyn file c) truyn d liu trong sut, khng li trong cc h thng k tip, chng l cc giao thc kim sot li, l cc th tc phc hi li, gi/nhn thi gian d) thit lp knh giao tip logic v h tr trao i d liu ng th t, chng l cc giao thc iu khin hot ng gia cc bn, thng bo ngoi l

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

328

Bi thi th FE (Bui sng) p n v Gii thch -

Q62. Trong hnh v di y, d liu 16 bit c sp xp trong cc hnh vung 4x4 v m chn-l c p dng cho c hng v ct. Ti a bao nhiu bit c th c sa bi phng php ny? y vng t m l m kim tra. 1 0 0 1 0 a) 0 (khng sa c) c) 2 0 1 0 1 0 0 1 1 0 0 b) 1 d) 3 0 0 0 1 1 1 0 1 1

Q63. Khi cc thng ip cha 90 k t c truyn vi tc 14,400bps trn ng truyn s dng bit start/stop, bao nhiu thng ip c gi trong 1 pht? y mt k t c 8 bit, khng bit chn-l, 1 bit start, 1 bit stop. Hiu qu s dng ng l 80%. a) 12 b) 16 c) 768 d) 960

Q64. Khi truyn mt tp kch thc trung bnh 1,000 bytes trn mt ng leased-line vi

tc 64,000 bps, gi tr no sau y l xp x ca h s s dng ng truyn (%)? Gi thit phn thng tin iu khin chim 20% lng d liu c truyn. a) 0.9 b) 6.3 c) 7.5 d) 30.0

Q65. Khi n bo xung t trn my ch 10Base-T sng lin tc, cu no trong cc cu sau y l gii ng tnh trng ca mng LAN? a) Hiu sut ca vic truyn d liu ang b gim do tc nghn ng truyn trong mng LAN. b) in th cung cp cho hub ang st gim do c qu nhiu my tnh cng c cm vo mt chia in. c) Mt trong s cc my tnh cm vo mng c tc x l rt cao v ang chim hu mng LAN. d) D liu khng th truyn i c do s hub cm vo ng truyn vt qu con s cho php.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

329

Bi thi th FE (Bui sng) p n v Gii thch -

Q66. Cu no trong cc cu sau y m t ng v cc thit b ni cc mng LAN (LAN-to-LAN) ? a) Cng mng (gateway) ch c s dng chuyn i giao thc nhng tng thp (t tng mt n tng ba trong m hnh OSI) b) Cu ni (bridge) truyn tip cc khung da trn a ch IP. c) B lc khuch i tn hiu gia cc trm lm tng khong cch ng truyn. d) B nh tuyn (router) truyn tip cc khung da trn a ch tng MAC. Q67. Mt bn ghi cha cc thnh phn t A n F. T hp A v B to thnh kha chnh cho bn ghi. Bn cnh , thnh phn F c th c xc nh t B. Tm dng chun 3 ca bn ghi ny trong cc la chn di y:

a) b) c) d) Q68.

A A A A

B B B C C F D

C D

D E C

E B D B E C

B F

B D E

F B F

u l m t chnh xc nht php chiu trong c s d liu quan h? a) Php chiu kt hp cc kt qu truy vn ca mt bng vi cc kt qu t cc bng khc to thnh mt bng duy nht. b) Php chiu chn ra t mt bng cc hng ph hp vi mt iu kin c bit no . c) Php chiu ch chn ra nhng ct c bit no t mt bng. d) Php chiu to ra mt bng mi bng cch kt hp nhiu nhm tha mn nhng iu kin c th t hai hay nhiu bng

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

330

Bi thi th FE (Bui sng) p n v Gii thch -

Q69.

Da trn bng SanPham sau y, bng SanPhamCoLai c to ra bng cch s dng [nh ngha Khung nhn]. Trong cc tin trnh cp nht sau y tin trnh no lm gim s lng cc hng xut hin trong bng SanPhamCoLai? a) SanPham
MaSanPham S001 S003 S005 TenSanPham PC T PC S PC R MoHinh T2003 S2003 R2003 GiaBan 1,500 2,000 1,400 GiaMua 1,000 1,700 800

[nh ngha khung nhn] CREATE VIEW SanPhamCoLai AS SELECT * FROM SanPham WHERE GiaBan GiaMua >= 400 b) c) d) e) Cp nht gi bn ca model R2003 thnh 1,300 Cp nht gi mua ca model R2003 thnh 900 Cp nht gi mua ca model S2003 thnh 1,500 Cp nht gi bn ca model T2003 thnh 1,300

Q70. u l m t chnh xc nht v tp nht k (log file) trong qun tr c s d liu (DBMS) ? a) Tp nht k c to ra bng cch ghi nh k cc d liu c cp nht trong b nh chnh vo a, v th rt ngn thi gian ca qu trnh phc hi c s d liu trong trng hp h thng b hng. b) Tp nht k c to ra bi vic lin tc ghi mt bn sao ca cng mt d liu vo c s d liu trn mt a khc hoc vo mt c s d liu trong mt trm khc nhm m bo cho h thng c th phc hi ngay lp tc trong trng hp a b li. c) Mt tp nht k c to ra bi vic nhn bn ni dung ca mt c s d liu trn mt a sao cho c th phc hi li c s d liu nu gp li. d) Mt tp nht k c to ra bng cch ghi cc gi tr d liu trc ri n cc cp nht d liu sau nhm s dng cho vic phc hi d liu.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

331

Bi thi th FE (Bui sng) p n v Gii thch -

Q71.

Hnh di y trnh by m hnh khi nim ca mt m ha kha cng khai. Hy tm cp t thch hp trong nhng cp sau y in vo hai A v B.
Ngi gi Vn bn m ha Vn bn m ha Ngi nhn

Vn bn

M ha A

Gii m B

Vn bn

A a) b) c) d) M cng khai ca ngi nhn M c nhn ca ngi nhn M cng khai ca ngi gi M c nhn ca ngi gi

B M c nhn ca ngi nhn M cng khai ca ngi nhn M c nhn ca ngi nhn M cng khai ca ngi nhn

Q72. Cu no trong s cc cu sau y m t ng v vic bo mt trn mng Internet? a) S dng tng la c th ngn cn cc thng tin quan trng trong mt cng ty khi b r r ra bn ngoi khi m h thng th in t ni b c ni vi bn ngoi thng qua mng Internet. b) Khi mt my ch lu d liu c s dng trn mng Internet th cc bin php cn thit phi c thc hin trnh cc truy cp tri php n server v vic gi mo d liu. c) Khi mt bc th in t c gi trn mng Internet, vic m ha th cho php ngi s dng kim tra c vic gi bc th. d) Nu mun s dng mng Internet th cn thit phi ng k trc vi mt h thng xc thc ngi dng. Q73. Chun no trong cc chun sau y c mc ch l t c s hi lng ca khch hng qua thng vic s dng mt cch c hiu qu h thng qun l cht lng trong bao gm cc qui trnh phng nga nhng sn phm khng tun theo qui tc? a) BS 7799 b) ISMS c) ISO 9001 d) ISO 14001

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

332

Bi thi th FE (Bui sng) p n v Gii thch -

Q74. Khi mi quan h gia gi nh trc v nhu cu c lng cho mt sn phm nht nh c c lng bng biu thc tuyn tnh th gi tr no trong cc gi tr sau y thch hp in vo 1) 2) 3)
A

di y?

Nu gi nh trc l $3000, th nhu cu c lng l 0. Nu gi nh trc l $1000, th nhu cu c lng l 60,000 sn phm. Nu gi nh trc l $1500, th nhu cu c lng l b) 35,000 c) 40,000
A

sn phm. d) 45,000

a) 30,000

Q75. nh ngha no sau y m t ng nht vai tr ca CIO? a) Khi thc hin mt chin lng IT, CIO l ngi thng qua mt k hoch nhm ti u hiu qu ca vic u t vo cc ti sn thng tin trong khp cng ty sao cho ph hp vi chin lc kinh doanh ca cng ty . b) CIO l ngi xc nh ra trng thi ca vic thc thi cng nh pht trin h thng v theo a ra xut v nhng ci tin c th nhm ti u ha chc nng ca h thng thng tin trong ton cng ty. c) CIO l ngi kim tra xem h thng thng tin trong cng ty c thc s p ng tt nhu cu ca cc hot ng kinh doanh hay khng v t a ra nhng li khuyn hu ch cho phng h thng thng tin. d) m bo h thng thng tin trong ton cng ty lun lun trong tnh trng hot ng tt nht, CIO l ngi thu nhn cc bo co t phng h thng thng tin bao gm c nhng yu cu v nhng vn rc ri lin quan n h thng, t a ra cc ch dn c th gii quyt. Q76. Tnh ton mt s mt hng da trn bo co kt qu kinh doanh c th hin trong bng di y. Trong trng hp ny, gi bn ha vn l bao nhiu la?
n v: $

Mt hng Tng cng bn Gi bin ng Gi c nh Li nhun a) 5,000 b) 7,000

S lng 10,000 8,000 1,000 1,000 c) 8,000 d) 9,000

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

333

Bi thi th FE (Bui sng) p n v Gii thch -

Q77. Trng hp no sau y c th p dng phng php Delphi? a) Phn tch nguyn nhn ca cc hng hc h thng xy ra trong qu kh. b) Phn tch phn on ca nhng ngi dng ang s dng dch v in thoi di ng. c) Phn tch nhng bin ng dn s trong tnh hnh th trng d) Phn tch cc xu hng k thut trong cc lnh vc truyn trong vng 10 nm k t by gi Q78. Trong nhng cu sau y cu no m t v biu iu khin ng nht? a) Biu mng c to ra bi cc mi tn ni cc hot ng li vi nhau v biu din quan h th t ca cc hot ng . Biu ny c s dng trong vic xc nh cc nt tht c chai ca tin trnh v chun b cc lch biu. b) Mt ng k chnh gia v hai ng k bin trn v di c v ra, sau th ca cc gi tr c trng ca sn phm c biu din trn . Phng php ny gip ta nhn ra c cc vn v cht lng v nhng trng hp bt bnh thng trong qui trnh, gim thiu cc nguyn nhn gy li v trnh lp li li. c) S lng li trong sn phm v lng thit hi c phn loi theo tng nguyn nhn, c tng hp v sp xp li theo th t gim dn. Phng php ny cho php chng ta d dng nhn ra nhng sn phm c ci tin mt cch hiu qu nht. d) Cc nhn t c th l nguyn nhn gy ra vn c sp xp theo hnh dng ging nh b khung xng c. Phng php ny gip cho ta nhn bit c nhng nguyn nhn gc ca vn v d dng gii quyt n hn.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

334

Bi thi th FE (Bui sng) p n v Gii thch -

Q79.

Nhm so snh cc bi thi tuyn ca nm ngoi vi nm nay, cng ty chn ra mt s lng ln nhn vin cng tham gia vo lm c 2 bi thi. Sau tng quan cho v ng hi qui c tnh bng cch v th im s ca cc nhn vin ny trn mt phng Oxy, vi im ca bi thi nm ngoi trn trc x v im bi thi nm nay trn trc Y. Kt lun no trong s cc kt lun sau y c th c a ra da trn kt qu? [Kt qu] Tng quan cho l 0.8. dc ca ng hi qui l 1.1. ng hi qui ct trc Oy ti 10. a) Da trn gi tr giao gia ng hi qui v trc Oy c th thy rng mt ngi t im 0 trong bi thi nm nay c th t c im 10 trong bi thi nm ngoi. b) Da vo dc ca ng hi qui c th thy l im thi trung bnh ca bi thi nm nay bng khong 1.1 ln im trung bnh ca bi thi nm ngoi. c) Da vo dc ca ng hi qui v im giao gia ng hi qui v trc Oy c th kt lun rng im thi ca bi thi nm nay c xu hng cao hn im ca bi thi nm ngoi. d) Da vo dc ca ng hi qui v gi tr tng qian c th thy l bi thi nm nay c cht lng cao hn.

Q80. Trong mt nh my, c 3 sn phm A, B v C c sn xut t cng mt nguyn liu M. Bng 1 biu din thi gian, khi lng nguyn liu M cn thit v li nhun khi sn xut 1 kg mi sn phm A, B v C. Bng 2 biu din lng ti nguyn c phn phi cho nh my hng thng. Ngi ta mun tnh s lng cc sn phm A, B, v C sn xut hng thng sao cho c th t c li nhun cao nht. Cho bit phng php no sau y ph hp nht gii quyt bi ton ny?
Bng 1 Cc iu kin sn xut Sn phm A B

C 1 2 5

Thi gian cn sn xut (gi/kg) Lng nguyn liu M cn thit (lt/kg) Li nhun ($/kg)

2 2 8

3 1 5

Bng 2 Lng ti nguyn c phn phi Thi gian sn xut 240 (gi /thng) Lng nguyn liu M 150 (lt/thng)

a) Phng php dch chuyn trung bnh c) Phng php lp trnh tuyn tnh

b) Phng php bnh phng nh nht d) H thng t hng s lng c nh

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

335

Bi thi th FE (Bui sng) p n v Gii thch -

Thi th p n v Gii thch cho cc cu hi bui sng Exam


Q1: [p n ng] d
Khng c li lm trn s ngha l cu tr li ng ( dng thp phn) trong nhm cu tr li khi c chuyn i thnh s nh phn th kt qu l mt s nh phn c phn l hu hn. Chng ta s chuyn i mi s thp phn trong nhm kt qu thnh mt s nh phn. lm iu ny, ta lin tip nhn phn s l sau du thp phn vi 2 v ly phn nguyn ca mi kt qu trong mi ln . Khi phn s l sau du thp phn bng 0 qu trnh chuyn i kt thc. a) 0.2 2 0.4 2 0.8 2 0.6 2 0.2 2 = 0.4 = 0.8 = 1.6 = 1.2 0.0 0.00 Lp 1.001 0.0011

= 0.4 lp v kt qu y l 0.4.

Do thnh phn c gch chn sau y lp li nh sau: (0.2)10 (0.0011)2 b) 0.3 2 0.6 2 = 0.6 = 1.2 0.0 0.01 0.010 0.0100 Lp 0.8 2 = 1.6 0.6 2 = 1.2 0.2 2 0.01001 0.010011

0.2 2 = 0.4 0.4 2 = 0.8

= 0.4 lp v kt qu y l 0.4.

Do thnh phn c gch chn sau y lp li nh sau: (0.3)10 (0.010011)2

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

336

Bi thi th FE (Bui sng) p n v Gii thch -

c)

0.4 2 = 0.8 0.8 2 = 1.6 0.6 2 = 1.2 0.2 2 = 0.4 0.4 2

0.0 0.01 Lp 0.011 0.0110

= 0.8 lp v kt qu y l 0.8

Do thnh phn c gch chn sau y lp li nh sau: (0.4)10 (0.0110)2 d) 0.5 2 = 1.0 0.1 Khng c phn l no sau du thp phn nn qu trnh chuyn i kt thc.

Do , kt qu nh sau: (0.5)10 (0.1)2

Q2: [p n ng]

V d, s thp phn c 3 ch s ln nht l 999 (= 103 1), v s thp phn c 4 ch s ln nht l 9,999 (= 104 1). Tng t, s thp phn ln nht c D ch s l (10D 1). i vi s nh phn, s ln nht c 3 ch s (3 bit) l (111)2 (= 7 = 23 1), v s ln nht c 4 ch s l (1111)2 (= 15 = 24 1). Tng t, s thp phn ln nht c B-bit l (2B 1). Theo kt qu trn, mi quan h gia mt s thp phn D ch s v mt s nh phn B bit c ch ra nh sau: 10D 1 2B 1 10D 2B Ly logarit c s 10 c hai v ca phng trnh trn ta c: log1010D log22B Dlog1010 Blog22logabn = nlogab D Blog102lognn = 1

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

337

Bi thi th FE (Bui sng) p n v Gii thch -

Q3: [p n ng]

Khi mt s m c biu din di dng s b hai th tt c cc bit tr thnh 1 nu v ch nu n c gi tr -1 h thp phn. Nu ngu nhin bn bit iu ny th c th tr li ngay lp tc l b. Hy cng kim tra kt qu trn vi mt s nh phn 8 bit. vit mt s dng cho trc di dng b hai, ta ly nghch o tt c cc bit ca s , kt qu thu c em cng vi s nh phn 1. Cng ch thm l kt qu ca vic ly nghch o tt c cc bit c gi l s b mt.
(1)10 = (00000001)2 ly nghch o mi bit 11111110 s b mt +) 1 cng thm 1 (11111111)2 = (-1)10

Lc ny, ly mt s nh phn n bit gm ton s 1 v chuyn i n thnh dng b hai 11111 ly nghch o mi bit 00000 +) 1 cng thm 1 00001 = (1)10 Do kt qu ca qu trnh chuyn i s nh phn ny sang dng s b hai l (1)10, nn s nh phn c tt c cc bit bng 1 s c gi tr l -1.

Q4: [p n ng]

Trn s l hin tng xy ra khi kt qu ca php ton khng th biu din c bng cch s dng mt s ch s cho trc (trong my tnh, s c biu din bng cc bit). V th, vic cng hai s dng c th gy ra trn b nh do kt qu ca php ton tng ln. Trng hp tng t cng c th xy ra khi cng hai s m do gi tr tuyt i ca kt qu tng ln.
A B C D E F G H

Trn s c th xy ra v gi tr dng tng ln khi cng hai s dng. Trn s khng th xy ra v s dng + s m c ngha l s dng + (- s dng); nh th lm gim gi tr s dng. Trn s khng th xy ra v gi tr tuyt i ca s m gim khi ta cng s vi mt s dng. Trn s c th xy ra v gi tr tuyt i ca mt s m tng ln khi s m + s m, c ngha l s m + (- s dng = s m - s dng. Trn s khng th xy ra v vic tr hai s dng s lm gim gi tr ca s dng. Trn s c th xy ra v s dng s m c ngha l s dng - (- s dng) = s dng + s dng; iu ny lm tng gi tr ca s dng. Trn s c th xy ra v khi tr s m cho mt s dng s lm tng gi tr tuyt i ca s m. Trn s khng th xy ra v s m s m c ngha l s m - (- s dng) = s m + s dng; nh th lm gim gi tr tuyt i ca s m.

Q5: [p n ng]

Do thi gian tnh ton t l vi ly tha bc ba ca s n s trong h phng trnh nn thi gian tnh ton y c th c biu din theo s n s ca h x v hng s t l k nh sau:: y = kx3 (1) Cn 2 giy mt my tnh gii mt h phng trnh tuyn tnh 100 n s. Vy, vi mt my tnh c tc x l nhanh gp 4 ln my tnh trn s gii h trn trong ca 2 giy = 0.5 giy. Lc ny, th x = 100 v y = 0.5 vo phng trnh (1) tm hng s t l k.
Ti liu n thi FE Tp.1
-- Phn2. Tp bi thi th --

338

Bi thi th FE (Bui sng) p n v Gii thch -

= k 1003 = k (102)3 = k 106 k = 0.5 106 = 0.5 10-6 Do , mi quan h gia x v y c biu din nh sau: y = 0.5 10-6x3 Trong trng hp ny cn gii h phng trnh tuyn tnh gm 1000 n s; do th x = 1,000 = 103 vo phng trnh (2) ta c: Y = 0.5 10-6 (103)3 = 0.5 10-6 109 = 0.5 103 = 500 (giy). 0.5

Q6: [p n ng]

ly 7 bits thp cn lic ngha l bit chn l c thay bng 0 v cc bit khc gi nguyn khng i. im mu cht y l php nhn logic (AND) vi 0 cho kt qu l 0 v nhn logic vi 1 cho kt qu l chnh n.
AND vi 0 0 1 AND) 0 AND) 0 0 0 kt qu l 0. 0 AND vi 1 0 1 AND) 1 AND) 1 2 bit ging nhau

Do , cu tr li n gin l thc thi php ton logic vi (01111111)2 = (7F)16. Trong cc li gii thch sau, x c ngha hoc l 1 hoc l 0. A)
x x x x x x x x AND) 0 0 0 0 1 1 1 1 0 0 0 0 x x x x M 8 bit = (0F)16

y ta ch thu c 4 bit thp B) OR)


x x x x x x x x M 8 bit 0 0 0 0 1 1 1 1 = (0F)16 x x x x 1 1 1 1

y ta ch thu c 4 bit cao, cn 4 bit thp u bng 1. C)


x x x x x x x x AND) 0 1 1 1 1 1 1 1 0 x x x x x x x M 8 bit = (0F)16

y, bit chn l (bit quan trng nht) bng 0 v 7 bit thp vn gi nguyn. D) Php ton logic ny ly nghch o tt c cc bit. V d:
1 0 1 0 1 0 1 0 XOR) 1 1 1 1 1 1 1 1 = (FF)16 0 1 0 1 0 1 0 1

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

339

Bi thi th FE (Bui sng) p n v Gii thch -

Q7: [p n ng]

Tp cc b phn khng gp s c no c m t di y: Tp cc b phn khng gp s c = ( A U B U C )

( A U B U C ) l tp cc b phn gp s c A, s c B hoc s c C. Do , tp cc b phn khng gp s c l phn b ca tp ny. V th, p n c th tnh bng cch ly tng s b phn 100 tr i s b phn thuc tp ( A U B U C ) .
Gi n( A U B U C ) l s phn t ca tp ( A U B U C ) . Ta c biu thc sau:

Lc ny, th cc gi tr s cho u bi vo biu thc trn. n(A) = 11 (s b phn gp s c A; c th c c s c B v/hoc s c C) n(B) = 7 (s b phn gp s c B; c th c c s c A v/hoc s c C) n(C) = 4 (s b phn gp s c C; c th c c s c A v/hoc s c B) n( A I B) = 3 (s b phn gp s c A v B; c th gp c s c C) n( A I C ) = 2 (s b phn gp s c A v C; c th gp c s c B) n( B I C ) = 0 (s b phn gp s c B v C; c th gp c s c A)

n( A U B U C ) = n( A) + n( B) + n(C ) n( A I B) n( A I C ) n( B I C ) + n( A I B I C )

(1)

Thay th cc gi tr trn vo phng trnh (1) ta c ( A U B U C ) = 11 + 7 + 4 3 2 0 + n( A I B I C ) = 17 + n( A I B I C ) . V n( B I C ) = 0, ( B I C ) l tp rng. Do , ( A I B I C ) cng l tp rng, suy ra n( A I B I C ) = 0. n( A U B U C ) = 17. V vy s b phn khng gp s c c tnh nh sau: n( A U B U C ) = 100 17 = 83 (b phn). Do s b phn khng gp s c l 83 nn p n l (b). Di y chng ta s gii thch ti sao li c cng thc (1). Xt th Ven sau, trong n(A), n(B), v n(C) c tnh nh sau:

n(A) = + + + 1 4 6 7 2 4 5 7 n(B) = + + + 3 5 6 7 n(C) = + + +

V vy, n(A) + n(B) + n(C) c th c tnh bng: n(A) + n(B) + n(C) = + + + + + + + + + + + 1 4 6 7 2 4 5 7 3 5 6 7 = ( + + + + + + ) + + + + + 1 2 3 4 5 6 7 4 5 6 7 7 Ni cch khc, n( A U B U C ) l tng t n , do n(A) + n(B) + n(C) tr thnh: 1 7 1 2 3 4 5 6 7 : n(ABC) n(A) + n(B) + n(C) = ( + + + + + + ) + ( + ) 4 7 : n(AB) + ( + ) 5 7 : n(BC)
Ti liu n thi FE Tp.1
-- Phn2. Tp bi thi th --

340

Bi thi th FE (Bui sng) p n v Gii thch -

+ ( + ) 6 7 : n(AC) 7 : n(ABC) Kt qu ta c cng thc sau: n(A) + n(B) + n(C) = n( A U B U C ) + n( A I B) + n( A I C ) + n( B I C ) n( A I B I C ) n( A U B U C ) = n(A) + n(B) +n (C)

n( A I B ) n( A I C ) n( B I C ) + n( A I B I C )
b

Q8: [p n ng]

Cng thc logic Z = X Y + X Y l tng logic loi tr (hay cn gi l loi tr OR). Kt qu ca php ton logic ny bng 0 nu cc bin logic X v Y c cng gi tr, v bng 1 nu X v Y c gi tr khc nhau. Do , ta c bng chn l ca biu thc Z = X Y + X Y nh sau:

X 0 0 1 1

Y 0 1 0 1

Z 0 1 1 0

Nu bn khng cng nhn suy din trn chnh l tng logic loi tr th bn c th tnh Z = X Y + X Y v kim tra li kt qu.

X 0 0 1 1

Y 0 1 0 1

X 1 1 0 0

Y 1 0 1 0

X Y 0 0 1 0

X Y 0 1 0 1

Z = X Y + X Y 0 1 1 0

Da vo bng trn ta c th thy p n l (b). a) Kt qu ca php ton bng 1 khi c X v Y u bng 1, ngc li kt qu bng 0. y l php nhn logic. c) Kt qu ca php ton bng 1 khi t nht mt trong hai bin X v Y bng 1, ngc li kt qu bng 0. y l cng logic. d) Kt qu ca php ton bng 1 khi hai bin X v Y c cng gi tr, ngc li kt qu bng 0. y l php ton tng ng.

Q9: [p n ng]

C 26 ch ci in hoa ting Anh (t A n Z) v 10 k t s (t 0 n 9); nh vy tng cng c 36 k t. Do ta ch cn tnh s bit cn biu din 36 k t ny. Tng qut, s dng mt s nh phn n bit ta c th biu din mt di gi tr t 0 n 2n 1 nu khng quan tm n cc s m. Trong bi ny ta cn 36 k t nn ta c php tnh sau: 2n 1 = 36 2n = 37 Kh c th tnh chnh xc phng trnh m ny, nn ta s dng mt c lng n gin nh sau: 25 = 32 < 37 < 26 = 64 Theo kt qu trn th ta cn phi s dng 6 bit biu din c 36 mu khc nhau.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

341

Bi thi th FE (Bui sng) p n v Gii thch -

Q10: [p n ng]

Bn khng cn phi bit r v automat, ch cn theo mt xu k t a ra trong cu hi. Gn cc nhn a, b, c, d v e cho cc trng thi nh hnh di y.

Mt chui k t c on trng thi ban u ( on nhn ( )

nhn nu n bt u v kt thc trng thi

). Ta s xem xt tng xu k t trong nhm tr li:


K t u vo Trng thi sau khi a vo

a) Trng thi trc


khi a vo

a a b a b b) Trng thi trc


khi a vo

0 1 0 1 1
K t u vo

a b a b c
Trng thi sau khi a vo

Khng c on nhn

a a b c e c) Trng thi trc


khi a vo

0 1 1 1 1
K t u vo

a b c e d
Trng thi sau khi a vo

Khng c on nhn

a b a b c d) Trng thi trc


khi a vo

1 0 1 1 1
K t u vo

b a b c e
Trng thi sau khi a vo

c on nhn

a b c e d
Ti liu n thi FE Tp.1
-- Phn2. Tp bi thi th --

1 1 1 1 0

b c e d d Khng c on nhn

342

Bi thi th FE (Bui sng) p n v Gii thch -

Q11: [p n ng]

Biu c php sau y biu din cc quy tc ca mt ngn ng lp trnh s dng biu chuyn trng thi. Khng ging nh BNF (Backus Naur Form), biu ny c xem l d hiu hn BNF v y khng c biu thc quy. Biu i theo chiu t tri qua phi, v d biu c php u tin ch ra rng chui k t khng cn phi bt u vi + hoc v theo sau l cc ch s c lp li. Du thp phn . khng bao gi ng v tr u tin.
Cc ch s c lp li Ch s Ch s

Cn c B1 Biu c php u tin c adu trong cu hi c th hiu nh sau: ra thp phn y (1) Xu c th bt u bng +, - hoc khng du. V vy theo (2) th n c th bt u bng mt s. (2) Sau du + hoc phi l mt ch s (hoc mt xu phi bt u bng ch s nu n khng c du) v ch s c th lp li nhiu ln. Do , s -100 lit k trong danh sch v d ca cu hi ny tun theo c php trn. Thnh phn nguyn ca 5.3 l 5, ca +13.07 l +13 cng tun theo c php trn. (3) Xu ch s theo c php (2) c th kt thc , hoc theo sau l du thp phn .; tuy nhin, nu nh c du thp phn th phi c t nht mt ch s theo sau du thp phn .. Do , -100 tha mn c php trn. Do c th c nhiu s sau du thp phn nn phn l ca 5.3 l.3, ca +13.07 l.07 cng tha m c php trn. V nhng l do trn nn 100, 5.3, v +13.07 u tha mn c php trong hnh v v d.

Trong biu c php th 2 ca cu hi ny, v th t (+, -, hoc khng c g c) ch s (c th nhiu) du thp phn c xc nh nn phi c mt ch s trc du thp phn. Hn na, thnh phn cn li c th t E (+, , hoc khng c g c) ch s (c th nhiu) nn theo sau E phi l +, - hoc mt ch s. Da vo nhng iu ny bn c th kim tra tng biu thc c lit k trong nhm cu tr li. a) Du thp phn phi ng sau mt ch s, nhng y li l du thay v l mt ch s. b) Do 5.2 tun theo th t ch s (c th nhiu) du thp phn ch s (c th nhiu) v b qua + hoc u nn n tun theo quy tc trn. Hn na, E-07 tun theo th t E ch s (c th nhiu), nn n cng tun theo quy tc trn. V vy, 5.2E07 tun theo quy tc trn. c) E phi c theo sau bi +, - hoc mt ch s. d) E khng th ng ngay sau du thp phn.

Q12: [p n ng]

Duyt theo th t trc l i theo th t nt, cy con tri, cy con phi nn n bt u vi gc a. Sau duyt tip tc ti nt con tri v c nt b. Ri i ti nt c ca cy con tri. Trong s cc la chn trong nhm cu tr li th ch c (a) l thc hin theo th t a b c. tham kho, chng ti s gii thch cc phng php duyt theo th t gia v theo th t sau. Duyt theo th t gia l i theo th t cy con tri, nt, v cy con phi nn khi gp a th s duyt cy con tri ca a theo ng a b c, v gp h. Sau khi gp h, n duyt nt c ri duyt tip tc ti cy con phi ca n i. V vy qu trnh qut chy theo ng h c i (hcibdajfegk) do phng n la chn l (c).

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

343

Bi thi th FE (Bui sng) p n v Gii thch -

Duyt theo th t sau l i theo th t cy con tri, cy con phi, v nt do n i theo ng h i c (hicdbjfkgea) v phng n la chn l (d). Phng php duyt theo th t trc, gia v sau c gi l duyt theo chiu su, khi ta qut mt cy nh phn bng nhng phng php ny th s c nhng c trng sau: Vi cy nh phn di y, nu kt qu u ra ging vi khi bn i qua pha tri ca cc nt th l phng php duyt theo th t trc. Nu kt qu u ra ging vi khi bn i qua di cc nt th l duyt theo th t gia. Nu kt qu u ra ging vi khi bn i qua pha phi ca cc nt th l duyt th t sau.

Kt qu ca phng php duyt theo th t trc l: a b c h i d e f j g k.

Kt qu ca phng php duyt theo th t gia l: h c i b d a j f e g k.

Kt qu ca phng php duyt theo th t sau l: h i c d b j f k g e a.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

344

Bi thi th FE (Bui sng) p n v Gii thch -

Q13: [p n ng]

Ngn xp h tr cu trc d liu LIFO (Vo-sau Ra-trc. Ni cch khc, i tng c lu tr sau cng l i tng c ly ra u tin. Da trn quy tc ny, ngn xp trong cu hi ny s thay i nh sau: PUSH 1 PUSH 5 ` POP PUSH 7 PUSH 6 PUSH 4
4 6 7 1

5 1

7 1

6 7 1

POP

POP

PUSH

6 7 1

7 1

3 7 1

(Kt qu cui)

Q14: [p n ng]

Phng php bm l phng php c s dng quyt nh v tr lu tr da trn mt mc d liu c th. V d nh mc d liu ny c th l nh danh ca mt nhn vin (employee ID). Mt php ton no c thc hin trn mi employee ID v kt qu c s dng cho a ch lu tr. Mc d liu ph thuc vo php ton bm c gi l mc kha, v hm c s dng ly a ch lu tr c gi l hm bm, gi tr nhn c gi l gi tr bm. a) Phng php bm l phng php dng xc nh v tr lu tr, khng lin quan n nhng g c s dng nh cu trc d liu. b) C nhiu trng hp i vi cc gi tr kha khc nhau hm bm u to ra cng a ch. Trng hp ny gi l xung t. Trong phng php bm, khng th trnh c xung t. Nu xy ra xung t, d liu c lu tr gi l t gc (home) cn d liu gy ra xung t gi l t ng ngha (synonym). d) Do s dng hm bm chuyn i d liu thnh a ch nn qu trnh chuyn i c th c thc hin trong cng mt lng thi gian. Ni mt cch khc, n khng h ph thuc vo kch thc ca bng (s phn t c trong bng). Nu xy ra xung t th cn thc hin li hm bm v phng php bm li khng nh hng n thi gian tm kim.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

345

Bi thi th FE (Bui sng) p n v Gii thch -

Q15: [p n ng]

Cc cu hi v lu trong bi thi bui sng hu nh lun lun l cc thut ton c bn tng i d theo di. Nu nh bn c th hiu c cc k hiu ca lu th ch cn bm st lu l . Trc ht chng ta s gii thch cc k hiu c dng trong lu . Bt u Kt thc i+1 i : Bt u qu trnh : Kt thc qu trnh : Qu trnh ( y, thay th kt qu ca i + 1 vo i) c ngha l thay th

<
A(i): A(i + 1) >
Chuyn i

: Quyt nh ( y, sang phi nu A(i) < A(i+1), i xung nu A(i) > A (i+1)) Du hai chm : ngha l so snh hai bn vi nhau : Bt u lp iu khin dng Lp li qu trnh gia v tr bt u lp v v tr kt thc lp cho n khi t c iu kin dng. y im bt u v kt thc c cng tn l Switch : Kt thc lp

Switch i=n

Switch Chuyn i

Tip theo, ta i theo lu ca cu hi. Gi tr khi to ca i l 1 ((1 i), v i c tng ln 1 mi ln (bi i + 1 i trong vng lp) cho ti khi i=n, ti qu trnh x l thot khi vng lp. Hn na, cn phi hiu rng A(i): A(i + 1) c ngha l c hai bn ca biu thc ny c so snh vi nhau. V d nh nu i = 1, A(1) v A(2) c so snh. Nu i = 2 th A(2) v A(3) c so snh. Vic so snh cc phn t lng ging v i ch vi chng nu chng khng tha mn l cc c tnh ca thut ton sp xp ni bt.

Q16: [p n ng]

B nh flash thuc v dng EEPROM (Electrically Erasable and Programmable ROM) v cng c gi l flash EEPROM. y l mt loi ROM phn t bn dn, trn d liu c ghi v xa bng in. D liu trn EEPROM phi c xa ton b trc khi ghi li, trong khi b nh flash c th xa v ghi y hoc theo mt khi. Cc thao tc xa v ghi c th c thc hin lp li nhiu ln (thc t gii hn trong mi nghn ln). V y l mt loi ca ROM nn khng cn ngun in d tr (n c th gi c d liu ngay c khi tt ngun). b) y l li gii thch cho EPROM (Erasable and Programmable ROM). c) y l li gii thch cho SRAM (Static RAM). d) y l li gii thch cho DRAM (Dynamic RAM).

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

346

Bi thi th FE (Bui sng) p n v Gii thch -

Q17: [p n ng]

Php ton m to ra 1 ch khi c u vo A v B u bng 1 l php nhn logic, v y l php ph nh. Php ph nh logic ca AND l NAND (ph nh logic ca php nhn logic). Chng ta s kim tra iu ny bng cch s dng bng tht.
A B A AND B A AND BA NAND B

0 0 1 1

0 1 0 1

0 0 0 1

1 1 1 0

Nu bn khng nhn ra php nhn logic, bn c th tip tc cc php ton logic cn li trong s cc cu tr li a ra v kim tra kt qu. a)
A B A AND B

b)

c)

A AND BNAND A OR B

d) A XOR B (Exclusive OR) 0 1 1 0

0 0 1 1

0 1 0 1

0 0 0 1

1 1 1 0

0 1 1 1

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

347

Bi thi th FE (Bui sng) p n v Gii thch -

Q18: [p n ng]

X l ng ng lnh l mt cng ngh tng tc ca cc CPU. N phn chia mt lnh thnh mt s bc, nh ch ra trong cu hi, mi bc c tr bng khong thi gian ca mt bc khi cc bc c thc hin. Gi nh rng khng c lnh no, nh lnh nhy v r nhnh, b b gi trong ng ng lnh ngha l tt c cc lnh c thc hin tun t. Nh ch ra trong biu cu hi, lnh u tin yu cu 6 bc thc hin, nhng mi mt lnh khc li c lm tr bi mt bc, v th c th nh gi thi gian thc hin ca ch mt bc. y, v 6 lnh c thc hin, nn lnh u tin chim khong thi gian bng 6 bc trong khi mi lnh trong s 5 lnh cn li ch chim khong thi gian ca mt bc, tng s l 5 bc. Do , mt tng s thi gian ca 11 bc hon thnh x l. Thi gian thc hin c 6 lnh = 11 (bc) 10 (nano giy/bc) = 110 (nano giy) C th kim tra li kt qu bng cch s dng hnh m phng sau y.
Lnh 1 Lnh 2 Lnh 3 Lnh 4 Lnh 5 Lnh 6

2 1

3 2 1

4 3 2 1

5 4 3 2 1

6 5 4 3 2 1 6 5 4 3 2 6 5 4 3 6 5 4 6 5 6

Tng s bc thc hin

10 11

Q19: [p n ng]

Cc cng ngh kin trc my tnh c phn thnh 4 nhm nh nu trong cu hi, ph thuc vo lung d liu v lnh. a) MIMD (Multiple Instruction Multiple Data stream) l cng ngh trong nhiu lnh c lp x l cc d liu khc nhau. Bao gm cc h thng b x l c th h tr x l song song v iu khin ng ng lnh. b) MISD (Multiple Instruction Single Data stream) l cng ngh trong nhiu lnh thc hin x l cng mt d liu. Bao gm cc my tnh m c th thc hin iu khin ng ng lnh. c) SIMD (Single Instruction Multiple Data stream) l cng ngh trong mt lnh thc hin x l nhiu d liu ng thi. Bao gm cc my tnh m c th thc hin x l song song nh cc b x l vector (cc b x l mng). d) SISD (Single Instruction Single Data stream) l cng ngh trong cc x l c thc hin tun t. Bao gm cc my tnh kiu kin trc Von Neumann.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

348

Bi thi th FE (Bui sng) p n v Gii thch -

Q20: [p n ng]

MIPS (Million Instructions Per Second) l mt n v o hiu sut my tnh bng mt triu lnh trn mt giy. Thi gian thc hin lnh trung bnh l khong thi gian cn thc hin mt lnh; y l 0.2 micro giy (0.2 10-6 giy). S lnh c th c thc hin trong mt giy l nghch o ca thi gian thc hin lnh trung bnh. S lnh thc hin trong mt giy

1 Average instruction execution time 1 = 6 0.2 10 (seconds/instruction) 1 = 10 6 ( seconds/in struction) 0.2


= = 5.0 106 (instructions/sec.) 5.0 MIPS

Q21: [p n ng]

Ngt c s dng treo tm thi chng trnh ang thc hin v mt s l do v chuyn iu khin n cho h iu hnh thc th mt chng trnh x l cn thit. Cc ngt ngoi gy ra bi cc tn hiu ngoi hoc cc iu kin phn cng c bit v cc ngt trong c tnh gy ra bi li gi ca h iu hnh trong mt chng trnh. Nu CPU pht hin ra mt ngt, h iu hnh s ct trng thi ca chng trnh ang c thc hin vo PSW (Program Status Word) trc khi thc hin ngt. Sau , n tm nguyn nhn gy ngt v chuyn iu khin ti chng trnh con x l ngt. Mt ngt khc cng c th xy ra trong khi khi ang x l mt ngt, v th nhiu ngt s c iu khin bng cch cp cho chng th t u tin x l, ph thuc vo loi ngt. Nguyn nhn v loi ngt Ngt ngoi Ngt kim tra thit b (Ngt d thng)
Ngt theo c ch xung nhp (Ngt nh thi) Ngt vo/ra Ngt tn hiu ngoi

Cc v d nguyn nhn gy ngt Li chc nng khi x l, li ngun hoc in p, li b nh chnh.


Kt thc khong thi gian xc nh (qung nh thi), du hiu thi gian xc nh. Hon thnh thao tc vo/ra, Thay i trng thi khi vo/ra (my in ht giy, v.v...) Do cc lnh t h thng iu khin hoc cc tn hiu ngoi.

Ngt trong Ngt chng trnh (Ngt Trn trn, m lnh khng hp l (m lnh cha c nh ngoi l) ngha), chia cho 0, ngt bo v b nh.
Ngt do li gi chng trnh iu khin (ngt lnh)

Yu cu hot ng vo/ra, chuyn i gia cc nhim v, li trang, li gi hm chng trnh iu khin (li gi h thng: SVC)

Cc p n a), c), v d) trong nhm cc cu tr li l cc ngt trong.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

349

Bi thi th FE (Bui sng) p n v Gii thch -

Q22: [p n ng]

T l thnh cng l xc sut m phn chng trnh cn thc thi nm trong b nh m. Gi tc l thi gian truy cp b nh m, tm l thi gian truy cp b nh chnh, v h l t l thnh cng. Khi , thi gian truy cp trung bnh (k hiu t) c tnh nh sau: t = h tc + (1 h) tm y chng ta bit thi gian truy cp trung bnh ca CPU X v Y. Thi gian truy cp b nh m v b nh chnh c tnh theo n v nano giy (10-9), tuy nhin n v ny c b qua v n khng nh hng trong cc tnh ton. Thi gian truy cp trung bnh ca CPU X:
tX

Thi gian truy cp trung bnh ca CPU Y:

tY

= h 40 + (1 h) 400 = 40h + 40 400h = 360h + 400 = h 20 + (1 h) 580 = 20h + 580 580h = 560h + 580

Trong cu hi ny, iu kin c a ra l tX = tY 360h + 400 = 560h + 580 200h = 180 h = 180 200 = 0.90

Q23: [p n ng]

Write-through l mt phng php theo , nu mt khi trong b nh m b thay i th khi cng c vit vo b nh chnh cng lc. Trong phng php ny, khi np mt khi cn thit mi vo b nh m, h thng c th ghi ln khi khng cn thit trong b nh m. a) v c) l cc gii thch ca phng php write-back. d) Write-through i hi truy cp n b nh chnh mi khi b nh m c cp nht, do tn sut truy cp b nh chnh cao hn so vi phng php write-back, trong b nh chnh c cp nht khi d liu c y ra khi b nh m. Do vy, y l m t phng php write-back.

Q24: [p n ng]

Mt tp cc bn ghi chiu di c nh khng ng ngha l mi khi l mt bn ghi. Cc thit b vo/ra c d liu theo tng khi, do n v ca mi ln c l mt bn ghi. Nu bn nhn ra l do s dng blocking trong mt tp tun t, bn c th ngay lp tc tm ra (d) l p n ng. a) Thm ch l nu d liu c lu tr trong cc tp ring bit v c truy cp tun t, th tt c cc bn ghi vn phi c c theo th t. Mt khc, vn mt cng mt lng thi gian c. Ngi ta c th ngh rng mt t thi gian hn c nu cc tp ring bit c c song song, nhng y cu hi a ra l khng tnh n h thng a x l. V th, chng ta c th loi tr trng hp c song song. b) Truy cp cc tp t chc theo ch s theo th t cc kha, d liu c c khi cc kha c tham chiu. V mt thi gian tham chiu cc kha nn thi gian x l s tng. c) Nu ch cc bn ghi cn thit c c bng cch tnh ton cc a ch bn ghi s dng cc gi tr kha, th thi gian c th phn no ngn hn. Tuy nhin, chng ta khng bit c bao nhiu bn ghi c c. Trong trng hp ti nht, c th tt c cc bn ghi phi c c, trong trng hp thi gian x l s tng do phi tnh ton cc a ch bn ghi. d) Nu s bn ghi c lu tr trong mt khi tng, mt ln c vt l c th c nhiu bn ghi, do vy, thi gian x l s ngn hn.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

350

Bi thi th FE (Bui sng) p n v Gii thch -

Q25: [p n ng]

CD (Compact Disc) l mt loi a quang, ban u c s dng lu tr m nhc, nhng n cng c s dng nh cc phng tin lu tr ca cc my tnh. Dung lng ln khong 700MB. N c th c ghi vi chi ph thp, v th n c s dng phn phi cc phn mm v lu tr cc t in, b sch gio khoa v d liu hnh nh. Loi CD-ROM CD-R CD-RW CD-Read Only Memory CD-Recordable: Ch ghi CD-Rewritable: sau khi xa hon ton, c th ghi li c trng

a) Disc at once (DAO) l cch ghi trn CD-R v CD-RW. C th ghi d liu trn ton b a mt ln. N khng cho php ghi thm. b) Track at once (TAO) l cch ghi trn CD-R. C th ghi d liu theo cc track. Sau khi d liu c ghi, c th cho php ghi thm. c) Packet writing l cch ghi trn CD-R. Khc vi vic ghi ln cc CD-R v CD-RW thng thng l theo tng track, phng php ny phn chia d liu thnh tng khi nh ghi. V vic ghi c thc hin theo nhiu khi nh hn, CD-R c th c s dng trong cc tng t nh a mm hoc MO. d) Multi-session l cch ghi trn CD-R v CD-RW. C th ghi d liu lm nhiu phin. ghi s dng nhiu phin, CD-R phi h tr phng thc TAO. Mt phin l mt vng trong nhiu track c tham gia cng nhau.

Q26: [p n ng]

USB 1.1 l chun giao tip gia mt PC v cc thit b ngoi vi. Nh mt hub, cho php ti 127 thit b c th c kt ni theo cu trc hnh cy. Tc truyn d liu c th t ch cao 12Mbps hoc ch thp 1.5Mbps. S dng kt ni cc thit b tc tng i thp. Cc my in v my qut c kt ni ch tc cao trong khi bn phm v chut c kt ni ch thp. Do , (b) l m t chnh xc ca chun USB 1.1. Cc la chn khc trong nhm cu tr li l khng chnh xc v cc l do sau: a) m thanh v hnh nh yu cu truyn tc cao, nhng USB 1.1 kt ni cc thit b tc tng i thp. Cu trc Daisy chain c ng dng cho SCSI. Kt ni theo cu trc hnh cy khng c mt my ch PC v ph hp vi chun 10BASE-T. c) y l gii thch ca chun RS-232C. d) y l gii thch ca chun SCSI.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

351

Bi thi th FE (Bui sng) p n v Gii thch -

Q27: [p n ng]

LCD (Liquid Crystal Display) l mt thit b hin th s dng c tnh ca mt loi vt cht gi l tinh th lng, c kh nng thay i cu trc phn t cng nh phn cc nh sng khi t vo mt in p. Bn thn tinh th lng khng t pht sng, nhng mn hnh c hin th bng cch s dng nh sng phn chiu trong cc vng sng v bng cch s dng nh sng nn t pha sau thit b trong cc vng ti. LCD c th s dng phng php ma trn n gin nh STN v DSTN hoc phng php ma trn ch ng nh TFT. LCD mng v v sng hn cc thit b hin th khc nh cc mn hnh CRT v PDP. Do c cng sut tiu th thp v ta nhit t, LCD c s dng trong cc my tnh xch tay, cc my tnh bn tit kim khng gian, v.v Phng php TFT (Thin Film Transistor) l mt phng php trong mi im mn hnh c iu khin bi mt transistor si mng (TFT). N c tng phn cao, thang mu xm, v tc p ng nhanh (tt/bt nhanh). Phng ph STN (Super Twisted Nematic) c cu trc n gin, v th chi ph sn xut thp, tuy nhin, cht lng hin th km hn ca TFT. Phng php DSTN (Dual-scan Super Twisted Nematic) l mt nng cp ca STN vi tc p ng cao hn. Diode pht quang hu c (Organic light-emitting diode (OLED)) hoc Organic Electronluminescence display (OLED) l loi mn hnh s dng mt vt cht hu c c kh nng pht quang khi t vo mt hiu in th. So vi mn hnh LCD, OLED c gc nhn rng hn, tng phn cao hn, thi gian p ng cao hn (khong 1000 ln so vi LCD), chng cng mng v nh hn. V OLED c kh nng t pht quang nn khng cn s dng nh sng nn. Thc t chng c th c s dng nh nh sng nn cho LCD. Vn i vi vic s dng rng ri cng ngh OLED l tui th v chi ph sn xut. Bng sau so snh tng i gia LCD v OLED. Du vng trn ngha l tnh nng tt hn. mng LCD OLED

rng Tng t nhau

Gc nhn

Tiu th in nng

Tui th

Chi ph sn xut

Q28: [p n ng]

B nh hnh nh lu tr d liu k t v ch s hin th trn mn hnh PC. Mt im nh (phn t nh) l mt n v cu thnh nn cc nh s v l mt im mu. Mt nh s hin th hnh nh bng cch t cc im nh ca n theo chiu ngang v chiu dc mn hnh. V mi im nh gm 24 bits v c 1024 768 im nh, dung lng b nh cn hin th l: 1,024 768 24 (bits) 1 byte gm 8 bit. Do , i ra byte ta c: Dung lng b nh cn hin th mn hnh = 1,024 768 24 8 = 1,024 768 3 = 2,359,296 (bytes) = 2.359296 (Mbytes, 1M = 106) 2.4 (Mbytes) (Lm trn n mt phn 10)

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

352

Bi thi th FE (Bui sng) p n v Gii thch -

Q29: [p n ng]

Hu ht cc my tnh hin nay lu tr c chng trnh v d liu trong b nh chnh v b nh o, chng nhn v thc hin cc lnh t b nh ln lt. a) Phng php nh a ch l s phn loi theo s lng cc a ch c nh r bi trng ton hng ca lnh. Ph thuc vo s lng a ch c th c nh r, c cc lnh a ch 0, cc lnh a ch 1, cc lnh a ch 2, cc lnh a ch 3, v.v b) B nh o l mt phng php qun l b nh s dng mt b nh ngoi nh a cng cung cp khng gian b nh rng hn dung lng vt l b nh chnh cung cp. c) iu khin chng trnh trc tip l mt phng php m CPU truyn d liu bng cch iu khin trc tip cc thit b vo/ra thng qua cc lnh c a ra bi chng trnh. Phn cng iu khin c th nh. Tuy nhin CPU gim st ton b cc hot ng vo/ra t khi bt u n khi kt thc, v n khng th thc hin bt c x l no khc trong sut thi gian thc hin hot ng vo/ra. Kt qu l, hiu sut s dng ca CPU s gim, v vy ngy nay phng php ny hu nh khng cn c s dng. d) Trong phng php chng trnh lu tr, chng trnh c lu tr nh d liu trong b nh, v khi iu khin nhn v thc thi cc lnh tun t. Hu ht cc my tnh ngy nay s dng phng php chng trnh lu tr. N cng c bit nh l my tnh von Neumann do John von Neumann, mt nh ton hc ngi M xut u tin.

Q30: [p n ng]

Chi ph l tng thi gian m khng c yu cu trc tip cho cc tin trnh ng dng trong sut thi gian chy ca h iu hnh. V d, chi ph bao gm thi gian yu cu np mt chng trnh, chuyn i cc nhim v, v phn trang trong mt h thng b nh o. y, chng ta b qua chi ph, v th thi gian yu cu chuyn i t vo/ra sang CPU coi nh bng 0. V khng c xung t no xy ra trong cc hot ng vo/ra ca mi nhim v, trc ht chng ta gii thch biu thi gian cho nhim v c cp u tin cao. Trong khong thi gian ri ca CPU, chng ta thm mt biu thi gian cho nhim v c cp u tin trung bnh. Sau , trong khong thi gian ri ca CPU, chng ta thm tip biu thi gian ca nhim v c cp u tin thp. Trong cc biu thi gian , thi gian c tnh theo mili giy. (1) Biu thi gian ca nhim v c cp u tin cao (High)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

CPU High I/O

High-3

High-2

High-2

5 5 (2) Biu thi gian ca nhim v c cp u tin trung bnh (Middle)


0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

CPU High I/O

High-3

Mid-2 5

High-2

Mid-2 5

High-2

Mid-2

Mid I/O

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

353

Bi thi th FE (Bui sng) p n v Gii thch -

(3) Biu thi gian ca nhim v c cp u tin thp (Low)


0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

CPU High I/O Mid I/O Low I/O

High-3

Mid-2 5

Low-1 High-2

Mid-2 Low-2 High-2 5

Mid-2

Low-1

6 5

5 4

(4) Biu thi gian chung Do , biu thi gian c m phng nh sau y, Trong , cc khi hp c ng vin m ch ra khong thi gian CPU nhn ri.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

CPU High I/O Mid I/O Low I/O

High-3

Mid-2
Low-1

High-2

Mid-2 Low-2 High-2

Mid-2

Low-1

5 6 5

5 5 4

V vy, trong thang thi gian biu trn, thi gian ri ca CPU l 2 mili giy t gia 6 v 8, 1 mili giy gia 10 v 11, 1 mili giy gia 17 v 18; Tng s c 4 mili giy thi gian ri.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

354

Bi thi th FE (Bui sng) p n v Gii thch -

Q31: [p n ng]

Thi gian ch x l ca mt cng vic l lng thi gian dng i cho n khi c x l. V d, nu CPU ang c s dng, thi gian ch l khong thi gian i cho n khi n tr nn c hiu lc. Thi gian xoay vng (TAT) l khong thi gian t khi mt cng vic c trnh cho n khi nhn c kt qu. Thi gian CPU l thi gian khi CPU ang c s dng, v thi gian vo/ra l thi gian khi cc khi vo/ra ang c s dng. Trong sut thi gian CPU v thi gian vo/ra, CPU v cc khi vo/ra c s dng thc s, v vy chng khng phi l mt phn ca thi gian ch x l. Mt khc, thi gian xoay vng bao gm thi gian i x l (i CPU hoc i cc khi vo/ra) v thi gian xoay vng l qung thi gian t khi trnh cng vic n khi nhn c kt qu.
CPU waiting time I/O unit waiting time CPU waiting time Ending process

CPU time

I/O time

CPU time

Turn around time

Cc ng nt m ch ra thi gian ch x l V th, thi gian ch x l c th c tnh bng hiu ca thi gian xoay vng vi thi gian CPU v thi gian vo/ra nh cng thc sau: The thick lines indicate process waiting time. Process waiting time = Turnaround time CPU time I/O time

Q32: [p n ng]

Qun l nhim v l mt trong s cc chc nng ca h iu hnh, v n bao gm, to nhim v, hy nhim v, cp pht ti nguyn (CPU, b nh chnh, cc khi vo/ra, v.v) v iu khin ngt. Task management is one of the functions of the OS, and it includes task creation, task deletion, b) L chc nng ca qun l cng vic. c) L chc nng ca qun l d liu. d) L chc nng ca qun l d liu.

Q33: [p n ng]

Spooling l mt chc nng cho php thc hin song song mt tin trnh vo ra ca mt cng vic, c lp vi vic thc hin chng trnh. Nu d liu ra c chuyn trc tip n my in trong khi thc hin chng trnh, hiu nng x l s gim do tc x l thp ca my in. V th, thay v gi d liu ra trc tip n my in, d liu c ghi vo mt tp c thit k lu tr d liu ra, gi l tp spool v t b nh th cp. Ni dung c lu tr trong tp spool c in ra bi mt chng trnh dch v c thit k c bit cho d liu u ra sau khi chng trnh hon thnh. a) y l gii thch ca mt bn ghi (nht k). b) y l chc nng qun l d liu, mt trong cc chc nng ca h iu hnh. c) y l gii thch ca h thng b nh o.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

355

Bi thi th FE (Bui sng) p n v Gii thch -

Q34: [p n ng]

API (Application Program Interface - Giao tip chng trnh ng dng) l mt k thut s dng cc hm khc nhau ca mt h iu hnh t cc ng dng. N l mt giao din m bo tng thch mc chng trnh ngun, v th n c dng gi cc hm h iu hnh t cc ng dng, nh hin th cc ca s v pht hin s di chuyn chut. Cc ng dng tm thy li ch t cc tnh nng khc nhau (nh cc chng trnh con v cc hm) ca h iu hnh qua API. Bng cch dng API, nng sut ca cc chng trnh c ci thin. Hn na, k c khi CPU c kin trc khc, cch s dng API s thay i mt cch linh hot ging nh dng trong h thng c. a) Cch dng cc b iu khin thit b cho php cc ng dng s dng phn cng, nhng cc ng dng khng gi iu khin trc tip v h iu hnh ng gia cc b iu khin thit b v cc ng dng. Ngc li, API l mt k thut cho php dng cc hm ca h iu hnh, n khng cho php cc ng dng iu khin trc tip phn cng. c) La chn ny m t tp pipe (dng ng), gi v nhn d liu gia cc tc v, v DDE (Dynamic Data Exchange - trao i d liu ng), m cc ca s khng hin th c khi thng ip c trao i gia nhiu tc v, nhng khng phi l cc hm ca API. Cng nh vy, clipboard l mt k thut lin h gia cc tc nhim d n c thc hin th cng. T quan im trn ton mng, kh xc nh chnh xc n l g, nhng vic x l bi h a x l ghp lng c chc nng c m t y. Hn na, CORBA, c t thng thng v vic trao i cc thng ip gia cc i tng trong mi trng h phn tn cng ph hp vi m t. d) Mt ln na, kh xc nh chnh xc n l g, nhng n m t s chun ha giao din ngi dng. thng nht cc mc hin th, v d nh menu, thn thin vi ngi dng v lm cho h thng d hiu. Theo ngha chun ha dng hin th, m t ny cng gii thch khi nim look-and-feel (nhn v cm nhn). Look-and-feel l n tng v nhng g m my tnh mang li, lin quan n hnh thc mn hnh iu khin ca my tnh v cm gic v tnh d iu khin; iu ny bao gm thit k ca s, sp xp cc biu tng, cc phng thc vn hnh v cc mn hnh v/hoc m thanh p ng c lin quan. Thng thng, Look-and-feel v c bn c chun ha trong h iu hnh hoc h thng ca s, v th bt k phn mm ng dng no chy trn cng h thng ca s c th c vn hnh vi cm gic gn nh ging ht nhau. Hin nay, cc mn hnh hin th v cc phng thc vn hnh c gii thiu bi Microsoft Windows v MacOS c thit lp nh l cc chun GUI look-and-feel.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

356

Bi thi th FE (Bui sng) p n v Gii thch -

Q35: [p n ng]

Th mc gc l th mc cp cao nht. Th mc hin ti l th mc ang s dng. Nu th mc hin ti l B1 v ta ch nh C2 l mt tp di th mc B2, ta di chuyn cc th mc nh sau: Directory B1 Directory A1 Directory B2 File C2 Th mc B1 Th mc A1 Th mc B2 Tp C2
(1) Th mc B1 Th mc A1 di chuyn th mc B1 ln mt mc n A1, ta c th ch nh th mc cha mt cch n gin nh sau: .. (2) Th mc A1 Th mc B2 di chuyn th mc A1 xung mt mc n B2, ta c th ch nh th mc B2 sau \ nh sau: ..\B2 (3) Ch nh tp C2 di th mc B2 ch nh tp C2 di th mc B2, ta c th ch nh tp C2 sau "\" nh sau: ..\B2\C2

a) .. cho bit th mc cha, l th mc A1. Phn tip theo \A1 ch ra rng th mc A1 di th mc A1, nhng khng c th mc no nh vy trong hnh ny. c) A1 ch ra rng th mc A1 di th mc hin ti B1, nhng khng c th mc no nh vy trong hnh ny. d) B1 ch ra rng th mc B1 di th mc hin ti B1, nhng khng c th mc no nh vy trong hnh ny.

Q36: [p n ng]

Mt h thng client/server 3 lp (kin trc 3 lp) l mt h thng trong cc ng dng kiu client/server c phn chia thnh 3 lp: lp giao din, lp chc nng (lp ng dng), v lp d liu (lp truy nhp c s d liu). Bng cch phn chia theo chc nng, h thng ny mun ci thin hiu nng v duy tr hiu qu h thng. V c vn dng pha server, s lin kt d liu b gim gia server v cc client. Hn na, t quan im hiu qu pht trin, phn chia h thng theo chc nng thnh 3 lp d thc hin cc cng vic song song trong qu trnh pht trin v thay i cc c t.
X l ca server X l ca client

Lp d liu Lp chc nng Lp giao din

: Truy nhp c s d liu : X l d liu : Giao tip vi ngi dng

Trong lp chc nng, cc iu kin tm kim gi t lp giao din c tp hp li thnh cc iu kin x l truy nhp vo c s d liu v gi n lp d liu. Sau , phn hi t lp d liu c thc hin p ng yu cu ca lp giao din v sau gi n lp giao din. a) Cc iu kin tm kim c gi ti lp giao din, v cc iu kin thao tc d liu c thu thp lp chc nng. b) Cc iu kin tm kim c gi ti lp giao din, v vic truy nhp d liu c din ra lp d liu. c) Vic truy nhp d liu c din ra lp d liu, v d liu c thao tc tng chc nng.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

357

Bi thi th FE (Bui sng) p n v Gii thch -

Q37: [p n ng]

Mt h a b x l ghp cht l mt cu hnh h thng trong nhiu b x l, di mt h iu hnh, chia s cc ti nguyn nh b nh chnh v cc a ng thi lin h vi b x l khc chn v thc hin cc nhim v ch x l. V tin trnh c th c thc hin bi bt k mt trong cc b x l no nn vic np c th c phn tn. Nu mt b x l b li, cc b x l khc c th thc hin cc tin trnh; y l cu hnh h thng vi tin cy v thng lng cao.

CPU
B nh chnh B nh th cp

CPU
a) y l gii thch ca h a b x l ghp lng. c) y l gii thch ca h song cng. d) y l gii thch ca h i ngu (h kp dual system).

Q38: [p n]

Ch s dng nh gi hiu nng h thng bao gm MIPS, FLOPS, nhp ng h, kt hp lnh, thi gian p ng, thng lng, thi gian chuyn i, TPS, Cc phng php nh gi hiu nng h thng gm benchmark, monitoring, a) OLTP (OnLine Transaction Processing X l giao dch trc tuyn) l mt ch x l trong cc giao dch c gi n mt my ch (host) t nhiu thit b u cui c kt ni n my ch trc tuyn, my ch thc hin dy cc x l bao gm truy cp c s d liu theo cc giao dch gi, v cc kt qu x l ngay lp tc tr v cc thit b u cui. Hiu nng c nh gi bi s giao dch c x l trong mt n v thi gian (TPS: s giao dch trong 1 giy). Bn cnh , MIPS l mt n v o hiu nng phn cng (CPU). b) Thi gian p ng v thi gian chuyn i l cc khong thi gian x l cc cng vic. Nu thi gian p ng hoc thi gian chuyn i di, h thng tr nn kh dng. V th, c cc ch s nh gi hiu nng t quan im ngi dng v khng phi t quan im ca ngi qun tr h thng. c) Mt t l tiu th cao cc ti nguyn h thng xut rng thi gian khi cc ti nguyn khng c s dng l ngn, qua ch ra rng ng gia cc ti nguyn d xy ra, lm cho thi gian p ng di hn. Do , thi gian p ng khng nhng khng tt hn m cn xu i. d) Nu s giao dch v cng vic c th c x l trong mt n v thi gian l ln, c ngha l nng sut x l cao. Nng sut x l cao i hi hiu nng x l cao. Do , n c th l mt ch s ph hp nh gi h thng.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

358

Bi thi th FE (Bui sng) p n v Gii thch -

Q39: [p n ng]

Trong mt cu hnh h thng con trong n h thng con c kt ni song song, nu ton b h thng l sn dng th t nht mt trong cc h thng con phi sn dng, tnh sn dng c th c biu din nh sau:
Tnh sn dng ca mt cu hnh n h thng con = 1 (1 p)n (p: tnh sn dng ca mi h thng con)

Trong cng thc trn, xc sut mi h thng con khng sn dng b tr bi xc sut ton th (xc sut 1) Ta thay p = 0.7 (70%) vo biu thc v tnh sn dng v tnh ton tnh sn dng ca cu hnh n h thng con song song ny (gi l A) A = 1 (1 0.7)n = 1 0.3n Ta mun tnh sn dng A c gi tr t nht l 99% (0.99) nn cc bt ng thc sau phi tha mn: 1 0.3n > 0.99 1 0.99 > 0.3n 0.01 > 0.3n

0.3n < 0.01

Bt ng thc ny c mt hm m, v th thi gian tnh ton bng tay s ln. V vy, chn trong cc s nguyn, bt u vi n=2, v kim tra iu kin tha mn. n = 2: 0.32 = 0.09 > 0.01 n = 3: 0.33 = 0.027 > 0.01 n = 4: 0.34 = 0.0081 < 0.01 Do khi n=4, bt ng thc 0.3n < 0.01 tha mn. Kt qu l, i hi t nht 4 h thng con.

Q40: [p n ng]

Trong biu DFD, cc tin trnh (vng trn) c phn r theo th t. Do , khi chng c phn r, nhiu tin trnh mc cao hn khng th kt hp vi cc tin trnh mc thp hn. Trong biu DFD cho trong cu hi ny, ch rng tin trnh 1 c hai mi tn lung d liu u vo v hai mi tn lung d liu u ra. a) Mc d tin trnh 1 c hai mi tn lung d liu u vo, mi mt tin trnh con ca n ch c mt mi tn lung d liu u ra. b) Tin trnh con 1-1 c mt mi tn lung d liu u vo, v tin trnh con 1-2 cng vy. Tng l 2. Vi lung d liu u ra, c mt mi tn t tin trnh con 1-1 v mi tn khc t tin trnh con 1-3, tng l 2. Do , y l c th coi l mt cch phn r ca DFD trong cu hi ny. c) Khi DFD phn tch thnh tng tin trnh, nhng t hp nh {(1-1), (1-2)}v {(2-1), (2-2)} c chp nhn. Tuy nhin, t hp nh {(1-1), (1-2), (2-1), (2-2)} m c nhiu tin trnh mc trn l khng c php. d) S mi tn lung d liu u vo v s mi tn lung d liu u ra tng ng l ng. Tuy nhin, mi tin trnh phi c t nht mt lung d liu u vo v t nht mt lung d liu u ra, m y li khng c lung d liu u vo ca tin trnh 1-2.
Ti liu n thi FE Tp.1
-- Phn2. Tp bi thi th --

359

Bi thi th FE (Bui sng) p n v Gii thch -

Q41: [p n ng]

Khi mt th tc c th c nh ngha, chnh th tc ny c th c dng trong nh ngha ca n. c gi l qui. Mt chng trnh qui l mt chng trnh trong mt hm hay mt chng trnh con dng chnh hm hay chng trnh con ca n. b) y l gii thch ca mt chng trnh ti nh v. c) y l gii thch ca mt chng trnh ng s dng. d) y l gii thch ca mt chng trnh ti s dng.

Q42: [p n ng]

S ti u ha ca mt trnh bin dch l qu trnh kim tra s d tha ca mt chng trnh ch (m un ch). N chuyn cc hng s trong mt vng lp ra ngoi vng lp, xa b v hp nht cc biu thc chung, v to ra m ch lm tng hiu qu x l ti thi im thc thi chng trnh. a) y l mt phng thc c dng trong my o Java. b) y l gii thch ca mt chng trnh bin dch cho. c) La chn ny c th c thc hin bng cch nhng cc lnh g ri vo trong chng trnh. Tuy nhin, n khng lin quan n tnh ti u ca chng trnh bin dch. La chn c th ny gii thch cho mt b d vt.

Q43: [p n]

Mt ngn ng lp trnh hng i tng (ngn ng hng i tng) l mt ngn ng lp trnh vit nn cc chng trnh nh l mt s kt hp ca cc i tng. Mt i tng l s ng gi ca d liu v cc th tc (cc phng thc c gi) iu khin d liu. Bng vic ng gi, d liu c n, v cc i tng c th iu khin d liu gin tip qua cc phng thc. a) La chn ny ch r d liu c dng bi mt lnh th khng c dng li bi lnh hoc cc lnh khc. Mc d iu ny khng m t chnh xc iu g nhng n cng gn vi gii thch ca ngn ng lp trnh logic. b) La chn ny l mt gii thch v ngn ng lp trnh hng th tc. d) La chn ny l mt gii thch ca ngn ng lp trnh hng chc nng.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

360

Bi thi th FE (Bui sng) p n v Gii thch -

Q44: [p n ng]

Ngn ng lp trnh c nhiu loi; cc ngn ng bin dch, ngn ng thng dch, Mt chng trnh vit bng ngn ng bin dch c chuyn thnh chng trnh ngn ng my bi mt trnh bin dch. Mt chng trnh vit bng mt ngn ng thng dch c dch v chy tng dng lnh ti mt thi im, v th tc x l chm hn so vi chng trnh ngn ng bin dch. a) COBOL (Common Business Oriented Language) ph hp vi cc tin trnh doanh nghip, v n l mt ngn ng bin dch, khng phi l mt ngn ng thng dch b) C l mt ngn ng lp trnh vn c pht trin vit UNIX. Hin nay, n c dng trong nhiu lnh vc, nhng n thc cht l mt ngn ng lp trnh m t h iu hnh. Ngoi ra, n cn mt trnh bin dch. c) Mt chng trnh vit bng Java c mt trnh bin dch chuyn sang mt ngn ng trung gian, ri chy ch thng dch trn mt my o. Do , c t ngn ng khng ph thuc vo nn tng. Mt nn tng tc l mt h iu hnh hoc mt mi trng my tnh trong c phn mm chy. Vi cc ng dng, nn tng l h iu hnh, v vi h iu hnh, nn tng l mi trng trong h iu hnh c vn hnh bi phn cng. Vi cc my PC, nn tng ng dng l Windows, v vi Windows, nn tng l mi trng trong Windows c vn hnh bi phn cng. d) Perl(Practical Extraction Report Language) l mt ngn ng ph hp cho vic x l cc tp vn bn. N c x l ch thng dch, v th khng cn chng trnh bin dch cho Perl.

Q45: [p n ng]

Pha thit k ngoi trong m hnh thc c ch ra di.


nh ngha yu cu Thit k ngoi Thit k trong Thit k chng trnh Lp trnh Kim th Ci t, vn hnh

Thit k ngoi l thit k h thng m khng quan tm n my tnh. Pha ny lin quan n vic xc nh v trin khai cc h thng con, thit k mn hnh v bo co, thit k m v thit k d liu logic. Chnh v th, cc ti liu thit k ngoi c chun b. b) Cc k hoch pht trin h thng l cc sn phm bn giao cho giai on xc nh yu cu. c) Mt lu l mt biu thc ha ca thut ton chng trnh v l mt phn ca cc sn phm bn giao cho cc giai on thit k chng trnh v lp trnh. d) c t c s d liu vt l l mt phn ca thit k tp, v chng l nhng sn phm bn giao cho giai on thit k trong.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

361

Bi thi th FE (Bui sng) p n v Gii thch -

Q46: [p n ng]

Reverse engineering is the technology of extracting the design specifications of a system from existing programs, files, documents, etc. b) This is a design technology focusing on the data structure. The Jackson method and the Warnier method take this approach. c) This explains emulation. d) This is generally done in systems development and is not an explanation of reverse engineering.

Q47: [p n ng]

mc ni m-un cng thp th bn ca m-un cng cao,v c lp ca cc m-un cng cng cao. V th, mc ni vi mc cao nht ca c lp m-un l mc ni d liu.
Loi bn bn trng khp bn logic bn phn loi bn th tc bn trao i bn thng tin bn chc nng bn Yu c lp Thp mc ni Mnh Loi mc ni

Mc ni ni dung Mc ni chung Mc ni ngoi Mc ni iu khin Mc ni nhn Mc ni d liu

Mnh

Cao

Yu

Q48: [p n ng]

Kim th hp trng l phng php kim th tp trung vo lun iu khin ca chng trnh, chun b d liu kim th bao ph cc ng chnh trong chng trnh, v thc hin cng vic kim th. V cu trc trong v logic ca chng trnh c kim tra cn thn nn cc hm chi tit c th c kim th theo quan im ca ngi lp trnh. Tuy nhin, cc hm c m t trong c t khng c ci t trong chng trnh s c loi b khi d liu kim th. Bn cnh , kim th hp trng c cc k thut khc nhau nh bao ph lnh, bao ph iu kin quyt nh (bao ph nhnh), bao ph iu kin (bao ph iu kin nhnh), bao ph iu kin/iu kin quyt nh, v bao ph a iu kin. V th, cu tr li l (d). (a) l li gii thch cho kim th t di ln, (b) l kim th t trn xung, v (c) l kim th hp en.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

362

Bi thi th FE (Bui sng) p n v Gii thch -

Q49: [p n ng]

[Bc 1] Nhn tng ch s vi trng s tng ng, ri ly tng cc kt qu. D liu : Trng s : Tng : 7 3 9 4

1
=

2
=

3
=

4
=

27 16

= 56

[Bc 2] Chia tng cho c s (11) v tm s d: 56 11 = 5 d 1 [Bc 3] Ly c s (11) tr i s d, sau ghp vi d liu ban u c m kim tra.: 11 1 = 10 Ch s kim tra Vy, kt qu khi thm ch s kim tra vo d liu l 73940.

Q50: [p n ng]

Nhng ngi s dng bn phm thnh tho s thy bn phm l thit b vo hiu qu hn chut. Tuy nhin, nhng ngi khng quen dng bn phm th li thy chut d dng hn. V th, nu c c 2 thit b trn, rt nhiu ngi c th s dng h thng d dng. . a) Nu hnh nh ca bn phm c hin th trn mn hnh, v ngi dng phi dng chut nhn phm Top th iu ny thng gy nn s kh chu.Dng bn phm g cc k t ch, s s nhanh hn rt nhiu b) Vic thit k mn hnh phi tun theo nhng quy tc chung, v d nh nhng th cn nhp vo u nm pha trn bn tri, v nhng th khng cn phi nhp u nm pha di bn phi. Tuy nhin, nu nh dng nhp vo khc vi cch b tr mn hnh th s lm cho ngi dng bi ri. d) Vi nhng chc nng c s dng thng xuyn, vic click hay click p chut s thun thin v hiu qu hn rt nhiu so vi vic s dng menu s m la chn pha nhp vo t bn phm. Tuy nhin, trong mt s trng hp c bit, giao din ngi dng s hiu qu hn ngay c vi nhng ngi quen dng bn phm th m t (d) l ng, nhng khng lin quan g ti trnh k nng ca ngi dng.

Q51: [p n ng]

XMLeXtended Markup Languagem rng chc nng ca HTML, loi b nhng chc nng khng cn thit ca SGML v ti u ngn ng dng cho Internet. Ging nh HTML, XML c s dng trn Internet, nhng trong khi HTML c nhng th c nh, XML h tr DTD (Document Type Definition) cho php ngi dng nh ngha nhng th ring ca mnh. a) XML da trn SGML nhiu hn l HTML. b) C nhiu cng c vit XML, nhng nhng phn mm word l cng c ph bin. Nhng trnh bin tp text thng thng cng c th c s dng. Trong trng hp , ta cn to trc tip d liu XML. c) Khng ch cu trc logic v style c nh ngha, m nhng thng tin v thuc tnh (nh thuc tnh tn, thuc tnh v kiu ) cng c th c nh ngha

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

363

Bi thi th FE (Bui sng) p n v Gii thch -

Q52: [p n ng]

Stub c s dng m phng chc nng ca cc modul mc di ca m-un c test. Ta thng test tng unit (unit test) v test t trn xung (top down test). a) y l m t v snapshot. c) y l m t v mt cng c g li. d) y l m t ca driver.

Q53: [p n ng]

Trong nhng hot ng c th, mng ca mt cng ty c s dng trao i d liu vi cc vn phng chi nhnh trong c nc. Tuy nhin, vic kim tra thng ch kim tra mng LAN vn phng tr s. V th, c nhng khc bit gia hot ng ca mng LAN tr s vi h thng mng ca ton cng ty. S khc nhau ny nh hng ti thi gian hi p. a) Thi gian x l ca mt chng trnh ng dng ph thuc vo kh nng thc thi ca server. N cng ph thuc vo s lng thit b ang hot ng vo thi im , nhng iu ny c th gii quyt bng cch kt ni cng mt s lng thit b vo mng LAN khi kim tra. c) S lng thit b kt ni vo mng rt c nh hng ti vic kim tra, nhng, nh gii thch cu a, iu ny c th d dng x l bng cch ni cng mt s lng thit b vo mng LAN khi kim tra. d) S lng cc tin trnh chy trn server ph thuc vo kh nng thc thi ca server. N thng t b nh hng bi kh nng hot ng ca mng.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

364

Bi thi th FE (Bui sng) p n v Gii thch -

Q54: [p n ng]

Vic xc nh s lng cc iu kin ( rng nhnh) l mt trong nhng k thut ca kim th hp trng (white box testing), n cng kim tra quan h gia cc iu kin ng/sai. Trong quyt nh A OR B, ta cn chun b 2 b d liu kim tra, mt cho trng hp ng v mt cho trng hp sai. xc nh tnh ng/sai, ta c th thay sai bng 0 v thay ng bng 1 ri thc hin cng logic (A OR B). a) Trong trng hp ny, ch c duy nht 1 trng hp kim th, v th vic kim th bng cch xc nh s lng iu kin s khng c thc hin. Thm na, v kt qu l ng nn ch dn khng c thc hin. A B A OR B F T T 0 1 1 b) Tt c cc trng hp kim th u cho kt qu ng, v th ta khng c c 2 b kt qu ng v sai. A B A OR B F T T 0 1 1 T F T 1 0 1 c) 2 b d liu kim th u c chun b k, mt b cho trng hp ng v mt b cho trn hp sai. Chng c th c s dng xc nh rng nhnh. A B A OR B F F F 0 0 0 T T T 1 1 1 d)Tt c cc b d liu u l ca trng hp ng, v th ta khng c 2 b kt qu ng, sai khc nhau.. A B A OR B F T T 0 1 1 T F T 1 0 1 T T T 1 1 1

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

365

Bi thi th FE (Bui sng) p n v Gii thch -

Q55: [p n ng]

PERT K thut nh gi v kim nghim chng trnh mt phng php lp lch biu, n dc s l dng trong cc d n c ln. Trong phng php ny biu mi tn c dng to ra lch biu: ng gng l ng lin kt cc hot ng khng c php chm tr trong biu mi tn. Nu mt hot ng trn ng gng b chm tr th ton b d n s b chm tr. a) Cc hot ng ny c th c xc nh bng phn tch ABC s dng biu Pareto. b) Biu mi tn c th xc nh c mi quan h v thi gian gia cc hot ng v thi gian cn thit hon thnh cc hot ng.Nhng n khng xc nh c th t thc hin cc hot ng no c th b thay i. d) Chi ph ca mi hot ng c th c xc nh thng quan biu mi tn, do chng ta c th xc nh c hot ng no c chi ph ln nht (v thi gian). Hot ng c chi ph ln nht khng th c xc nh thng qua ng gng.

Q56: [p n ng]

Phng php cho im chc nng (FP method) l mt m hnh chi ph cho php gm kch thc phn mm theo ngha gim s lng chc nng trong phn mm, ch khng phi gim s bc ca chng trnh. iu ny da trn khi nim : nhng g ngi dng tht s cn khng phi ch l bn thn chng trnh m cn l nhng thng tin (v d mn hnh hay l ca mt sheet) m chng trnh a ra. Trong phng php FP, cc chc nng c chia thnh 5 loi, v vi mi chc nng, ta s tnh im cho n. Sau , thi gian load s c c lng bng cch so snh kt qu tnh vi gi tr thc lc trc. Chc nng Gii thch S lng im c xc nh bng loi thng tin vo v mc phc tp ca u vo bn ngoi thng tin . S lung im c xc nh bng loi thng tin ra v mc phc tp cu u ra bn ngoi thng tin . S lng im c xc nh bng loi cu hi v mc phc tp ca cu Yu cu bn ngoi truy vn. S im c xc nh bng loi v mc phc tp ca nhng truy cp ng File logic bn trong thi.
File giao ngoi din bn S im c xc nh bng loi v mc phc tp ca giao din kt ni vi cc h thng khc

a) y l m t phng php cc bc chng trnh. b) y l m t phng php c lng t di ln. c) y l m t ca phng php ng dng.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

366

Bi thi th FE (Bui sng) p n v Gii thch -

Q57: [p n ng]

Ch s kim tra l mt k t c thm vo sau d liu gc ngn nga nhng li nhp liu ca d liu s v nhng d liu khc. . D liu c x l

XXXXXX
D liu gc

Ch s kim tra

Ch s kim tra thu c bng cch thc hin mt s lng nht nh cc thao tc trn d liu gc. Khi d liu c nhp vo, ton b khi gm c s kim tra cng c nhp vo. My tnh sau s s dng nhng thao tc tng t vi thao tc to s kim tra kim tra s kim tra c nhp. Nu kt qu kim tra trng khp, d liu nhp s c xc nh l chnh xc. Ch s kim tra thng c s dng kim tra code. Nu code ban u c 5 ch s,th mt s kim tra c thm vo, d liu sau s c 6 ch s. b) y l gii thch cho chc nng ca mng trong d liu. Nu cc m v khch hng c gn nhng s lin tip nhau th chng c th c lit k theo th t m chng c nhp vo c) y l gii thch cho chc nng nhn dng code.V d, nu m khch l MINATO -011 th r rng khch hng l MINATO. Mt v d khc nh m sn phm TV-011, ta c th bit ngay sn phm ny l tivi d) y l gii thch cho chc nng phn loi ca m. V d, nu m khch hng c nh dng 1-100, trong s u tin l m vng, th d liu c phn chia theo a l.

Q58: [p n ng]

Gim dn ngha l khi lng hay s lng gim dn theo thi gian. H thng chi ph gim dn l h thng c thu ph trong gi ca ti nguyn s dng phi tr ph s gim khi lu lng s dng cng nh s lng ngi dng tng ln.Trong h thng ny, t l chi ph phi tr gim khi s lng ngi v lu lng s dng tng ln. vi s tng ln ca.Nh vy, th h thng chi ph gim dn nh hnh bn.Trong , trc honh ch lu lng s dng, cn trc tung ch chi ph s dng.Gi tr ca y gim khi x. th (a) v (d) l i lp vi h thng chi ph gim dn v t l ph phi tr tng khi lu lng s dng tng. th (b) khng ng v chi ph khng th l hng s trong h thng ny.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

367

Bi thi th FE (Bui sng) p n v Gii thch -

Q59: [p n ng]

Mt ngun cung cp t ngt c th hiu l do mt in hoc do s h hng ca h thng cung cp in. Cc thit b nh bng n chiu sng th khng b nh hng qu nhiu v hin ny, tuy nhin h thng my tnh c th b h hng phn cng hoc cc vn khc. V chng trnh ang c thc thi v b dng t ngt nn h thng file, c s d liu c th b ph hy. a) CVCF (Constant Voltage and Constant Frequency Ngun cung cp tn s v in p khng i) l thit b cung cp ngun in c tn s v in p n nh, nu mt in t ngt, khi ny s dng ngun cung cp. b) UPS (Uninterrupted Power Supply Ngun cp in khng ngt) cn gi l b lu in, n l ngun cung cp d phng cho h thng my tnh.UPS bo v my tnh khi b mt d liu do mt ngun cp in t ngt. Khi mt in t ngt, h thng s chuyn t in li sang s dng nng lng trong pin ca UPS do bin thin in p l nh nht. My tnh c th x l thm trong khong t 5 n 120 pht na. V thng thng UPS cng cung cp sn CVCF. c) My pht in ring l mt thit b cn thit nu tnh trng mt in ko di. V my pht in ring cn thi gian khi ng nn n khng th cp in ngay lp tc cho my tnh khi mt in. Ch khi no in p t c mc n nh th n mi c cung cp cho my tnh.Nh vy, my pht in ring v UPS l mt b y cung cp nng lng cho h thng trong trng hp mt in. My pht in ring khng ph hp trong trng hp mt in trong khong thi gian ngn do kch thc v gi c ca n. d) Thit b nhn nng lng d phng l mt thit b gm 2 chc nng. Khi b mt in li, h thng nhn nng lng d phng s cung cp in cho h thng in ca cng ty (my tnh,thit b chiu sng,). Khi c in li, th thit b nhn nng lng d phng s t ng np nng lng phc v cho ln tip theo. Do mt thi gian nn n khng ph hp khi mt in trong thi gian ngn.

Q60: [p n ng]

V chng ta ang kim tra xem c li pht sinh khi chng ta thay i hoc sa cha h thng hay khng nn y l kim th trong giai on bo tr ch khng phi l trong giai on pht trin h thng. a) Kim th hiu nng l kim th xc nh h thng pht trin c p ng c cc mc tiu v hiu nng t ra hay khng. Kim tra thi gian hi p(Response time) v TPS c tin hnh cho h thng x l trc tuyn(online system) trong khi kim tra tc truyn v thi gian x l c tin hnh cho h thng x l theo l (batch process). b) Kim th chu ng (Endurance Test), Kim th ny c thc hin xc nhn mt h thng c th tr vng trong nhiu gi lin tc thc hin cc lnh, cc thao tc hay khng. c) Kim th hi quy l kim th c tin hnh trong sut giai on bo tr.Trong giai on ny h thng c th b sa i loi b li pht sinh hoc thay th mt phn ca c t h thng.Kim th nay bo m rng nhng thay i v sa cha khng lm anh hng n cc phn khc ca h thng. d) Kim th ngoi l l kim th c tin hnh bng cch a cc d liu ngoi l, v d nh d liu vt ra ngoi phm vi cho php. Kim th ny kim tra xem h thng c hot ng nh th no khi c li d liu.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

368

Bi thi th FE (Bui sng) p n v Gii thch -

Q61: [p n ng]
M hnh tham chiu OSI : Tng 7 Tng 6 Tng 5 Tng 4 Tng 3 Tng 2 Tng 1

d
Trao i thng tin gia cc ng dng. M t dng ca thng tin truyn. Qun l cc hnh thc tng tc. Bo m cht lng d liu truyn gia cc tin trnh. nh ngha n v d liu. nh ngha n v khung. nh ngha v trng thi vt l v in

Application layer Presentation layer Session layer Transport layer Network layer Data link layer Physical layer

a) M t tng vn chuyn do cp n vn kim sot lung, kim sot li v kim sot d liu. b) M t tng ng dng do cp n truy cp t xa v truyn file. c) M t tng lin kt d liu v n cp n giao thc kim sot li, kim sot thi gian gi nhn, kim sot khi phc d liu. d) M t tng phin v n thit lp mt knh giao tip logic, qun l ng x l (kim sot cc im ng b), v bo li.

Q62: [p n ng]

Kim tra Parity c th pht hin v sa mt bit li bng cch thm m parity cho tng hng v tng ct. Phng php ny c th pht hin c 2 bit li, nhng khng th sa c. Trong v d ny, ngi ta a ra mt bng trong s lng bit 1 l chn, c theo chiu ngang cng nh chiu dc. v vy Parity l chn. Vi 3 bt li, cng vic pht hin li c tn hnh nh hnh v.Gi s 3 bit li nm trong vng t m vin(gc trn bn tri) :
0 0 0 1 0 1 0 0 1 0 0 1 1 0 0 0 0 0 1 1 1 0 Tng s bit 1 l l. 1 1

Tng s bit 1 l l. Trng hp ny ging vi trng hp c 1 bit li, nu ta tin hnh sa li ca 1 bit nh trong hnh th ton b s tr thnh khng c li, nh vy li c th pht hin nhng khng th sa c.
0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 0 0 0 1 1 1 0 1 1

V vy kim tra parity c th pht hin v sa sai nu s bit li l 1.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

369

Bi thi th FE (Bui sng) p n v Gii thch -

Q63: [p n ng]

Trong phng thc truyn start/stop, mi k t bao gm 8 bt, mt bt c chn vo u v mt bit c chn vo cui chui bit cn truyn. V vy d di chui bit cn truyn l 10 bit cho mt k t. Mt thng ip bao gm 90 k t (90 10 = 900 bits), th thi gian truyn cho n c tnh nh sau : Thi gian truyn mt thng ip = = = 90 bytes 10 bits/byte 14,400 bits/sec 9 102 144 102 9 (sec) 144

Nh vy, s lng thng ip c truyn trong mt giy l : S lng thng ip truyn i trong mt giy = = 1 Thi gian truyn mt thng ip 144 (thng ip) 9

S lng thng ip c truyn trong mt pht = S lng thng ip truyn i trong mt giy 60 = 144 9
60 = 960 (thng ip)

Tuy nhin, t l s dng ng truyn l 80%, v vy s lng thng ip c th c truyn trong mt pht l s: 9600.8=768 (thng ip).

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

370

Bi thi th FE (Bui sng) p n v Gii thch -

Q64: [p n ng]

T l s dng ng truyn l t l gia lng d liu thc s chuyn qua mng v kh nng thc t ca ng truyn : T l s dng ng Amount of data transferred 100 (%) Transmission speed truyn = (1) Tnh ton lu lng d liu truyn. Cc files c kch thc l 1000 bytes, nhng thng tin iu khin chim 20% tng d liu truyn. Mt file gi i mt 2 giy, vy lu lng d liu truyn trong mt giy l : Lu lng(mt giy)= = 1,000 (1 + 0.2) 2 1,200 2

= 600bytes/sec Mi byte l 8 bits,v vy s lng bt truyn trong mt giy l : S lng bit truyn i trong mt giy = 600 8 = 4,800 (bits/sec) (2) Tnh ton t l s dng ng truyn. Tc truyn thng l 64,000 bits/sec v lu lng d liu thc t l 4,800 bits/sec, T l s dng ng truyn c tnh nh sau : Tc s dng ng 4,800 (bits/sec) 100 64,000 (bits/sec) truyn = 48 640 100 = = 0.075 100
7.5 (%)

Q65: [p n ng]

10BASE-T l mng LAN kiu CSMA/CD; n l mng sao vi mt my ch truy cp gia. My ch ny i khi c trang b mt n bo xung t, n ny s sng trong trng hp c xung t xy ra. b) Khng c gii hn v s lng my tnh c th c kt ni vo mng 10BASE-T; tuy nhin, kt ni xp tng n my ch b gii hn 4 tng. Nu gii hn ny b vt qu th d liu s khng th n c mt s my tnh nhng n bo xung t khng sng trong trng hp ny. c) Trong phng php CSMA/CD c lut qui nh kt ni phi l 1-to-1, v th thi gian x l ca cc my tnh khng lin quan. Nu d liu c gi i v c nhn, n bo xung t cng khng sng. d) Nu my ch vt qu 4 tng kt ni, d liu khng th truyn n mt s my tnh nhng n bo xung t vn khng sng.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

371

Bi thi th FE (Bui sng) p n v Gii thch -

Q66: [p n ng]

a) Cng mng l mt thit b hay mt phn mm c s dng kt ni cc mng trong tt c cc tng (ch yu l t tng 4 tr ln) trong m hnh tham chiu c bn OSI. b) Cu ni l thit b kt ni cc mng LAN s dng giao thc ca tng th 2 (tng lin kt d liu) trong m hnh tham chiu c bn OSI. Bi v y l tng lin kt d liu, kt ni s truyn cc khung tin da trn a ch MAC. B nh tuyn mi l truyn cc khung tin da trn a ch IP. c) B lp kt ni cc mng LAN s dng giao thc ca tng th nht (tng vt l) trong m hnh tham chiu c bn OSI. N khuych i cc tn hiu v m rng khong cch ng truyn. d) B nh tuyn kt ni cc mng LAN s dng giao thc ca tng th 3 (tng mng) trong m hnh tham chiu c bn OSI. Bi v l tng mng nn kt ni s truyn cc khung tin da trn a ch IP. Trong khi cu ni truyn khung tin theo a ch MAC.

Q67: [p n ng]

Dng chun 3 l dng chun trong tt c cc thuc tnh khng phi l kha chnh u c suy dn trc tip t cc thuc tnh trong kha chnh. Trong bn ghi m cu hi a ra, kha chnh l (A,B), kha ny c th suy dn ra C,D,E v F. Nhng F li c th c suy dn t B. N c suy dn t mt phn ca kha chnh v th n phi b loi tr. iu ny c ngha l F c suy dn t (A,B) nhng cng c th c suy dn t ring (B) mt phn ca kha chnh. Khi mt phn ca kha chnh c th suy dn ra mt thuc tnh khng nm trong kha chnh, ngi ta gi l ph thuc hm tng phn (partial functional dependency); ngc li, nu tt c suy dn ch c th i t kha chnh th ngi ta gi l ph thuc hm ton phn (full functional dependency). By gi, ta tch cc bn ghi ra sao cho F c th tr thnh ph thuc hm ton phn. C th, ta c th c c dng chun ba nh sau:

iu ny ng vi la chn (b).

Q68: [p n ng]

Php chiu ly ra cc ct c th t mt bng. a) y l nh ngha php hp. b) y l nh ngha php chn. d) y l nh ngha php chiu.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

372

Bi thi th FE (Bui sng) p n v Gii thch -

Q69: [p n ng]

Cu ln SQL cho c dch nh sau: : To ra khung nhn " SanPhamCoLai" CREATE VIEW SanPhamCoLai AS : AS ni tip cu lnh SELECT trong nh ngha VIEW SELECT * : Tt c cc thuc tnh u c ly. FROM SanPham : Cc thuc tnh c ly t bng SanPham. WHERE GiaBan GiaMua >= 400 : (GiaBan GiaMua >= 400) Cu lnh SQL ny tnh lch gia gi bn v gi mua cho mi sn phm trong bn SanPham v ch ly nhng hng m gi tr chnh lch ln hn hoc bng 400. Khi cu lnh ny c thc hin, 2 hng s c ly ra nh trong bng di y.
MaSanPham MoHinh GiaBan GiaMua GiaBan GiaMua

Gi tr chnh lch

S001 S003 S005

T2003 S2003 R2003

1500 2000 1400

1000 1700 800

500 300 600

c ly c ly

a) Khi gi bn cho m hnh R2003 c cp nht thnh 1300, (GiaBan GiaMua) tr thnh: (GiaBan GiaMua) = 1300 800 = 500 >= 400 N c chn t trc v vn c chn sau khi thay i cho nn s hng khng i. b) Khi gi bn cho m hnh R2003 c cp nht thnh 900, (GiaBan GiaMua) tr thnh: (GiaBan GiaMua)= 1400 900 = 500 >= 400 N c chn t trc v vn c chn sau khi thay i cho nn s hng khng i. c) Khi gi bn cho m hnh S2003 c cp nht thnh 1500, (GiaBan GiaMua) tr thnh: (GiaBan GiaMua) = 2000 1500 = 500 >= 400 N khng c chn trc khi thay i v c chn sau khi thay i nn s hng c chn s tng ln. d) Khi gi bn cho m hnh T2003 c cp nht thnh 1300, (GiaBan GiaMua) tr thnh: (GiaBan GiaMua) = 1300 1000 = 300 < 400 N c chn trc khi thay i nhng khng c chn sau khi thay i nn s hng c chn s gim.

Q70: [p n ng]

File nht k trong mt h c s d liu l file ghi li ni dung ca cc bn ghi trong c s d liu trc khi chng c cp nht (thng tin trc khi cp nht, phin bn trc), ni dung ca cc bn ghi trong c s d liu sau khi cp nht (thng tin sau khi cp nht phin bn sau), v cc thng tin giao dch. Khi mt li xy ra trong c s d liu, c s d liu s c phc hi li bng c thng tin c c trong cc file nht k ny. a) y l gii thch v file im canh. b) y l gii thch v nhn bn file, trong cng 1 file nh vy c to ra trn nhng a khc, trong trng hp b li v a th nhng a nhn bn kia s c s dng lm vic. c) y l gii thch v sao lu.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

373

Bi thi th FE (Bui sng) p n v Gii thch -

Q71: [p n ng]

Trong phng php m ha kha cng khai, mt vn bn thng c m ha s dng m cng khai ca ngi nhn v ngi nhn s gii m vn bn m ha s dng m c nhn ca anh ta.

Q72: [p n ng]

Mng Internet l mt mng lm vic m, v vy vic trao i cc thng tin trn mng i hi cc bin php bo mt chng hn nh m ha. Mt t chc cn phi ci t h thng tng la ti im kt ni ca n vi mng Internet phng chng cc truy cp tri php t bn ngoi vo. a) Tng la l mt h thng hoc mt my tnh lm nhim v bo v mt mng ni b chng hn nh mng LAN trong mt cng ty khi cc truy cp tri php. N c ci t chn li cc truy cp tri php t bn ngoi vo mt mng LAN khi c ni vi mng ngoi chng hn nh mng Internet. Mc ch ca tng la l chng truy cp tri php t bn ngoi, nhng khng phi l chng r r thng tin t bn trong. Vic r r cc thng tin quan trng t hoc bn trong cng ty khng th c phng chng mt cch t ng, v vy cn phi c cc bin php khc na. b) Mt khi truy cp c php hot ng trn mng Internet, ngi ta khng th d on trc c mng li s hot ng nh th no. V vy, cn phi c cc bin php nhm chng truy cp tri php n cc c s d liu v chng gi mo d liu. c) Vic kim tra xem th in t c n ni khng v vic m ha l hai vn hon ton khc nhau. Vic kim tra th n ch l xc minh xem ngi nhn nhn c th hay cha, n khng lin quan g n vic ni dung ca bc th nh th no. Ngc li, m ha l bin php c s dng vi mc ch khin cho ni dung ca bc th khng th c c bi mt ngi khc. d) Mng Internet l mt mng li m i vi tt c mi ngi. Nu ai ng k vi nh cung cp dch v Internet kt ni th h c th dng mng Internet. Vic ng k ngi dng hp l ca h thng l khng cn thit.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

374

Bi thi th FE (Bui sng) p n v Gii thch -

Q73: [p n ng]

S dng h thng qun l cht lng mt cch c hiu qu ngha l vic qun l cht lng c thc thi mt cch hiu qu. Mc ch l t c s hi lng ca khch hng bng cch thc thi y cc hot ng qun l cht lng. y khng phi l s nh gi v cc chun hay cht lng ca mi sn phm c sn xut ra m l nhgi h thng qun l cht lng. a) BS7799 l chun qun l an ton thng tin c a ra bi t chc BSI (Hc vin chun Anh Quc). Mt chun cng tng t nh BS7799 c chun ha trn ton th gii bi t chc ISO l ISO/IEC 17799. b) ISMS (Information Security Management System H thng qun l bo mt thng tin) l mt c cu tng quan cho cc cng ty v cc t chc nhm qun l thng tin mt cch chnh xc v bo mt cc thng tin mt. N l mt h thng qun l tt c cc ri ro bao gm khng nhng cc bin php bo mt cho h thng my tnh m cn c nhng qui nh c bn v bo mt trong vic x l thng tin, nhng k hoch c th da trn cc qui nh, p dng v thc thi cc k hoch, v nh k xem xt li cc qui nh v cc k hoch. Vic tng nhanh cc truy cp tri php, cc virus my tnh, r r thng tin khin cho ngi ta cng ngy cng quan tm n vn qun l thng tin nhiuh hn, v cng nhiu cng ty c c chng ch ISMS. c) ISO 9001 l mt chun trong s cc chun trong chui ISO 9000 c xy dng bi t chc ISO, lin quan n h thng m bo cht lng ca cc cng ty. Chui ISO 9000 l mt tn tng qut cho cc chun quc t lin quan n cc h thng qun l cht lng. ISO 9001 a ra cc hng dn t c chng ch, cn cc chun khc a ra cc hng dn t c chng ch ISO 9001. y khng phi l mt chun sn phm m l mt s chng nhn quc t rng cng ty hay t chc tun theo cc iu sau: T chc c kh nng cung cp nhng sn phm ph hp vi yu cu ca khch hng v cc yu cu hp l khc. T chc lun lun c gng ci thin s hi lng ca khch hng.
ISO 9000 Cc khi nim v nh ngha v h thng qun l cht lng H thng qun l cht lng Yu cu tng quan, Yu cu v ti liu Trch nhim qun l (tp trung vo khch hng, cc qui nh cht lng, kim tra li, v..v..) Qun l ti nguyn (Cung cp ti nguyn, nhn lc, mi trng lm vic..v..v) Bn sn phm (Lp k hoch cho vic bn sn phm, cc qui trnh lin quan n khch hng, thit k v xy dng, v..v..) o c, phn tch, v ci tin (Qun l cc o c, qun l cc sn phm khng tun theo chun) Cc hng dn cho vic ci tin hiu nng.

ISO 9001

ISO 9004

ISO 9001 c chnh sa vo thng 12 nm 2000; cc yu cu trc y c t chc thnh 4 loi nh sau: Trch nhim qun l Qun l ti nguyn Qun l bn hng o c, phn tch v ci tin N c xc nh bng cc thnh phn nh: khi nim v cc h thng qun l cht lng v cc ci tin lin tc. d) ISO 14001 l mt chun quc t c xy dng bi ISO sao cho cc cng ty v cc t chc c th thc hin cc hot ng kinh doanh trong mi trng ton cu. N chng nhn cc kt qu qun l mi trng ca cc t chc, chng hn nh vic pht trin ngun nhn lc v thit lp h thng, gim gnh nng ln mi trng. ISO 14001 l mt chun cho vic chng nhn; cc t chc trung gian (t chc chng nhn) ng k vi cc cp thm quyn thc hin vic nh gi cc chun trn.
Ti liu n thi FE Tp.1
-- Phn2. Tp bi thi th --

375

Bi thi th FE (Bui sng) p n v Gii thch -

Q74: [p n ng]

V mi quan h gia gi nh trc v nhu cu c lng c th c tnh bng biu thc tuyn tnh, nn gi s x l gi nh trc v y l nhu cu c lng, ta c phng trnh sau: y = ax + b (a 0) [1] Thay th cc gi tr ca (1) v (2) c cho trong cu hi vo phng trnh [1] trn, ta c th tm ta a v b. (1) V x = 3000 v y = 0, ta c 0 = a 3000 + b 3000a + b = 0 b = 3000a Kt qu l, phng trnh [1] c th vit thnh: y = ax 3,000a [2] (2) V x = 1000 v y = 60000, thay th cc gi tr ny vo phng trnh [2], ta c: 60000 = 1000 a 3000a =1000a 3000a = 2000a 60000 a = = 30 2000 Vy, ta c th tm b nh sau: b = 3000a = 3000 (30) = 90000 Hay, phng trnh [1] c th vit thnh: y = 30x + 90000 [3] (3) Thay x = 1500 vo phng trnh [3] tm nhu cu c lng: y = 30 1500 + 90000 = 45000 + 90000 = 45000 (sn phm)

Q75: [p n ng]

CIO (Chief Information Officer Gim c thng tin) l cn b cp cao nht c nhim v qun l ton b cc h thng thng tin. Thng thng, trng phng qun l cc h thng thng tin s l mt CIO. CIO khng ch i hi phi c kin thc v cc h thng thng tin m cn c trch nhim thit lp cc chin lc my tnh ha trong cng ty, v vy anh ta/c ta cn phi c mt s hiu bit rng ri v ngnh cng nghip, lnh vc kinh doanh ca cng ty, v cng tc qun l. V vy, vai tr ca mt CIO l: khi thc hin mt chin lc IT, CIO l ngi thng qua mt k hoch nhm ti u hiu qu ca vic u t vo cc ti sn thng tin trong khp cng ty sao cho ph hp vi chin lc kinh doanh ca cng ty .

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

376

Bi thi th FE (Bui sng) p n v Gii thch -

Q76: [p n ng]

Mt im ha vn l mt im trong gi bn v ph tn l bng nhau, cho bit rng li nhun l 0. Nu gi bn trong sut mt thi k xc nh nh hn gi bn ti im ha vn, kt qu l l, nu chng ln hn, kt qu l li nhun. im ha vn c tnh ton nh sau:
Gi bn im ha vn

Chi phi co dinh 1- chi phi bien thien / gia ban 1,000 = = 5,000. 8,000 1 10,000

Nu bn khng bit cng thc ny, bn vn c th tr li cu hi s dng mt mt phng quan h, trc x l gi bn tng cng v chi ph l trc y nh di y.
12000 11000 10000 9000 8000 7000 6000 5000 4000 3000 2000 1000 0 0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 11000 12000

ng gi (tng cng) ng chi ph bin thin (tng cng)

im ha vn

ng chi ph c nh

(1)V ng chi ph c nh Chi ph c nh l hng s ($1,000), do vy y l ng song song vi trc x ng chi ph c nh: y = 1,000 (2) Tnh chi ph bin thin Chi ph bin thin l cc chi ph m t l trc tip n s lng bn. Nu chi ph bin thin l y v tng s lng bn l x, chng ta c biu thc Chi ph bin thin: y = x ( l hng s t l) (A) T bng c a ra trong cu hi, chng ta nhn thy rng khi x (tng lng bn) l 10.000$, y (chi ph bin thin) l 8000$, a vo cng thc (A), chng ta c kt qu 8,000 = 10,000. = 8,000 10,000 = 0.8

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

377

Bi thi th FE (Bui sng) p n v Gii thch -

(3) V ng gi tng cng. ng gi tng cng l tng cc chi ph c nh v chi ph bin thin. ng gi tng cng s thu c t biu thc ca (1) v (2) trn. ng chi ph bin thin (chi ph tng cng): y = 0.8x + 1,000 (B) (4) V ng bn tng cng V ng bn tng cng to gc 45 vi trc x (th hin chi ph v gi bn bng nhau) ng bn tng cng: y = x (C) (5) Tnh gi bn im ha vn Gi bn im ha vn l gi tr x ca giao im gi ng chi ph bin thin (chi ph tng cng) v ng gi tng cng. Do vy chng ta c (B) = (C). 0.8x + 1,000 = x x = 5,000

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

378

Bi thi th FE (Bui sng) p n v Gii thch -

Q77: [p n ng]

Phng php Delphi l mt k thut lp k hoch logic c s dng trong lp k hoch tng lai di hn v lp k hoch cng ngh. N c pht trin bi Rand Corporation ca Hoa Kv c phn loi di cc phng php trc gic. Cc phng php trc gic l cc phng php lp k hoch hoc d on da trn cc kinh nghim v hiu bit ca con ngi. Phng php Delphi c cc u im trong c tnh phn hi. Trong phng php ny, cc la chn ca mt s lng ln ngi c tp hp v phn tch thng qua bn cu hi, kt qu ca kho st c tng kt, c a ra cho ngi kho st v sau qu trnh kho st c lp li. Phng php ny c nhiu u im. u tin, n hiu qu khi k hoch khng th d on v s thay i cng ngh khng th tin hnh khi n thc hin mt phng php trc gic. N cng c th gip trnh cc nh hng bi tp cc thay i n t cc cuc gp i thoi chnh thc. Thm vo , khi mt kt lun t kho st khc vi quan im a s, cc quan im mi cha c gi tr.vn c th c s dng t cc l do c thm vo bi bn yu cu. Do vy s trnh by v la chn trong cc cu hi kho st l quan trng n s thnh cng ca phng php ny. a) Cc phn tch kt qu dng a ra v phn tch ngun gc nguyn nhn ca cc vn c tm ra trong cc h thng v cc hot ng. Khng c mt phng php thit lp c th cho n, nhng t nht trong trng hp ny khng cn lp li cc kho st ging nhau nh trong phng php Delphi. b) Mt phn on l mt n v m c phn chia chi tit. Mt phn on ca nhng ngi s dng dch v in thoi di ng c th c xc nh bi vic phn chia thng qua gii tnh hay nhm tui. Trong phn tch phn on, tn xut s dng dch v c nghin cu cho mi lp phn on. V d s phn tch c th kho st tt c cc ngi s dng dch v in thoi da trn tui ca h nh sau:
Tui Tng khng qu 20 21 n 30 31 n 40 41n 50. T 51tr ln Dch v 1 Dch v 2 Dch v 3 Dch v 4

10% 20%

20% 15%

50% 25%

20% 40%

Kho st c lm mt ln v khng cn kho st li nh phng php Delphi. c) Cc phn tch v s bin ng dn s l cc nghin cu v s thay i dn s t cc kha cnh khc nhau. V d n c th nghin cu s lng ngi mi sinh v s lng ngi cht.Trong trng hp ny, n s l cc phn tch theo chui thi gian, do cc kho st khng c lp li cng cc i tng nh phng php Delphi.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

379

Bi thi th FE (Bui sng) p n v Gii thch -

Q78: [p n ng]

Mt biu iu khin l mt biu c s dng kim tra nu cc tin trnh trong iu kin n nh v/hoc duy tr cc tin trnh trong iu kin n nh. Mt cp ca cc ng c v xc nh cc gii hn iu khin (mt cho gii hn iu khin trn v mt cho gii hn iu khin di), cc im c nh du xc nh c trng hay cc iu kin tin trnh. Nu cc im nm gia hai ng gii hn iu khin v nu chng khng c mt kiu d thng c trng, cc tin trnh c xem xt l trong cc iu kin n nh. Nu cc im nm ngoi ng gii hn iu khin hoc nu c mt vi kiu d thng trong cch chng dng ln, chng ta kt lun rng c mt vi l do khng nn c b qua. Nu trong trng hp ny, chng ta phn tch nguyn nhn v a ra cc d on chc chn rng n s khng xut hin li trong th t duy tr cc tin trnh trong cc iu kin n nh. Gii hn iu khin trn Trung tm (trung bnh) Gii hn iu khin di Gi tr d thng a) Mt biu mng li vi cc mi tn kt ni cc hot ng ring l v xc nh mi quan h th t ca chng cng c bit n nh mt biu mi tn. Cc c chai tin trnh c xc nh bng vic phn tch cc hnh ng trong mt ng gng (ti hn) b) Phn tch ABC l ph hp y d) Biu nguyn nhn v kt qu (hay biu xng c fishbone diagram) c th c s dng.

Q79: [p n ng]

V tng quan cho l 0.8 do n l mt tng quan mnh. ng hi quy cho thy mi quan h gia x v y xp x nh mt ng thng, dn n im ca nm trc trn trc x v im nm nay trn trc y. Do vy ng hi quy c biu din nh sau: y = ax + b (a 0) (1) V dc l 1.1 iu ny c ngha a = 1.1; do ct trc y ti 10 nn b =10. Chng ta c ng y = 1.1x + 10 a) im nm nay l 0 ngha l y = 0. do vy gi tr ca x (im nm ngoi) nh sau: 0 = 1.1x10 1.1x = 10 x = 9.090 -9.1 (lm trn n mt phn mi gn nht) Do im nm ngoi l 9.1 ch khng phi 10. b) im trung bnh cn c tnh ton bi vic thm cc im ring l. V d nu trung bnh nm ngoi l 50, x =50 khi ta c th nhn thy mi quan h gia x v y nh sau y = 1.1 50 + 10 = 65 y 65 = = 1.3 x 50 Khng quan tm n cc im ring l, im trung bnh khng phi l 1.1 ln im nm ngoi. c) Khi nhn vo b trn, ngi t im 50 nm trc s c im 65 nm nay. Do vy chng ta c th kt lun rng cc im d dng c c trong k kim tra nm nay hn nm trc. d) S phn tch ch v cc im v chng ta khng th c lng ni dung ca cc bi kim tra. Hn na, cu ni rng im bi thi nm nay cao hn khng nht thit ngha rng im d kim hn.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

380

Bi thi th FE (Bui sng) p n v Gii thch -

Q80: [p n ng]

a) Phng php dch chuyn trung bnh l mt phng php trong gi tr trung bnh c tnh ton cho mt s lng xc nh ca cc mc lin tip trc v sau mt gi tr c a ra trong tp d liu chui thi gian v sau cc gi tr kt qu trung bnh c lit k tm ra mt mu hay mt xu hng. V d n c s dng trong nh lng hng ha tn kho. Nu cc trng s c gn n cc gi tr tm ra gi tr trung bnh, n c gi l phng php trung bnh trng s. V d gi s rng tp d liu chui thi gian a ra mt gi tr cho mi thng trong mt giai on ca mt nm v cc gi tr l y1, y2, y11, y12. Khi dch chuyn trung bnh cho bt c mt giai on 3 thng no c a ra s nh sau: Y2 = (y1 + y2 + y3) / 3 Y3 = (y2 + y3 + y4) / 3 Y4 = (y3 + y4 + y5) / 3 . Y11 = (y10 + y11 + y12) / 3 Cc gi tr, Y2, Y3, Y4, Y11 c gi l cc gi t dch chuyn trung bnh. b) Phng php bnh phng nh nht c s dng c lng mi quan h tng quan gia hai s lng. V d nu c mt thc t rng nhng ngi c kt qu cao trong ton hc cng c kt qu cao trong khoa hc th cc im kim tra ton hc v khoa hc c biu din trong mt biu phn tn vi nhiu im v d. T biu phn tn ny, ai c th thu c biu thc quan h gia cc im mn ton v khoa hc. Khi mt biu thc c tm ra, bn bit im ca mt bi kim tra ton hay khoa hc, bn c th d on im kia. c) Lp trnh tuyn tnh l mt phng php trong cc hot ng nghin cu, trong mt hm mc tiu c biu din nh mt biu thc tuyn tnh v cc rng buc c biu din nh bt ng thc tuyn tnh hay ng thc tuyn tnh. Nu chng ta cho k hiu s lng sn phm l a, b, v c cho sn phm A, B, v C tng ng. Vi mc ch li nhun cao nht, chng ta c cc rng buc nh sau 2a + 3b + c < 240 2a + b + 2c < 150 Da vo cc rng buc ny, chng ta c th tm ra gi tr a, b, v c c gi tr ti a ca hm mc tiu: 8a + 5b + 5c d) H thng t hng s lng c nh l mt phng thc t hng trong s lng t hng c gi khng i nhng thi gian t hng khc nhau ph thuc vo s thay i ca yu cu. N l mt khi nim cho php s thay i ca yu cu c quan tm trong khong thi gian t hng. Mt n hng c thc hin khi s hng trong kho gim di mt mc xc nh v n cng c gi l phng thc im t hng

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

381

Bi thi th FE (Bui chiu)

Bi thi th (Bui chiu)


K s IT c bn

Cc cu hi phi c tr li theo quy nh di y:

Cu hi s La chn cu hi Thi gian thi

Q1 - Q5 Bt buc

Q6 - Q7 La chn 1 trong 2 150 pht

Q8 - Q9 La chn mt trong 2

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

382

Bi thi th FE (Bui chiu)

[Gii thch cc nh dng gi m lnh]

C php ngn ng gi m lnh

Din t Vng lin tc ni m t khai bo v tin trnh

bin Biu thc Cng vic 1 [ Cng vic 2 ]


Biu din iu kin S biu din iu kin

Tn khai bo, kiu ca th tc, bin Gn gi tr ca mt biu thc cho mt bin Mt s la chn cng vic. Nu iu kin din t l ng th cng vic 1 c thc hin [m rng] Nu iu kin l sai th cng vic 2 c thc hin. Mt tin trnh lp i lp li vi iu kin u tin. Cng vic cn c thc thi trong khi iu kin cn ng.

Cng vic

[Ton t]

Php ton Php ton mt ton hng Php ton nhn v chia Php ton cng v tr Php ton quan h Nhn logic Cng logic Php ton xor
[hng s kiu logic]

Ton t + - not * / + > < >= <= = and or xor

Mc u tin Cao

Thp

true false

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

383

Bi thi th FE (Bui chiu)

T cu 1 n cu 5 l bt buc. Hy tr li tt c cc cu.

Q1. c cc din t sau v cc php ton logic v b cng y , sau tr li cc cu hi con t 1 n 3. (1) Cc k hiu mch logic cho cc php ton logic chnh nh sau.

(2)

Hnh di y m t b cng y , cng cc s nh phn c nh. Bng biu din bng tht ca b cng y .

Fig. B cng y (k con s) Bng Bng tht ca b cng y

Ck 0 0 0 0 1 1 1 1

Input Ak 0 0 1 1 0 0 1 1

Output Bk 0 1 0 1 0 1 0 1 Ck+1 0 0 0 1 0 1 1 Zk 0 1 1 0 1 0 1

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

384

Bi thi th FE (Bui chiu)

Cu hi con 1
T nhm cc cu tr li sau, la chn cu tr li chnh xc in vo ch trng bng tht ca b cng y . trong

Nhm cu tr li: a) c)
0 1 0 0

b) d)

0 1

1 1

Cu hi con 2
T nhm cc cu tr li sau, la chn cu tr li chnh xc in vo ch trng mch logic ca b cng y .
Ak Bk Zk

trong

Ck

Ck+ 1

Nhm cu tr li a) b) c)

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

385

Bi thi th FE (Bui chiu)

Cu hi 3
Khi mt mch logic c cu hnh vi b cng y cng s nh phn n ch s biu din di dng s b hai, php cng ca cc ch s c ngha nht (An, Bn v Cn ) l nguyn nhn gy ra trn (phn t m trong bng tht ca b cng y ). Mt mch logic cho vic pht hin iu ny bng cch cu hnh vi mt phn t XOR. Chn t nhm cc cu tr li sau y s kt hp ng ca cc u vo X v Y cho mch logic ny.

Nhm cu tr li: a) An, Bn b) An, Zn e) Cn, Zn c) f) Bn, Zn Cn+1, Zn

d) Cn, Cn+1

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

386

Bi thi th FE (Bui chiu)

Q2. c cc m t di y v c s d liu quan h. Sau tr li cc cu hi con t 1 n 3. C s d liu quan h di y gm c mt bng Nhn vin v mt bn K nng nhn vin. Bang_Nhan_Vien MaNhanVien TenNhanVien 0001 0002 0003 0004 0005 0006 Brown Charles Taylor Williams Parker James Phong A1 A2 B1 D3 A1 B1 Bang_Ky_Nang_Nhan_Vien MaNhanVien MaKyNang NgayDangKy 0001 0001 0002 0002 0002 0005 FE DB NW FE SW NW 19991201 20010701 19980701 19990701 20000701 19991201

Cu hi con 1.
T cc nhm cu tr li pha di, chn cc cu tr li ng in vo cc trng trong on m t sau. True c tr v cho mnh EXISTS khi kt qu ca cu truy vn con tn ti v False c tr v nu khng tn ti. Khi cu truy vn SQL sau c thc thi th s lng nhn vin c chn l

SELECT MaNhanVien FROM Bang_Ky_Nang_Nhan_Vien WHERE EXISTS (SELECT * FROM Bang_Ky_Nang_Nhan_Vien WHERE MaKyNang = 'FE') Nu cu truy vn con cha tham chiu n mt bng khc trong cu truy vn chnh th Mnh EXISTS nh gi tng hng tng ng vi tham chiu . Khi cu truy vn SQL sau c thc thi th s lng nhn vin c chn l

SELECT TenNhanVien FROM BangNhanVien A WHERE EXISTS (SELECT * FROM Bang_Ky_Nang_Nhan_Vien B WHERE MaKyNang = 'FE' AND A.MaNhanVien = B.MaNhanVien)

Nhm cu tr li cho A v B: a) 0 e) 4 b) 1 f) 5 c) 2 g) 6 d) 3

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

387

Bi thi th FE (Bui chiu)

Cu hi con 2.
Cu truy vn SQL sau a ra mt s m nhn vin. Nhn vin no s c chn? T nhm cu tr li di y, chn cu tr li ng. SELECT DISTINCT MaNhanVien FROM Bang_Ky_Nang_Nhan_Vien B1 WHERE EXISTS (SELECT * FROM Bang_Ky_Nang_Nhan_Vien B2 WHERE B1.MaNhanVien = B2. MaNhanVien AND B1.MaKyNang < > B2.MaKyNang)

Nhm cu tr li: a) Nhng nhn vin no c t nht mt k nng. b) Nhng nhn vin no ch c duy nht mt k nng. c) Nhng nhn vin no khng c k nng. d) Nhng nhn vin no c nhiu k nng.

Cu hi con 3.
Bn mun thm tn nhn vin vo thng tin thu c t Cu hi 2. T nhm cu tr li di y, chn cu tr li ng in vo trng trong cu truy vn SQL sau.

SELECT DISTINCT A.MaNhanVien, TenNhanVien FROM Bang_Nhan_Vien A, Bang_Ky_Nang_Nhan_Vien B1 WHERE EXISTS (SELECT * FROM Bang_Ky_Nang_Nhan_Vien B2 WHERE B1. MaNhanVien = B2. MaNhanVien AND B1.MaKyNang < > B2. MaKyNang)

Nhm cu tr li:

a) AND A.MaNhanVien = B1. MaNhanVien b) BETWEEN A. MaNhanVien AND B1. MaNhanVien c) LIKE A. MaNhanVien = B1. MaNhanVien

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

388

Bi thi th FE (Bui chiu)

d) OR A. MaNhanVien = B1. MaNhanVien

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

389

Bi thi th FE (Bui chiu)

Q3. c on m t chng trnh sau, sau tr li cc cu hi t 1 n 3.

[M t chng trnh]

Chng trnh ny thc thi chc nng ca mt trnh son tho vn bn. (1) Trnh son tho vn bn ny c th cha 80 k t trn mt dng v ti a ln n MAX dng. (2) (i) (i) Bin ton cc sau c khai bo CP: Bin ny ch ra dng c thc hin

(3) Cc chng trnh con sau c nh ngha INSERT(x): Thm mt dng mi x ti dng c ch bi CP. Vic thm ny s lm cho dng hin ti v cc dng sau b y xung 1 dng. (ii) DELETE(): (iii) LAST(): (iv) GET(): Xa dng ch bi CP. Vic xa ny lm cho dng tip theo v cc dng sau y ln 1 dng. Tr v th t dng dng cui (s dng ca vn bn). Nu vn bn rng tr v 0. Tr v xu k t trn dng ch bi CP.

Cu hi con 1.
Mt xu k t kiu mng LINE[i] (i = 1, 2, , MAX) v bin kiu nguyn TAIL c nh ngha trong chng trnh. Xu k t Li trn dng i c lu tr trong LINE[i]v mt ch s ca phn t mng (0 nu rng) lun c gn vi dng cui cng c lu tr trong bin TAIL. Bin CP cha mt ch s ca phn t mng ng vi dng c thc thi. T nhm cu tr li di y, chn chng trnh con m tng s lng (theo trnh t) tnh ton cn thit l mt hng s khng ph thuc s dng vn bn (chn tt c cc cu tr li thch hp).

Ch s phn t 1 2
TAIL

LINE L1 L2

n
MAX Hnh 1.

Ln

V d: S dng mng

Nhm cu tr li: a) DELETE ( ) b) GET ( ) c) INSERT (x) d) LAST ( )

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

390

Bi thi th FE (Bui chiu)

Cu hi con 2.
Chng trnh c thay i s dng mt danh sch mc ni kp dng con tr nh hnh 2. Phn t i trong danh sch bao gm con tr tr n phn t cha dng i1, xu k t Li dng i v con tr tr n phn t cha dng i+1. Nu mt phn t no khng tn ti gi tr con tr s l 0. Bin HEAD l mt con tr tr n phn t cha dng u tin. Bin TAIL l con tr tr n phn t cha dng cui cng. Bin CP l con tr tr n phn t cha dng ang c thc thi. T nhm cu tr li di y chn chng trnh con m tng s lng (theo trnh t) tnh ton cn thit l mt hng s khng ph thuc s dng vn bn (chn tt c cc cu tr li thch hp).

Hnh 2. V d: S dng con tr

Nhm cu tr li: a) DELETE ( ) Cu hi con 3. T nhm cu tr li di y, chn cc cu tr li ng in vo cc trng on sau: trong b) GET ( ) c) INSERT (x) d) LAST ( )

Mt danh sch lin kt 2 chiu s dng con tr c thc thi bng cch dng 3 mng. Hnh 3 l mt v d ca trng hp m s dng ti a l 10. Bin CP cha ch s ca cc phn t mng cha dng c x l. Bin HEAD cha ch s phn t mng cha dng u tin. Bin TAIL cha ch s ca phn t mng cha dng cui cng. Bin EMPTY cha ch s ca phn t mng u tin trong danh sch rng cha. Gi s rng cc dng L1, L2, L3, L4, v L5 c lu tr nh hnh 3 v CP=8. Nu DELETE() c thc thi xa phn t mng cha L3 sau gi tr ca HEAD v TAIL khng thay i v EMPTY = 8, PREV[9] =
A

, NEXT[2] =

, v NEXT[8] =

. Gi s rng phn t

mng b xa c thm vo u danh sch rng.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

391

Bi thi th FE (Bui chiu)

CP 8 HEAD 4 TAIL 6 EMPTY 3

Ch s phn t 1 2 3 4 5 6 7 8 9 10

PREV 4 0 9 2 8

LINE L2 L1 L5 L3 L4

NEXT 0 8 5 2 7 0 10 9 6 1

Hnh 3. V d: Thc thi danh sch lin kt 2 chiu s dng mng

Nhm cu tr li: a) 0 e) 7 b) 1 f) 8 c) 2 g) 9 d) 3 h) 10

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

392

Bi thi th FE (Bui chiu)

Q4. c on m t v chng trnh di y ri tr li cc Cu hi con 1, 2, v 3.

[M t chng trnh]
Chng trnh con HeapSort l mt chng trnh sp xp cc s nguyn c lu tr trong mt mng theo th t tng dn bi phng php vun ng. (1) (2) Num s nguyn (Num >= 2) cn sp xp c lu tr trong mt mng cc bin ton cc A[1], A[2], ... , A[Num]. Phng php vun ng dng cy nh phn sp xp d liu. Biu din mt cy nh phn lu tr cc phn t ca mng theo cch sau: nu mt nt no lu tr gi tr ca phn t A[i] th nt con bn tri ca n lu tr gi tr ca phn t A[2*i] v nt con bn phi lu tr gi tr ca phn t A[2*i+1]. Trong hnh v di y, cc trn biu din cc nt, s bn trong trn l gi tr ca nt, v bn cnh cc trn l cc phn t tng ng ca mng. (3) Nh trong hnh v di y, ng l mt cy nh phn trong gi tr ca mi nt ln hn hoc bng gi tr ti cc nt con ca n.

V d v mt ng (4) Th tc sp xp nh sau. (i) Cc phn t A[1], A[2], ... , A[Num] ca mng A l cc phn t cn sp xp. (ii) Cc phn t cn sp xp biu din qua mt cy nh phn nh theo m t (2), v ng c to ra bng cch i ch gi tr cc phn t. Do , ti gc ca cy (A[1]) lu tr gi tr ln nht trong s cc phn t cn sp xp. (iii) i ch gi tr ti nt gc ca cy (A[1]) v gi tr ti nt cui cng ca cy (l nt tng ng vi phn t cui cng cn sp xp). (iv) Nt cui cng ca cy c g khi cy nh phn (S cc phn t c lu tr gim i 1.) (v) Qu trnh t Bc (ii) n bc (iv) c lp li cho n khi ch cn gc ca cy. (5) Th tc xy dng ng nh sau:

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

393

Bi thi th FE (Bui chiu)

(i) To gc ca cy l nt cha. (ii) Kt thc nu khng c nt con. (iii) So snh gi tr ca nt con (l nt c gi tr ln hn trong hai nt con) vi gi tr ca nt cha, v i ch gi tr ca chng nu gi tr ca nt cha nh hn gi tr ca nt con, ngc li chng trnh s dng nu gi tr ca nt cha ln hn hoc bng gi tr ca nt con. (iv) Lp li Bc (i) n bc (iii) cho cy con c gc l nt c gi tr c i ch. (6) c t cc tham s ca chng trnh con c th hin trong cc Bng t 1 n 4. Bng 1 c t cc Tham s ca HeapSort Dng D u vo / ngha liu u ra Ch s phn t mng tng ng vi nt S nguyn u vo cui cng ca cy Bng 2 c t cc Tham s ca InitHeap Dng u vo / ngha D liu u ra Ch s phn t mng tng ng vi nt S u vo cui cng ca cy biu din ng c nguyn vun ln u Bng 3 c t cc Tham s ca Make Heap Dng u vo / ngha D liu u ra

Tn Tham s Num

Tn Tham s Last

Tn Tham s Top

S nguyn S nguyn

u vo u vo

Ch s phn t ca mng tng ng gc cy con biu din ng c vun li. Ch s phn t ca mng tng ng nt cui cng ca cy con biu din ng c vun li.

Last

Bng 4 Tn Tham s X Dng D liu

c t cc Tham s ca Swap ngha Ch s phn t mng i ch vi A[Y] Ch s phn t mng i ch vi A[X]

u vo / u ra

S nguyn S nguyn

u vo u vo

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

394

Bi thi th FE (Bui chiu)

[Chng trnh]

Integer type: A[1000000]/*S dng nh mt bin ton cc */ HeapSort(Integer type: Num) Integer type: Idx /* Vun ng ln u */ InitHeap(Num) /* Sp xp */ Idx: Num, Idx > 1, -1 Swap(1, Idx) MakeHeap(1, Idx-1)

MakeHeap(Integer type: Top, Integer type: Last) Integer type: L, R A R L + 1 R <= Last /* So snh 3 phn t */ A[L] < A[R] /* Phn t phi ln hn */ A[Top] < A[R] Swap(Top, R) MakeHeap(R, Last) /* Phn t tri ln hn */ A[Top] < A[L] Swap(Top, L) MakeHeap(L, Last)

/* So snh hai phn t */ B A[Top] < A[L] Swap(Top, L) MakeHeap(L, Last)

Swap(Integer type: X, Integer type: Y) Integer type: Tmp Tmp A[X] A[X] A[Y] A[Y] Tmp

Cu hi con 1 T cc tp cu tr li di, la chn cu tr li chnh xc chn vo cc trng trong chng trnh trn.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

395

Bi thi th FE (Bui chiu)

Tp cu tr li cho A: a) L Top c) L Top * 2 Tp cu tr li cho B: a) L <= Last c) R <= Last - 1 b) L < Last d) R <= Last - 2 b) L Top + 1 d) L Top * 2 + 1

Cu hi con 2 T tp cu tr li di, la chn cu tr li chnh xc chn vo cc trng trong on m t sau y.


S dng ng trong hnh v, vi cc Bc (iii) v (iv) ca (4) trong on [M t chng trnh] c thc thi mt ln v Bc (ii) c hon thnh, th ch s phn t mng lu tr g tr 12 (ban u c lu tr trong A[10]) l
D C

. S ln chuyn i gi tr cc nt y l

Tp cu tr li: a) 2 e) 6 Cu hi con 3
Chng trnh con InitHeap vun ng ln u c xy dng nh s dng chng trnh con Make Heap. T tp cu tr li di, la chn cu tr li chnh xc nht in vo trng trong chng trnh sau y. InitHeap(Integer type: Last) Integer type: Idx

b) 3 f) 7

c) 4 g) 8

d) 5 h) 9

Make Heap(Idx, Last)

Tp cu tr li:

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

396

Bi thi th FE (Bui chiu)

a) Idx: 1, Idx <= Last, 2 b) Idx: 1, Idx <= Last / 2, 1 c) Idx: Last, Idx >= 1, -2 d) Idx: Last / 2, Idx >= 1, -1

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

397

Bi thi th FE (Bui chiu)

Q5. c phn m t di y v thit k chng trnh ri tr li cc cu hi con 1 v 2.

Bn d nh thit k mt chng trnh tr chi ging c v h c. Trong tr chi ny, ngi chi p li cc ch lnh (ging c/h c v/hoc c trng) s dng thit b nhp bng cch thao tc trn cc nt bm. Mt loi ca s s hin th ra khi cu tr li chnh xc v mt loi ca s khc hin th khi cu tr li khng chnh xc. M hnh ny ch c lp li trong mt s ln xc nh v s cu tr li chnh xc s c hin th thnh im s ca ngi chi. Cu hnh phn cng v cc ca s ca tr chi cho cc cu tr li chnh xc v khng chnh xc c trnh by trong Hnh 1 di y.

Hnh 1. Cu hnh phn cng v hin th tr li ng/sai ca tr chi. Thit b xut s a ra mt ch lnh bng ging ni v hin th cu tr li ng v cu tr li ca ngi chi sau khi ht thi gian pht hin cu tr li. Khi tr chi kt thc, chng trnh s hin th im ca ngi chi. Thit b nhp ch pht hin c nt u tin c nhn sau khi ch th c a ra v thng bo cho chng trnh v nt bm ny.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

398

Bi thi th FE (Bui chiu)

[Gii thch chng trnh]


(1) Bn trong chng trnh s lu gi trng thi hin thi ca c. Trng thi c : Ging (Up) hoc H (Down) Trng thi c trng: Ging (Up) hoc H (Down) (2) Chng trnh s c tp gi tr ban u v thit lp trng thi ca c trng v c thnh H (Down) nh dng tp gi tr khi to Thi gian pht hin cu tr li Thi gian hin th ca s cho tr li sai S ln lp li

(3)

Chng trnh s chn ngu nhin mt c cho cc ch th ging c/h c v mt ch th c th la chn da trn trng thi ca c c cho trong bng di. Sau , chng trnh gi thng tin ny ti cc thit b xut. Bng: Trng thi c v cc ch th c th la chn Trng thi c Up Down Cc ch lnh c th la chn Lower Khng h Raise Khng ging

(4)

C 5 kiu thao tc c th nhn c t cc thit b nhp: ging c , h c , ging c trng, h c trng, v khng di chuyn c no (khi chng trnh khng nhn c cu tr li trong thi gian pht hin cu tr li).

(5)

Chng trnh s pht hin ra cu tr li ca ngi chi. Nu ng, chng trnh s cng thm 1 vo s cu tr li ng v gi ca s cu tr li ng ti thit b xut. Nu sai, chng trnh s gi ca s cu tr li sai ti cc thit b xut v sau khi ht thi gian hin th ca s cu tr li sai trong tp gi tr khi to, chng trnh s thit lp c trong ca s ny sang trng thi ng.

(6) (7)

Chng trnh lp li cc bc (3) ti (5) vi s ln lp li c ch ra trong tp gi tr khi to. Chng trnh s gi im ca ngi chi ti cc thit b xut.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

399

Bi thi th FE (Bui chiu)

Cu hi con 1
Hnh 2 di y l biu chuyn trng thi ca cc c. Hy chn cc cu tr li ng t cc nhm cu tr li di y in vo cc trng trong phn m t sau y v Hnh 2.

S0 biu th trng thi khi to v cu tr li ging c (raise the red flag) tng ng vi trng A thi (i) t S0 ti S1. Trong trng hp ny, S1 trng thi . Cn cu tr li tng ng vi bc chuyn trng thi (ii) t S3 ti S1 l C .
B

v bc chuyn trng thi t S3 ti S2 l

(i) S0 (ii)

S1 S2

(iii) S3

Hnh 2. Biu chuyn trng thi ca cc c

Nhm cu tr li cho A: a) c ging v c trng ging b) c ging v c trng h c) c h v c trng ging d) c h v c trng h Nhm cu tr li cho B and C: a) ging c b) h c c) ging c trng d) h c trng Cu hi con 2
Hnh 3 di y biu din lu ca chng trnh ny. Trng thi ban u c thit lp trong qu trnh khi to. Ngoi tr qu trnh khi to v thit lp s ln lp, hai qu trnh no tham chiu ti
Ti liu n thi FE Tp.1
-- Phn2. Tp bi thi th --

400

Bi thi th FE (Bui chiu)

ni dung ca tp gi tr khi to?

Bt u Qu trnh khi to Lp
N:1, 1, S vng lpote

Quy trnh chnh bt u


La chn ch lnh

a ra ch lnh
Pht hin cu tr li

Quy trnh chnh Chnh xc


Sai ng
Correct count Correct count +1

Lp Hin th im

X l tr li sai

X l tr li ng

Kt thc Ch : Phn m t lp pha trn cng ca vng lp c ngha nh sau: Tn bin: gi tr khi to, gia tng, gi tr kt thc Chuyn trng thi Quy trnh chnh kt thc

Hnh 3. Lu

Nhm cu tr li: a) X l tr li sai c) La chn ch lnh e) Hin th im g) Pht hin cu tr li b) a ra ch lnh d) Chuyn trng thi f) X l tr li ng

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

401

Bi thi th FE (Bui chiu)

La chn mt cu hi t Q6 v Q7. Nu hai cu hi c la chn, ch cu hi th nht s c chm.

Q6. c m t v on chng trnh C di y ri tr li Cu hi con.

[M t chng trnh] Chng trnh ny s phn tch mt xu k t gn th v t cc gi tr th vo cc phn t ring r.


(1) C php cho cc xu k t gn th gm c cc k hiu s dng trong din gii c php c nh ngha trong Bng 1 bn di v cc k hiu <, >, / c s dng nh cc th bi (token).

Bng 1
::= { }*

ngha cc K hiu c s dng trong Din gii C php K hiu ngha c nh ngha Hoc Cc phn t bn trong { v } c lp li t 0 n nhiu ln.

tagged_character_string ::= {tagged_structure}* tagged_structure ::= start_tag tag_value {tagged_structure}* end_tag start_tag ::= <tag_name> end_tag ::= </tag_name> tag_name ::= chui k t khng bao gm <, >, / or \0 tag_value ::= chui k t khng bao gm <, >, / or \0 mt chui k t trng character_string ::= {character}* (2) c t chng trnh nh sau: (i) Hm parse_ml_string s phn tch mt xu tagged_character_string (thng qua con tr xu mlstr) vo cc phn t v lu tr chng trong mt mng elmtbl theo th t xut hin cc start_tags ca n. S cc phn t c lu tr trong bin elmnum. y, mi phn t c biu din bi mt cu trc d liu nh sau:
typedef struct { char *tag; int depth; char *value; } ELEMENT; /* Tag_name */ /* su lng nhau (1, 2,...) */ /* Tag_value */

(ii) S cc th cha trong mt xu tagged_character_string khng vt qu 256.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

402

Bi thi th FE (Bui chiu)

(iii) Khng c bt c li c php trong mt xu tagged_character_string. (3) di.) Mt xu tagged_structure c th cha mt xu tagged_structure khc. (Theo Hnh 1 bn

<STUDENT>BILL<AGE>14</AGE></STUDENT>
tagged_structure mc thp tagged_structure mc cao

Hnh.1 V d cc tagged_structure lng nhau (4) Chiu su ca cc th lng nhau l cc gi tr s 1, 2, 3,..., gi tr 1 c s dng ni n mc cao nht ca xu tagged_structure. (5) Kt qu vic thc thi chng trnh ny vi xu tagged_character_string c biu din trong Hnh 2 v Bng 2 di y. <STUDENT>BILL<AGE>14</AGE><SCHOOL>Junior <PLACE>Tokyo</PLACE></SCHOOL></STUDENT>
Ch : Xu k t khng bao gm m CR/LF.

Hnh.2 Gi tr ca xu gn th mlstr

Bng 2 Mng elmtbl Tn th Chiu su th Gi tr th tag depth Value Con tr tr ti STUDENT Con tr tr ti BILL 1 Con tr tr ti AGE 2 Con tr tr ti 14 Con tr tr ti SCHOOL Con tr tr ti 2 Junior Con tr tr ti PLACE 3 Con tr tr ti Tokyo

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

403

Bi thi th FE (Bui chiu)

[Chng trnh]
#define MAXELMNUM 256 typedef struct { char *tag; int depth; char *value; } ELEMENT; char *parse_ml_data(char *, int); ELEMENT elmtbl[MAXELMNUM]; int elmnum = 0; void parse_ml_string(char *mlstr) { while (*mlstr != '\0') { mlstr = parse_ml_data(mlstr + 1, 1); } } char *parse_ml_data(char *mlstr, int level) { /* X l start_tag */ elmtbl[elmnum].tag =

elmtbl[elmnum].depth = level; for (; *mlstr != '>'; mlstr++); *mlstr = '\0'; /* X l tag_value */ elmtbl[elmnum].value =

for (mlstr++; *mlstr != '<'; mlstr++); *mlstr = '\0';

/* X l tag_structure mc cao */ while (

mlstr = parse_ml_data(mlstr + 1, level + 1); /* X l End_tag */ for (mlstr += 2; *mlstr != '>'; mlstr++); return mlstr + 1; }

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

404

Bi thi th FE (Bui chiu)

Cu hi con T tp cc cu tr li di, la chn cu tr li chnh xc chn vo cc trng trong chng trnh trn. Tp cu tr li cho A v B: a)
mlstr

b) ++mlstr e) *(++mlstr)

c) f)

mlstr + 1 *mlstr++

d) *mlstr g) *(mlstr + 1) Tp cu tr li cho C: a) elmnum++ d) *elmnum++

b) level++ e) *level++

c) f)

mlstr++ *mlstr++

Tp cu tr li cho D: a) *(mlstr + 1) == < c) *(mlstr + 1) == / e) *(mlstr + 1) == >

b) *(mlstr + 1) != < d) *(mlstr + 1) != / f)


*(mlstr + 1) != >

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

405

Bi thi th FE (Bui chiu)

Q7. c phn m t v mt chng trnh Java v chng trnh , ri tr li cc cu hi con

1 v 2.

[M t chng trnh]
Chng trnh v mt im (point) di chuyn trong mt khng gian hnh ch nht nh sau:

im c biu din bi lp Point, lp ny lu tr cc ta (x y) biu din v tr ca im v vn tc di chuyn. Vn tc l mt s dng v biu din qung ng di chuyn theo chiu trc x v trc y trn mt n v thi gian. Hnh ch nht trong hnh trn c cho bi lp Space, v cc phng thc lp sau c th c gi. (1) public static int getMaxX() Phng thc ny tr v gi tr ln nht (gi tr dng) ca ta x trong khng gian hnh ch nht. (2) public static int getMaxY() Phng thc ny tr v gi tr ln nht (gi tr dng) ca ta y trong khng gian hnh ch nht (3) (4) public static void draw(Point) Phng thc ny v im c xc nh bi i s ti cc ta ca im. public static void erase(Point) Phng thc ny dng xa im c xc nh bi i s. Lp tru trng Motion s dng mt th hin im ca lp Point lm gi tr ban u trong phng thc khi to, v,di chuyn v xa im lp i lp li theo th t hin th s chuyn ng ca im . Cc ta ca im sau khi di chuyn c a ra bi phng thc update.
SimpleMotion l lp con ca lp Motion, n ci t phng thc update v main. Phng thc update biu din chuyn ng ca mt im theo ng thng vi vn tc khng i trong khng

gian hnh ch nht v ny ra khi cc cnh ca hnh ch nht. Phng thc main dng chy th chng trnh. Ch rng gi s cc gi tr ban u ca cc ta ca Point c sinh ra bi phng thc main nm trong khng gian hnh ch nht, v khng cn tnh n cc xung t gia cc im

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

406

Bi thi th FE (Bui chiu)

[Chng trnh 1]
public class Point { private int x, y, speed; public Point(int x, int y, int speed) { this.x = x; this.y = y; this.speed = speed; } public int getX() { return x; } public int getY() { return y; } public int getSpeed() { return speed; } }

[Chng trnh 2]
public abstract class Motion implements Runnable { private Point point; public Motion(Point point) { this.point = point; } public void run() { while (true) { Space.draw(point); try { Thread.sleep(40); } catch (InterruptedException e) {} Point current = point;

A
Space.erase(current); } }

public abstract Point update(Point point); }

[Chng trnh 3]
public class SimpleMotion extends Motion { private int directionX = 1, directionY = 1; public SimpleMotion(Point point) { super(point); }

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

407

Bi thi th FE (Bui chiu)

public Point update(Point point) { int speed = point.getSpeed(); int x = point.getX() + directionX * speed; int y = point.getY() + directionY * speed; if (x <= 0) { x = -x; directionX *= -1; } x %= 2 * Space.getMaxX(); if (x >= Space.getMaxX()) { x = 2 * Space.getMaxX() - x; directionX *= -1; } if (y <= 0) { y = -y; directionY *= -1; } y %= 2 * Space.getMaxY(); if (y >= Space.getMaxY()) { y = 2 * Space.getMaxY() - y; directionY *= -1; } return new Point(x, y, speed); } public static void main(String[] args) { Point[] points = { new Point(10, 20, 3), new Point(50, 10, 5), new Point(150, 60, 2) }; for (int i = 0; i < points.length; i++) { new Thread( } } }

).start();

Cu hi con 1
T cc nhm cu tr li di y, chn cc cu tr li ng in vo cc trng trong cc chng trnh trn.

Nhm cu tr li cho A:
a) current = update(current) c) point = update(point) b)
current = update(point)

d) update(current)

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

408

Bi thi th FE (Bui chiu)

e) update(point)

Nhm cu tr li cho B:
a) new Motion(points[i]) c) new Runnable(points[i]) e) points[i] b) new Point(points[i]) d) new SimpleMotion(points[i])

Cu hi con 2
T nhm cu tr li di y, chn cu tr li ng cho chuyn ng ca im P trong hnh di y khi phng thc run c thc thi. Gi s rng im P l mt th hin ca lp Point c xc nh cho phng thc khi to ca lp SimpleMotion, v gi tr ca speed l 1. Bit rng tt c cc trong chng trnh trn u c cc cu tr li ng.

Nhm cu tr li:
a) im P chuyn ng theo hnh mi tn (i). b) im P chuyn ng theo hnh mi tn (ii). c) im P chuyn ng theo hnh mi tn (iii). d) im P chuyn ng theo hnh mi tn (iv)

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

409

Bi thi th FE (Bui chiu)

La chn mt cu hi t Q8 v Q9. Nu hai cu hi c la chn, ch cu hi th nht s c chm.


Q8. c m t chng trnh v chng trnh C di y ri tr li cc cu hi con t 1 n

4.

[M t chng trnh]
Chng trnh tm ng qua mt m cung. (1) D liu cho m cung c hin th bng mt hnh vung 8 ct v 8 dng, nh c ch ra trong Hnh 1 di y, c lu trong mt mn M hai chiu. Cc hnh vung c t mu xm biu th tng, mu trng biu th ng i. (2) Mng M lu tr mt m biu th im bt u (0xf0), c gn cho hnh vung li vo, mt m biu th im kt thc (0xf1), mt m biu th cho tng (0x00), c gn cho cc hnh vung tng, v mt m biu th cho ng i (0xff), c gn cho cc hnh vung ng i.
Start point
M[0][0] M[0] [7]

[0] M[7]

M[7][7]

End point

Fig. 1 Example of Maze (3) (4) Ngoi tr im bt u v im kt thc, tt c cc hnh vung trn vin ngoi ca m cung (cc hnh vung c gi tr ct hoc hng bn trong M hoc 0 hoc 7) l tng. Di y l cc bin ton cc c s dng trong chng trnh ny: Tn bin M x y dir Mc ch Lu tr d liu m cung (mng hai chiu) Hng ca hnh vung bn trong m cung Ct ca hnh vung bn trong m cung Hng di chuyn trong khi i qua m cung

Gi s rng cc gi tr khi to c np vo cc bin ton cc ny. Hm maze tm kim qua m cung tm ng t li vo n li ra.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

410

Bi thi th FE (Bui chiu)

[Program]
(Line No.)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

#define #define #define #define #define #define #define #define #define

UP RIGHT DOWN LEFT ROAD WALL SMAX ENTRANCE EXIT

0 1 2 3 0x00 0xff 8 0xf0 0xf1

/* M ng i */ /* M tng */ /* M im bt u */ /* M im kt thc */

int rcheck(void); int fcheck(void); void go(void); void maze(void); int M[SMAX][SMAX], x, y, dir; void maze() { while ( M[y][x] != EXIT ) { if ( ( rcheck() == ROAD ) || ( rcheck() == EXIT ) ) { dir = ( dir+1 ) % 4; go(); } else if ( ( fcheck() == ROAD ) || ( fcheck() == EXIT ) ) go(); else dir = ( dir+3 ) % 4; } return; } int rcheck() { ( dir == UP ) if else if ( dir == RIGHT ) else if ( dir == DOWN ) else } int fcheck() { ( dir == UP ) if else if ( dir == RIGHT ) else if ( dir == DOWN ) else }

return return return return

M[y][x+1]; M[y+1][x]; M[y][x-1]; M[y-1][x];

return return return return

M[y-1][x]; M[y][x+1]; M[y+1][x]; M[y][x-1];

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

411

Bi thi th FE (Bui chiu)

49 void go() 50 { ( dir == UP ) 51 if 52 else if ( dir == RIGHT ) 53 else if ( dir == DOWN ) 54 else 55 }

y--; x++; y++; x--;

Cu hi con 1
Cho m cung c ch ra trong Hnh 2 di, u l kt qu ng u ra ca bi chng trnh ny? La chn cu tr li ng trong nhm cu tr li bn di. 1 n 8 c ch ra trong hnh c s dng biu din v tr cc hnh vung trong m cung. Trong chng trnh ny, gi tr cc bin ton cc x, y, v dir c ch ra nh di y ti thi im hm maze c gi:
x = 1 y = 0 dir = DOWN
Start point
M[0] [0] M[0] [7]

3 4

2 6
M[7] [0]

M[7] [7]

End point

Hnh. 2 Cc v tr ca hnh vung trong m cung

Nhm cu tr li:
a) im bt u12135657im kt thc b) im bt u121343565787im kt thc c) im bt u1357im kt thc d) im bt u1343565787im kt thc

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

412

Bi thi th FE (Bui chiu)

Cu hi con 2
Cho m cung trong Hnh 3 di y, u l kt qu ng u ra bi chng trnh ny? La chn cu tr li ng trong nhm cu tr li pha di. Trong chng trnh ny, gi tr ca cc bin ton cc x, y, v dir c ch ra nh di y ti thi im hm maze c gi.
x = 1 y = 0 dir = DOWN
Start point
M[0] [0] M[0] [7]

1 2

4 3

M[7] [0]

M[7] [7]

End point

Hnh. 3 M cung khng gii quyt c

Nhm cu tr li:
a) im bt u14321432... c lp li v hn. b) im bt u12341234 c lp li v hn. c) im bt u1222... c lp li v hn. d) im bt u12341 im bt u (Chng trnh kt thc) e) im bt u1234111 c lp li v hn.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

413

Bi thi th FE (Bui chiu)

Cu hi con 3
Cu lnh sau y c thm vo chng trnh a ra cc v tr ca cc hnh vung, bao gm im bt u v im kt thc, c i qua v cc v tr ca cc di chuyn. u l ch ng nht thm vo cu lnh ny trong chng trnh? Hy chn cu tr li ng t nhm cu tr li pha di. Gi s rng #include <stdio.h> c t u ca chng trnh.
printf("dir=%d y=%d x=%d\n", dir, y, x);

Nhm cu tr li:
a) Ngay sau Dng 20 v ngay sau Dng 29 b) Ngay sau Dng 23 v ngay sau Dng 29 c) Ngay sau Dng 28 v ngay sau Dng 29

Cu hi con 4
Gi s rng hm lcheck c s dng thay cho rcheck tm ra cc gii php cho m cung, v hm lcheck thay cho rcheck trong Dng 11, 21, v 22. Nu s thay i trn c thc hin th cn phi thay i nhng g cho chng trnh? Hy chn cu tr li ng t nhm cu tr li di y.
int lcheck() { ( dir == UP ) if return M[y][x-1]; else if ( dir == RIGHT ) return M[y-1][x]; else if ( dir == DOWN ) return M[y][x+1]; else return M[y+1][x]; }

Nhm cu tr li:
a) == ROAD trn Dng 21 phi c thay bi == WALL. b) +1 trn Dng 23 phi c thay i thnh +3 v +3 Dng 28 phi c thay i thnh +1. c) UP trn Dng 35 v 43 phi c thay i thnh RIGHT, RIGHT trn Dng 36 v 44 phi c thay i thnh DOWN, v DOWN trn Dng 37 v 45 phi c thay i thnh LEFT. d) Tt c cc th hin ca t Dng 51 n Dng 54 phi c thay i thnh ++ v tt c cc th hin ca ++ c thy trn cng cc dng y phi c thay i thnh
--.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

414

Bi thi th FE (Bui chiu)

Q9. c m t chng trnh v chng trnh Java di y ri tr li cu hi con 1 v 2.

[M t chng trnh]
y l chng trnh cho mt my tnh in t thc hin cc php ton cng, tr, nhn v chia trn cc s nguyn. Thnh phn I/O c cung cp bi mt chng trnh chy th, v c th c s dng chy th chng trnh thnh phn my tnh chnh. (1) Lp CalculatorEvent l mt s kin c sinh ra khi mt nt trn my tnh c n. Gi tr ca trng type biu din cc s kin. Cc s kin c th l DIGIT, OPERATOR, hoc CLEAR, v chng biu din tng ng cho cc nt s (t 0 n 9) trn my tnh, nt php ton (v d nh +) hoc nt bng (=), hoc nt xa (C). Khi type l DIGIT, gi tr s tng ng vi nt s c lu trong trng value. Khi type l OPERATOR, k t biu din cho loi php ton hoc = c lu trong trng value. Khi type l is CLEAR th value khng c s dng. (2) (3) Giao din CalculatorOutput khai bo phng thc display hin th cc gi tr s v li trn my tnh. Lp Calculator chnh l my tnh chnh. Phng thc eventDispatched nhn cc s kin v thc hin cc php ton, ph hp vi loi s kin. Ch rng cc kt qu tnh ton cng, tr, nhn v chia ca hai gi tr s ph hp vi kt qu ca cc php ton trn kiu d liu int ca Java. (4) Lp CalculatorTest l mt chng trnh chy th Calculator. CalculatorOutput c ci t l mt lp khng tn. Trong ci t ny, phng thc display a ra gi tr s hoc chui k t bi System.out. Phng thc main sinh ra CalculatorEvent t chui k t c ly v t tham s args[0], v gi phng thc eventDispatched ca Calculator. S tng ng gia cc k t v cc nt trn my tnh c ch ra trong bng di y. K t '0' n '9' '+' '-' '*' '/' '=' 'C' Nt trn my tnh Nt s (0 n 9) Nt cng (+) Nt tr (-) Nt nhn () Nt chia () Nt bng (=) Nt xa (C)

V d nh, chui k t 2+7= biu din cc nt trn my tnh theo th t 2, +, 7, v = ang c

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

415

Bi thi th FE (Bui chiu)

bm. Khi chui k t c truyn cho phng thc main cho tham s args[0], chng trnh hin th kt qu nh sau: 2 2 7 9

[Chng trnh 1]
public class CalculatorEvent { public static final int DIGIT = 1; public static final int OPERATOR = 2; public static final int CLEAR = 3; private int type, value; public CalculatorEvent(int type) {

} public CalculatorEvent(int type, int value) { if (type < DIGIT || type > CLEAR) throw new IllegalArgumentException(); this.type = type; this.value = value; } public int getType() { return type; } public int getValue() { return value; } }

[Chng trnh 2]
public interface CalculatorOutput { public void display(int value); public void display(String value); }

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

416

Bi thi th FE (Bui chiu)

[Chng trnh 3]
public class Calculator { private int accumulator = 0, register = 0; private int operator = 0; private CalculatorOutput output; public Calculator(CalculatorOutput output) { this.output = output; } public void eventDispatched(CalculatorEvent event) { switch (event.getType()) { case CalculatorEvent.DIGIT: if (operator == '=') { register = 0; operator = 0; } register = register * 10 + event.getValue(); output.display(register); break; case CalculatorEvent.OPERATOR: try { register = calculate(); output.display(register); accumulator = register; operator = event.getValue(); } catch (ArithmeticException e) { output.display("Error"); accumulator = 0; operator = 0; } if (operator != '=') register = 0; break; case CalculatorEvent.CLEAR: register = 0; accumulator = 0; operator = 0; output.display(register); break; } } private int calculate() { switch (operator) { case '+': return accumulator + register; case '-': return accumulator - register; case '*': return accumulator * register; case '/': return accumulator / register; } return register; } }

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

417

Bi thi th FE (Bui chiu)

[Chng trnh 4]
public class CalculatorTest { public static void main(String[] args) { Calculator calc = new Calculator( { public void display(int value) { System.out.println(value); } public void display(String value) { System.out.println(value); } }); String keys = args[0]; for (int i = 0; i < keys.length(); i++) { char c = keys.charAt(i); CalculatorEvent event = null; if (c '0' && c '9') { event = new CalculatorEvent( } else if event } else if event ); (c == '=' || c == '+' || c == '-' || c == '*' || c == '/') { = new CalculatorEvent( CalculatorEvent.OPERATOR, c); (c == 'C') { = new CalculatorEvent( CalculatorEvent.CLEAR);

} if (event != null) calc.eventDispatched(event); } } }

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

418

Bi thi th FE (Bui chiu)

Cu hi con 1
T cc nhm cu tr li di y, hy chn cc cu tr li ng in vo cc trng trong cc chng trnh trn.

Nhm cu tr li cho A:
a) CalculatorEvent(type, 0) b) new CalculatorEvent(type, 0) c) return new CalculatorEvent(type, 0) d) super(type, 0) e) this(type, 0)

Nhm cu tr li cho B:
a) implements CalculatorOutput() b) interface CalculatorOutput() c) new CalculatorOutput() d) new Temp() implements CalculatorOutput e) public class Temp implements CalculatorOutput

Nhm cu tr li cho C:
a) c - '0', CalculatorEvent.DIGIT b) c, CalculatorEvent.DIGIT c) CalculatorEvent.DIGIT d) CalculatorEvent.DIGIT, c e) CalculatorEvent.DIGIT, c - '0'

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

419

Bi thi th FE (Bui chiu)

Cu hi con 2
Bng sau y ch ra cc kt qu u ra cui cng khi phng thc main c thc thi vi cc chui k t di c truyn vo nh cc tham s. T cc nhm cu tr li di y, hy chn cu tr li ng cn chn vo trng bng. Gi thit rng tt c cc trng Xu k t 3+4*5= 3*4***= 3*4=+5 3+4/0= trong chng trnh u c cu tr li ng. Kt qu ra 35
D E F

trong

Nhm cu tr li:
a) 0 e) 7 i) / by zero b) 3 f) 12 j) Error c) 4 g) 17 d) 5 h) 53

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

420

Bi thi th FE (Bui chiu) p n v gii thch -

Thi th
Q1:

p n v gii thch cho cc cu hi bui chiu

im chnh

B bn tng c 2 u vo trong khi b cng y c 3 u vo. Php cng logic loi tr l php ton m nhn gi tr 0 khi 2 gi tr u vo c gi tr ging nhau.

B cng l mt mch dng cng cc bit nh phn vi nhau, c th l b bn tng hoc b cng y . B bn tng l mch m khng quan tm n nh ch s thp hn (t ngha hn) v c s dng cng ch s thp nht (t ngha nht). B cng y l mch m tnh c nh t cc ch s thp hn v c s dng cng cc ch s khng phi ch s thp nht Hnh di y, a mt v d v cng s 3 bit. Ai (i = 1, 2, 3) v Bi (i = 1, 2, 3) l cc con s nh phn c cng. Si (i = 1, 2, 3) l kt qu ca php cng mi bit v C l bit nh c dng cng cc bit cao hn A3 B3
B cng y

A2 B2
B cng y

A1 B1
B cng y

A3A2A1 +) B3B2B1 CS3S2S1

Bit nh C S3 S2

Bit nh S1

Cu hi con 1: [Cu tr li ng]

Ck (= 1), Ak ( = 0), v Bk ( = 1) c cng cng nhau, v kt qu ca php cng ny l Zk vi mt s nh Ck + 1. Php cng c thc hin nh sau: 1 = Ck +) 0 = Ak 1 1 = Ck + A k +) 1 = Bk 10

Ck + 1 Z k V Ck + 1 = 1 v Zk = 0, chng ta c nh sau: Ck 1 u vo Ak 0 u ra Bk 1 Ck + 1 1 Zk 0

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

421

Bi thi th FE (Bui chiu) p n v gii thch -

Cu hi 2: [Cu tr li ng] Php ton ly c Ck + 1 nh sau: Ak Bk XOR

Zk

Ak XOR Bk Ck Ck

Ak AND Bk

OR Ak AND Bk

Ck+1

Nh trong hnh ny, nu chng ta P l kt qu ca php logic trong hp mu xm, th kt qu ca php cng logic (OR) ca P v Ak AND Bk l Ck+1. Thm vo , P l kt qu ca cc php ton nh phn Ak XOR Bk v Ck. T nhm cc cu tr li, ch ra rng php ton ny l php nhn logic (AND), php tng logic (OR) hoc php cng logic loi tr (XOR). V vy chng ta c th t chc ton b thng tin trong bng sau. Ck 0 0 0 0 1 1 1 1 Ak 0 0 1 1 0 0 1 1 Bk 0 1 0 1 0 1 0 1 P ? ? ? ? ? ? ? ? Ak AND Bk 0 0 0 1 0 0 0 1 (P OR Ak AND Bk) = Ck + 1 0 0 0 1 0 1 1 1

y, tng logic ca P v Ak AND Bk l Ck+1. Do chng ta ca th c lng c gi tr ca P nh sau. V php ton y l php cng logic, nu Ck+1 l 0, th c hai bin (u vo) u phi bng 0. Nhng nu Ck+1 l 1, th mt trong hai bin u vo s bng 1. Ak AND Bk 0 0 0 1 0 0 0 1 Ck + 1 0 0 0 1 0 1 1 1 Gi tr c lng ca P 0 0 0 1, 0 0 1 1 1, 0

T bng c lng gi tr ca P, chng ta c th bit c php ton gia Ak XOR Bk v Ck. Hn na t nhm cu tr li ch c cc php nhn logic, cng logic v cng loi tr nn chng ta ch gii hn cc cu tr li trong . Ak XOR Bk 0 Ck 0 P 0 Cc php ton logic c th Nhn logic, Cng logic, Cng loi tr

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

422

Bi thi th FE (Bui chiu) p n v gii thch -

1 1 0 0 1 1 0

0 0 0 1 1 1 1

0 0 1, 0 0 1 1 1, 0

Nhn logic Nhn logic Nhn logic nu l 0. Khng c php ton no nu l 1. Nhn logic Nhn logic, Cng logic Nhn logic, Cng logic Nhn logic nu l 0. Cng logic hoc cng logic loi tr nu l 1

T chng ta thy rng ch c mt php ton tha mn tt c cc trng hp l php nhn logic

Cu hi 3: [Cu tr li ng] Phn mu xm trong bng tht c gi tr nh di y. Trong cu hi, ch s l k, nhng v chng ta ch quan tm n bit cao nht (c ngha ln nht), nn chng ta s dng ch s n. Bit cao nht l Cn gi rng thanh ghi c n bit, do Cn + 1 tr thnh bit trn, khng nm trong thanh ghi. Ck 0 1 Input Ak 1 0 Output Bk 1 0 Ck + 1 1 0 Zk 0 1

Case 1 Case 2

Di y, chng ta cng Cn, An, v Bn trong 2 trng hp. (1) trng hp 1 0 = Cn 1 = An +) 1 = Bn 10 Cn + 1 Z n Trong trng hp ny, An v Bn l cc bit cao nht, c hai u c gi tr 1, tc l chng ta ang cng 2 s m. Tuy nhin Zn bit cao nht ca kt qu l 0 ch ra rng l mt s dng. Do php ton khng c thc hin chnh xc. iu ny l v c hin tng trn s xy ra, y gi tr 1 ch ra rng l s m cho Cn+1 (khng xut hin trong kt qu) (2) Trng hp 2 1 = Cn 0 = An +) 0 = Bn 01 Cn + 1 Z n

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

423

Bi thi th FE (Bui chiu) p n v gii thch -

y, An v Bn l cc bit cao nht, c hai u mang gi tr 0, v th n l php cng hai s dng. Tuy nhin Zn bt cao nht ca kt qu li mang gi tr 1, ch ra rng l mt s m. Do php ton cng khng c thc hin chnh xc. iu ny l v hin tng trn s b xy ra, y gi tr 0 ch ra rng y l s dng cho Cn+1 (khng xut hin trong kt qu) Chng ra cng tng hp kt qu: An 0 1 Bn 0 1 Cn 1 0 Zn 1 0 Cn + 1 0 1

Bi v php trn xy ra vi bit nh, nn chng ta ch quan tm n Cn v Cn+1. Sau chng ta rng trn xy ra khi hai gi tr ny khng bng nhau. Trong cu hi con, u tin php cng logic loi tr c thc s dng, v php tng logic loi tr ca 2 gi tr Cn v Cn+1 l 1 khi chng khng bng nhau. Do vic trn c th c pht hin bng cch cng logic loi tr Cn v Cn+1.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

424

Bi thi th FE (Bui chiu) p n v gii thch -

Q2:

im chnh

EXISTS tr v true khi kt qu ca cu truy vn con c t nht 1 dng. DISTINCT loi b cc trng lp.

EXISTS l mt mnh SQL c thc thi t cu truy vn con (ngoi mnh SELECT). Vi mi dng kt qu ca cu truy vn chnh, nu kt qu ca cu truy vn con (mnh SELECT trong ngoc n) c t nht 1 dng, gi tr true c tr v; nu khng c dng no th gi tr false c tr v. Nu gi tr l true, ni dung ca ct c ch trong mnh SELECT trong cu truy vn chnh c la chn. Cu hi con 1: [p n ng] A g, Bc

A: Trong mnh SELECT cu truy vn con, iu kin la chn d liu l skill_code = FE. Trong bng k nng nhn vin c 2 dng m m k nng l FE, v th EXISTS tr v true. Do vy cu lnh SQL c th c lm r nh sau: SELECT MaNhanVien FROM Bang_Ky_Nang_Nhan_Vien WHERE (dieu_kien = true) V vy chng ta c th kt lun rng v tt c cc dng trong bng k nng nhn vin u tha mn iu kin nn tt c cc m nhn vin t bng k nng u c la chn. Bng ny c 6 dng. B: Mnh SELECT trong cu truy vn chnh ly mt dng t bng nhn vin, gi tr ca n c chuyn n cu truy vn con. Trong cu truy vn con, ni dung ca dng nhn c c nh gi v ly kt qu tr v cho cu truy vn chnh. Sau , cu truy vn chnh nh gi kt qu ca cu truy vn con lin quan n dng chn trc ri quyt nh xem c ly lm kt qu cui cng hay khng. Trong cu truy vn con, bng nhn vin (A) v bng k nng nhn vin (B) c kt ni v cc hng c m k nng l FE c chn. V d, dng u tin ca bng nhn vin (0001, Brown, A1) c kt ni vi bng k nng nhn vin bi nhn vin m 0001 nh hnh di y:

Bang_Nhan_Vien MaNhanVien TenNhanVien 0001 Brown 0002 Charles 0003 Taylor 0004 Williams 0005 Parker 0006 James

Phong A1 A2 B1 D3 A1 B1

Bang_Ky_Nang_Nhan_Vien MaNhanVien MaKyNang NgayDangKy 0001 FE 19991201 0001 DB 20010701 0002 SAD 19980701 0002 FE 19990701 0002 SW 20000701 0005 SAD 19991201

By gi c 2 dng trong bng k nng nhn vin c cng mt m nhn vin 001 nhng ch mt dng u tin trong c m k nng l FE. y, kt qu ca cu truy vn con l true (c 1 dng) v th TenNhanVien xc nh trong cu truy vn chnh c chn t bng nhn vin. Tng t, dng th 2 ca bng nhn vin (0002, Charles, A2) c m nhn vin xut hin trong cc

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

425

Bi thi th FE (Bui chiu) p n v gii thch -

dng 3,4,5 ca bng k nng nhng ch c dng 4 c m k nng FE. Do tn nhn vin ny c chn. Ngc li, khng c dng no trong bng k nng c m nhn vin ging cc dng 3,4 hoc 6 ca bng nhn vin. Do cc tn nhn vin ny khng c chn. Vi dng 5 (0005, Parker, A1) ca bng nhn vin, c mt dng trong bng k nng c cng m nhn vin, tuy nhin m k nng khc FE nn tn nhn vin ny khng c chn. Tm li, chng ta thy c 2 dng (Brown v Charles) c chn nh hnh v di y. Trong hnh v ny cc dng nt lin ch ra cc mi lin h m cc i tng c chn; cc dng nt t ch ra cc m nhn vin c tn ti trong bng k nng nhng m k nng khc FE.

Bang_Nhan_Vien MaNhanVien TenNhanVien 0001 Brown 0002 Charles 0003 Taylor 0004 Williams 0005 Parker 0006 James

Phong A1 A2 B1 D3 A1 B1

Bang_Ky_Nang_Nhan_Vien MaNhanVien MaKyNang NgayDangKy 0001 FE 19991201 0001 DB 20010701 0002 SAD 19980701 0002 FE 19990701 0002 SW 20000701 0005 SAD 19991201

tng ca EXISTS c th hin trn. Tuy nhin kt qu cui cng y l nhng tn nhn vin no thuc cc hng tha mn iu kin cu truy vn con (MaKyNang=FE) c chn. Cu hi con 2: [p n ng] d

Trong mnh SQL ny bng k nng nhn vin c nh ngha bi 2 tn B1 v B2. Kt qu s nh sau: iu kin ca cu truy vn con B1. MaNhanVien=B2.MaNhanVien tm cc hng vi cng mt m nhn vin trong bng k nng. Hn na, trong cc hng ny nu tha mn iu kin khc m k nng (B1.MaKyNang <> B2.MaKyNang) s c chn. Tm li chng ta c th v mt hnh v nh di y. Cc dng nt lin ch ra chng c chn v c m k nng khc nhau; cc dng nt t ch ra chng khng c chn v c m k nng ging nhau.

Bang_Ky_Nang_Nhan_Vien (B1)
MaNhanVien MaKyNang NgayDangKy

Bang_Ky_Nang_Nhan_Vien (B2)
MaNhanVien MaKyNang NgayDangKy

0001 0001 0002 0002 0002 0005

FE DB SAD FE SW SAD

19991201 20010701 19980701 19990701 20000701 19991201

0001 0001 0002 0002 0002 0005

FE DB SAD FE SW SAD

19991201 20010701 19980701 19990701 20000701 19991201

Nu khng bn tm n DISTINCT, v cc m nhn vin ca cc hng c ng nt lin tng ng c a ra khi B1, cc gi tr c chn l (0001, 0001, 0002, 0002, 0002, 0002, 0002, 0002). Tuy nhin mnh SELECT trong cu truy vn chnh a ra DISTINCT nn cc gi tr trng lp c loi b v tun t (0001, 0002) c chn. V vy, cc m nhn vin vi nhiu k nng c chn. ng thi nu mt m nhn vin ch c mt hng (m 005), m k nng lun lun ging nhau nn n khng c chn.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

426

Bi thi th FE (Bui chiu) p n v gii thch -

Cu hi con 3: [p n ng]

chn ra cc tn nhn vin, bng nhn vin l cn thit v v th n cng l cn thit kt ni bng nhn vin vi bng k nng nhn vin. Ct c bn nhn c trong c bng nhn vin v bng k nng nhn vin l m nhn vin. Sau , chng ta kt ni m nhn vin ca bng nhn vin (A) v bng k nng nhn vin (B1) s dng iu kin AND. Bi vy cn thm vo AND A.MaNhanVien = B1.MaNhanVien

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

427

Bi thi th FE (Bui chiu) p n v gii thch -

Q3:

im chnh

Tng khi lng tnh ton l hng s ngha l khi lng tnh ton nh nhau trong mi trng hp. Mt danh sch lin kt 2 chiu c mt con tr tin v mt con tr li.

Mt bin ton cc l bin c th tham chiu n t mi chng trnh con. Mt bin s dng trong mt chng trnh c th l bin ton cc hoc bin cc b. Mt bin cc b l bin ch hp l trong phm vi chng trnh m n c khai bo. Cu hi con 1: [p n ng] b, d Yu cu khi lng (th t) tnh ton cn thit l hng s, bt chp s dng. N c ngha l khi lng x l khng thay i bt chp th t ca cc th tc v php ton. a) DELETE() xa cc dng ch bi CP. Bng vic xa, dng k tip v cc dng pha di s u c chuyn ln 1 dng, bi vy ly v d xa dng Line 1 cn chuyn Line 2 Line 1, Line 3 Line 2, , Line n Line (n 1), c (n-1) dch chuyn. Nu dng Line 2 c chuyn, Line 1 nguyn v tr c nhng Line 3 Line 2, Line 4 Line 3, , Line n Line (n 1), c (n-2) dch chuyn. Bi vy, s dng dch chuyn ph thuc vo gi tr ca n nn s lng tnh ton khng phi hng s. b) GET() tr v xu k t ca dng ch bi CP. N ch n gin ly ra xu k t t v tr ch bi CP nn s lng tnh ton l hng s. c) INSERT() thm mt dng mi x vo dng ch ra bi CP. Bng vic thm vo, tt c cc dng bn di dng thm vo dch xung di 1 dng. V d, nu 1 dng c thm vo trc dng u tin, Line n Line (n + 1), Line (n 1) Line n, , Line 1 Line 2, c n dch chuyn, v vic thm v dng Line 1 xy ra. Nu mt dng c thm vo trc dng th 2, Line 1 nguyn v tr, nhng Line n Line (n + 1), Line (n 1) Line n, , Line 2 Line 3, c (n-1) dch chuyn, v sau vic thm vo Line 2 xy ra. Bi vy, s lng cc dch chuyn ph thuc vo gi tr ca n nn khi lng tnh ton khng l hng s. d) LAST() tr v s th t n ca dng cui ( s lng dng ca vn bn). Nu vn bn rng, n tr v 0. Nh ch ra hnh 1, n c lu TAIL, v th n n gin ly ra gi tr ca TAIL. Bi th, khi lng tnh ton l hng s.

Cu hi con 2: [p n ng]

a,

b,

Cho mt danh sch, vic xa v thm n gin l thay i con tr, v th cn thay i dng l cn thit. Trong cc gii thch di y, LCP ch ra dng cn x l (dng ch bi CP). Hn na, LL l dng ngay trc n v LR l dng ngay sau n. a) DELETE() thay i kt ni con tr nh hnh di y. x ch ra mt tr b xa v mt mi tn n ch con tr c kt ni.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

428

Bi thi th FE (Bui chiu) p n v gii thch -

LL

PLR

PCPL

LCP

PCPR

PRL

LR

LL

PLR

PCPL

LCP

PCPR

PRL

LR

Vic thay i con tr c thc hin nh sau:

(1) PCPR c cha trong PL sao cho LL tr n LR v LCP b xa. (2) PCPL c cha trong PRL sao cho LR tr n LL v LCP b xa.
X l ny ch bao gm 2 php ton (1) v (2) nn s lng tnh ton l hng s. b) GET() n gin c LCP ti v tr c ch bi CP, do s lng tnh ton l hng s. c) INSERT(x) thay i con tr kt ni nh hnh v di y. Gi s rng LA l dng c thm v con tr ca dng thm vo bit.

LL

PLR

PCPL

LCP

PCPR

PRL

LR

LL

PLR

PCPL

LCP

PCPR

PRL

LR

Dng thm

PAL

LA

PAR

Vic thay i con tr din ra nh sau: (1) PCPL c cha trong PAL sao cho LA tr n

LL khi LA c thm.

(2) PLR c cha PAR sao cho PAR tr ti LCP khi LA c thm. (3) Gi tr con tr ca dng c thm c cha trong PCPL sao cho LCP tr ti LA khi LA c thm vo (4) Gi tr con tr ca dng c thm c cha trong PLR sao cho LL tr ti LA khi LA c thm vo Qu trnh ny ch bao gm cc bc t (1) n (4) nn tng khi lng tnh ton l hng s. d) y khng c thng tin v s dng u, do tnh tng s dng cn phi tin hnh tnh ton tht, bt u t HEAD v cc con tr tip theo. Hoc, s dng c th tnh t TAIL. Do vy, LAST() cn thi gian tnh ton di hn khi c nhiu dng hn. V vy khi lng tnh ton khng phi l hng s.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

429

Bi thi th FE (Bui chiu) p n v gii thch -

Cu hi con 3: [p n ng]

A c,

B g,

Cd

Hnh v di y ch ra lm th no cc dng i t HEAD v TAIL. Vic xa ca L3 dch chuyn con tr nh ch ra di y: HEAD CP TAIL

4 0 L1 2
4 2

4 4 L2 8
8

6 8 L4 6
9 6

2 L3 9

9 L5 0

0 L1 2
4 2

4 L2 9
8

DELETE () 2 L3 9 2 L4 6
9 6

9 L5 0

Do 8 c chuyn thnh 9 sao cho NEXT[2] tr n PREV[9] tr n L2.

L4, v 8 is changed to 2 sao cho

Sau , chng ta chuyn con tr ca danh sch rng. Khi phn t s 8 b xa, n tr thnh u ca danh sch rng. V vy EMPTY thay i t 3 thnh 8. Hn na, chng ta chc chn rng NEXT[8] ca phn t s 8 xa s tr n 3 (l u ca danh sch rng trc khi xa).

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

430

Bi thi th FE (Bui chiu) p n v gii thch -

Q4:
Trong mt ng, gi tr ca gc l ln nht v gi tr nt cha ln hn gi tr nt con. HeapSort lp li qu trnh a nt gc ra ngoi v vun ng cho cy cn li.

im chnh

ng l mt cy nh phn lu tr d liu t nt nng n nt su, cng bc ca cy, t tri qua phi, gi tr c nhng gii hn sau:

Gi tr nt cha > gi tr nt con (hoc gi tr nt cha < gi tr nt con )


Nh vy, cc phn t c gi tr ln hn (nh hn) c tp hp xung quanh gc v cc phn t c gi tr nh hn (ln hn) gn v pha cc nt l hn. V gc ca cy cha phn t c gi tr ln nht (nh nht) nn cu trc d liu ny thch hp cho vic xc nh gi tr ln nht (nh nht). Mt ng c th c biu din bi mt mng theo cch sau. Nu mt nt lu tr gi tr ca phn t A[i]th nt con bn tri lu tr gi tr ca phn t A[2i], v nt con bn phi lu tr gi tr ca phn t A[2i + 1]. Theo , mng A cha cc phn t nh sau:
Ch s 1 2 3 4 5 6 7 8 9 10

A[]

91
Cha

86
Con tri

72
Con phi

72

45

69

24

55

12

Cu hi con 1: [p n ng]

Con phi

Con tri

Cha

(Ch ) Nu phn t u tin l nt cha, nt con tri ca n c ch s 1 2 = 2. Nt con phi c ch s 1 2 + 1 = 3. Nu phn t th hai l nt cha, con tri ca n c ch s 2 2 = 4. Nt con phi c ch s 2 2 + 1 = 5.

A c,

Ba

A: Trong chng trnh HeapSort, sau khi i ch gi tr nt u tin v nt th Idx-th (Swap(1, Idx)) chng trnh s gi chng trnh con Make Heap. Chng trnh con Make Heap vun cy cn li thnh ng. lm iu ny, Make Heap so snh cc gi tr ca nt cha, nt con tri, v nt con phi . Sau kt qu so snh ny c s dng truyn tham s cho chng trnh Make Heap khi gi qui. Ch s ca nt cha c lu tr trong bin Top, v vy cc ch s ca nt con tri v nt con phi cn phi c xc nh trong trng A v cu lnh tip theo. Nu nt cha c ch s l TOP th ch s ca nt con tri l (Top 2) v ch s ca nt con phi l (Top 2 + 1). Biu thc R L + 1 ngay sau trng A cho thy L l ch s ca nt con tri v R l ch s ca nt con phi. Vy p n y l biu thc L Top 2 c chn vo. B: Biu thc R < Last khng th c trong trng hp khng c nt con phi bi v Last l ch s ca phn t cui cng v R l ch s ca nt con phi. Trong trng hp ny, ta kim tra

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

431

Bi thi th FE (Bui chiu) p n v gii thch -

liu c mt nt con tri hay khng. Nu c, ta so snh gi tr ca nt cha (vi ch s Top) v gi tr ca nt con tri (vi ch s L). D th no cng c mt nt con tri c xc nh bi L < Last ging nh R < Last s dng phn trc trong chng trnh. Do vy, chng ta chn L < Last y.

Cu hi con 2: [p n ng]

C g,

Dc

Theo thut ton ca chng trnh con MakeHeap, ta s tm hiu mng trong biu ng c m t trong cu hi thay i nh th no.

(1) i ch ln th nht
Gc A[1] v phn t cui cng A[10] c i ch. Sau , ng c vun li.
Ch s 1 2 3 4 5 6 7 8 9 10

A[]

91

86

72

72

45

69

24

55

12

12 A[] 12

86 86

72 72

72 72

69 So snh 45 69

45

24 24

55 55

1 1

91 91

(2) i ch ln th hai
Gi tr 86 (A[2], nt con tri) c gi tr ln nht theo kt qu so snh, v vy A[1] v A[2]c i ch.
Ch s 1 2 3 4 5 6 7 8 9 10

A[]

12

86

72

72

45

69

24

55

91

86
1

12
2

72
3

72
4

45
5

69
6

24
7

55
8

1
9

91
10

Tip theo, nt A[2] (nt va c i ch ) coi l nt cha v qu trnh x l tng t xy ra. A[] 86 12 72 72 45 69 24 55 1 91

(3) i ch ln th ba
Theo kt qu so snh, 72 (A[4], nt con tri) c gi tr ln nht, v vy A[2] v A[4] c i ch.
Ch s 1 2 3 4 5 6 7 8 9 10

A[]

86

12

72

72

45

69

24

55

91

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

432

Bi thi th FE (Bui chiu) p n v gii thch -

86

72

72

12

45

69

24

55

91

Tip theo, nt A[4] (nt va c i ch ) coi l nt cha v qu trnh x l tng t xy ra.


1 2 3 4 5 6 7 8 9 10

A[]

86

72

72

12

45

69

24

55

91

(4) i ch ln th t
Theo kt qu so snh, 55 (A[8], nt con tri) c gi tr ln nht, v vy A[4] v A[8] c i ch.
Index 1 2 3 4 5 6 7 8 9 10

A[]

86

72

72

12

45

69

24

55

91

86

72

72

55

45

69

24

12

91

Tip theo, coi A[8]l nt cha chng ta tip tc so snh, nhng do A[8]khng c nt con no nn chng trnh kt thc y. Vy c tt c 4 ln i ch gi tr cc nt. Trng thi cui cng ca mng A c biu din di y, theo gi tr ca 12 c lu tr trong phn t mng c ch s l 8.
1 2 3 4 5 6 7 8 9 10

A[]

86

72

72

55

45

69

24

12

91

Theo trn th c 4 ln i ch gi tr ca cc nt. Cu hi con 2: [p n ng] C g, Dc

Mt ng c vun bng vic to nt gc (A[1]) c gi tr ln nht. V vy ta s vun ng cho cy con khi coi A[i] l nt cha. Ta tip tc vun ng cho cc cy con trong khi gim dn ch s i 1 cho n lc vun ti nt A[1]; khi cy c vun thnh ng. Mt nt khng c nt con no th khng cn vun ng, nn gi tr khi to ca i l ch s ca nt u tin c mt nt con. Nt con tri ca A[j] l (A[j 2]), v nt con phi l (A[j 2 + 1]), nn nt cha ca nt ca A[k] l A[k / 2]. Dn n ch s ca nt cui cng vi mt con l thng ca s cc phn t (Last) cho 2, .., (Last / 2). Trong trng hp c th, khi Last = 10, ch s ca nt cui cng c mt nt con l (10 / 2 = ) 5. Vy ta cn vun li ng mi ln ch s Idx gim i 1, vi gi tr khi to l (Last / 2), cho n khi Idx = 1 (trong khi Idx 1). Do p n y l Idx: Last / 2, Idx >= 1, -1.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

433

Bi thi th FE (Bui chiu) p n v gii thch -

Q5:
Trong bc chuyn trng thi, ch chuyn tip ch c xc nh bng trng thi hin ti v u vo. Ch rng ban u c c trng v c u h (down). A b, B d, Ca

im chnh

Cu hi con 1: [p n ng]

S0 l trng thi bt u, ti c h (red flag down) v c trng h (white flag down). iu ny c th kim tra bng (2) ca [M t chng trnh]. a) Theo on m t ca cu hi con, bc chuyn (i) l thao tc ging c (raise the red flag) v vy trng thi S1 l c ging (red flag up) v c trng h (white flag down). b) Chuyn tip (ii) l t S3 sang S0. V S0 l trng thi c ging (red flag down) v c trng h (white flag down) nn S3 phi l mt trng thi c t nht mt trong cc c ging (up). Mt khc, S1 l trng thi c ging (red flag up) v c trng h (white flag down) nn S3 phi l trng thi c trng ging (white flag up) v c h (red flag down). Do bc chuyn (ii) l hnh ng h c trng (lower the white flag). c) S1 l trng thi c ging (red flag up) v c trng h (white flag down), cn S3 l trng thi c h (red flag down) v c trng ging (white flag up), vy S2 l trng thi c ging (red flag up) v c trng ging (white flag up). Di y l phn tng kt ca nhng trng thi ny.

Trng thi (State) S0 S1 S2 S3

C (Red flag) H (Down) Ging (Up) Ging (Up) H (Down)

C trng (White flag) H (Down) H (Down) Ging (Up) Ging (Up)

Do , bc chuyn (iii) l ging c (raise the red flag). Cu hi con 2: [p n ng] a, g

Thng tin trong tp gi tr ban u, theo (2) ca [Gii thch chng trnh] bao gm (thi gian pht hin cu tr li, thi gian hin th ca s cho tr li sai, s ln lp li). Qu trnh s dng thi gian tm ra cu tr li c th c xc nh nh sau. Ch (4) ca [Gii thch chng trnh]: C 5 loi thao tc c th nhn c t cc thit b nhp: ging c , h c , ging c trng, h c trng, v khng di chuyn c no (khi khng pht hin ra cu tr li no trong thi gian pht hin cu tr li). M t trn gip ta thy r rng thi gian pht hin cu tr li l cn thit trong qu trnh lin quan n cc thao tc ny. Qu trnh ny l qu trnh pht hin tr li. Bn cnh , qu trnh s dng thi gian hin th ca s cho tr li sai c th c xc nh nh sau. Ch (5) ca phn [Gii thch chng trnh]: Chng trnh s pht hin ra cu tr li ca ngi chi. Nu ng, chng trnh s cng thm 1 vo s cu tr li ng v gi ca s cu tr li ng ti thit b xut. Nu sai,
Ti liu n thi FE Tp.1
-- Phn2. Tp bi thi th --

434

Bi thi th FE (Bui chiu) p n v gii thch -

chng trnh s gi ca s cu tr li sai ti cc thit b xut v sau khi ht thi gian hin th ca s cu tr li sai trong tp gi tr khi to, chng trnh s thit lp c trong ca s ny sang trng thi ng. M t trn gip ta thy r rng thi gian hin th tr li sai l cn thit trong qu trnh lin quan n cc thao tc ny. Qu trnh ny l qu trnh x l tr li sai.

Q6:

im chnh

K t u tin l <, nn phi duyt t k t th hai. Trong vng lp for ch s s dng khi gp k t >, nn phi duyt t k t tip theo.

Cu hi con: [p n ng]

A a,

B c,

C a,

Dd

Chng trnh tuy phc tp nhng vi v d c th trong Hnh 2 v Bng 2 th on chng trnh tr nn d hiu hn. Thm na, nhng ch thch trong chng trnh l ph hp. Theo [M t chng trnh] (2) (iii) ch r rng khng c li c php no trong cc xu k t gn th, v vy mt xu k t bt u vi k t < c ngha bt u mt th trong khi k t > th xc nh kt thc th, v hai k t lun to thnh mt cp. Trong chng trnh, phn XXXX trong <XXXX> c lu tr nh tn ca th. Nh vy, lin h (mt cch tng ng) cu lnh mlstr = parse_ml_date(mlstr +1, 1); vi cu lnh char *parse_ml_date(char *mlstr, int level), ta thy qu trnh duyt bt u t k t th hai ca mlstr v su bt u t 1. y gi thit rng k t u tin ca mlstr l <. A: Tham kho Bng 2, con tr tr ti STUDENT c lu tr trong elmtbl[elmnum].tag. Gi tr khi to ca elmnum l 0, v vy con tr tr ti STUDENT (cng l a ch ca k t S) c lu tr trong elmtbl[0].tag. Vy p n ng chn vo trng l mlstr. Hn na, trong cu lnh tip theo s lu tr chiu su ca th v con tr ca xu duyt qua cc k t cho n khi gp k t >. Trn thc t k t \0 c lu tr v tr ca > ch nh rng qu trnh lu tr tn th hon thnh. B: y l qu trnh lu tr gi tr th, v vy theo Bng 2, ta thy con tr tr ti BILL c lu tr trong elmtbl[elmnum].value. Hn na, trong vng lp for, con tr xu dng ti v tr ca >. Do khi tng gi tr ca con tr 1 th s tr ti v tr ca k t B. Vy p n ng s l mlstr + 1. C: Sau khi lu tr gi tr th, ta duyt tip n k t < hoc </. iu ny th hin trong vng lp for sau trng B. Ngay khi bt u phn tch th, con tr dng ti v tr ca k t <, v vy chng trnh cn xc nh k t tip l k t / hay khng. Nu k t tip l / th chiu su th khng thay i, ngc li th tn ti th khc mc thp hn bn trong. Vy y ta cn tng ch s mng lu tr ln 1 v p n ng chn vo trng l elmnum++. D: Theo gii thch p n C, nu k t tip theo khng phi l / th tn ti th khc mc thp hn bn trong. Trong trng hp ny, hm parse_ml_date c gi qui, v s phn tch xu li tip tc. Vy y, ta chn vo trng iu kin k t tip theo khng phi l /.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

435

Bi thi th FE (Bui chiu) p n v gii thch -

v p n l *(mlstr + 1) != /.

Q7:

im chnh

Lung (thread) c bt u nh mt n v thc thi ring r v xy ra ng thi vi phng thc main. Chiu dng cho x l bn tri, chiu dng cho y l xung di.

Cu hi con 1 : [p n ng]

A c,

Bd

Mt lung l mt n v ca qu trnh thc thi chng trnh, v n c th c bt u nh mt n v thc thi ring r xy ra ng thi vi phng thc main (phng thc main c thc thi ngay t u). Trong Java, c 2 cch to to mt lung. Cch th nht l tha k lp Thread, v cch th hai l ci t giao din Runnable. Chng trnh ny s dng cch th hai. A: Trong lp tru tng Motion, thm vo cho phng thc khi to Motion v phng thc run(), c s dng tip tc hin th chuyn ng ca im, phng thc tru tng update c nh ngha xc nh chuyn ng ca im. Trong phng thc run(), mt im c v ti v tr ta c nh ngha bi while(true){}. Cu lnh while thc hin vic sau: (1) v im, (2) dng 40 mili giy, (3) trng A, v (4) xa im. y, c nhu cu di chuyn im gia (2) v (4) trn, v vy trong trng A cn gi phng thc update() di chuyn im v thay i ni dung ca im. Do , chng ta cn chn point = update(point) Ch rng Point current = point; ngay trc trng A l qu trnh rt li xa im trc khi di chuyn vi Space.erase(current) ngay sau trng A. B: trng B nm bn trong new Thread () ca for (int i = 0; i < point.length; i++) l mt qu trnh c lp li. iu ny ch ra rng s lung s c to ra tng ng vi s im c v. Vi mt lung, nh c cp trn th giao din Runnable phi c ci t, nhng lp Motion l mt lp tru tng v khng th c sinh ra nh mt lung. Ni cch khc, lp SimpleMotion, tha k lp tru tng Motion, c sinh ra nh mt lung. Do new SimpleMotion(points[i]) c chn y.

Cu hi con 2 : [p n ng]

Trong hnh v ca cu hi con 2, gc tri di cng c t l gc ta (0, 0). Do , cc du hiu ban u cho mi chuyn di (i), (ii), (iii) v (iv) nh sau: (i) X m, Y dng (ii) X dng, Y dng (iii) X m, Y m (iv) X dng, Y m T [Chng trnh 3], ta thy trong phng thc update(), cc gi tr x v y c tnh ton t directionX v directionY tng ng. Dng 2 nh r cc gi tr ban u ca directionX v directionY u l 1. V vy X v Y u dng. V th c x v y ang di
Ti liu n thi FE Tp.1
-- Phn2. Tp bi thi th --

436

Bi thi th FE (Bui chiu) p n v gii thch -

chuyn theo chiu tng, tc l mi tn (ii). Cu tr li l im P di chuyn theo chiu mi tn (ii).

Q8:
Cc hng chuyn ng l i ln, sang phi, i xung, v sang tri. rcheck( ) l hm dng xc minh xem n c th chuyn ng sang bn phi khng.

im

Ch u tin l trong cc dng t mt n 4, UP, RIGHT, DOWN, v LEFT c nh ngha l cc hng s biu din cc hng i ln, sang phi, i xung v sang tri v tng ng vi cc gi tr l 0, 1, 2, v 3. Cu hi bn thn n khng cho bt c ch nh v cc li hng dn nhng tn ca chng li cho cc manh mi. Trong cu hi 1, iu kin khi to l x = 1 v y = 0, du chm im bt u ca hnh 1. y, hng chuyn ng c th ch l i xung, v vy bn nhn thy rng DOWN thc s ngha l hng xung. By gi, quan tm n cc x l ca cc hm rcheck() , fcheck(), v go(). (1) rcheck( ) Khi dir = UP hm ny s tr v M[y][x + 1], v vy n ang tr v to ca hnh vung bn phi. Nu dir = RIGHT hm ny s tr v M[y + 1][x], vi vy n ang tr v to ca hnh vung bn di. Nu dir = DOWN hm ny s tr v M[y][x 1] vi vy n ang tr v to ca hnh vung bn di, v khi dir = LEFT hm ny s tr v M[y 1][x], y l ta hnh vung bn trn n. Trong cc hnh v bn di, mi mi tn (, , , v ) ch nh cc hng c xc minh bi gi tr ca dir, v hnh vung ti l v tr ca cc ta tr v. x1 y-1 y y+1 dir = UP dir = RIGHT dir = DOWN dir = LEFT x x+1 x1 x x+1 x1 x x+1 x1 x x+1

Trong mi hnh v trn, nu mi vng xm hoc l ROAD hoc l EXIT, th chng trnh c th x l hnh vung ti. V vy x l hnh vung ti, chng ta phi t dir = (dir + 1) %4. Bng bn di ch nh nhng bin i ca dir cho hot ng ny. dir hin ti Ga tr 0 1 2 3 (dir + 1) %4 1 2 3 0 dir mi

Cc im dir mi n hnh vung bn phi ca hng chuyn ng. K t y, chng trnh u tin s kim tra xem n c th chuyn n hnh vung bn phi khng. Ch rng nu n c th, im s chuyn n hnh vung , nu khng chng trnh gi hm fcheck() v quyt nh bn trong hm hng ca im nn di chuyn tip theo. (2) fcheck() Quan tm iu chnh trong hm rcheck().

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

437

Bi thi th FE (Bui chiu) p n v gii thch -

dir dir dir dir

= = = =

UP: RIGHT: DOWN: LEFT: x x+1

M[y 1][x] M[y][x + 1] M[y + 1][x] M[y ][x 1] x1 x x+1

Tr v ta hnh vung bn trn Tr v ta hnh vung bn phi Tr v ta hnh vung bn di Tr v ta hnh vung bn tri x1 x x+1 x1 x x+1

x1 y-1 Y y+1

dir = UP

dir = RIGHT

dir = DOWN

dir = LEFT

Nu vng ti trong mi hnh trn hoc l ROAD hoc l EXIT, th chng trnh c th hng vo vng ti, v vy chng trnh gi trc tip hm go() v tip tc. iu ny ang kim tra c hay khng c th i n hnh vung tip theo trong hng chuyn ng. K t y, bn c th nhn thy rng nu hm rcheck() xc minh c rng hng n hnh vung bn phi l khng th th chng trnh s kim tra xem n c th chuyn n hnh vung tip theo trong hng ca chuyn ng. By gi, nu chng trnh gi hm rcheck() hoc fcheck() v tm thy rng khng c chyn ng no c th th bn c th nhn thy t dng 28, gi tr ca dir c thay i trong theo hng ca hnh vung bn tri. Khi iu ny xy ra, hm go() khng c gi, v n ch lien quan n thay i ca dir. dir hin ti Ga tr 0 1 2 3 (dir + 3) %4 3 0 1 2 dir mi

Mi quan h gia hng hin ti v hng mi (ti) theo sau. Ch rng hng c tr v bng gc 90 bn tri (Ngc chiu kim ng h). x1 y-1 Y y+1 dir = UP dir = RIGHT dir = DOWN dir = LEFT x x+1 x1 x x+1 x1 x x+1 x1 x x+1

(3) go() Mi quan h gia gi tr ca dir v hng chuyn ng theo sau. Ch rng, khng ging rcheck()", "fcheck()" v go() thay i thc s cc ta . dir = UP :y-Chuyn n hnh vung bn trn dir = RIGHT :x++ Chuyn n hnh vung bn phi dir = DOWN :y++ Chuyn n hnh vung bn di dir = LEFT :M[y][x 1] Chuyn n hnh vung bn tri

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

438

Bi thi th FE (Bui chiu) p n v gii thch -

Cu hi 1 : [Tr li dng]

Trc tin, chng trnh gi hm rcheck( ) v xem n c th i tip khng. Bi v gi tr khi to ca dir l DOWN (= 2), chng trnh kim tra hnh vung bn phi ca hng chuyn ng ( l M[0][0]). i vo theo hng l khng th, v vy chng trnh gi hm fcheck() kim tra hng chuyn ng (hnh vung bn di, l hnh vung 1). Bi v n c th chuyn n hnh vung 1, hm go() c gi, v v tr chuyn n M[1][1] (hnh vung 1). Tip theo, hm rcheck() c gi li, v hnh vung bn phi ca hng chuyn ng (M[1][0]) c kim tra, nhng li mt ln na hnh vung ang chuyn ng khng c cho php. V vy hm fcheck() c gi, v ri hnh vung trong hng chuyn ng M[2][1]) c kim tra. Tip tc v hnh vung l c th, v vy by gi chng trnh chuyn n M[2][1]. Nhng x l ny c lp li, v ng chuyn ng t hnh vung 1 n hnh vung 2. M [0] [1] 1 2 a 6 b 5 7 3 4 8

Ti M[4][1], chng trnh khng th i n bt c ni u bi hm rcheck() hoc fcheck(), v vy cu lnh trong dng 28 c thc thi. Hm go() tr v hng chuyn ng bng gc 90 bn tri, v vy hng c thay i n dir = 1 (RIGHT, ). Tip n chng trnh gi hm rcheck() v hnh vung bn phi ca hng chuyn ng (hnh vung bn di, M[5][1], gia hnh vung 2 v hnh vung 6) c kim tra. Tuy nhin n khng th chuyn n , v vy hm fcheck() c gi kim tra hnh vung trong hng chyn ng (M[4][2], gi hnh 2 v hnh 5). y cng l hnh vung khng th chuyn ng n. Li mt ln na, dng lnh 28 c thc thi, tr v hng chuyn ngj bi gc 90 bn tri, thnh hng ln . Trong trng thi ny, hng ln s chuyn im t hnh 2 n hnh mt. Tuy nhin ti hnh 1, chng trnh kim tra hnh vung bn phi ca hng ca chuyn ng, nguyn nhn n chuyn hng n hnh vung 3. Chnh t, chng ta c bn di: im bt u hnh vung 2 hnh vung 1 hnh vung 3 hnh vung 6 hnh vung 1 hnh vung 1 hnh vung 3 hnh vung 2 (Ri tr v) (Ri tr sang phi) (Ti hnh vung 3, hng l , v vy n chuyn sang bn phi, l hng xung). hnh vung 5 () M[5][3] hnh vung 6 (Ti hnh vung 5, n chuyn vo hng ). () M[6][3] hnh vung 5 (Ti hnh vung 6, mt tr v 90 bn tri xy ra hai ln, thay i hng . Ti M[6][3], n tr v hng .) hnh vung 7 (Ti hnh vung 5, hng thay i n bn phi, hng

hnh vung 5

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

439

Bi thi th FE (Bui chiu) p n v gii thch -

n hnh vung 7) hnh vung 7 im cui. V vy, ng i l im u12135657im cui.

2 a 6

Cu hi 2 : [Tr li ng]

Nh din gii trong cu hi 1, chng ta ch nh s di chuyn. y n di chuyn nh th no: 1 2 4 3

Hnh vung 1: Chng trnh mong i bn phi ca hng di chuyn, nhng n khng th di chuyn sang bn phi. Vi vy n hng vo trong hng ca chuyn ng. Hnh vung 2: Chng trnh mng i sang bn phi, nhng n khng th chuyn n . V vy n mng i hng ti, nhng chuyn ng hng ti cng khng th. V vy n thay i hng sang tri (). Hnh vung 3: Li mt ln na, chng trnh kim tra hnh vung bn phi v hnh vung u ng trc. Khng c chuyn ng no l c th. V vy n thay i sang hng bn tri ca hng chuyn ng, thay i . Hnh vung 4: Li mt ln na, chng trnh kim tra hnh vung bn phi v hnh vung u ng trc. Khng c chuyn ng no l c th. V vy n thay i sang hng bn tri ca hng chuyn ng, thay i . V vy, chuyn ng 1234 c lp li. Cu tr li ri l im bt u12341234 c lp li v tn.

Cu hi 3 : [Tr li ng]

Sau cu lnh while (dng 20), chng ta them mt cu lnh print. By gi, t iu kin
Ti liu n thi FE Tp.1
-- Phn2. Tp bi thi th --

440

Bi thi th FE (Bui chiu) p n v gii thch -

mang vo trong cu lnh while l M[y][x]! = EXIT, chng trnh s thot cu lnh iu kin while khi M[y][x] = EXIT. Ri, t im cui M[y][x] khng c in, mt cu lnh print cng c yu cu thm vo sau dng 29. V vy, mt cu lnh print nn c thm trc tip sau mi dng 20 v 29. Cu hi 4 : [Tr li ng] b X lsy ca hm lcheck() nh sau: x1 y-1 Y y+1 dir = UP dir = RIGHT dir = DOWN dir = LEFT x x+1 x1 x x+1 x1 x x+1 x1 x x+1

Tri ngc vi hm rcheck() kim tra pha bn phi ca hng chuyn ng, hm lcheck() kim tra pha bn tri. Chng trnh dung hm lcheck() xem n c th chuyn sang bn tri khng. Nu n c th, hng ca chuyn ng c tr v bng gc 90 bn tri. V iu ny, chng ta thay i dng 23 m iu chnh ging dng 28, chuyn ng ly tr v bi gc 90 bn tri. T khi dng 23 c thay i lm tr v gc 90 bn tri, dng 28 cn c thay i m quay hng bn phi bng gc 90 . K t y, chng ta nhn thy rng nhng thay i sau l cn thit: (S dng) 23 dir = (dir+1) % 4; 28 dir = (dir+3) % 4; /* 90 bn tri */ /* 90 bn phi */

dir = (dir+3) %4; dir = (dir+1) %4;

V vy, cc thay i c ch nh: +1 trong dng 23 phi c thay i thnh +3 v +3 trong dng 28 phi c thay i thnh +1.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

441

Bi thi th FE (Bui chiu) p n v gii thch -

Q9:

im

Loi s kin l DIGIT, OPERATOR, v CLEAR. CLEAR c mt t cc tham s.

Vai tr ca mi lp nh sau: (1) Lp CalculatorEvent y l lp khi mt nt tnh ton c nhn. C hai hm khi to gi l CalculatorEvent c iu ny l bi v c trng hp mt tham s truyn vo l cn thit v c trng hp tham s truyn vo l khng cn thit, ph thuc vo loi phm c nhn. (2) Giao din CalculatorOutput y l giao din ch khai bo hai phng thc tru tng display vi cc loi tham s khc nhau, c dng nh l cc tham s ca hm khi to ca lp Calculator. (3) Lp Calculator y l lp tnh ton bn thn n. Ch rng tham s khi to c nh ngha l mt bin ca loi giao din CalculatorOutput. Khi lp ny ly i tng c th, bin loi giao din c ch nh s ly trc tip thay th bn trong u ra bin loi giao din. (4) Lp CalculatorTest y l lp kim tra lp Calculator v y phng thc main c nh ngha. Ch rng tham s cn thit xy dng mt i tng lp Calculator c miu t, bao gm trng B.

Cu hi 1 : [Tr li chnh xc]

A e,

B c,

Ce

A: trng A l x l khi to khi ch c mt tham s (int type). Khi type is CLEAR (phm clear), tham s th hai value khng c dng, v mt vi gi tr ph hp c t vo cho value ca tham s th hai, v nhng tham s ny gi hai hm khi to. Cho tt c la chn trong nhm cu tr li, tham s hai l 0. Cng vy, cho cc tham s gi hai hm khi to, chng s dng t kha this tham chiu n bn thn chng. T y, this(type,0) c thm vo. B: trng B l tham s khi i tng calc ca lp Calculator c to. Da trn vic CalculatorOutput c ng gi l lp nc danh no v do phng thc display u ra l gi tr s c ch nh hoc xu k t n System.out trong gi ny, mt ch nh c th a ra l trng B phi to mt lp nc danh c ng gi giao din CalculatorOutput. Ngoi ra, Tham s c truyn n hm khi to ca lp Calculator l mt bin ca loi giao din v lp ng gi giao din CalculatorOutput phi ng gi hai loi phng thc (mt cho mi loi) display. V nhng l do ny, trong phn cha ng trng B ny, giao din CalculatorOutput c ng gi l mt lp khng t tn (lp nc danh), v, ti cng thi im, n phi c c th bng mt t kha mi. T ay, cu tr li cn bao gm tn ca giao din c ng gi bi mt lp nc danh. Cu tr li l new CalculatorOutput().

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

442

Bi thi th FE (Bui chiu) p n v gii thch -

Tnh c, mt lp nc danh c dng trong cc tnh hung a dng, nh l khi chng ta ly mt lp tn ti hoc giao din, thay i n mt phn to mt lp mi, v c mong dng lp mi ny cc b trong mt lp. Nh trong mt trng hp, gi v k tha ly t bn ngoi cc t kha extends hoc implements. C: trng C ph hp vi cc tham s c dng khi trng hp event c to khi cc gi tr u vo l 0 n 9. Tham s c truyn vo, quan tm n cc trng hp ging nh = v +, v tham s u tin l CalculatorEvent.DIGIT. Cho tham s th hai, chng trnh c th n gin truyn vo s c nhp, nhng cc k t t 0 n 9 cn c chuyn i n cc s t 0 n 9. Khi cc k t 0 n 9 ph hp vi 0x30 vi 0x39 trong s hexa, chuyn i n cc gi tr s cs th hon thnh n gin bng vic tr i s hexa 0x30. V vy, nhng g cn c thm vo trng C l CalculatorEvent.DIGIT, c - 0.

Cu hi 2 : [Tr li ng]

D a,

E d,

Fi

D: y l trng hp y u vo l nhng k t xu 3*4***=. Khi t kha x l c vo nhiu ln lin tip, cu lnh tip theo sau khi hin th kt qu hot ng thc thi register = 0;, thit lp bin nh kt qu (register) n 0. K t y, thm ch nu t kha bng c nhn, kt qu hin th l 0. E: Ti thi im 3*4 = c nhn, ng thi hin th v gi tr ca bin accumulator l 12. Khi +5 ch nh, Ga tr hin th cui l gi tr vo cui 5. y l bi v register c gn bng 0 khi k hiu bng c nhn. Vi register 0, cho n khi s khc c thm n u vo gi tr 5, hin th ch nh 5. T y, kt qu hin th l 5. F: Ti thi im 3 + 4 / 0 c vo, accumulator chas 7, l kt qu ca tnh ton 3 + 4, trong khi register gi tr u vo cui 0. Ri, khi t kha bng c nhn, chia cho 0 xy ra, kch hot x l ngoi l ArithmeticException. T y, Error c hin th.

Ti liu n thi FE Tp.1


-- Phn2. Tp bi thi th --

443