SlideShare a Scribd company logo
Lecture 4
           Interprocess and Scheduling

                 4.1. Interprocess communication
                 4.2. Classical IPC problems
                 4.3. Scheduling




Sistem Operasi          http://fasilkom.narotama.ac.id/
                                                          1
Interprocess Communication
                   Race Conditions




Two processes want to access shared memory at same time
  Sistem Operasi    http://fasilkom.narotama.ac.id/
                                                          2
Critical Regions (1)

Four conditions to provide mutual exclusion
1.   No two processes simultaneously in critical region
2.   No assumptions made about speeds or numbers of CPUs
3.   No process running outside its critical region may block
     another process
4.   No process must wait forever to enter its critical region



     Sistem Operasi       http://fasilkom.narotama.ac.id/
                                                                 3
Critical Regions (2)




        Mutual exclusion using critical regions
Sistem Operasi       http://fasilkom.narotama.ac.id/
                                                       4
Mutual Exclusion with Busy Waiting (1)




  Proposed solution to critical region problem
     (a) Process 0.
Sistem Operasi
                           (b) Process 1.
                      http://fasilkom.narotama.ac.id/
                                                        5
Mutual Exclusion with Busy Waiting (2)




  Sistem Operasi   http://fasilkom.narotama.ac.id/
Peterson's solution for achieving mutual exclusion   6
Mutual Exclusion with Busy Waiting (3)




Entering and leaving a critical region using the
Sistem Operasi TSL instruction
                http://fasilkom.narotama.ac.id/
                                                   7
Sleep and Wakeup




Producer-consumer http://fasilkom.narotama.ac.id/ fatal race condition8
   Sistem Operasi
                  problem with
Semaphores




TheSistem Operasi http://fasilkom.narotama.ac.id/
    producer-consumer problem using semaphores      9
Mutexes




Implementation of mutex_lock and mutex_unlock
 Sistem Operasi   http://fasilkom.narotama.ac.id/
                                                    10
Monitors (1)




Sistem Operasi   Example of a monitor
                    http://fasilkom.narotama.ac.id/
                                                      11
Monitors (2)




• Outline of producer-consumer problem with monitors
  – only one monitor procedure active at one time
  Sistem Operasi           http://fasilkom.narotama.ac.id/
  – buffer has N slots                                       12
Monitors (3)




Solution to producer-consumer problem in Java (part 1)
 Sistem Operasi    http://fasilkom.narotama.ac.id/
                                                         13
Monitors (4)




Solution to producer-consumer problem in Java (part 2)
Sistem Operasi    http://fasilkom.narotama.ac.id/
                                                         14
Message Passing




The producer-consumer problem with N messages
 Sistem Operasi  http://fasilkom.narotama.ac.id/
                                                   15
Barriers




• Use of a barrier
      – processes approaching a barrier
      – all processes but one blocked at barrier
Sistem Operasi         http://fasilkom.narotama.ac.id/
      – last process arrives, all are let through        16
Dining Philosophers (1)


•   Philosophers eat/think
•   Eating needs 2 forks
•   Pick one fork at a time
•   How to prevent deadlock




    Sistem Operasi         http://fasilkom.narotama.ac.id/
                                                             17
Dining Philosophers (2)




A nonsolution to the dining philosophers problem
 Sistem Operasi         http://fasilkom.narotama.ac.id/
                                                          18
Dining Philosophers (3)




Sistem Operasi         http://fasilkom.narotama.ac.id/
Solution to dining philosophers problem (part 1)         19
Dining Philosophers (4)




Sistem Operasi      http://fasilkom.narotama.ac.id/
Solution to dining philosophers problem (part 2)      20
The Readers and Writers Problem




 A solution to the readers and writers problem
Sistem Operasi   http://fasilkom.narotama.ac.id/
                                                   21
The Sleeping Barber Problem (1)




Sistem Operasi   http://fasilkom.narotama.ac.id/
                                                   22
The Sleeping Barber Problem (2)




Sistem Operasi    http://fasilkom.narotama.ac.id/
                 Solution to sleeping barber problem.   23
Scheduling
                   Introduction to Scheduling (1)




• Bursts of CPU usage alternate with periods of I/O wait
   – a CPU-bound process
   – an I/O bound process
  Sistem Operasi           http://fasilkom.narotama.ac.id/
                                                             24
Introduction to Scheduling (2)




Sistem Operasi   Scheduling Algorithm Goals
                        http://fasilkom.narotama.ac.id/
                                                          25
