SlideShare une entreprise Scribd logo
1  sur  17
INTERPROCESS
          COMMUNICATION




(M.SC Computer Science)




13/05/12             GROUP - F   1
OUTLINE

     WHAT IS IPC
     ABOUT RACE CONDITION
     CRITICAL REGIONS
     MANAGE RACE CONDITION
     DINING PHILOSOPHER PROBLEM
     MESSAGE PASSING




05/13/12                GROUP I    2
What is IPC ?

     Processes frequently need to communicate with other
      processes.

     Generally shared memory is used to establish the
      connection among processes.

     This memory must be shared carefully to avoid
      inconsistency.



13/05/12                     GROUP - F                      3
IPC: Race Condition

                       Spooler directory
                              .
                                                           . Race condition :-
                                                  out= 4
                          4       abc                      The situation where two
                                                           or more processes are
           Process A      5       prog.c                   reading or writing some
                                                   in =6   shared data is called race
                          6                                condition.

           Process B
                                     .
                                     .
                                     .

            Two processes want to access shared memory at same time
13/05/12                                   GROUP - F                                4
IPC: Critical Regions
Critical Region/ Critical Section
     The part of the program where the shared memory is
     accessed is called the critical region.
           conditions to provide mutual exclusion
             No two processes will be in critical region
              simultaneously.
             No process running outside its critical region
              may block another process.
             No process must wait forever to enter its
              critical region.

13/05/12                       GROUP - F                       5
How to Manage Race Condition ?

      Mutual Exclusion with Busy Waiting
           Strict Alternation
      Mutual Exclusion without Busy Waiting
           Sleep and wakeup
           Semaphore
           Message Passing



13/05/12                         GROUP - F     6
STRICT ALTERNATION
while(TRUE)                         while(TRUE)
{                                   {
  while(turn!=0) /* loop /;                while(turn!=1) /* loop */
   critical_region();                    critical_region();
   turn=1;                            turn=0;
   noncritical_region();              noncritical_region();
  }                                 }




           Process A                           Process B
            DRAWBACK: wastage of CPU time by Busy waiting

13/05/12                       GROUP - F                               7
Sleep and Wakeup: Producer Consumer Problem
Function performed by Producer :
Repeat forever-------->
. item=produce item()
. while(count=max)      sleep()
. insert_item(item)
. count=count+1
. if count=1) then wakeup consumer)
Function produced by Consumer :
repeat forever--------------->
. while(count=0) sleep();
. item=remove item()
. Count-count-1
. if count=max-1) then wakeup producer)
. consume(item)
DRAWBACK : Both may sleep forever.
                                           SOLUTION: USE OF WAKEUP WAITING BIT
 13/05/12                                 GROUP - F                          8
Semaphores: Producer Consumer Problem

Semaphore
     An integer to keep count of wakeups saved for future use

Down (semaphore)
• If value > 0, Decrement it and continue (one stored wakeup is
used)
• If value = 0, Process is put to sleep without completing Down

Up (semaphore)
     if one or more processes were sleeping on that semaphore (unable
to
     complete down operation), one of them is chosen by the system at

     random and allowed to complete its Down

13/05/12                           GROUP - F                            9
Semaphores: Producer Consumer Problem
Function performed by producer:
Repeat forever------>
     Generate something to put in buffer
     Perform DOWN operation on empty count;
     Enter critical region
     Put new item in buffer
     Leave critical region
     Perform UP on full counts
Function performed by consumer :
repeat forever------->
      Perform DOWN operation on full.
      Enter critical section.
      Take item from buffer
      Leave critical region
      Perform UP operation on empty counts
                                          CONCLUSION: NO BUSY WAITING
13/05/12                             GROUP - F                          10
Readers and writers problem


           This model deals with the access to database.


    Constraints:
Allows multiple processes to read database simultaneously.

Doesn't allow any other process to access database when a
   process writes into the database .




05/13/12                          GROUP I                    11
Application of semaphore in readers and writers
problem


    Function performed by reader :

    Enter into critical section and increase reader_counter, and check if
    it becomes 1 if it is perform down operation on a semaphore db.

    Exit the critical section .

    Read database

    Enter into critical section and decrease reader_counter by 1 .

    if it becomes 0 perform UP operation on semaphore db. Exit the
    critical section.

    Functions performed by writer

    Perform DOWN on semaphore db .

    Write into database.

    Perform UP operation on db.

    Exit .

