I want to know how can I avoid a deadlock in this program
void transfer(int from, into to, double amount) {
sem_t *sem_from, *sem_to;
sem_from=get_sem(from); //function that obtains the semaphore from bank account argument
sem_to=get_sem(to);
sem_wait(sem_from);
sem_wait(sem_to);
withdraw(from, amount);
deposit(to, amount);
sem_post(sem_to);
sem_post(sem_from);
}
Thanks.