当前位置:网站首页>Chapter II Classic synchronous exercises
Chapter II Classic synchronous exercises
2022-06-28 23:11:00 【Wangchenfeng】
Catalog
One . Single topic selection ( common 10 topic ,83 branch )
3. ( Single topic selection ) About process status , The following statement is true ( ).
Two . Other ( common 2 topic ,17 branch )
One . Single topic selection ( common 10 topic ,83 branch )
1. ( Single topic selection ) The following process states are in transition , Which one is incorrect ( ).
A. be ready → Blocking
B. function → be ready
C. be ready → function
D. Blocking → be ready
My answer : A right key : A
8.3 branch
Analysis of the answer : Ready state means that everything is ready , Only owe CPU The state of , As long as it is not running , It will not become a state other than ready .
2. ( Single topic selection ) The system has n(n>2) A process , And the process scheduler is no longer executed , Which of the following is unlikely to happen ?( )
A. There is a running process , There is no ready process ,n-1 A blocking process .
B. There is a running process , There is a ready process ,n-2 A blocking process .
C. There is a running process ,n-1 A ready process , There is no blocking process .
D. There is no running process , Yes 2 A ready process ,n-2 A blocking process .
My answer : D right key : D
8.3 branch
Analysis of the answer :
D In the options , There is a ready process ,CPU Once you're free , The system will select a ready process to execute , So it is impossible to have a ready process without a running process .
3. ( Single topic selection ) About process status , The following statement is true ( ).
A. Once the process is formed , The first thing to enter is the running state .
B. A process must go through the three basic states of the process before it can end .
C. A process may be in some basic state at the same time .
D. In a time-sharing system , The time slice of a running process has expired and the process has not finished running , The process will go to the ready state .
My answer : D right key : D
8.3 branch
4. ( Single topic selection ) The operating system is based on ( ) To control and manage processes that execute concurrently .
A. Basic state of the process
B. Process control block
C. Multiprogramming
D. Priority of the process
My answer : B right key : B
8.3 branch
5. ( Single topic selection ) In a single processor system , If they exist at the same time 10 A process , The processes in the ready queue can have at most ( ) individual .
A. 1
B. 8
C. 9
D. 10
My answer : C right key : C
8.3 branch
6. ( Single topic selection ) There is a counting semaphore S:(1) If several processes are right S the 28 Time P Operation and 18 Time V After the operation , Semaphore S The value of is 0.(2) Suppose several processes are on semaphores S the 15 Time P Operation and 2 Time V operation . How many processes are waiting for semaphores at this time S Of the queue ( ).
A. 2
B. 3
C. 5
D. 7
My answer : B right key : B
8.3 branch
Analysis of the answer :
7. ( Single topic selection ) The following about PV The correct statement of operation is ( ).I.PV An operation is a system call command II.PV Operation is a low-level process communication primitive III.PV An operation is a process that cannot be interrupted IV.PV Operation consists of two non interruptible processes
A. I、III
B. II、IV
C. I、II、IV
D. I、IV
My answer : C right key : B
0 branch
Analysis of the answer :
8. ( Single topic selection ) There are two concurrent processes P1 And processes P2, The shared initial value is 1 Of x,P1 Yes x Add l,P2 Yes x reduce 1. Add 1 Sum minus 1 The sequence of instructions for operation is as follows :// Add 1 operation load R1,x // take x To register R1 in inc R1store x,R1 // take R1 The content is stored in x// reduce 1 operation load R2,x // take x To register R2 in dec R1store x,R2 // take R2 The content is stored in x After the two operations are completed ,x Value ( ).
A. May be -1 or 3
B. Only for 1
C. May be 0,1 or 2
D. May be -1,0,1 or 2
My answer : C right key : C
8.3 branch
Analysis of the answer :
9. ( Single topic selection ) stay 9 A producer .6 The shared capacity of consumers is 8 The manufacturer of the buffer - Consumer problem , The initial value of semaphore of mutually exclusive buffer is ( ).
A. 1
B. 6
C. 8
D. 9
My answer : A right key : A
8.3 branch
10. ( Single topic selection ) Set the semaphore associated with a resource (K) The initial value is 3, The current value is 1. if M Indicates the number of available resources ,N Indicates the number of processes waiting for the resource , be M,N Namely ( ).
A. 0,1
B. 1,0
C. 1,2
D. 2,0
My answer : B right key : B
8.3 branch
Two . Other ( common 2 topic ,17 branch )
11. ( Other ) A fast food restaurant has 4 Class Employee :( l ) Foreman : Accept customers' orders ;( 2 ) The cook : Prepare customers' meals ;( 3 ) Contractor : Pack the prepared food ;( 4 ) cashier : Collect and submit food . Each employee can be regarded as a process , Try a synchronization mechanism to write programs that can make four types of employees run correctly and concurrently .
My answer :**0 branch

