Operating System - Process Syncronization - Notes, Study notes of Operating Systems

Detailed informtion about Process Synchronization, The Critical-Section Problem, Peterson’s Solution, Synchronization Examples , Atomic Transactions, Synchronization Hardware.

Typology: Study notes

2010/2011

Uploaded on 09/01/2011

visir66
visir66 🇮🇳

4.4

(74)

97 documents

1 / 145

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PROCESS SYNCHRONIZATION
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Operating System - Process Syncronization - Notes and more Study notes Operating Systems in PDF only on Docsity!

PROCESS SYNCHRONIZATION

Process Synchronization

  • (^) Background
  • (^) The Critical-Section Problem
  • (^) Peterson’s Solution
  • (^) Synchronization Hardware
  • (^) Semaphores
  • (^) Classic Problems of Synchronization
  • (^) Monitors
  • (^) Synchronization Examples
  • (^) Atomic Transactions

Types of Process

  • (^) Cooperating Process
  • (^) Competitive Process
  • (^) Producer Consumer Problem is a type of cooperative process.

Interprocess communication

  • (^) Processes frequently need to communicate with other processes.
  • (^) For example, in a shell pipeline, the output of the first process must be passed to second process, and so on down the line.
  • (^) Thus there is a need for communication between processes, preferably in a well-structured way not using interrupts.
  • (^) This we refer as InterProcess Communication or IPC.

Interprocess communication

  • (^) In some operating systems, processes that are working together may share some common storage that each one can read and write.
  • (^) Example
    • (^) Memory Block
    • (^) Shared file
    • (^) Shared Variable

Example of IPC

A print spooler.

  • (^) When a process wants to print a file, it enters the file name in a special spooler directory.
  • (^) Another process, the printer daemon, periodically checks to see if so are any files to be printed, and if so removes their names from the directory and do the Job. Spooler Process 1 Process 2 in out

Example of IPC

  • (^) At a certain instant, slots 0 to 3 are empty (the files have already been printed) and slots 4 to 6 are full (with the names of files to be printed).

Example of IPC

  • (^) More or less simultaneously, processes A and B decide they want to queue a file for printing.

Example of IPC

  • (^) Eventually, process A runs again, starting from the place it left off last time.
  • (^) It looks at next free slot, finds a 7 there, and writes its file name in slot 7, erasing the name that process B just put there.
  • (^) Then it computes next free slot + 1, which is 8, and sets in to 8.

RACE CONDITION

  • (^) The spooler directory is now internally consistent, so the printer daemon will not notice anything wrong, but process B will never receive any output.
  • (^) Situations like this, where two or more processes are reading or writing some shared data and the final result depends on who runs precisely when, are called race conditions.

Critical Sections

  • (^) How do we avoid race conditions?
  • (^) It is important to find some way to prohibit more than one process from reading and writing the shared data at the same time.
  • (^) what we need is mutual exclusion
  • (^) The difficulty above occurred because process B started using one of the shared variables before process A was finished with it.

Critical Sections

  • (^) That part of the program where the shared memory is accessed is called the critical region or critical section.
  • (^) If we could arrange matters such that no two processes were ever in their critical regions at the same time, we could avoid race conditions.

Critical Sections

  • (^) At time T 2 process B attempts to enter its critical region but fails because another process is already in its critical region and we allow only one at a time. Mutual exclusion using critical regions.

Critical Sections

  • (^) Consequently, B is temporarily suspended until time T 3 when A leaves its critical region, allowing B to enter
  • (^) immediately Mutual exclusion using critical regions.