0% found this document useful (0 votes)
83 views11 pages

National University of Science and Technology

This document discusses several topics related to operating systems including: 1. The two general roles of an operating system are to provide an abstraction layer and manage resources. 2. The three-state process model consists of ready, running, and blocked states. Processes transition between these states. 3. It describes scheduling algorithms like first-in first-out, shortest job first, and round robin and calculates the average waiting time for each. Round robin had the lowest average waiting time.
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)
83 views11 pages

National University of Science and Technology

This document discusses several topics related to operating systems including: 1. The two general roles of an operating system are to provide an abstraction layer and manage resources. 2. The three-state process model consists of ready, running, and blocked states. Processes transition between these states. 3. It describes scheduling algorithms like first-in first-out, shortest job first, and round robin and calculates the average waiting time for each. Round robin had the lowest average waiting time.
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/ 11

NATIONAL UNIVERSITY OF SCIENCE AND

TECHNOLOGY

FACULTY OF INDUSTRIAL TECHNOLOGY


B.ENG (HONS) TELECOMMUNICATIONS ENGINEERING

NAME : TENDAI B. CHINGWENA


STUDENT NO. : 174743T
MODULE CODE: TCL 2108
MODULE : COMPUTER ARCHITECTURE & OSs
LECTURER : MR MUSARIWA
1. The two general roles of an operating system and their importance
-The first general role of an operating system is to provide an abstraction
layer for software to run on a machine without necessarily needing to know
hardware-specific implementation details. It is important in order to reduce
the burden on application software developers, extend the basic hardware
with added functionality and provided a common base for all applications.
-The second general role of an operating system is to provide resource
management to the machine’s users, by ensuring progress, fairness and
efficient usage of computing resources.

2. The Three State Model.


-The three-state process model consists three states in which a process
can undergo which are ready, running and blocked.
1.Running: The process that is currently being executed.
2.Ready: The process that is queuing and prepared to execute when
given the opportunity.
3.Blocked: A process that cannot execute until some event occur, such
as the completion of an I/O operation.
-Process entering into the system goes into the READY state; process can
only enter into the RUNNING state via READY state. For each of the
three state processes occupy some main memory.
-A process can transition between a running and ready state if the
software’s time slice finishes and the scheduler schedule another task to
run.
-A process can transition from ready to running if the scheduler
schedules it.
-Process can also transition from running to blocked if a resource that is
required is unavailable.
3. Describe how a multi-threaded application can be supported by a user-level
threads package. It may be helpful to consider (and draw) the components of
such a package, and the function they perform. [4]

-Multi-tasking is achieved by the operating system running small slices of a


number of applications consecutively.
-If the slices are small enough processed fast enough it gives the illusion of
simultaneous execution.
-To manage this process effectively a section of the kernel manages which
tasks to run, which is called the scheduler.
-The scheduler decides which applications will receive the next time slice with
the goal of keeping the system responsive but effectively occupying the
systems resources with processes.

3. What is the producer consumer problem? Give an example of its


occurrence in operating systems. [4]
-The producer consumer problem is a classic concurrency problem. It
arises when a process is producing some data (the producer), and another
process is using that data (the consumer). The producer and the consumer
however could be operating at different rates, ie the consumer could be
using data quicker than the producer can produce it.

-An example in an operating system would be interfacing with a network


device. The network device produces data at a certain rate and places it
on a buffer, the operating system then consumes the data at another rate.

5.
Deadlock Starvation
- deadlock is a situation where a -starvation is a situation where a
number of processes cannot proceed signal process is never given a
without a resource that another resource or event that it requires to
holds, but at the same time cannot proceed, this includes CPU time.
release any resources that it is
currently holding
-Is also known as circular wait -Is also known as lived lock
-No process progresses -high priority progresses only while
low priority isn’t allowed.
-Arises due to mutual exclusion, hold -Arise due to uncontrolled
and wait, no pre-emption and management of resources.
circular wait.
-Are prevented by disallowing the Prevented using aging where the
above conditions from occurring and priority of a process increases with
allow pre-emption. increase in waiting time.

6. The four conditions required for deadlock to occur are:


i. Mutual Exclusion – the processes must be trying to access the same
resource at the same time.
ii. Hold and Wait – a process can hold the allocated resource (i.e) doesn’t
return it back while awaiting to be assigned more resources.
iii. No pre-emption – a resource is voluntarily released by a process holding
it when it has completed its task (i.e) resource can’t be forcibly taken
from it.
iv. Circular Wait – the processes exist in a circular chain, where each is
waiting for the resource held by the next member of the chain.
7. The four general strategies for dealing with deadlocks are
i. Ignorance – If deadlocks are not liable to happen, the effort required to
deal with them outweighs the problem of deadlocks actually occurring.
ii. Detection and Recovery
Grant a resource to a process but periodically check for the present of a
deadlock using a kept log file of resource ownership and request.
iii. Deadlock Avoidance – The most difficult option. We disallow deadlock
by setting “safe states”, in which process completion is always
guaranteed.
iv. Deadlock Prevention – Negate one of the four deadlock conditions. Most
infeasible, attacking hold and wait is prone to starvation, and attacking
no pre-emption is downright idiotic.
8. For the Producer-Consumer problem, solutions may be based on
semaphores and message passing.
Comparisons on the benefits of the two techniques.
Semaphores. Message passing.
-A semaphore is used to ensure that -it is easier to build massively parallel
one section of code is run before hardware.ie Message passing
another section, even when they’re programming models tend to be
in different processes. more tolerant of higher
communication latencies.
-Make use of shared memory where -Communication is done by the
communication is done automatic. programmer. The programmer is
The system is responsible for sharing responsible for transmitting data to
data between variables. and from between variables.
-semaphore systems offered -Message passing can be done across
by OSs are for synchronization of systems
processes or threads all on one
system.
-Semaphores can by implemented by -Message passing + shared memory
message queues plus shared memory can provide message passing within
and vice versa. one system.
- semaphores are often lighter- -less light
weight
partly since they can depend on
being between local
threads/processes.