right key :
semaphore S1 , S2 ,S3 , S4 ; S1 = 1 ;S2 =S3 = S4 = 0 ; cobegin {P1() { while(1) { There are customers coming ; wait( S1 ); Accept customers' orders ; signal( S2 ); } }P2 () { while(1){ wait(S2 ) ; Prepare customers' meals ;signal( S3 ) ; } }P3() { while(1){ wait(S3 ) ; Pack the prepared food ;signal( S4 ) ; }} P4 () { while(1){ wait( S4 ) ; Collect and submit food ;signal( S1 ) ; } }} coend
***:8.3 branch
12. ( Other ) A bank provides 1 A service window and 10 A seat for customers to wait . When the customer arrives at the bank , If a seat is available , Then go to the number taking machine to get a number , Wait for the call . Only one customer is allowed to use the number picking machine at a time . When the salesperson is free , Select a customer by calling , And serve them . The activity process of customers and salespeople is described as follows :cobegin{ process customer i{ Get a number from the number machine ; Wait for the call ; Get services ;}process Sales Clerk { while(TRUE){ Call ; Serving customers ; } }}coend Please add the necessary semaphores and P、V( or wait()、signal()) operation , Realize mutual exclusion and synchronization in the above process . Ask to write a complete process , Explain the meaning of semaphore and assign initial value .
My answer :**0 branch

right key :
semaphore enmpty=10,// Empty seats mutex=1,// Sign taking is mutually exclusive full=0,// Number of customers waiting service=0;// Wait for the call cobegin{ process customer i { P(empty);//wait(empty) P(mutex);//wait(mutex) Get a number from the number machine ; V(mutex);//signal(mutex); V(full);//signal(full) P(service);//wait(service) Wait for the call Get services ;}process Sales Clerk { while(TRUE){ P(full);//wait(full) V(empty);//signal(empty) V(service)//signal(service), Call Serving customers ; } }}coend
Analysis of the answer :
***:8.7 branch
边栏推荐
- 生产环境sonarqube安装
- hiredis的代码示例
- Websocket for im instant messaging development: concept, principle and common sense of mistakes
- Lecun predicts AgI: big model and reinforcement learning are both ramps! My world model is the new way
- 小样本利器2.文本对抗+半监督 FGSM & VAT & FGM代码实现
- C语言-单词分析解析
- Do you know all the wonderful functions of the vlookup function?
- 【深度学习】(2) Transformer 网络解析,代码复现,附Pytorch完整代码
- CMake教程(一)
- Qtcreater5.15.0 source code compilation process record
猜你喜欢

Basic knowledge diagram of K-line Diagram -- meaning of single K-line

leetCode-栈类型详解

微搭低代码中实现二维码生成

At the end of June, how many people in Kangkang are ready to change jobs

Encounter with avita 11: long lost freshness under strong product power

在线SQL转HTMLTable工具

Progress of dbnn experiment

老家出资,俞敏洪设立两支基金

WMS仓库管理系统模块之波次拣货

Lecun predicts AgI: big model and reinforcement learning are both ramps! My world model is the new way
随机推荐
hiredis的代码示例
【剑指Offer】50. 第一个只出现一次的字符
【Flutter 问题系列第 71 篇】Flutter 中 Uint8List 和 Image 之间的相互转换
在DialogFragment的onStop(完全不可见)时调用dismiss退出界面报错解决办法
Linq连表查询
一文读懂,WMS仓储管理系统与ERP有什么区别
在线文本过滤小于指定长度工具
TDD and automated testing
笔记
LeetCode 324 擺動排序 II[排序 雙指針] HERODING的LeetCode之路
CIN at QT (the clearest tutorial in the whole network)
机器学习6-决策树
Google Earth Engine(GEE)——利用sentinel-2数据进行农作物提取分析
WEB API学习笔记1
2022 PMP project management examination agile knowledge points (4)
云计算的迷路者
Understand shell script in one article
论文解读(DCN)《Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering》
Differences among CPU, GPU, TPU and NPU
超级工厂里的生意图鉴
