여담 :
이것은 적어도 이전의 이발사보다, 읽기 및 쓰기, 문제를 더 어렵게 철학자, 최근 조금 어려운 숙제를해야한다.
그러나 프로그램, 하향식 (top-down)의 구조를 할, 그것은 어렵지 않았다.
은행의 알고리즘 소개 :
![](https://upload-images.jianshu.io/upload_images/16981913-bae01e974827b3ee.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-b4725c586f78cf11.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-19fa9d79fac1302f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-c73f9b149297a9b9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-8e6aab644e2fd6ec.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-a63f7ee8b7e06111.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-ed1854fb5de0ce66.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-ff88aa1eaef8dc57.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
코드 :
초기화 () 초기화 리셋 () 안전한 은행 () 은행의 알고리즘을 재활용 () 보안 알고리즘
![](https://upload-images.jianshu.io/upload_images/16981913-50fe8c3fa17517bd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-d02b477fafc34141.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-3739fdbde56c419b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-5e4b402cf7bf42c8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-d1a11a00b01e9962.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-d9683e4c4216f8da.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-b83485b4bd1bd2fc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-887219ccaabf1036.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
렌더링 :
![](https://upload-images.jianshu.io/upload_images/16981913-800fb83aec079dff.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-a73a0940e239ce84.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-eead37887682e49d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/16981913-c74d638b37e44756.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
문제가 발생 :
이들은 pthread_mutex_t 뮤텍스와 것 같다, 가장 큰 문제는 (COND, 뮤텍스), 결과는 pthread_cond_wait 수없는 문 sem_t 뮤텍스와 함께 시작하는 것입니다;
벡터가 지정 될 때 상기 어레이 맑은 할당 [I] 대신 Allocation.clear ()
![](https://upload-images.jianshu.io/upload_images/16981913-3584cc2a94e306ab.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
원인 :
첫째 : 내가 추가하는 것을 잊었다 &
![](https://upload-images.jianshu.io/upload_images/16981913-0386dded26970c8c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
둘째 : 나는 ++ 계속, 내가 ++ 전에는 pthread_create를 호출하지만, 시간 차이를 통과가 주도 할 수도 있지만 것은 국경에 이르는 수가 증가 전입니다. 배열에 대한 그래서.
![](https://upload-images.jianshu.io/upload_images/16981913-a3c994064c8c1a50.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
뿐만 아니라 일반적인 닫는 괄호 잊지으로, 세미콜론을 잊지 ....