16
Kingdom of Saudi Arabia Ministry of Higher Education Salman Bin Abdul-Aziz University College of Computer Engineering and sciences ة ودي سع ل ا ة ي ب ر لع ا كة ل م م ل ا ي ل عا ل م ا ي عل ت ل ا ارة# ور# ز ي# ر لع د ا) ب ع, ن) ب, مان سل عة ام) ج) ب س حا ل وم ا ل ع و دسة# ب ه ة ي كلCourse Title: CS3700-Operating System CS3700 On class Quiz 2 Answer key ) ب? للطا م ا سا: Instructor Name: Dr. Mohamed Osman ي? مع ا) ح ل م ا ق ر لا: Date: 26-10-2014, Time: 10 minutes ة) ي عJ س لا: Using round robin RR algorithm with quantum 2 calculate: 1- the turnaround time for each process 2- the waiting time for each process 3- the average waiting time Process arri Burst Time Arrive time P 1 5 0 P 2 12 4 P 3 3 8

Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية

Kingdom of Saudi ArabiaMinistry of Higher Education

Salman Bin Abdul-Aziz UniversityCollege of Computer

Engineering and sciences

المملكة العربية السعوديةوزارة التعليم العالي

جامعة سلمان بن عبد العزيزكلية هندسة وعلوم الحاسب

Course Title: CS3700-Operating System CS3700On class Quiz

2Answer key

الطالب :اسمInstructor Name: Dr. Mohamed Osman الجامعي :الرقمDate: 26-10-2014, Time: 10 minutes :الشعبة

Using round robin RR algorithm with quantum 2 calculate:1- the turnaround time for each process2- the waiting time for each process3- the average waiting time

Process   arri   Burst Time Arrive time   P1  5 0    P2   12 4   P3  3 8 

Page 2: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية

R1

R4

R3

R5

R2

R6

P1

P2

P3

Kingdom of Saudi ArabiaMinistry of Higher Education

Salman Bin Abdul-Aziz UniversityCollege of Computer

Engineering and sciences

المملكة العربية السعوديةوزارة التعليم العالي

جامعة سلمان بن عبد العزيزكلية هندسة وعلوم الحاسب

Course Title: CS3700-Operating System CS3700On class Quiz

3

الطالب :اسمInstructor Name: Dr. Mohamed Osman الجامعي :الرقمDate: 09-11-2014, Time: 10 minutes :الشعبة

Having the following sets:

P: P1, P2, P3

R: R1, R2, R3, R4, R5, R6, E: P 1→ R1 , P 1→ R5 , P 2→ R 2 ,P 2→ R 3 , P 3→ R 4 , P3 → R 6

R 1→ P 2, R 2→ P 3 , R 4→ P 2 ,R 3 → P 1 ,R 5→ P 3 , R 6→ P 1

a) Draw the resource allocation graph of the previous system?

b) Examine if the system deadlocked or not and list all the cycles?

The system is deadlocked because:1- all the processes are holding and waiting no process can run 2- There is cycles and all resources are one instant

The cycles are:

P1,P2, P3 ----- P1, P2 --- P1, P3 ---- P2, P3 ----- P2, P1------P3,P1,P2

Page 3: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية

Kingdom of Saudi ArabiaMinistry of Higher Education

Salman Bin Abdul-Aziz UniversityCollege of Computer

Engineering and sciences

المملكة العربية السعوديةوزارة التعليم العالي

جامعة سلمان بن عبد العزيزكلية هندسة وعلوم الحاسب

Course Title: CS3700-Operating System CS3700On class Quiz

4Answer Key

الطالب :اسمInstructor Name: Dr. Mohamed Osman الجامعي :الرقمDate: 18-11-2014, Time: 10 minutes :الشعبة

(1)Having the following graph answer the below questions:

(a)    What are the processes in the graph?

P0, P1, P2, P3,P4

(b)   What are the resource types in the graph and how many instances of each resource type are there?

R5,R7 : 2 instants, R6: 1 instant, R8: 3 instant

(c)    Which resource type is being requested by processes P0, P1,P2, P3 and P4?

P0 requested R5, P1 requested R6 , P2 requested R7, P4 requested R8

(e)    Which processes are waiting? Which processes are running?

P0, P1, and P2 are waiting; P4, and P3 are running.

(f)    Are there any cycles in the graph? If yes, write them down.

Yes

The cycle P0,P4,P0 ----P0,P1,P2,P4,P0

(g)   Is there a deadlock? If no, give the order in which processes will run and exit.No : P3, P2, P1,P0 ------ P4, P2, P1,P0(e) Is the system in safe state? (explain)System is in safe state because there exists a sequence <P3, P2, p1, Po> and <P4, P2, p1, Po> which is mean the requested resource from each processes can be satisfied by currently available resources or can be satisfied by resources held by other process. (the requested can be applied immediately for P4 , and after waiting for P2,P1,P0)

Page 4: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية

(2)Conceder the following snapshot at time T0 Allocation Max Available NeedA B C A B C A B C

P 0 0 1 2 3 4 9 2 2 3 337 .

P 1 1 3 0 3 3 3 203 .

P 2 4 1 2 5 2 2 110 .

P 3 2 0 1 2 2 4 023 .

P4 0 0 2 4 5 6 454 .

 Answer the following questions using the banker's algorithm:

a) What is the content of the matrix Need?

b) Is the system in a safe state? If yes write a sequence.

Yes P2,P1,P3,P4,P0 or P2, P3,P1,P4,P0

c) If a request from Process P0 arrives for (0, 2,3) can the request be granted immediately? Please explain your answer in detail.

Yes it can be granted immediately because the request is less than the available

But this will leads to unsafe state and deadlocked because the available after satisfied the request will became less than any needed (2, 0, 0) i.e. any additional requested cannot be satisfied.

Page 5: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية

First-fit algorithm

Memory

Best-fit algorithm

Memory

Worst-fit algorithm

Memory

Kingdom of Saudi ArabiaMinistry of Higher Education

Salman Bin Abdul-Aziz UniversityCollege of Computer

Engineering and sciences

المملكة العربية السعوديةوزارة التعليم العالي

جامعة سلمان بن عبد العزيزكلية هندسة وعلوم الحاسب

Course Title: CS3700-Operating System CS3700On class Quiz

5Answer

الطالب :اسمInstructor Name: Dr. Mohamed Osman الجامعي :الرقمDate: 25-11-2014, Time: 10 minutes :الشعبة

Fill the following memory scheme for each of the three contiguous memory allocation algorithms. Place the following processes (in order) (P1: (12 KB), P2: (24 KB), P3: (15 KB), P4: (32 KB)).

What the total size of internal and external fragmentation of each one of the above allocation algorithm after allocated the above processes? (Put your answer in the following table)

First-fitBest-fitWorst-fit

The total size of internal fragmentation341738

The total size of external fragmentation20015

Total fragmentation541753

Page 6: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية

Scheduling algorithmRound Robin(RR) & Priority

Page 7: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية
Page 8: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية
Page 9: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية
Page 10: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية

Dead lock avoidanceAvoidance algorithms

Page 11: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية
Page 12: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية
Page 13: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية

Contiguous memory allocation algorithmsTutorial1

Page 14: Course Title: CS3700-Operating System - psau.edu.sa€¦ · Web viewBin Abdul-Aziz University College of Computer Engineering and sciences المملكة العربية السعودية

Tutorial 2