events in general. agenda post/wait technique i/o multiplexing asynchronous i/o signal-driven i/o...

16
Events in General

Upload: delilah-logan

Post on 18-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Events in General

Page 2: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Agenda

• Post/wait technique

• I/O multiplexing

• Asynchronous I/O

• Signal-driven I/O

• Database events

• Publish/subscribe model

• Local vs. distributed events

Page 3: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Post/wait technique

• Operating systems and some DBMSes

• Wait for an event to happen

• Post an event; i.e., make it happen

• Problems• multiple listeners not usually possible

• waiting for different types of events not possible without multiple threads

• posting before waiting/waiting for non-event

Page 4: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Quick Review

User Space

Kernel Space

Hardware

System CallData Transfer

Device I/OChar/Block transfer

Page 5: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Blocking and Non-blocking I/O

• Blocking• send request and wait for completion

• Non-blocking• send request and check later for completion

• Check later:– periodically (polling)

– occasionally

– deferred wait

Page 6: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

I/O Multiplexing

• Unix select() kernel function

• Send I/O requests and continue executing

• Wait for one or more of multiple events• and/or a timeout to occur

• events are read, write or exception

• kernel notifies caller when I/O initiates

• Demultiplex event and handle it• handler copies data from kernel space to user space

Page 7: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Asynchronous I/O

• Register handler function, send I/O request to kernel and continue executing

• Kernel notifies handler function• after I/O has completed

• kernel copies data from kernel space to user space

• Not really in most Unixes • it’s a POSIX thing

Page 8: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Signal-driven I/O

• Register handler function for signal, send I/O request and continue executing

• Kernel notifies (signals) handler function • after I/O has initiated

• Handler copies data from kernel space to user space

Page 9: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Database Events

• InterBase’s mechanism• Post/wait technique

• Named events

• Applications can register for multiple events

• synchronous or asynchronous

• Events under transaction control

• Multiple postings of same event yields only one event

Page 10: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Publish/Subscribe Model

• Interested parties subscribe to service• consumers (listeners)

• Publisher of service provides information• supplier (source)

• Push: send out information

• Pull: request information

• Java Event Model: • supplier pushes GUI events to consumer

Page 11: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Event Channels

• Familiar push model: one-to-many

• Channels allow:• push or pull

• many-to-many

Supplier 1

Supplier 2

Consumer 1

Consumer 2

Consumer 3

Channel

Page 12: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Event Channels: Advantages

• Multiple suppliers and multiple consumers

• Could:• buffer incoming events for later delivery

• ensure quality of service

• hide communication models

• filter events

• route events

• make events persist

Page 13: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Local vs. Distributed Events

• Most event models don’t consider distribution

• Why is this?

• Industry solutions:• CORBA

• ACE

Page 14: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Blocking I/O Example

Page 15: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Non-blocking I/O (Poll) Example

Page 16: Events in General. Agenda Post/wait technique I/O multiplexing Asynchronous I/O Signal-driven I/O Database events Publish/subscribe model Local vs. distributed

Non-blocking I/O (Select) Example