0% found this document useful (0 votes)
33 views8 pages

Ôn tập deadlock - bài tập lập lịch cho CPU - TRẦN THỊ NHẬT LINH

The document discusses scheduling algorithms including round robin, shortest job first, and shortest remaining time first. It provides examples of applying these algorithms to scheduling processes and calculating their average waiting times and turnaround times. Key scheduling concepts like Gantt charts and preemption are also covered.

Uploaded by

Linh Nhật
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views8 pages

Ôn tập deadlock - bài tập lập lịch cho CPU - TRẦN THỊ NHẬT LINH

The document discusses scheduling algorithms including round robin, shortest job first, and shortest remaining time first. It provides examples of applying these algorithms to scheduling processes and calculating their average waiting times and turnaround times. Key scheduling concepts like Gantt charts and preemption are also covered.

Uploaded by

Linh Nhật
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Tên: Trần Thị Nhật Linh

Lớp: 22SE1B

Mã SV: 22IT.B122

Bài làm

Which one of the following is the deadlock avoidance algorithm?

A. banker’s algorithm

B. round-robin algorithm

C. elevator algorithm

D. karn’s algorithm

What is the drawback of banker’s algorithm?

A. in advance processes rarely know how much resource they will need

B. the number of processes changes as time progresses

C. resource once available can disappear

D. all of the mentioned

For an effective operating system, when to check for deadlock?

A. every time a resource request is made

B. at fixed time intervals

C. every time a resource request is made at fixed time intervals

D. none of the mentioned

A problem encountered in multitasking when a process is perpetually denied necessary resources


is called ____________

A. deadlock

B. starvation

C. inversion
D. aging

Which one of the following is a visual (mathematical ) way to determine the deadlock
occurrence?

A. resource allocation graph

B. starvation graph

C. inversion graph

D. none of the mentioned

The circular wait condition can be prevented by ____________

A. defining a linear ordering of resource types

B. using thread

C. using pipes

D. all of the mentioned

For a deadlock to arise, which of the following conditions must hold simultaneously?

A. Mutual exclusion

B. No preemption

C. Hold and wait

D. All of the mentioned

For a Hold and wait condition to prevail ____________

A. A process must be not be holding a resource, but waiting for one to be freed, and then request
to acquire it

B. A process must be holding at least one resource and waiting to acquire additional
resources that are being held by other processes

C. A process must hold at least one resource and not be waiting to acquire additional resources

D. None of the mentioned

Deadlock prevention is a set of methods ____________


A. to ensure that at least one of the necessary conditions cannot hold

B. to ensure that all of the necessary conditions do not hold

C. to decide if the requested resources for a process have to be given or not

D. to recover from a deadlock

To ensure that the hold and wait condition never occurs in the system, it must be ensured that
____________

A. whenever a resource is requested by a process, it is not holding any other resources

B. each process must request and be allocated all its resources before it begins its execution

C. a process can request resources only when it has none

D. all of the mentioned

A deadlock avoidance algorithm dynamically examines the __________ to ensure that a circular
wait condition can never exist.

A. resource allocation state

B. system storage state

C. operating system

D. resources

All unsafe states are ____________

A. deadlocks

B. not deadlocks

C. fatal

D. none of the mentioned

The Banker’s algorithm is _____________ than the resource allocation graph algorithm.

A. less efficient

B. more efficient
C. equal

D. none of the mentioned

The data structures available in the Banker’s algorithm are ____________

A. Available

B. Need

C. Allocation

D. All of the mentioned

An edge from process Pi to Pj in a wait for graph indicates that ____________

A. Pi is waiting for Pj to release a resource that Pi needs

B. Pj is waiting for Pi to release a resource that Pj needs

C. Pi is waiting for Pj to leave the system

D. Pj is waiting for Pi to leave the system

If the wait for graph contains a cycle ____________

A. then a deadlock does not exist

B. then a deadlock exists

C. then the system is in a safe state

D. either deadlock exists or system is in a safe state

If deadlocks occur frequently, the detection algorithm must be invoked ________

A. rarely

B. frequently

C. rarely & frequently

D. none of the mentioned


