SlideShare a Scribd company logo
2
Most read
3
Most read
11
Most read
SYNCHRONIZATION
HARDWARE
WHAT IS PROCESS SYNCRONIZATION.
• Process Synchronization is a way to coordinate processes that
use shared data
• Cooperating processes are processes that share resources.
• Executing many concurrent processes, process synchronization
helps to maintain shared data consistency and cooperating
process execution
• A race condition occurs when two or more operations are
executed at the same time, not scheduled in the proper
sequence, and not exited in the critical section correctly.
PROCESS SYNCHRONIZATION
• Several processes are run in operating system.
• Some of them share resources due to which problem like data
inconsistency arise
• For example :One process changing the data in memory
location where another process is trying to read the same
memory location. It is possible that the data read by the second
process will be erroneous
PROCESS
B
PROCES
SA
.
.
.
.
.
.
DATA
DATA
DATA
WRITES READS
IN PRODUCER CONSUMER PROBLEM:
(BOUNDED BUFFER PROBLEM)
The problem is to make sure that the producer won't try to add
data into the buffer if it's full and that the consumer won't try to
remove data from an empty buffer.
DATA
DATA
DATA
DATA
PRODUCE
R
CONSUME
R
A SECTION OF CODE,
• A Critical Section Environment contains:
• Entry Section Code requesting entry into
the critical section.
• Critical Section Code in which only one
process can execute at any one time.
• Exit Section The end of the critical section,
releasing or allowing others in.
• Remainder Section Rest of the code AFTER
the critical section.
THE CRITICAL SECTION MUST ENFORCE ALL
THREE OF THE FOLLOWING RULES:
• Mutual Exclusion: No more than one process can execute in its
critical section at one time.
• Progress: If no one is in the critical section and someone wants
in, then those processes not in their remainder section must be
able to decide in a finite time who should go in.
• Bounded Wait: All requesters must eventually be let into the
critical section.
WHY WE NEED HARDWARE BASE SOLUTON
• Software-based solutions such as Peterson’s are not
guaranteed to work on modern computer architectures . In the
following discussions, we explore several more solutions to the
critical-section problem.
SOLUTION TO CRITICAL-SECTION
PROBLEM USING LOCKS
do {
acquire lock
critical section
release lock
remainder section
} while (TRUE);
TESTANDSET INSTRUCTION
boolean TestAndSet (boolean *target)
{
boolean rv = *target;
*target = TRUE;
return rv:
}
SOLUTION USING TESTANDSET
• Shared boolean variable lock, initialized to FALSE
• Solution:
do {
while ( TestAndSet (&lock ))
; // do nothing
// critical section
lock = FALSE;
// remainder section
} while (TRUE);
BOUNDED-WAITING MUTUAL EXCLUSION
WITH TESTANDSET()
do {
waiting[i] = TRUE;
key = TRUE;
while (waiting[i] && key)
{
key = TestAndSet(&lock);
}
waiting[i] = FALSE;
// critical section
j = (i + 1) % n;
while ((j != i) && !waiting[ j ])
j = (j + 1) % n;
if (j == i)
lock = FALSE;
else
waiting[j] = FALSE;
// remainder section
} while (TRUE);
F F F F
F F F F
Waitin
g
Key
Lock F
1 2 3 4
BOUNDED-WAITING MUTUAL EXCLUSION
WITH TESTANDSET()
do {
waiting[i] = TRUE;
key = TRUE;
while (waiting[i] && key)
{
key = TestAndSet(&lock);
}
waiting[i] = FALSE;
// critical section
j = (i + 1) % n;
while ((j != i) && !waiting[ j ])
j = (j + 1) % n;
if (j == i)
lock = FALSE;
else
waiting[j] = FALSE;
// remainder section
} while (TRUE);
F /T F F F
F /T F F F
Waitin
g
Key
Lock F/T
1 2 3 4
SWAP INSTRUCTION
• Definition:
void Swap (boolean *a, boolean *b)
{
boolean temp = *a;
*a = *b;
*b = temp:
}
SOLUTION USING COMPARE AND SWAP
• Shared Boolean variable lock initialized to FALSE; Each process has a local Boolean variable key
• Solution:
do {
key = TRUE;
while ( key == TRUE)
{
Swap (&lock, &key );
}
// critical section
lock = FALSE;
// remainder section
} while (TRUE);

More Related Content