Scheduling in Batch Systems (1)




   An example of shortest job first scheduling
Sistem Operasi   http://fasilkom.narotama.ac.id/
                                                   26
Scheduling in Batch Systems (2)




Sistem Operasi   Three level scheduling
                     http://fasilkom.narotama.ac.id/
                                                       27
Scheduling in Interactive Systems (1)




• Round Robin Scheduling
  – list of runnable processes
  – list of runnable processes after B uses up its quantum
  Sistem Operasi      http://fasilkom.narotama.ac.id/
                                                             28
Scheduling in Interactive Systems (2)




A scheduling algorithm with four priority classes
 Sistem Operasi   http://fasilkom.narotama.ac.id/
                                                    29
Scheduling in Real-Time Systems


Schedulable real-time system
• Given
     – m periodic events
     – event i occurs within period Pi and requires Ci
       seconds
• Then the load can only be handled if
                        m
                          Ci
                     ∑ P ≤1
                     i =1
Sistem Operasi             i
                     http://fasilkom.narotama.ac.id/
                                                         30
Policy versus Mechanism

• Separate what is allowed to be done with
  how it is done
      – a process knows which of its children threads
        are important and need priority

• Scheduling algorithm parameterized
      – mechanism in the kernel

• Parameters filled in by user processes
      – policy set by user process
Sistem Operasi       http://fasilkom.narotama.ac.id/
                                                        31
Thread Scheduling (1)




      Possible scheduling of user-level threads
        • 50-msec process quantum
        • threads run http://fasilkom.narotama.ac.id/
Sistem Operasi
                      5 msec/CPU burst                  32
Thread Scheduling (2)




      Possible scheduling of kernel-level threads
        • 50-msec process quantum
        • threads run http://fasilkom.narotama.ac.id/
Sistem Operasi        5 msec/CPU burst
                                                        33
Question ?




Sistem Operasi   http://fasilkom.narotama.ac.id/
                                                   34

More Related Content

PPT
Chapter 02
PPT
Chapter 02
PPT
Real-Time Scheduling Algorithms
PPTX
RTOS MICRO CONTROLLER OPERATING SYSTEM-2
PPT
The Windows Scheduler
PPTX
Windows process-scheduling
PPT
Chapter 02
Chapter 02
Real-Time Scheduling Algorithms
RTOS MICRO CONTROLLER OPERATING SYSTEM-2
The Windows Scheduler
Windows process-scheduling

What's hot (20)

PPT
Chapter 02 modified
PDF
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
PPTX
Windows process scheduling presentation
PDF
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
PPT
Real time-embedded-system-lec-02
PDF
Os Question Bank
PPT
Rtos Concepts
PDF
Rtos part2
PDF
3 process management
PPTX
Lecture 5 process concept
PPT
process management
PDF
Real Time Operating Systems
PDF
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
PPTX
Operating system - Process and its concepts
PPT
Chapter 19 - Real Time Systems
PPT
Real Time Operating Systems
PPT
OS Process and Thread Concepts
DOCX
Os notes
PPTX
Processes and operating systems
Chapter 02 modified
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
Windows process scheduling presentation
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
Real time-embedded-system-lec-02
Os Question Bank
Rtos Concepts
Rtos part2
3 process management
Lecture 5 process concept
process management
Real Time Operating Systems
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating system - Process and its concepts
Chapter 19 - Real Time Systems
Real Time Operating Systems
OS Process and Thread Concepts
Os notes
Processes and operating systems
Ad

Viewers also liked (20)

PDF
Chapter9
PPTX
1. review jurnal effect dwi hastho
PPT
Ipc ppt
PPT
Op Sy 03 Ch 23
PDF
Kcd226 Sistem Operasi Lecture06
PPTX
PPTX
2. review jurnal barrier dwi hastho
PPT
Ch4: Processes (OS)
PPT
Chapter 3 - Processes
PPT
PPT
PPT
My SQl
PPT
IP Addressing
PPT
Saftey
PPT
PPT
I/O Management
PPT
Shell Script
PPT
Interprocess Communication
PPT
Network Security
PPT
Operating systems
Chapter9
1. review jurnal effect dwi hastho
Ipc ppt
Op Sy 03 Ch 23
Kcd226 Sistem Operasi Lecture06
2. review jurnal barrier dwi hastho
Ch4: Processes (OS)
Chapter 3 - Processes
My SQl
IP Addressing
Saftey
I/O Management
Shell Script
Interprocess Communication
Network Security
Operating systems
Ad

