Deadlock vs Starvation
Qhov sib txawv tseem ceeb ntawm kev tuag thiab kev tshaib kev nqhis yog qhov ua rau thiab kev sib raug zoo ntawm lawv; Nws yog kev tuag uas ua rau kev tshaib plab. Lwm qhov sib txawv ntawm kev tuag thiab kev tshaib kev nqhis yog qhov kev tuag yog ib qho teeb meem thaum kev tshaib plab tuaj yeem, qee zaum, pab kom tawm ntawm qhov kev tuag. Nyob rau hauv lub ntiaj teb computer, thaum sau ib tug computer program yuav muaj ntau tshaj ib tug txheej txheem / xov uas yuav concurrently khiav ib tug tom qab lwm yam nyob rau hauv thiaj li yuav ua kom tiav cov kev pab cuam uas yuav tsum tau rau qhov kev pab cuam. Yog li ntawd, txhawm rau kom muaj kev ncaj ncees, tus programmer yuav tsum tau ua kom ntseeg tau tias tag nrho cov txheej txheem / xov yuav tau txais lossis tau txais kev nkag tau txaus rau cov peev txheej uas lawv xav tau. Yog tsis yog, yuav muaj kev tuag, thiab nws yuav ua rau kev tshaib plab tom qab. Feem ntau, ib qho kev ncaj ncees tsis muaj qhov kev tuag lossis kev tshaib kev nqhis. Deadlocks thiab kev tshaib kev nqhis yuav tshwm sim feem ntau thaum muaj ntau cov xov sib tw rau cov peev txheej tsawg.
Deadlock yog dab tsi?
Ib qho kev tuag yog ib qho mob uas tshwm sim thaum ob txoj xov lossis cov txheej txheem tos ib leeg kom ua tiav txoj haujlwm. Lawv tsuas yog tso tseg tab sis tsis nres lossis ua tiav lawv txoj haujlwm. Hauv computer science, deadlocks tuaj yeem pom txhua qhov chaw. Hauv kev sib pauv ntaub ntawv, thaum ob txheej txheem txhua qhov hauv nws tus kheej hloov pauv tib ob kab ntawm cov ntaub ntawv tab sis nyob rau hauv qhov kev txiav txim rov qab, yuav ua rau muaj kev tuag. Hauv kev sib koom ua ke, qhov kev tsis sib haum xeeb yuav tshwm sim thaum ob qho kev sib tw yuav tos ib leeg mus rau tom ntej. Hauv kev sib txuas lus hauv xov tooj, kev kaw tsis raug tuaj yeem tshwm sim vim poob lossis kev ua tsis ncaj ntawm cov teeb liab.
Tam sim no, deadlock yog ib qho ntawm cov teeb meem tseem ceeb hauv kev ua haujlwm ntau thiab kev suav ua ke. Raws li kev daws teeb meem, lub kaw lus kaw hu ua txheej txheem synchronization yog siv rau software thiab kho vajtse.
Kev tshaib kev nqhis yog dab tsi?
Los ntawm phau ntawv txhais lus ntawm kev kho mob kev tshawb fawb, kev tshaib plab yog tshwm sim los ntawm qhov hnyav lossis tag nrho cov khoom noj uas xav tau rau kev saib xyuas lub neej. Ib yam li ntawd, hauv computer science, kev tshaib kev nqhis yog ib qho teeb meem uas tau ntsib thaum ntau cov xov los yog cov txheej txheem tos tib yam kev pab, uas yog hu ua deadlock.
Yuav kom tawm ntawm qhov kev tuag, ib qho ntawm cov txheej txheem lossis cov xov yuav tsum tau tso tseg lossis thim rov qab kom lwm cov xov lossis txheej txheem tuaj yeem siv cov peev txheej. Yog hais tias qhov no tsis tu ncua tshwm sim thiab tib cov txheej txheem los yog xov yuav tsum muab los yog yob rov qab txhua lub sij hawm thaum cia lwm yam txheej txheem los yog threads siv cov kev pab, ces cov txheej txheem xaiv los yog xov, uas dov rov qab yuav undergo ib qho teeb meem hu ua starvation. Yog li ntawd, txhawm rau kom tau tawm ntawm qhov kev tuag, kev tshaib kev nqhis yog ib qho kev daws teeb meem. Yog li ntawd, qee zaum kev tshaib kev nqhis yog hu ua ib hom tsiaj txhu. Thaum muaj ntau cov txheej txheem tseem ceeb lossis cov xov, cov txheej txheem tseem ceeb qis lossis xov yuav ib txwm tshaib plab hauv qhov tsis muaj kev tuag.
Muaj ntau qhov kev tshaib kev nqhis xws li tshaib plab ntawm cov peev txheej thiab tshaib plab CPU. Muaj ntau yam piv txwv txog kev tshaib plab. Lawv yog Cov Neeg Nyeem Ntawv-sau ntawv teeb meem thiab noj mov philosophers qhov teeb meem, uas muaj npe nrov dua. Muaj tsib tus kws txawj ntse uas ntsiag to zaum ntawm ib lub rooj puag ncig nrog lub tais ntawm spaghetti. diav rawg yog muab tso rau ntawm txhua khub ntawm philosophers uas nyob ib sab. Txhua tus philosopher yuav tsum alternately xav thiab noj. Txawm li cas los xij, tus kws tshawb fawb tsuas tuaj yeem noj spaghetti thaum nws muaj ob sab laug thiab sab xis.
"Nyob noj mov"
Dab tsi yog qhov txawv ntawm Deadlock thiab Starvation?
txheej txheem:
• Hauv kev tuag, ob txoj xov lossis cov txheej txheem yuav tos ib leeg thiab ob leeg tsis mus tom ntej.
• Hauv kev tshaib kev nqhis, thaum ob lossis ntau dua xov lossis cov txheej txheem tos tib qhov peev txheej, ib tus yuav thim rov qab thiab cia lwm tus siv cov peev txheej ua ntej thiab txuas ntxiv cov xov tshaib plab lossis txheej txheem yuav rov sim dua. Yog li ntawd, txhua txoj xov lossis cov txheej txheem yuav ua li cas mus tom ntej.
Rov qab:
• Nyob rau hauv qhov kev tsis sib haum xeeb, ob qho tib si tseem ceeb tshaj plaws xov / txheej txheem, nrog rau cov xov tseem ceeb / txheej txheem qis, yuav tos ib leeg mus ib txhis. Nws yeej tsis kawg.
• Tab sis, nyob rau hauv kev tshaib kev nqhis, cov uas muaj qhov tseem ceeb tsawg yuav tos lossis rov qab tab sis qhov tseem ceeb tshaj yuav ua mus.
Tau lossis Xauv:
• Kev tuag yog ib puag ncig tos.
• Kev tshaib kev nqhis yog ib hom kev ua neej nyob thiab qee zaum pab kom tawm ntawm qhov kev tuag.
Deadlock and starvation:
• Kev tuag ua rau kev tshaib plab, tab sis kev tshaib plab tsis ua rau muaj kev tuag.
Caus:
• Kev kaw yuav tshwm sim vim muaj kev sib cais, tuav thiab tos, tsis muaj preemption lossis ncig tos.
• Kev tshaib plab tshwm sim vim tsis muaj peev txheej, tswj tsis tau cov peev txheej, thiab cov txheej txheem ua ntej.
Summary:
Deadlock vs. Starvation
Kev tuag thiab kev tshaib kev nqhis yog qee qhov teeb meem uas tshwm sim vim cov ntaub ntawv sib tw thiab haiv neeg uas tshwm sim thaum lub sijhawm ua haujlwm nrog rau kev siv kho vajtse. Nyob rau hauv ib tug deadlock, ob threads yuav infinite tos ib leeg yam tsis tau ua thaum, nyob rau hauv ib tug tshaib plab, ib tug xov yuav yob rov qab thiab cia lwm yam xov los siv cov kev pab. Kev tuag yuav ua rau kev tshaib kev nqhis thaum kev tshaib kev nqhis yuav pab txoj xov kom tawm ntawm qhov kev tuag.