PPTX
Semaphore
PDF
Semaphores
PPT
Classical problem of synchronization
PPT
Chapter 6 - Process Synchronization
PPT
Peterson Critical Section Problem Solution
PDF
5 process synchronization
PPTX
Operating system critical section
PPT
Thrashing allocation frames.43
Semaphore
Semaphores
Classical problem of synchronization
Chapter 6 - Process Synchronization
Peterson Critical Section Problem Solution
5 process synchronization
Operating system critical section
Thrashing allocation frames.43

What's hot (20)

PPTX
Paging and Segmentation in Operating System
PPT
16. Concurrency Control in DBMS
PPTX
CPU Scheduling in OS Presentation
PPTX
Process synchronization
PPTX
Paging and segmentation
PDF
Distributed Operating System_4
PPT
Congetion Control.pptx
PPTX
Demand paging
PPTX
Concurrency control
PPTX
Memory Management in OS
PPTX
Computer architecture virtual memory
PPTX
joins in database
PPTX
Data link layer
PPTX
Heuristics Search Techniques in AI
PPT
Bus interconnection
PPTX
Transaction management DBMS
PPTX
Process synchronization in Operating Systems
PPTX
Computer network switching
PPTX
Graph in data structure
PPT
Modes Of Transfer in Input/Output Organization
Paging and Segmentation in Operating System
16. Concurrency Control in DBMS
CPU Scheduling in OS Presentation
Process synchronization
Paging and segmentation
Distributed Operating System_4
Congetion Control.pptx
Demand paging
Concurrency control
Memory Management in OS
Computer architecture virtual memory
joins in database
Data link layer
Heuristics Search Techniques in AI
Bus interconnection
Transaction management DBMS
Process synchronization in Operating Systems
Computer network switching
Graph in data structure
Modes Of Transfer in Input/Output Organization
Ad

Similar to Synchronization hardware (20)

PPTX
Synchronization in os.pptx
PPT
Process synchronization(deepa)
PDF
CH05.pdf
PPTX
Operating system 23 process synchronization
PDF
OperatingSystem-Unit2_Process Management
PDF
OS Process synchronization Unit3 synchronization
PPTX
process synchronization topic of operating system
PDF
Lecture 5- Process Synchonization_revised.pdf
PPT
Operating Systems - "Chapter 5 Process Synchronization"
PPT
PPT
Operating System
PDF
Slides for OS 06-Sync.pdf
PDF
OPERATING SYSTEM NOTESS ppt Unit 2.1.pdf
PPTX
Lecture 9 - Process Synchronization.pptx
PDF
Shared Memory
PPTX
MODULE 3 process synchronizationnnn.pptx
PPT
Process Synchronization -1.ppt
PDF
Ch5 process synchronization
PPTX
operating system notes about deadlock 3.pptx
PPTX
synchronization in operating system structure
Synchronization in os.pptx
Process synchronization(deepa)
CH05.pdf
Operating system 23 process synchronization
OperatingSystem-Unit2_Process Management
OS Process synchronization Unit3 synchronization
process synchronization topic of operating system
Lecture 5- Process Synchonization_revised.pdf
Operating Systems - "Chapter 5 Process Synchronization"
Operating System
Slides for OS 06-Sync.pdf
OPERATING SYSTEM NOTESS ppt Unit 2.1.pdf
Lecture 9 - Process Synchronization.pptx
Shared Memory
MODULE 3 process synchronizationnnn.pptx
Process Synchronization -1.ppt
Ch5 process synchronization
operating system notes about deadlock 3.pptx
synchronization in operating system structure
Ad

Recently uploaded (20)

PPTX
GSA Content Generator Crack (2025 Latest)
PPTX
Introduction to Windows Operating System
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Cost to Outsource Software Development in 2025
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PDF
Salesforce Agentforce AI Implementation.pdf
PPTX
chapter 5 systemdesign2008.pptx for cimputer science students
PDF
MCP Security Tutorial - Beginner to Advanced
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PPTX
Cybersecurity: Protecting the Digital World
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
assetexplorer- product-overview - presentation
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PPTX
Patient Appointment Booking in Odoo with online payment
GSA Content Generator Crack (2025 Latest)
Introduction to Windows Operating System
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Cost to Outsource Software Development in 2025
iTop VPN Crack Latest Version Full Key 2025
wealthsignaloriginal-com-DS-text-... (1).pdf
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
How to Use SharePoint as an ISO-Compliant Document Management System
Salesforce Agentforce AI Implementation.pdf
chapter 5 systemdesign2008.pptx for cimputer science students
MCP Security Tutorial - Beginner to Advanced
Weekly report ppt - harsh dattuprasad patel.pptx
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
Cybersecurity: Protecting the Digital World
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Oracle Fusion HCM Cloud Demo for Beginners
assetexplorer- product-overview - presentation
Autodesk AutoCAD Crack Free Download 2025
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Patient Appointment Booking in Odoo with online payment

