联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Matlab编程Matlab编程

日期:2024-05-15 11:43

EECS 111: System Software, Spring 2024, Homework 2

1.  Suppose that a university wants to show off how politically correct it is by applying the U.S. Supreme Court’s ‘‘Separate but equal is inherently unequal’’ doctrine to gender as well as race, ending its long-standing practice of gender-segregated bathrooms on cam-pus. However, as a concession to tradition, it decrees that when a woman is in a bath- room, other women may enter, but no men, and vice versa. A sign with a sliding marker on the door of each bathroom indicates which of three possible states it is currently in:

Empty

• Women present

Men present

In pseudocode, write the following procedures: woman_wants_to_enter, man_wants_to_enter, woman_leaves, man_leaves. You may use whatever counters and synchronization techniques you like.

2.  Servers can be designed to limit the number of open connections. For example, a server may wish to have only N socket connections at any point in time. As soon as N connections are made, the server will not accept another incoming connection until an existing connection is released. Explain how semaphores can be used by a server to limit the number of concurrent connections.

3. What is the difference between compare_and_swap() and test_and_set() instructions in a multiprocessor environment. Show how to implement the wait() and signal() semaphore operations in multiprocessor environments using the compare_and_swap() and test_and_set() instructions. The solution should exhibit minimal busy waiting.

4.  Design an algorithm for a bounded-buffer monitor in which the buffers (portions) are embedded within the monitor itself.

5.  Discuss the tradeoff between fairness and throughput of operations in the readers–writers problem. Propose a method for solving the readers–writers problem without causing starvation.

6.  How does the signal() operation associated with monitors differ from the corresponding operation defined for semaphores?

7. Race conditions are possible in many computer systems. Consider a banking system with two methods: deposit (amount) and withdraw (amount). These two methods are passed the amount that is to be deposited or withdrawn from a bank account. Assume that a husband and wife share a bank account and that concurrently the husband calls the withdraw() method and the wife calls deposit(). Describe how a race condition is possible and what might be done to prevent the race condition from occurring.





版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp