问题 多项选择题

有三个进程PA、PB和PC合作解决文件打印问题:PA将文件记录从磁盘读入主存的缓冲区1,每执行一次读一个记录;PB将缓冲区1的内容复制到缓冲区2,每执行一次复制一个记录;PC将缓冲区2的内容打印出来,每执行一次打印一个记录。缓冲区的大小等于一个记录的大小。请用P、V操作来保证文件的正确打印。

答案

参考答案:semaphore emptyA, emptyB, fullA, fullB;
emptyA=emptyB=A;
fullA=fullB=0;
main()
{
Cobegin
PA()
PB()
PC()
Coend;
{
While(A)
{
从磁盘读一个记录;
P(emptyA);
将记录存入缓冲区A;
V(fullA);
}
}
PB()
{
While(A)
{
p(fullA);
从缓冲区A中取出记录;
V(emptyA);
p(emptyB);
将记录存入缓冲区B;
V(fullB);
}
}
PC()
{
While(A)
{
P(fullB);
从缓冲区B中取出记录;
V(emptyB);
打印记录;
}
}

解析: 本题目考查进程的同步与互斥。由于缓冲区的大小等于一个记录的大小,这里存在两个简单情况的“生产者一消费者”问题:PA(生产者)与PB(消费者),PB(生产者)与PC(消费者)。PA进程套用生产者进程即可,PB进程只有在缓冲区1有新数据且缓冲区2空闲时才复制文件,因此需要与PA同步,又需要与PC同步,PC进程套用消费者进程即可。

阅读理解

任务型阅读。

    Abraham Lincoln said. "All that I am, or hope to be, I owe to my angel mother!" (a)Mothers not only give

us lives and spend their lives taking care of us, they also are our first teachers. 

                                                            

    Write a "love letter" to Mom on Mother's Day. You can change your words on the (1)____________

a lot of times. AIso, she can (2)_____________ your letter over and over again.

    (b)These steps can help you write a warm letter to Mom:

    (d)1.Relax-This "love-letter" is a talk between you and Mom and there are no rules. Even if you make a

mistake, is Mom going to be (3)_____________?

2. Collect Your Thought-Take some time to think about your years growing up.

3. Write from Your Heart-Write your letter as if you were there talking to Mom face

to face. Tell her how much you (4)____________ her. Your "love letter" to Mom on Mother's Day will

make her very (5)____________.

    (c) 金钱决不能买到! It is sure to be cherished (珍爱), saved and read many times over. It is the best

way to (6)___________ your love to Mom!

根据上文,完成下面的任务。

1. 根据短文内容,将下面的的词语填写到短文中(1)-(6)处。

    show,love,happy,letter,angry,read

2. 把(a)处划线句子翻译成汉语。

    ____________________________________________________________________________

3. 完成(b)处划线句子的同义句。 

    These steps can help you write _____________ ______________ warmly.

4. 把(c)处划线句子翻译成英语。

    ____________________________________________________________________________

5. 用(d)处划线句子中的词组改写下列句子。

    Lucy sits behind me.Jim sits in front of me.

    I sit ______________ Lucy ______________ Jim..

单项选择题