Similar to Kcd226 Sistem Operasi Lecture04 (9)

PDF
Kcd226 Sistem Operasi Lecture03
PDF
Kcd226 Sistem Operasi Lecture02
PDF
Kcd226 Sistem Operasi Lecture05
PDF
Kcd226 Sistem Operasi Lecture01
PDF
Kbk436 Sistem Operasi Lanjut Lecture02
PDF
Kbk436 Sistem Operasi Lanjut Lecture01
PDF
Kcd226 Sistem Operasi Lecture01
PDF
Kbk436 Sistem Operasi Lanjut Lecture01
PPT
Kcd226 Sistem Operasi Lecture03
Kcd226 Sistem Operasi Lecture02
Kcd226 Sistem Operasi Lecture05
Kcd226 Sistem Operasi Lecture01
Kbk436 Sistem Operasi Lanjut Lecture02
Kbk436 Sistem Operasi Lanjut Lecture01
Kcd226 Sistem Operasi Lecture01
Kbk436 Sistem Operasi Lanjut Lecture01

More from Cahyo Darujati (9)

PPTX
Presentasi jaring pengaman sandi untuk mendukung spbe 29042019 rev2
PDF
Melindungi, Mengamankan, Menanggulangi, dan Memulihkan Keamanan Informasi Pen...
PDF
Melawan penyebaran hoax di media sosial dengan teknologi
PDF
Security is a process not a magic
PPT
01.welcome.ppt.sosialisasi.skkni.surabaya
ODP
Mengatur referensi penelitian
PPTX
Tatakelola Teknologi Informasi
ODP
Pen test methodology
PPT
pengenalan ipv6
Presentasi jaring pengaman sandi untuk mendukung spbe 29042019 rev2
Melindungi, Mengamankan, Menanggulangi, dan Memulihkan Keamanan Informasi Pen...
Melawan penyebaran hoax di media sosial dengan teknologi
Security is a process not a magic
01.welcome.ppt.sosialisasi.skkni.surabaya
Mengatur referensi penelitian
Tatakelola Teknologi Informasi
Pen test methodology
pengenalan ipv6

Recently uploaded (20)

PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
master seminar digital applications in india
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
Lesson notes of climatology university.
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Classroom Observation Tools for Teachers
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Insiders guide to clinical Medicine.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
master seminar digital applications in india
STATICS OF THE RIGID BODIES Hibbelers.pdf
RMMM.pdf make it easy to upload and study
Lesson notes of climatology university.
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Computing-Curriculum for Schools in Ghana
Renaissance Architecture: A Journey from Faith to Humanism
Abdominal Access Techniques with Prof. Dr. R K Mishra
Classroom Observation Tools for Teachers
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
102 student loan defaulters named and shamed – Is someone you know on the list?
Insiders guide to clinical Medicine.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Anesthesia in Laparoscopic Surgery in India
O5-L3 Freight Transport Ops (International) V1.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Chapter 2 Heredity, Prenatal Development, and Birth.pdf

