问题 单项选择题

已知有10个进程共享一个互斥段,如果最多允许6个进程同时进入互斥段,则信号量s的初值为 (1) ,信号量S的变化范围是 (2)

2()

A.0~10

B.-1~9

C.-4~6

D.-5~5

答案

参考答案:C

解析:

本题考查操作系统进程管理中进程同步和进程互斥的基础知识。

根据试题23的分析,在操作系统的进程管理中经常使用信号量(Semaphore)机制。其中“P操作”是检测信号量是否为正值,若不是,则阻塞调用进程;“v操作”是唤醒一个阻塞进程恢复执行。根据用途不同,信号量分为公用信号量和私用信号量。公用信号量用于实现进程问的互斥,初值通常设为1,它所联系的一组并行进程均可对它实施P、v操作;私用信号量用于实现进程间的同步,初始值通常设为0或n。

根据题意,有10个进程共享一个互斥段,而互斥段最多允许6个进程同时进入,所以系统资源有6个可被调用,信号量S可置初值为6。

同时信号量是一个整数,当信号量大于等于零时,表示可供并发进程使用的资源实体数;当信号量小于零时,其绝对值表示正在等待使用临界区的进程数。

因此,当第一个申请资源的进程访问时,对信号量S执行一次P操作,信号量S减1后等于5,大于零,进程可继续执行;……,当第十个申请资源的进程访问时,对信号量S执行P操作,信号量S减1后等于-4,小于零,进程进入阻塞队列等待。即信号量S的变化范围是-4~6。

完形填空

第二节完形填空(共20小题;每小题1.5分,满分30分)

阅读下面短文,掌握其大意,从每题所给的A、B、C、D四个选项中,选出最佳选项。

Obviously, there was a wall separating my father and me. But I was 21 my father's love. Nobody knew how 22 I was when I saw other fathers and 23 walking hand in hand. 24 , for me, it was only a dream.

With years going by, I couldn't 25 it any more. So I decided to tear down this 26 into pieces. But I needed courage.

Everything began to 27 after I wrote a letter to my father. I can imagine the 28 look on my father's face when he read the letter, which was really a 29 to him.

"I am sorry, my daughter. It is my fault that I have 30 your feelings. But I 31 , from now on, I'll try my best to be a good father." My father told me this later. 32 , tears rolled down my cheeks.

He ignored my feelings before, but now he really 33 the importance of love and has changed a lot. Now 34 I come home from school, my father will talk with me. He will ask me 35 I get along well with my teachers and classmates and if everything is going well in school.

36 , I have entered my father's world. I opened the door to his heart. My 37 has come true!

I have succeeded in gaining happiness by my own 38 and I'll 39 it for ever and ever. He is my father, the only one I have.

"Wherever you go, whatever you do, your mother and I will be 40 there for you," said my father.

21. A. angry with   B. indifferent(不在乎)about

C. eager for   D. wondering about

22. A. jealous(嫉妒的)   B. disappointed      C. uninterested       D. puzzled

23.A. mothers B. daughters   C. sons    D. teenagers

24.A. However      B. Therefore   C. Anyway     D. And

25.A. change  B. make  C. suffer  D. bear

26.A. situation       B. wall    C. love    D. dream

27.A. turn      B. fade    C. change       D. vary

28.A. surprised      B. exited C. appreciated D. interested

29.A. reminder      B. comfort      C. blow   D. shock

30.A. avoided B. ignored      C. harmed      D. forgot

31.A. decide   B. guess  C. promise      D. hope

32.A. For the moment   B. The moment      C. Every moment   D. At that momen t

33.A. understands   B. masters      C. attaches      D. follows

34.A. in time  B. at times      C. at the time  D. every time

35.A. how      B. whether      C. why    D. when

36.A. Finally  B. Luckily      C. Clearly       D. Regularly

37.A. expectation   B. thought      C. plan    D. dream

38.A. way      B. effort  C. hands  D. behaviour

39.A. value     B. hide    C. keep   D. remember

40.A. correctly       B. perfectly    C. right   D. very

判断题