0% found this document useful (0 votes)
12 views7 pages

Os Assignment

Uploaded by

fategay688
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)
12 views7 pages

Os Assignment

Uploaded by

fategay688
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/ 7

1.

Inter Process Communication (IPC):

Inter process communication is used for exchanging useful information between numerous
threads in one or more processes (or programs). IPC is the way by which multiple processes or
threads communicate among each other.

There are 2 basic models for IPC:

 Shared Memory
 Message Passing

IPC in Shared Memory System:-

Shared memory system is the fundamental model of inter process communication. In a shared
memory system, in the address space region the cooperating communicate with each other by
establishing the shared memory region.

Working

The Shared Memory System, the cooperating processes communicate, to exchange the data with
each other. Because of this, the cooperating processes establish a shared region in their memory.
The processes share data by reading and writing the data in the shared segment of the processes.

Let us assume, P1 wants to share some data with P2.

So, P1 and P2 will have to perform the following steps –


Step 1 − Process P1 has some data to share with process P2. First P1 takes initiative and
establishes a shared memory region in its own address space and stores the data or information
to be shared in its shared memory region.
Step 2 − Now, P2 requires the information stored in the shared segment of P1. So, process P2
needs to attach itself to the shared address space of P1. Now, P2 can read out the data from
there.
Step 3 −The two processes can exchange information by reading and writing data in the shared
segment of the process.
IPC in Message Passing System:-

Message Passing provides a mechanism to allow processes to communicate and to synchronize


their actions without sharing the same address space.

Now let discuss the message passing step by step.


Step 1 − Message passing provides two operations which are as follows −
 Send message
 Receive message
Messages sent by a process can be either fixed or variable size.
Step 2 −For fixed size messages the system level implementation is straight forward. It makes
the task of programming more difficult.
Step 3 −The variable sized messages require a more system level implementation but the
programming task becomes simpler.
Step 4 − If process P1 and P2 want to communicate they need to send a message to and receive
a message from each other that means here a communication link exists between them.
2. Critical Section:
When more than one processes access the same code segment that segment is known as the
critical section. The critical section cannot be executed by more than one process at the same
time. Operating system faces the difficulties in allowing and disallowing the processes from
entering the critical section.

Solution to the Critical Section Problem:


The critical section problem needs a solution to synchronize the different processes. The
solution to the critical section problem must satisfy the following conditions −

 Mutual Exclusion
Mutual exclusion implies that only one process can be inside the critical section at any
time. If any other processes require the critical section, they must wait until it is free.
 Progress
Progress means that if a process is not using the critical section, then it should not stop
any other process from accessing it. In other words, any process can enter a critical
section if it is free.
 Bounded Waiting
Bounded waiting means that each process must have a limited waiting time. It should not
wait endlessly to access the critical section.

3. Mutual Exclusion:

Mutual exclusion implies that only one process can be inside the critical section at any time. If
any other processes require the critical section, they must wait until it is free.
There are four conditions applied on mutual exclusion. These are the following:

 Mutual exclusion must be guaranteed between the different processes when


accessing the shared resource. There cannot be two processes within their respective
critical sections at any time.
 No assumptions may be made about speed or the number of CPUs.
 When more than one process wants to enter its critical section, it must be granted
entry in a finite time, that is, it will never be kept waiting in a loop that has no end.
 No process that is outside its critical section should interrupt another for access to
the critical section.

4. Shortest Remaining Time First (SRTF):

Execution of any process can be stopped after a certain amount of time on arrival of every
process, the short term scheduler schedules those processes from the list of available processes
and running processes that have the least remaining burst time. The preemptive version of SJF
scheduling is known as Shortest Remaining Time First.

PROCESS ARRIVAL TIME BURST TIME

P1 0 5

P2 1 2

P3 2 5

P4 3 3

GANTT CHART:-

P1 P2 P2 P4 P1 P3

0 1 2 3 6 10 15

TURN AROUND TIME: WAITING TIME:

P1=10-0=10 P1=10-5=5
P2=3-1=2 P2=2-2=0

P3=15-2=13 P3=13-5=8

P4=6-3=3 P4=3-3=0

AVERAGE WAITING TIME=5+0+8+0/4=13/4=3.25

AVERAGE TURN AROUND TIME=10+2+13+3/4=28/4=7

5. Features of OS:

Process Management: Process management helps OS to create and delete processes. It also
provides mechanisms for synchronization and communication among processes.

Memory Management: Memory management module performs the task of allocation and de-
allocation of memory space to programs in need of this resource.

File Management: It manages all the file-related activities such as organization storage,
retrieval, naming, sharing, and protection of files.

Device Management: Device management keeps tracks of all devices. This module also
responsible for this task is known as the I/O controller. It also performs the task of allocation and
de-allocation of the devices.

I/O System Management: OS can effectively handle I/O operations to hide the peculiar
behavior of hardware from the end-user.

Security Management: Security module protects the data and information of a computer
system against malware threat and authorized access.

Process Management
Security Management Memory Management

Features of operating system

File Management
I/O System Management
Device Management

6. Semaphore:

Semaphores are integer variables that are used to solve the critical section problem by using two
atomic operations wait and signal that are used for process synchronization.

Types of Semaphore:

Counting Semaphores
These are integer value semaphores and have an unrestricted value domain. It is used to control
access to a resource that has multiple instances. If the resources are added, semaphore count
automatically incremented and if the resources are removed, the count is decremented.

Binary Semaphores
The binary semaphores are like counting semaphores but their value is restricted to 0 and 1. It is
used to implement the solution of critical section problems with multiple processes
Binary Semaphore

Advantages of Semaphores

 Semaphores allow only one process into the critical section. They follow the mutual
exclusion principle strictly and are much more efficient than some other methods of
synchronization.
 There is no resource wastage because of busy waiting in semaphores as processor time is
not wasted unnecessarily to check if a condition is fulfilled to allow a process to access
the critical section.
 Semaphores are implemented in the machine independent code of the microkernel. So
they are machine independent.

Disadvantages of Semaphores

 Semaphores are complicated so the wait and signal operations must be implemented in the
correct order to prevent deadlocks.
 Semaphores are impractical for last scale use as their use leads to loss of modularity. This
happens because the wait and signal operations prevent the creation of a structured layout
for the system.
 Semaphores may lead to a priority inversion where low priority processes may access the
critical section first and high priority processes later.

You might also like