gpt4 book ai didi

c - 死锁 - 转移程序

转载 作者:太空宇宙 更新时间:2023-11-04 06:36:30 27 4
gpt4 key购买 nike

<分区>

我想知道为什么这个程序会死锁

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);
}

谢谢。

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com