05/13/12                           GROUP I                              12
Dining Philosophers problem in IPC
A problem used for modeling processes competing for access to limited
    number of resources .
General incident:
For each philosopher
-> take_fork(left)
-> take_fork(right)
->eat()
-> put_fork(left)
-> put_fork(right)
Problem : Occurrence of DEADLOCK
Solution : Application of SEMAPHORE



13/05/12                          GROUP - F                             13
Application of Semaphore in Dining Philosophers
problem

        For each philosopher(i)
->take_fork(i)
   ...enter critical region
   ...set semaphore state[i]=hungry
   ...test whether left or right neighbour is in eating state ,
        If not then state[i]=eating , perform UP on semaphore ph(i)
   ...exit critical region
   ... perform DOWN operation on semaphore ph(i)

->eat()
->put_fork(i)
   ....enter critical region
   .... state[i]=thinking
                           RESULT IS NO DEADLOCK , NO STARVATION
13/05/12                                 GROUP - F                    14
Message Passing
 buffer size=N
 Function performed by producer
 while(TRUE)
 item=produce item()                          NO SHARED MEMORY IS USED

 receive(consumer,&m)
 build_message(&m,item)
 send(consumer,&m)
 End
 Function performed by consumer
 send N empty slots
 while (TRUE)
 receive_message(producer,&m)
 item=extract_item(&m)
 send(producer,&m)
 consume(item)
 end

13/05/12                          GROUP - F                              15
REFERENCES

   OPERATING SYSTEM (Andrew S. Tanenbaum)

  DISTRIBUTED OPERATING SYSTEM
( P.K.SINHA)




05/13/12              GROUP I                16
05/13/12   GROUP I   17

Contenu connexe

Similaire à Ipc

5 process synchronization
5 process synchronization5 process synchronization
5 process synchronizationBaliThorat1
 
Improving the ZFS Userland-Kernel API with Channel Programs - BSDCAN 2017 - M...
Improving the ZFS Userland-Kernel API with Channel Programs - BSDCAN 2017 - M...Improving the ZFS Userland-Kernel API with Channel Programs - BSDCAN 2017 - M...
Improving the ZFS Userland-Kernel API with Channel Programs - BSDCAN 2017 - M...Matthew Ahrens
 
Rails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & ToolsRails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & Toolsguest05c09d
 
Microsoft kafka load imbalance
Microsoft   kafka load imbalanceMicrosoft   kafka load imbalance
Microsoft kafka load imbalanceNitin Kumar
 
XML Parsing with Map Reduce
XML Parsing with Map ReduceXML Parsing with Map Reduce
XML Parsing with Map ReduceEdureka!
 
Rein_in_the_ability_of_log4j
Rein_in_the_ability_of_log4jRein_in_the_ability_of_log4j
Rein_in_the_ability_of_log4jRazorsight
 
Operating Systems: Revision
Operating Systems: RevisionOperating Systems: Revision
Operating Systems: RevisionDamian T. Gordon
 
Java Hates Linux. Deal With It.
Java Hates Linux.  Deal With It.Java Hates Linux.  Deal With It.
Java Hates Linux. Deal With It.Greg Banks
 
360|Flex Greenthreading In Flex
360|Flex Greenthreading In Flex360|Flex Greenthreading In Flex
360|Flex Greenthreading In FlexHuyen Tue Dao
 
Oracle Release 12 E-Business Suite Patching Best Practices
Oracle Release 12 E-Business Suite Patching Best PracticesOracle Release 12 E-Business Suite Patching Best Practices
Oracle Release 12 E-Business Suite Patching Best PracticesScott Jenner
 
Set model and page fault.44
Set model and page fault.44Set model and page fault.44
Set model and page fault.44myrajendra
 
Introduction to Hadoop part 2
Introduction to Hadoop part 2Introduction to Hadoop part 2
Introduction to Hadoop part 2Giovanna Roda
 
The Pensions Trust - VM Backup Experiences
The Pensions Trust - VM Backup ExperiencesThe Pensions Trust - VM Backup Experiences
The Pensions Trust - VM Backup Experiencesglbsolutions
 
Cloudera Impala Internals
Cloudera Impala InternalsCloudera Impala Internals
Cloudera Impala InternalsDavid Groozman
 
Apache Flink Worst Practices
Apache Flink Worst PracticesApache Flink Worst Practices
Apache Flink Worst PracticesKonstantin Knauf
 
