- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
操作系统例题若干(Examples of operating system)
操作系统例题若干(Examples of operating system)
(a) there are 100 seats in the library. Each reader entering the library must register on the registration form and withdraw from the registration form when exiting. How many procedures? How many processes are there? Answer: a program; set a process for each reader
(1) when there are no seats in the library, the arriving reader is waiting (blocked) at the library
(2) when there are no seats in the library, the arriving readers do not wait and go home immediately.
Solution (1)
Set semaphore: S=100; MUTEX=1
P (S)
P (MUTEX)
register
V (MUTEX)
Read
P (MUTEX)
Cancellation
V (MUTEX)
V (S)
The solution (2)
Set integer variables COUNT=100;
Semaphore: MUTEX=1;
P (MUTEX);
IF (COUNT==0)
{V (MUTEX);
RETURN;
}
COUNT=COUNT-1;
register
V (MUTEX);
Read
P (MUTEX);
COUNT=COUNT+1;
V (MUTEX);
RETURN;
(two) a single plank bridge with east-west orientation; implemented with P and V operations:
(1) only one person is allowed to cross the bridge at a time;
(2) when there are pedestrians on a single plank bridge, pedestrians in the same direction can cross the bridge at the same time, and people in the opposite direction must wait.
(3) when there are pedestrians from east to West on the single plank bridge, pedestrians in the same direction can cross the bridge at the same time, and only one person is allowed to cross the bridge from west to east. (this question is the same as that of readers, East and west to readers, West to East).
(1) solution
Set semaphore MUTEX=1
P (MUTEX)
Cross the bridge
V (MUTEX)
(2) solution
Set semaphore: MUTEX=1 (East West mutually exclusive)
MD=1 (East to West count count mutex)
MX=1 (West to East count count mutex)
Set an integer variable: CD=0 (the number of people on the bridge going east to West)
CX=0 (the number of people on the west side of the bridge)
From east to west:
P (MD)
IF (CD=0)
{P (MUTEX)}
CD=CD+1
V (MD)
Cross the bridge
P (MD)
CD=CD-1
IF (CD=0)
{V (MUTEX)}
V (MD)
From west to east:
P (MX)
IF (CX=0)
{P (MUTE
您可能关注的文档
- 《优化学习》八年级 寒假作业 答案(Optimization learning eight grade winter vacation assignment answer).doc
- 《中国古代文学作品知识汇编》(A compilation of ancient Chinese literary works).doc
- 《仙剑奇侠传3》难点攻略指引(The Legend of Sword and Fairy 3 difficult strategy guide).doc
- 《仙剑奇侠传5前传》全称号取得方法及装备作用(Legend of Sword and Fairy 5 full title prequel method and equipment).doc
- 《再扶汉室》综合简介(Then a comprehensive description of the Han Fu).doc
- 《再扶汉室作品说明书》(Work instruction again towards the revival of the Han Dynasty).doc
- 《医学细胞生物学》第08章 细胞核(Medical cell biology, chapter 08, nucleus).doc
- 《中国古代史》考试大纲557(Examination outline of ancient Chinese history 557).doc
- 《周易》中的成语(Idioms in the book of changes).doc
- 《周易》的决策智慧(The wisdom of decision making in Zhouyi).doc
- 操作系统,(Operating system,).doc
- 操作系统概论历年真题(Introduction to the operating system over the years).doc
- 摘掉绩效考核走形式帽子(Take off performance appraisal and take form hat).doc
- 操作考试流程(Operation examination process).doc
- 操作系统试题(OS test questions).doc
- 搞笑的成都话。。。。(Funny Chengdu dialect....).doc
- 操盘六绝活(Hailun skills six).doc
- 操盘手1(Trader 1).doc
- 操盘手前线股票主力控盘战略秘技课程(The main stock trader front Kongpan strategic course cheats).doc
- 操作文件的api(Operation file API).doc
文档评论(0)