9. -Correctness relies on critical regions not being modified by two or more


different processes at the same time.
-The problem can be eliminated by
i. Mutual Exclusion – One thread cannot access the critical region while
another is inside.
ii. Progress – The critical sections solution must not impede an entire
thread’s progress, halting the CPU.
iii. Boundedness – We shall not starve any process; the resource must be
freed so that each thread can access the critical region fairly.
10. In LINUX, semaphores are numbered, and a process can ask for
semaphores only in ascending order.
-This prevent deadlocks when all users of a set of locks acquire them in the same
order. The ascending numbers rule is just one way to impose an order.
-During the time of acquiring semaphores, if it blocks on one, it is guaranteed to
be waiting for someone that doesn't currently have any of the semaphores it
does. Because they both had to acquire semaphores in the same order.

11. Both WINDOWS and UNIX boost the priority of I/O-bound processes.
- This is to ensure any waiting on I/O is performed in parallel with other
processes.
-To ensure that CPU-bound processes are not starved of CPU by I/O bound
processes the priority of those tasks are gradually increased to ensure they are
given a chance to run.

12.
Process Burst time(Ms)

P1 10

P2 29

P3 3

P4 7

P5 12

FIFO
Gantt chat
P1 P2 P3 P4 P5
0 10 39 42
49 61
Average waiting time= individual waiting time for the above processes/
number of processes.
= (0+10+39+42+49+61)/5
= 40.2ms
Non-pre-emptive (Shortest Job First)
Gantt chat
P1 P3 P4 P5 P2
0 10 13 20
32 61
Average waiting time= individual waiting time for the above processes/
number of processes.
= (0+10+13+20+32+61)/5
= 27.2ms
Round Robin
P1 P2 P3 P4 P5 P2 P5 P2
0 10 20 23 30 40 50
52 61
Average waiting time= individual waiting time for the above processes/
number of processes.
= (0+(10+20+2) +20+23+40)/5
= 23ms

 The round robin scheduling algorithm gives the minimum average time
which means that it has a fast respond at the same time being fair as each
round robin cycle, every process is given a fixed time to execute. No
process is left behind which can allow the elimination of starvation.

13.
Process Allocation Claim matrix Available Need Matrix
Matrix matrix
P1 2 2 3 3 6 8 2 3 0 1 4 5
P2 2 0 3 4 3 3 2 3 0 2 3 0
P3 1 2 4 3 4 4 4 3 3 2 2 0
P1 2 2 3 3 6 8 5 5 7 1 4 5
7 7 10

i. Available matrix for resources [R1 R2 R3] = No of resource unit -Total


Allocation = [7 7 10] - [5 4 10] = [ 2 3 0]
ii.All processes have eventually run to completion. The sequence of
execution is <P2, P3, P1> which satisfies the safety criteria, therefore the
current allocation state is safe.
14 a.FIFO
1 1 1 1 1 5 5 5 5 5
2 2 2 2 2 2 2 1 1
3 3 3 3 3 3 3 2
4 4 4 4 4 4 4
Page Page Page Page Page Page Page Page Page Page
fault fault fault fault hit fault hit hit fault fault

-Therefore, there are 7-page faults and three-page hits that have occurred.
b. Second Chance (FIFO)
R R R R R R R R R R
0 1 0 1 0 1 0 1 1 1 0 1 0 2 1 2 0 2 1 2
0 2 0 2 0 2 0 2 0 5 0 5 0 5 0 5 0 5
0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3
0 4 0 4 0 4 0 4 0 4 0 1 0 1
Page Page Page Page Page Page Page Page Page Pag
fault fault fault fault hit fault fault hit fault hit

- Therefore, there are 7-page faults and three-page hits that have occurred
c. Least Recently Used
1 1 1 1 1 1 1 1 1 1
2 2 2 2 5 5 5 5 5
3 3 3 3 2 2 2 2
4 4 4 4 3 3 3
Page Page Page Page Page Page Page Page Page Page
fault fault fault fault hit fault fault fault hit hit

Therefore, there are 7-page faults and three-page hits that have occurred.
15 a. FIFO
200

180

160

140

120

100

80

60

40

20

0
Category Category Category Category
1 2 3 4

Series 1

Total overhead movement=30-27+129-27+129-110+186-110+186-147+147-


41+41-10+64-10+120-64
=486cylinders.
b. SSTF
200

180

160

140

120

100

80

60

40

20

0
Category Category Category Category
1 2 3 4

Series 1

Total overhead movement= (186-10) + (186-27) + 3


=338cylinders.
c. SCAN
200

180

160

140

120

100

80

60

40

20

0
Category Category Category Category
1 2 3 4

Series 1

Total overhead movement=30+186


=216cylinders.

d. C-SCAN
250

200

150

100

50

0
CategoryCategory
1 Category
2 Category
3 4

Series 1 Column3 Column2 Column1

Total overhead movement= 30+199+ (199-30)


=398cylinders.
e. LOOK

Series 1

200

180

160

140

120

100

80

60

40

20

0
Category Category Category Category
1 2 3 4

Total overhead movement= (30-10) + (186-10)


= 196 cylinders.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy