Os Assignment
Os Assignment
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.
Shared Memory
Message Passing
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.
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:
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.
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
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
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
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.