2007-05-23 Cecchet_PGCon2007.ppt
2007-05-23 Cecchet_PGCon2007.ppt2007-05-23 Cecchet_PGCon2007.ppt
2007-05-23 Cecchet_PGCon2007.pptnadirpervez2
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internalsKostas Tzoumas
 

Similaire à Ipc (20)

5 process synchronization
5 process synchronization5 process synchronization
5 process synchronization
 
Improving the ZFS Userland-Kernel API with Channel Programs - BSDCAN 2017 - M...
Improving the ZFS Userland-Kernel API with Channel Programs - BSDCAN 2017 - M...Improving the ZFS Userland-Kernel API with Channel Programs - BSDCAN 2017 - M...
Improving the ZFS Userland-Kernel API with Channel Programs - BSDCAN 2017 - M...
 
Rails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & ToolsRails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & Tools
 
Microsoft kafka load imbalance
Microsoft   kafka load imbalanceMicrosoft   kafka load imbalance
Microsoft kafka load imbalance
 
XML Parsing with Map Reduce
XML Parsing with Map ReduceXML Parsing with Map Reduce
XML Parsing with Map Reduce
 
Rein_in_the_ability_of_log4j
Rein_in_the_ability_of_log4jRein_in_the_ability_of_log4j
Rein_in_the_ability_of_log4j
 
Operating Systems: Revision
Operating Systems: RevisionOperating Systems: Revision
Operating Systems: Revision
 
Java Hates Linux. Deal With It.
Java Hates Linux.  Deal With It.Java Hates Linux.  Deal With It.
Java Hates Linux. Deal With It.
 
360|Flex Greenthreading In Flex
360|Flex Greenthreading In Flex360|Flex Greenthreading In Flex
360|Flex Greenthreading In Flex
 
Oracle Release 12 E-Business Suite Patching Best Practices
Oracle Release 12 E-Business Suite Patching Best PracticesOracle Release 12 E-Business Suite Patching Best Practices
Oracle Release 12 E-Business Suite Patching Best Practices
 
CLIPS Basic Student Guide
CLIPS Basic Student GuideCLIPS Basic Student Guide
CLIPS Basic Student Guide
 
Set model and page fault.44
Set model and page fault.44Set model and page fault.44
Set model and page fault.44
 
Introduction to Hadoop part 2
Introduction to Hadoop part 2Introduction to Hadoop part 2
Introduction to Hadoop part 2
 
Ipc feb4
Ipc feb4Ipc feb4
Ipc feb4
 
The Pensions Trust - VM Backup Experiences
The Pensions Trust - VM Backup ExperiencesThe Pensions Trust - VM Backup Experiences
The Pensions Trust - VM Backup Experiences
 
Being agile with modern Java
Being agile with modern JavaBeing agile with modern Java
Being agile with modern Java
 
Cloudera Impala Internals
Cloudera Impala InternalsCloudera Impala Internals
Cloudera Impala Internals
 
Apache Flink Worst Practices
Apache Flink Worst PracticesApache Flink Worst Practices
Apache Flink Worst Practices
 
2007-05-23 Cecchet_PGCon2007.ppt
2007-05-23 Cecchet_PGCon2007.ppt2007-05-23 Cecchet_PGCon2007.ppt
2007-05-23 Cecchet_PGCon2007.ppt
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internals
 

Dernier

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 

Dernier (20)

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 

