Process

Five States of Process

New: The process is being created.
Running: Instructions are being executed.
Waiting: The process is waiting for some event to occur (such as an I/O completion or reception of a signal).
Ready: The process is waiting to be assigned to a processor.
Terminated: The process has finished execution.”

Process vs Thread

  1. One process has at least one thread
  2. Threads (of the same process) run in a shared memory space. A thread is an entity within a process that can be scheduled for execution. All threads of a process share its virtual address space and system resources.
  3. Processes run in separate memory spaces. Each process is started with a single thread, often called the primary thread, but can create additional threads from any of its threads.

Ways of IPC(Inter process communication)

  1. Shared Memory(Producer-Consumer Problem)
  2. Message passing(Pipe, Socket(TCP, UDP), Semaphore and Signal)

Mutex vs Semaphore

Similarity in their implementation a mutex would be referred as binary semaphore

A mutex is locking mechanism used to synchronize access to a resource.

Semaphore is signaling mechanism (“I am done, you can carry on” kind of signal).

Producer-Consumer Model

Deadlock

Deadlock is a situation when two or more processes wait for each other to finish and none of them ever finish.

Consider an example when two trains are coming toward each other on same track and there is only one track, none of the trains can move once they are in front of each other. The Similar situation occurs in operating systems when there are two or more processes hold some resources and wait for resources held by other(s)

Four conditions of Deadlock

Mutual Exclusion: One or more than one resource are non-sharable (Only one process can use at a time)

Hold and Wait: A process is holding at least one resource and waiting for resources.

No Preemption: A resource cannot be taken from a process unless the process releases the resource.

Circular Wait: A set of processes are waiting for each other in circular form.

Deadlock Avoidance

Banker’s Algorithm

Virtual Memory

Thrashing

results matching ""

    No results matching ""