实现银行家算法的多线程程序 [英] multithreaded program that implements the banker’s algorithm
问题描述
我将编写一个实现
银行家算法的多线程程序。一些客户要求并从银行发放资金。银行家只有在系统处于安全状态时才会发出请求。系统处于不安全状态的请求将被拒绝。
将被拒绝。这个编程任务结合了三个独立的主题:
(1)多线程,(2)防止竞争条件,以及(3)避免死锁
你如何编写程序?困惑| :confused:困惑| :confused:困惑| :confused:困惑| :confused:
me will write a multithreaded program that implements the
banker’s algorithm . Several customers request and
release resources fromthe bank. The bankerwill grant a request only if it leaves
the system in a safe state. A request that leaves the system in an unsafe state
will be denied. This programming assignment combines three separate topics:
(1)multithreading, (2) preventing race conditions, and (3) deadlock avoidance
How do you write a program؟Confused | :confused: Confused | :confused: Confused | :confused: Confused | :confused:
推荐答案
当我编写程序时,我通常首先要了解我的要求是什么。现在,你有一套不错的要求。您现在需要做的是将它们分解为单个任务,并且由于您打算将其作为多线程,您需要考虑更改值将产生的影响。例如,假设我们在保险库中有一个
When I write a program, I typically start by trying to understand what my requirements are. Now, you have a decent set of requirements there. What you need to do now is break these down into individual tasks, and as you are intending this to be multithreaded, you need to consider what effect changing values will have. An example, suppose that we have a bank that has
200的银行。现在,两个客户来到门口 - 一个想要存款
200 in the vaults. Now, two customers come through the door - one wants to deposit
100而另一个想要撤销
100 and the other wants to withdraw
这篇关于实现银行家算法的多线程程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!