Ipc

  • 1. INTERPROCESS COMMUNICATION (M.SC Computer Science) 13/05/12 GROUP - F 1
  • 2. OUTLINE  WHAT IS IPC  ABOUT RACE CONDITION  CRITICAL REGIONS  MANAGE RACE CONDITION  DINING PHILOSOPHER PROBLEM  MESSAGE PASSING 05/13/12 GROUP I 2
  • 3. What is IPC ?  Processes frequently need to communicate with other processes.  Generally shared memory is used to establish the connection among processes.  This memory must be shared carefully to avoid inconsistency. 13/05/12 GROUP - F 3
  • 4. IPC: Race Condition Spooler directory . . Race condition :- out= 4 4 abc The situation where two or more processes are Process A 5 prog.c reading or writing some in =6 shared data is called race 6 condition. Process B . . . Two processes want to access shared memory at same time 13/05/12 GROUP - F 4
  • 5. IPC: Critical Regions Critical Region/ Critical Section The part of the program where the shared memory is accessed is called the critical region. conditions to provide mutual exclusion  No two processes will be in critical region simultaneously.  No process running outside its critical region may block another process.  No process must wait forever to enter its critical region. 13/05/12 GROUP - F 5
  • 6. How to Manage Race Condition ?  Mutual Exclusion with Busy Waiting  Strict Alternation  Mutual Exclusion without Busy Waiting  Sleep and wakeup  Semaphore  Message Passing 13/05/12 GROUP - F 6
  • 7. STRICT ALTERNATION while(TRUE) while(TRUE) { { while(turn!=0) /* loop /; while(turn!=1) /* loop */ critical_region(); critical_region(); turn=1; turn=0; noncritical_region(); noncritical_region(); } } Process A Process B DRAWBACK: wastage of CPU time by Busy waiting 13/05/12 GROUP - F 7
  • 8. Sleep and Wakeup: Producer Consumer Problem Function performed by Producer : Repeat forever--------> . item=produce item() . while(count=max) sleep() . insert_item(item) . count=count+1 . if count=1) then wakeup consumer) Function produced by Consumer : repeat forever---------------> . while(count=0) sleep(); . item=remove item() . Count-count-1 . if count=max-1) then wakeup producer) . consume(item) DRAWBACK : Both may sleep forever. SOLUTION: USE OF WAKEUP WAITING BIT 13/05/12 GROUP - F 8
  • 9. Semaphores: Producer Consumer Problem Semaphore An integer to keep count of wakeups saved for future use Down (semaphore) • If value > 0, Decrement it and continue (one stored wakeup is used) • If value = 0, Process is put to sleep without completing Down Up (semaphore) if one or more processes were sleeping on that semaphore (unable to complete down operation), one of them is chosen by the system at random and allowed to complete its Down 13/05/12 GROUP - F 9
  • 10. Semaphores: Producer Consumer Problem Function performed by producer: Repeat forever------>  Generate something to put in buffer  Perform DOWN operation on empty count;  Enter critical region  Put new item in buffer  Leave critical region  Perform UP on full counts Function performed by consumer : repeat forever------->  Perform DOWN operation on full.  Enter critical section.  Take item from buffer  Leave critical region  Perform UP operation on empty counts CONCLUSION: NO BUSY WAITING 13/05/12 GROUP - F 10
  • 11. Readers and writers problem  This model deals with the access to database.  Constraints: Allows multiple processes to read database simultaneously. Doesn't allow any other process to access database when a process writes into the database . 05/13/12 GROUP I 11
  • 12. Application of semaphore in readers and writers problem  Function performed by reader :  Enter into critical section and increase reader_counter, and check if it becomes 1 if it is perform down operation on a semaphore db.  Exit the critical section .  Read database  Enter into critical section and decrease reader_counter by 1 .  if it becomes 0 perform UP operation on semaphore db. Exit the critical section.  Functions performed by writer  Perform DOWN on semaphore db .  Write into database.  Perform UP operation on db.  Exit . 05/13/12 GROUP I 12
  • 13. Dining Philosophers problem in IPC A problem used for modeling processes competing for access to limited number of resources . General incident: For each philosopher -> take_fork(left) -> take_fork(right) ->eat() -> put_fork(left) -> put_fork(right) Problem : Occurrence of DEADLOCK Solution : Application of SEMAPHORE 13/05/12 GROUP - F 13
  • 14. Application of Semaphore in Dining Philosophers problem  For each philosopher(i) ->take_fork(i) ...enter critical region ...set semaphore state[i]=hungry ...test whether left or right neighbour is in eating state , If not then state[i]=eating , perform UP on semaphore ph(i) ...exit critical region ... perform DOWN operation on semaphore ph(i) ->eat() ->put_fork(i) ....enter critical region .... state[i]=thinking RESULT IS NO DEADLOCK , NO STARVATION 13/05/12 GROUP - F 14
  • 15. Message Passing buffer size=N Function performed by producer while(TRUE) item=produce item() NO SHARED MEMORY IS USED receive(consumer,&m) build_message(&m,item) send(consumer,&m) End Function performed by consumer send N empty slots while (TRUE) receive_message(producer,&m) item=extract_item(&m) send(producer,&m) consume(item) end 13/05/12 GROUP - F 15
  • 16. REFERENCES  OPERATING SYSTEM (Andrew S. Tanenbaum)  DISTRIBUTED OPERATING SYSTEM ( P.K.SINHA) 05/13/12 GROUP I 16
  • 17. 05/13/12 GROUP I 17