0% found this document useful (0 votes)
40 views

Assignment 2

This document contains a student's assignment submission which includes responses to 3 questions about operating systems concepts. It provides the student's name, registration number, class, and instructor. The first question discusses the role of the process control block (PCB) during context switching. The second question compares shortest job first preemptive and round robin scheduling algorithms and calculates waiting and turnaround times. The third question explains how readers-writer problems can be solved using mutex locks and semaphores.

Uploaded by

Daniyal Hassan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Assignment 2

This document contains a student's assignment submission which includes responses to 3 questions about operating systems concepts. It provides the student's name, registration number, class, and instructor. The first question discusses the role of the process control block (PCB) during context switching. The second question compares shortest job first preemptive and round robin scheduling algorithms and calculates waiting and turnaround times. The third question explains how readers-writer problems can be solved using mutex locks and semaphores.

Uploaded by

Daniyal Hassan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Operating System

ASSIGNMENT#2

Name Maouz Anwer

Registration No SP20-BSE-046

Class Section A

Instructor`s name Mrs. Memoona Malik


Q1: What is the role of PCB during context switching?

Answer: A process control block (PCB) is a data structure used by computer operating systems to
store all the information about a process. It is also known as a process descriptor. When a process is
created (initialized or installed), the operating system creates a corresponding process control block.

During context switch, the running process is stopped and another process runs. The kernel must
stop the execution of the running process, copy out the values in hardware registers to its PCB, and
update the hardware registers with the values from the PCB of the new process.

Q2: Compare SJF preemptive and Round robin with time quantum 3 for scheduling

processes that are provided below and analyze which algorithm executes maximum number

of processes in 15 cycles. Also calculate the waiting and turnaround times for each process.

Compute the average waiting and turnaround time for both scheduling algorithms.

Process Burst time arrival time

P1 9 0

P2 7 2

P3 4 3

P4 5 5

P5 3 6

Q3: How Readers-writer problem can be solved using mutex locks and semaphores?

Answer: Read-write problem using Mutex Locks:

As the hardware solution is not easy to implement for everyone, a strict software approach called
Mutex Locks was introduced. In this approach, in the entry section of code, a LOCK is acquired over
the critical resources modified and used inside critical section, and in the exit section that LOCK is
released.
As the resource is locked while a process executes its critical section hence no other process can
access it.

Read-write problem using Semaphores

It is a significant technique for managing concurrent processes by using the value of a simple integer
variable to synchronize the progress of interacting processes.So it is basically a synchronizing
tool and is accessed only through two low standard atomic operations, wait and signal designated
by P(S) and V(S) respectively.

In very simple words, semaphore is a variable which can hold only a non-negative Integer value,
shared between all the threads, with operations wait and signal.

i. Wait: Decrements the value of its argument S, as soon as it would become non-negative(greater
than or equal to 1).

ii. Signal: Increments the value of its argument S, as there is no more process blocked on the queue.

You might also like