




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
讀寫(xiě)鎖的特點(diǎn):讀共享,寫(xiě)?yīng)氄迹瑢?xiě)優(yōu)先級(jí)高讀寫(xiě)鎖仍然是一把鎖,有不同的狀態(tài):讀寫(xiě)讀寫(xiě)鎖場(chǎng)景練習(xí)線程A加寫(xiě)鎖成功 線程B請(qǐng)求讀線程B線程A持有讀鎖 線程B請(qǐng)求寫(xiě)線程B線程A擁有讀鎖 線程B請(qǐng)求讀B加鎖 BCA釋放后,BB釋放后,C線程A持有寫(xiě)鎖 然后線程B請(qǐng)求讀鎖 然后程C請(qǐng)求BC阻A釋放,C加C釋放,B加constpthread_rwlockattr_t*restrictattr);pthread_rwlock_trwlock=銷毀讀intintintint條件變 條件變量不是所,要和互斥量-pthread_mutex_t*restrictmutex,structtimespec}
time_t longtv_nsec;/*nanosecondes*tv_sec絕對(duì)時(shí)間,填寫(xiě)的時(shí)候time(NULL)+600==>設(shè)置超時(shí)條件變量阻塞pthread_mutex_t*restrict先釋放鎖阻塞在cond條件變量上intpthread_cond_destroy(pthread_cond_t初始化一個(gè)條constpthread_condattr_t*restrictattr);intpthread_cond_broadcast(pthread_cond_t條件變量的作用:避免無(wú)必要內(nèi)容 創(chuàng)建線程回收線程線程退出pthread_exit殺死線程pthread_cancel線程分離pthread_detach,也可以通過(guò)屬性設(shè)置pthread_attr_setdetachstate設(shè)置屬性分離,之前需要查看線程IDpthread_self在進(jìn)程內(nèi)唯一 信號(hào)量是進(jìn)化版的互斥量,允許多個(gè)線程共享資intsem_init(sem_t*sem,intpshared,unsignedintsem定義的信號(hào)量0代表線程信非0代表進(jìn)程信value定義信號(hào)量的sem_destroy摧毀信號(hào)intsem_destroy(sem_t*sem);申請(qǐng)信號(hào)量,申請(qǐng)成功value--intsem_wait(sem_t*sem);釋放信號(hào)量value++intsem_post(sem_t分區(qū)linux-day09-線程同步的第9 實(shí)現(xiàn)常見(jiàn)兩個(gè)現(xiàn)象的死鎖,鎖了又鎖以及交叉實(shí)現(xiàn)哲學(xué)家分區(qū)linux-day09-線程同步的第10errno #defineEPERM 1/*Operationnotpermitted*/#defineENOENT 2/*Nosuchfileordirectory*/#defineESRCH 3/*Nosuchprocess*/#defineEINTR /*Interruptedsystemcall*/#defineEIO /*I/Oerror*/#defineENXIO /*Nosuchdeviceoraddress*/#defineE2BIG /*Argumentlisttoolong*/#defineENOEXEC /*Execformaterror*/#defineEBADF /*Badfilenumber*/#defineECHILD /*Nochildprocesses*/#defineEAGAIN /*Tryagain*/#defineENOMEM12/*Outofmemory*/#defineEACCES13/*Permissiondenied*/#defineEFAULT14/*Badaddress*/#defineENOTBLK15/*Blockdevicerequired*/#defineEBUSY 16/*Deviceorresourcebusy*/#defineEEXIST17/*Fileexists*/#defineEXDEV /*Cross-devicelink*/#defineENODEV /*Nosuchdevice*/#defineENOTDIR /*Notadirectory*/#defineEISDIR /*Isadirectory*/#defineEINVAL 22 /*Invalidargument*/#defineENFILE /*Filetableoverflow*/#defineEMFILE 24 /*Toomanyopenfiles*/#defineENOTTY /*Notatypewriter*/#defineETXTBSY /*Textfilebusy*/#defineEFBIG /*Filetoolarge*/#defineENOSPC /*Nospaceleftondevice*/#defineESPIPE /*Illegalseek*/#defineEROFS /*Read-onlyfilesystem*/#defineEMLINK /*Toomanylinks*/ /*Brokenpipe /*Mathargumentoutofof /*Mathresultnotrepresentable#defineEDEADLK /*Resourcedeadlockwouldoccur*/#defineENALONG /*Filenametoolong*/#defineENOLCK /*Norecordlocksavailable*/#defineENOSYS /*Invalidsystemcallnumber*/#defineENOTEMPTY /*Directorynotempty*/ /*Toomanysymboliclinks#defineEWOULDBLOCK EAGAIN/*Operationwouldblock*/#defineENOMSG /*Nomessageofdesiredtype*/#defineEIDRM /*Identifierremoved*/#defineECHRNG /*Channelnumberoutofrange*/#defineEL2NSYNC /*Level2notsynchronized*/#defineEL3HLT /*Level3halted*/ /*Level3reset#defineELNRNG /*Linknumberoutofrange*/#defineEUNATCH /*Protocoldrivernotattached*/#defineENOCSI /*NoCSIstructureavailable*/#defineEL2HLT /*Level2halted*/ /*Invalidexchange#defineEBADR 53 /*Invalidrequestdescriptor*/#defineEXFULL /*Exchangefull*/ /*Noanode#defineEBADRQC /*Invalidrequestcode*/#defineEBADSLT /*Invalidslot*/ #defineEBFONT /*Badfontfileformat*/#defineENOSTR /*Devicenotastream*/#defineENODATA /*Nodataavailable*/#defineETIME /*Timerexpired*/ /*Outofstreamsresources#defineENONET /*Machineisnotonthenetwork*/#defineENOPKG 65 /*Packagenotinstalled*/#defineEREMOTE /*Objectisremote*/#defineENOLINK /*Linkhasbeensevered*/#defineEADV /*Advertiseerror*/ /*Srmounterror#defineECOMM /*Communicationerroronsend*/#defineEPROTO /*Protocolerror*/#defineEMULTIHOP /*Multihopattempted*/#defineEDOTDOT /*RFSspecificerror*/#defineEBADMSG /*Notadatamessage*/#defineEOVERFLOW /*Valuetoolargefordefineddatatype*/#defineENOTUNIQ /*Namenotuniqueonnetwork*/#defineEBADFD /*Filedescriptorinbadstate*/#defineEREMCHG /*Remoteaddresschanged*/ /*Cannotaccessaneededshared#defineELIBBAD 80 /*Accessingacorruptedsharedlibrary*/ /*.libsectionina.outcorrupted*/#defineELIBMAX /*Attemptingtolinkintoomanysharedlibraries*/ /*Cannotexecasharedlibrary /*Illegalbytesequence#defineERESTART /*Interruptedsystemcallshouldberestarted*/#defineESTRPIPE /*Streamspipeerror*/#defineEUSERS /*Toomanyusers*/#defineENOTSOCK88/*Socketoperationonnon-socket*/#defineEDESTADDRREQ89/*Destinationaddressrequired*/#defineEMSGSIZE90/*Messagetoolong*/#defineEPROTOTYPE /*Protocolwrongtypeforsocket*/#defineENOPROTOOPT /*Protocolnotavailable*/#defineEPROTONOSUPPORT93 /*Protocolnotsupported*/#defineESOCKTNOSUPPORT94 /*Sockettypenotsupported*/#defineEOPNOTSUPP /*Operationnotsupportedontransportendpoint*/ /*Protocolfamilynotsupported#defineEAFNOSUPPORT /*Addressfamilynotsupportedbyprotocol*/ /*Addressalreadyinuse /*Cannotassignrequested /*Networkisdown#defineENETUNREACH101/*Networkisunreachable*/#defineENETRESET102/*Networkdroppedconnectionbecauseofreset*/#defineECONNABORTED103/*Softwarecausedconnectionabort*/#defineECONNRESET104/*Connectionresetbypeer#define/*Nobufferspaceavailable#define/*Transportendpointisconnected#defineENOTCONN /*Transportendpointisnotconnected*/#defineESHUTDOWN /*Cannotsendaftertransportendpointshutdown*/#defineETOOMANYREFS /*Toomanyreferences:cannotsplice*/#defineETIMEDOUT /*Connectiontimedout*/#defineECONNREFUSED /*Connectionrefused*/#defineEHOSTDOWN /*Hostisdown*/#defineEHOSTUNREACH /*Noroutetohost*
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年稷山社工面試試題及答案
- 2025年運(yùn)籌學(xué)對(duì)策論試題及答案
- 2025年零售媒體行業(yè)研究報(bào)告
- 2025年課程標(biāo)準(zhǔn)考試題及答案
- 鋼結(jié)構(gòu)拆除專項(xiàng)施工方案
- 5f的徑向分布函數(shù)極大值
- c++多線程同步原子操作原理
- 住宅水電施工方案
- 水罐施工方案
- 加熱涂料施工方案
- 兒童社區(qū)獲得性肺炎管理指南(2024修訂)
- 國(guó)際貿(mào)易規(guī)則變革研究
- 職業(yè)技能大賽互聯(lián)網(wǎng)營(yíng)銷師(直播銷售員)賽項(xiàng)備賽試題庫(kù)(濃縮300題)
- 智鼎在線測(cè)評(píng)題庫(kù)推理題
- 中職教育一年級(jí)上學(xué)期電子與信息《二極管的單向?qū)щ娦浴方虒W(xué)課件
- 《凝練的視覺(jué)符號(hào)》(新課標(biāo)美術(shù)上課)-圖文
- 幼兒園小班語(yǔ)言活動(dòng)《拔蘿卜》課件
- 英文繪本故事Brown.Bear.Brown.Bear.What.Do.You.See
- 讀后續(xù)寫(xiě)人與自然類我?guī)椭従育埦盹L(fēng)后花園重建順利融入當(dāng)?shù)厣鐓^(qū)講義-2024屆高三英語(yǔ)二輪復(fù)習(xí)
- CJJ28-2014城鎮(zhèn)供熱管網(wǎng)工程施工及驗(yàn)收規(guī)范
- 2024年彌勒市東風(fēng)農(nóng)場(chǎng)有限責(zé)任公司招聘筆試參考題庫(kù)附帶答案詳解
評(píng)論
0/150
提交評(píng)論