Digression:
This should be a bit difficult homework recently, at least, than the previous barber, read and write, philosophers problem more difficult.
But do the structure of the program, top-down, it was not difficult.
About banker's algorithm:
Code:
init () initialization reset () recycling Banker () banker's algorithm safe () security algorithm
Renderings:
Problems encountered:
The main problem is to start with a statement sem_t mutex, the results can not pthread_cond_wait (& cond, & mutex); it seems to be with pthread_mutex_t mutex;
vector is specified when the array clear Allocation [i], instead Allocation.clear ()
wrong reason:
First: I forgot to add &
Second: i ++ continues, although calling pthread_create before i ++, but there might be led to pass the time difference is the increased number i, leading to cross-border. So for an array.
As well as common closing parenthesis forget, forget the semicolon ....