Synchronization hardware

  • 2. WHAT IS PROCESS SYNCRONIZATION. • Process Synchronization is a way to coordinate processes that use shared data • Cooperating processes are processes that share resources. • Executing many concurrent processes, process synchronization helps to maintain shared data consistency and cooperating process execution • A race condition occurs when two or more operations are executed at the same time, not scheduled in the proper sequence, and not exited in the critical section correctly.
  • 3. PROCESS SYNCHRONIZATION • Several processes are run in operating system. • Some of them share resources due to which problem like data inconsistency arise • For example :One process changing the data in memory location where another process is trying to read the same memory location. It is possible that the data read by the second process will be erroneous PROCESS B PROCES SA . . . . . . DATA DATA DATA WRITES READS
  • 4. IN PRODUCER CONSUMER PROBLEM: (BOUNDED BUFFER PROBLEM) The problem is to make sure that the producer won't try to add data into the buffer if it's full and that the consumer won't try to remove data from an empty buffer. DATA DATA DATA DATA PRODUCE R CONSUME R
  • 5. A SECTION OF CODE, • A Critical Section Environment contains: • Entry Section Code requesting entry into the critical section. • Critical Section Code in which only one process can execute at any one time. • Exit Section The end of the critical section, releasing or allowing others in. • Remainder Section Rest of the code AFTER the critical section.
  • 6. THE CRITICAL SECTION MUST ENFORCE ALL THREE OF THE FOLLOWING RULES: • Mutual Exclusion: No more than one process can execute in its critical section at one time. • Progress: If no one is in the critical section and someone wants in, then those processes not in their remainder section must be able to decide in a finite time who should go in. • Bounded Wait: All requesters must eventually be let into the critical section.
  • 7. WHY WE NEED HARDWARE BASE SOLUTON • Software-based solutions such as Peterson’s are not guaranteed to work on modern computer architectures . In the following discussions, we explore several more solutions to the critical-section problem.
  • 8. SOLUTION TO CRITICAL-SECTION PROBLEM USING LOCKS do { acquire lock critical section release lock remainder section } while (TRUE);
  • 9. TESTANDSET INSTRUCTION boolean TestAndSet (boolean *target) { boolean rv = *target; *target = TRUE; return rv: }
  • 10. SOLUTION USING TESTANDSET • Shared boolean variable lock, initialized to FALSE • Solution: do { while ( TestAndSet (&lock )) ; // do nothing // critical section lock = FALSE; // remainder section } while (TRUE);
  • 11. BOUNDED-WAITING MUTUAL EXCLUSION WITH TESTANDSET() do { waiting[i] = TRUE; key = TRUE; while (waiting[i] && key) { key = TestAndSet(&lock); } waiting[i] = FALSE; // critical section j = (i + 1) % n; while ((j != i) && !waiting[ j ]) j = (j + 1) % n; if (j == i) lock = FALSE; else waiting[j] = FALSE; // remainder section } while (TRUE); F F F F F F F F Waitin g Key Lock F 1 2 3 4
  • 12. BOUNDED-WAITING MUTUAL EXCLUSION WITH TESTANDSET() do { waiting[i] = TRUE; key = TRUE; while (waiting[i] && key) { key = TestAndSet(&lock); } waiting[i] = FALSE; // critical section j = (i + 1) % n; while ((j != i) && !waiting[ j ]) j = (j + 1) % n; if (j == i) lock = FALSE; else waiting[j] = FALSE; // remainder section } while (TRUE); F /T F F F F /T F F F Waitin g Key Lock F/T 1 2 3 4
  • 13. SWAP INSTRUCTION • Definition: void Swap (boolean *a, boolean *b) { boolean temp = *a; *a = *b; *b = temp: }
  • 14. SOLUTION USING COMPARE AND SWAP • Shared Boolean variable lock initialized to FALSE; Each process has a local Boolean variable key • Solution: do { key = TRUE; while ( key == TRUE) { Swap (&lock, &key ); } // critical section lock = FALSE; // remainder section } while (TRUE);