Kcd226 Sistem Operasi Lecture04

  • 1. Lecture 4 Interprocess and Scheduling 4.1. Interprocess communication 4.2. Classical IPC problems 4.3. Scheduling Sistem Operasi http://fasilkom.narotama.ac.id/ 1
  • 2. Interprocess Communication Race Conditions Two processes want to access shared memory at same time Sistem Operasi http://fasilkom.narotama.ac.id/ 2
  • 3. Critical Regions (1) Four conditions to provide mutual exclusion 1. No two processes simultaneously in critical region 2. No assumptions made about speeds or numbers of CPUs 3. No process running outside its critical region may block another process 4. No process must wait forever to enter its critical region Sistem Operasi http://fasilkom.narotama.ac.id/ 3
  • 4. Critical Regions (2) Mutual exclusion using critical regions Sistem Operasi http://fasilkom.narotama.ac.id/ 4
  • 5. Mutual Exclusion with Busy Waiting (1) Proposed solution to critical region problem (a) Process 0. Sistem Operasi (b) Process 1. http://fasilkom.narotama.ac.id/ 5
  • 6. Mutual Exclusion with Busy Waiting (2) Sistem Operasi http://fasilkom.narotama.ac.id/ Peterson's solution for achieving mutual exclusion 6
  • 7. Mutual Exclusion with Busy Waiting (3) Entering and leaving a critical region using the Sistem Operasi TSL instruction http://fasilkom.narotama.ac.id/ 7
  • 8. Sleep and Wakeup Producer-consumer http://fasilkom.narotama.ac.id/ fatal race condition8 Sistem Operasi problem with
  • 10. Mutexes Implementation of mutex_lock and mutex_unlock Sistem Operasi http://fasilkom.narotama.ac.id/ 10
  • 11. Monitors (1) Sistem Operasi Example of a monitor http://fasilkom.narotama.ac.id/ 11
  • 12. Monitors (2) • Outline of producer-consumer problem with monitors – only one monitor procedure active at one time Sistem Operasi http://fasilkom.narotama.ac.id/ – buffer has N slots 12
  • 13. Monitors (3) Solution to producer-consumer problem in Java (part 1) Sistem Operasi http://fasilkom.narotama.ac.id/ 13
  • 14. Monitors (4) Solution to producer-consumer problem in Java (part 2) Sistem Operasi http://fasilkom.narotama.ac.id/ 14
  • 15. Message Passing The producer-consumer problem with N messages Sistem Operasi http://fasilkom.narotama.ac.id/ 15
  • 16. Barriers • Use of a barrier – processes approaching a barrier – all processes but one blocked at barrier Sistem Operasi http://fasilkom.narotama.ac.id/ – last process arrives, all are let through 16
  • 17. Dining Philosophers (1) • Philosophers eat/think • Eating needs 2 forks • Pick one fork at a time • How to prevent deadlock Sistem Operasi http://fasilkom.narotama.ac.id/ 17
  • 18. Dining Philosophers (2) A nonsolution to the dining philosophers problem Sistem Operasi http://fasilkom.narotama.ac.id/ 18
  • 19. Dining Philosophers (3) Sistem Operasi http://fasilkom.narotama.ac.id/ Solution to dining philosophers problem (part 1) 19
  • 20. Dining Philosophers (4) Sistem Operasi http://fasilkom.narotama.ac.id/ Solution to dining philosophers problem (part 2) 20
  • 21. The Readers and Writers Problem A solution to the readers and writers problem Sistem Operasi http://fasilkom.narotama.ac.id/ 21
  • 22. The Sleeping Barber Problem (1) Sistem Operasi http://fasilkom.narotama.ac.id/ 22
  • 23. The Sleeping Barber Problem (2) Sistem Operasi http://fasilkom.narotama.ac.id/ Solution to sleeping barber problem. 23
  • 24. Scheduling Introduction to Scheduling (1) • Bursts of CPU usage alternate with periods of I/O wait – a CPU-bound process – an I/O bound process Sistem Operasi http://fasilkom.narotama.ac.id/ 24
  • 25. Introduction to Scheduling (2) Sistem Operasi Scheduling Algorithm Goals http://fasilkom.narotama.ac.id/ 25
  • 26. Scheduling in Batch Systems (1) An example of shortest job first scheduling Sistem Operasi http://fasilkom.narotama.ac.id/ 26
  • 27. Scheduling in Batch Systems (2) Sistem Operasi Three level scheduling http://fasilkom.narotama.ac.id/ 27
  • 28. Scheduling in Interactive Systems (1) • Round Robin Scheduling – list of runnable processes – list of runnable processes after B uses up its quantum Sistem Operasi http://fasilkom.narotama.ac.id/ 28
  • 29. Scheduling in Interactive Systems (2) A scheduling algorithm with four priority classes Sistem Operasi http://fasilkom.narotama.ac.id/ 29
  • 30. Scheduling in Real-Time Systems Schedulable real-time system • Given – m periodic events – event i occurs within period Pi and requires Ci seconds • Then the load can only be handled if m Ci ∑ P ≤1 i =1 Sistem Operasi i http://fasilkom.narotama.ac.id/ 30
  • 31. Policy versus Mechanism • Separate what is allowed to be done with how it is done – a process knows which of its children threads are important and need priority • Scheduling algorithm parameterized – mechanism in the kernel • Parameters filled in by user processes – policy set by user process Sistem Operasi http://fasilkom.narotama.ac.id/ 31
  • 32. Thread Scheduling (1) Possible scheduling of user-level threads • 50-msec process quantum • threads run http://fasilkom.narotama.ac.id/ Sistem Operasi 5 msec/CPU burst 32
  • 33. Thread Scheduling (2) Possible scheduling of kernel-level threads • 50-msec process quantum • threads run http://fasilkom.narotama.ac.id/ Sistem Operasi 5 msec/CPU burst 33
  • 34. Question ? Sistem Operasi http://fasilkom.narotama.ac.id/ 34