Consider a system having 'm' resources of the same type. These resources are shared by 3
processes A, B, C, which have peak time demands of 3, 4, 6 respectively. The minimum value of
'm' that ensures that deadlock will never occur is

A. 11

B. 12

C. 13

D. 14

A system has 3 processes sharing 4 resources. If each process needs a maximum of 2 units, then

A. deadlock can never occur

B. deadlock may occur

C. deadlock has to occur

D. none of the mentioned

Which requested resources are granted with deadlock detection?

A. Resources

B. Processes

C. Programs

D. Data

_________ that implies an unsafe state?

A. the existence of deadlock

B. that deadlock will eventually occur

C. the pages of deadlock

D. that some unfortunate sequence of events might lead to deadlock

What are the conditions that cause the deadlock?

A. Coffman, Elphick and Shoshani


B. Mutual exclusion, Wait for, No preemption, Circular wait.

C. Deadlock, Banker, Semaphore, loop for.

D. Cannot determined

In Page Replacement algorithm, how many advantages are there?

A.3

B.5

C.6

D.7

BÀI TẬP LẬP LỊCH CHO CPU:

Giả sử có 4 tiến trình với thời gian thực hiện như sau:

 P1: 8 đơn vị thời gian


 P2: 4 đơn vị thời gian
 P3: 9 đơn vị thời gian
 P4: 5 đơn vị thời gian

Thời gian quantum (time slice) là 3 đơn vị thời gian.

Yêu cầu:

1. Vẽ biểu đồ Gantt cho tiến trình này theo giải thuật RR


2. Tính thời gian chờ trung bình và thời gian hoàn thành trung bình cho các tiến trình.

Bài 2: Giả sử có 5 tiến trình với thời gian thực hiện như sau:

 P1: 6 đơn vị thời gian


 P2: 2 đơn vị thời gian
 P3: 8 đơn vị thời gian
 P4: 3 đơn vị thời gian
 P5: 4 đơn vị thời gian

Các tiến trình đến lần lượt theo thứ tự P1, P2, P3, P4, P5 tại thời điểm 0.

Yêu cầu:

1. Vẽ biểu đồ Gantt cho tiến trình này theo giải thuật SJF_ non Preemptive
2. Tính thời gian chờ trung bình và thời gian hoàn thành trung bình cho các tiến trình.
Bài 3:

Giả sử có 4 tiến trình với thời gian thực hiện như sau:

 P1: 7 đơn vị thời gian (đến lúc 0)


 P2: 5 đơn vị thời gian (đến lúc 1)
 P3: 1 đơn vị thời gian (đến lúc 3)
 P4: 2 đơn vị thời gian (đến lúc 5)

Yêu cầu:

1. Vẽ biểu đồ Gantt cho tiến trình này theo giải thuật SJF_ Preemptive
2. Tính thời gian chờ trung bình và thời gian hoàn thành trung bình cho các tiến trình.

Bài làm

Bài 1:

1.

P1 P2 P3 P4 P1 P2 P3 P4 P1 P3

0 3 6 9 12 15 16 19 21 23 26

2.

- Thời gian chờ trung bình: ((23-8) + (16-4) + (26 - 9) + (21 - 5))/4 = 15

- Thời gian hoàn thành trung bình: (23 +16 + 26 + 21)/4 = 21.5

Bài 2:

1.

P2 P4 P5 P1 P3

0 2 5 9 15 23
2.

- Thời gian chờ trung bình: ((15 - 6) + (2 - 2) + (23 - 8) + (5 - 3) + (9 - 4))/5 = 6.2-


Thời gian hoàn thành trung bình: (15 + 2 + 23 + 5 + 9)/5 = 10.8

Bài 3:

1.

P1 P2 P3 P2 P4 P2 P1

0 1 3 4 5 7 9 15

2.

- Thời gian chờ trung bình: ((15 - 7) + (8 - 5) + (1 - 1) + (2 - 2))/4 = 2.75

- Thời gian hoàn thành trung bình: ((15 – 0) + (9 – 1) + (4 - 3) + (7 - 5))/4 = 6.5

You might also like