COMP 252 Operating Systems - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

COMP 252 Operating Systems

Description:

There is an old writer, the new writer waits until the old one finishes. ... However, readers come after the writer must wait for the writer finishes writing. ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 13
Provided by: cse2
Category:

less

Transcript and Presenter's Notes

Title: COMP 252 Operating Systems


1
COMP 252Operating Systems
  • Lab 06

2
Outline
  • Review questions week 10
  • Synchronization readers-writers problem
  • Project_2 guidelines

3
Review questions week 10
  • Please refer to our course web
  • http//course.cse.ust.hk/comp252/web07fall/Lab6/la
    b06_review.pdf

4
Synchronization readers-writers problem
  • The problem consists of readers and writers that
    share a data resource
  • The readers only want to read from the resource
  • The writers want to update (write) the resource

5
Synchronization readers-writers problem
  • There is no problem if two or more readers access
    the resource simultaneously
  • However
  • If a writer and some other thread (either a
    reader or a writer) access the resource
    simultaneously, the result becomes
    indeterminable.

6
Synchronization readers-writers problem
  • To ensure that these difficulties do not arise,
    we require
  • writers have exclusive access to the shared data
    resource
  • This synchronization problem is referred to as
    the readers-writers problem
  • can be used to test synchronization primitive
  • more details on textbook p202

7
Project_2 guidelines
  • In this project, you will learn
  • how to use semaphores
  • get a better understanding about synchronization
  • Your task is to solve the readers-writers problem
    on Nachos
  • semaphores on Nachos have already been introduced
    in our previous lab

8
Project_2 guidelines
  • You should solve this problem in two strategies
  • reader-first
  • writer-first
  • In both strategies, a writer has exclusive access
    to the share data while readers can share with
    other readers.

9
Project_2 guidelines
  • In reader-first strategy
  • a reader can access the shared data (i.e., starts
    reading) as long as there is no writer inside the
    critical section.
  • A writer can only access the shared data when
    there is no reader or writer inside the critical
    section.
  • This is the solution that the textbook provides.

10
Project_2 guidelines
  • In writer-first strategy, when a new writer
    comes, here are some circumstances
  • No other persons reading or writing, he/she could
    write.
  • There are some readers waiting (i.e. they did not
    start reading), the writer could start to write.
    That is to say, the priorities of writers are
    higher than readers.

11
Project_2 guidelines
  • Cont.
  • There is an old writer, the new writer waits
    until the old one finishes.
  • There are some readers reading. Then the new
    writer waits until all the readers finishes.
    However, readers come after the writer must wait
    for the writer finishes writing.

12
Project_2 guidelines
  • Project_2 instructions and Nachos source code can
    be found on our course web.
  • For Nachos semaphores, please refer to the
    Semaphore class defined in Nachos.
  • threads/synch.h
  • threads/synch.cc
Write a Comment
User Comments (0)
About PowerShow.com