Visnu Assignment 2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

STIK2044 Operating System

Assignment 2

Topic 3: Process and Processor Management


Topic 4: Process Synchronization

1. Write the correct unit names that match the definition below:

Definition Name
Unit of work submitted by the user. Program (Job)
An instance of execution of a program that is identifiable and
Process(Task)
controllable by the operating system.
A portion of a process that can run independently. Thread
(3 marks)
2. Write the correct JOB STATE for the situation given below:

Job State changes


Situation
From To
Process Scheduler initiates using predefined algorithm Ready Running

Process Scheduler initiates by instruction in job Running Waiting

Job Scheduler initiates using predefined policy Hold Ready


Process Scheduler or Job Scheduler initiates upon job
Running Finished
completion
Process Scheduler initiates according to predefined Running
Ready
time limit or other criterion back
Process Scheduler initiates by signal from I/O device
Waiting Ready
manager
(6 marks)

3. Name TWO (2) types of pointer listed Thread Control Block (TCB).
(4 marks)
1)Pointer to process that this thread
2)Pointer to all other threads crated by this thread.

4. List THREE (3) limitations of the system that operating system needs to resolve before
objects (jobs, processes, threads) can be schedule.
(3 marks)

1)Finite number of resources (disk drives,printers,tape drives)


2)Some resources cannot be shared once allocated (printers).
3)Some resources require operator intervention before reassigning .

1
5. List and explain SIX (6) good job/process scheduling policy criteria.
(6 Marks)

1)Maximize throughput
• Run as many jobs as possible in given amount of time
2)Minimize response time
• Quickly turn around interactive requests
3)Minimize turnaround time
• Move entire job in and out of system quickly
4)Minimize waiting time
• Move job out of READY queue quickly
5)Maximize CPU efficiency
• Keep CPU busy 100 percent of time
6)Ensure fairness for all jobs
• Give every job equal CPU and I/O time

6. List THREE (3) types of preemptive scheduling algorithm and THREE (3) types of non-
preemptive scheduling algorithm.
(6 marks)
Preemptive Scheduling Algorithm
1)Earliest Deadline First
2)Round Robin
3)Shortest Remaining Time

Non-Preemptive Scheduling Algorithm


1)Shortest Job Next
2)Priority Scheduling
3)First Come ,First Served (FCFS)

7.Figure 1 below shows a timeline for job sequence A-B-C using the FCFS algorithm.

Figure 1

a. If the jobs arrived in a different order, say C-A-B, what is the average turnaround
time for this new sequence (C-A-B) using the FCFS algorithm? Show your
calculation.
Job C Job A Job B
0 1 16
18
Turnaround Time=(1+16+18)/3= 11.67

(3 marks)

2
b. If the jobs arrived in a different order, say B-C-A, what is the average turnaround
time for this new sequence (B-C-A) using the FCFS algorithm? Show your
calculation.
c. Job B Job C Job A
0 2 3 18
Turnaround Time =(2+3+18)/3=7.67

(3 marks)

c. If average turnaround time for figure 1 is 11.67, what can you say about the
disadvantage of the FCFS algorithm?
The turnaround time is unpredictable and may resulted in long turnaround
time because the process will run until it finishes because it is preemptive
algorithm

(2 marks)

8. If four jobs, all in the READY queue at Time 0. The CPU cycle, or run time, is
estimated as follows:

Job A B C D
CPU Cycle 6 1 5 9

Draw a timeline for job sequence above using the SJN algorithm.
Job B Job C Job A Job D
0 1 6 12
21

(4 marks)
9. Priorities can also be determined by the Processor Manager based on characteristics
intrinsic to the jobs. List and explain THREE (3) of the characteristics.
Memory requirements
*jobs requiring large amounts of memory
*allocated lower priorities(vice versa)

Number and type of peripheral devices


*jobs requiring many peripheral devices
*allocated lower priorities(vice versa)
Total CPU time
*jobs having a long CPU cycle
*given lower priorities

(9 marks)

10. Discuss THREE (3) disadvantages of Master/Slave Multiprocessing Configuration.


1. Reliability: no higher than single processor system

3
2. Potentially poor resources usage
3. Increases number of interrupts
4. The master processor would be overloaded.
-The master processor running the operating system could fall behind the
processors running users applications.

(9 marks)

11. What is the other name for Tightly Coupled Multiprocessing Configuration?
-Symmetric multiprocessing.
(1 mark)

12. List FOUR (4) advantages of the Tightly Coupled Multiprocessing Configuration
over loosely coupled configuration.
-More reliable
-Uses resources effectively
-Balance loads well
-Degrades gracefully in failure situation

(4 marks)

13. The lack of process synchronization in an operating system results in deadlock and
starvation. List the difference between a deadlock and a starvation.

Deadlock Starvation
A deadlock is a condition in which two or Starvation happens if same transaction is
more transaction are waiting for each always choosen as victim
other.
Deadlock is also know as circular waiting
Starvation is also known as lived lock
Aquire locks at one before starting Use FIFO order among competing
request.
It is a situation where transaction are It means that transaction goes in a state
waiting for each other where transaction never progress.

(4 marks)
14. P1 and P2 are two programs competing to complete a task. Both programs require
access to files F1 and F2 simultaneously.

a. Name the type of deadlock that results from the scenario above.
-Deadlocks on file requests

(1 mark)
b. Suggest TWO (2) ways the deadlock named in 14(a) can be resolved.
-one program is closed
-one program is forcibly removed and file is released
-put on hold for duration of situation

4
(4 marks)

15. Lock-Release is a process synchronization algorithm used to resolve conflicts


between processors. This algorithm however, has TWO (2) catastrophic drawbacks.
Name and explain these drawbacks.

Busy Waiting
-Consumes processors time
Starvation
-Selection of waiting process is arbitrary
Deadlock
-The flag con only be reset by low priority process but has been pre-empted by
high priority process

(6 marks)

16. The Processor Manager is a composite of two sub-managers. List and explain this
TWO (2) sub-managers.
-Job scheduler : higher level scheduler
*job scheduling responsibilities.
*job initiation based on certain criteria

-Process scheduler :lower-level scheduler


*process scheduling responsibilities.
*determines execution steps
*process scheduling: based on certain criteria
(4 marks)

17. List all FOUR (4) conditions that are present when a deadlock occurs.
1. Mutual exclusion
2. Resource holding
3. No pre-emption
4. Circular wait

(4 marks)

18. What are the TWO (2) drawbacks of Test-and-set locking mechanisms?
Starvation
*many processes waiting to enter a critical region
*processes gain access in arbitray fashion

Busy waiting
*waiting processes remain in unproductive, resource-consuming wait loops.

(2 marks)

5
19. Write the sequence of events to demonstrate the deadlocks in spooling. The printer
needs all job output before printing begins.
1. Printer needs all output before printing begins
2. Spooling system fills disk space
3. No job has entire output in spool
4. Partially completed output for all
5. Results in deadlock

(4 marks)

20. List ALL factors to consider when selecting job that will become a victim if the
operating system need to terminate a job for deadlock recovery.

1. Select victim with least-negative affect


2. Job priority under consideration
3. CPU time used by job
4. Number of other job will be affected if job selected as victim
5. Jobs modifying data
(4 marks)

21. Give FOUR (4) examples of how concurrent programming can be applied to reduce
complexity.
 Array operations
 Matrix multiplication
 Searching databases
 Sorting and merging files
(4 marks)

You might also like