问题 问答题

某车站售票厅,任何时刻最多可容纳20名购票者进入,当售票厅中少于20名购票者时,则厅外的购票者可立即进入,否则需在外面等待。若把一个购票者看做一个进程,请回答下列问题:
(1)用P、V操作管理这些并发进程时,应怎样定义信号量,写出信号量的初值以及信号量各种取值的含义。
(2)根据所定义的信号量,利用P、V操作写出能正确并发执行的进程。
(3)若欲购票者最多为n个人,写出信号量可能的变化范围(最大值和最小值)。

答案

参考答案:(1)定义一信号量S,初始值为20。
S>0,S的值表示可继续进入售票厅的人数;
S=0,表示售票厅中已有20名顾客(购票者);
S<0,|S|的值为等待进入售票厅的人数。
(2) COBEGIN
Pi(i=1,2,….)
{
P(S);
进入售票厅:
购票:
退出:
V(S);
}
COEND
(3)S的最大值为20;
S的最小值为20-N。

解析: 本题目考查进程的同步问题。

单项选择题

Questions from 36 to 40 are based on the following passage:China’s entrance into the World Trade Organization(WTO) will benefit not only itself but the whole world, said an article in People’s Daily.For the last nine years negotiations have gone on concerning restoring China’s status in the General Agreement on Tariffs and Trade (GATT),which is replaced by WTO. The negotiation have drawn attention from all over the world.Only when consensus is reached on key issues, can the final decision, involving more than 100 member states , be made.It is expected that China’s bid will eventually pass, though final details and a timetable have not been decided yet, said the People’s Daily.Over the past years, China has taken important steps to conform with international trade regulations based on the Uruguay-round talks. It is clear that China has made its markets more open, both in commercial and tertiary industries. Since 1992, a series of measures has been taken in lowering tariff rates and reducing non-tariff barriers.These reforms demonstrate China’s readiness to join the WTO. Serious disputes, however,still remain between China and some key member states over the obligations China should undertake.China should be responsible for reform compatible with its current development level, the article stressed. In future negotiations, we should insist on this point and give the member states a clearer understanding of the practical situation in China.China has a population of 1.2 billion, which increases by 10 million each year. The government must be very cautious in reforms to prevent dramatic economic downfalls, which may have disastrous results not only in China but around the world.China’s per capita income remains less than $500, there are still 70 million people who do not have enough for basic food and clothing. The negotiators should bear in mind the country’s development level when they decide the obligations China should assume.Otherwise, negotiation results will be meaningless, or worse; they could stifle the Chinese market. It is like the old Chinese saying: “Killing the hen to get the eggs.”China is in transition from a planned economy to a market one. With such a big population and large economic development scale, a transitional period is necessary for any new reform measure. This is also the case when adopting some international practice.

What is the former economy mode in China before its reform ( )

A.Market economy

B.Market economy and planned economy

C.Planned economy

D.None of the above

单项选择题 共用题干题