Lecture Notes for Client-Server Interfaces
15 March 2001 - Single-Threaded Concurrency
- one computation, many requests
- multiplex the computation over the requests
- simple requests imply trivial multiplexing
- "simple" means short
- long requests are not so simple
- why bother
- simplicity - no synchronization or communication (sorta)
- improved performance - low overhead
- multiplexing sockets - asynchronous io
- this is event-driven (or data-driven) programming
- io events
- timer events - time-outs, heartbeats
- could use alarm signals - complex and insecure
- fortunately,
select()
can combine time and io
- implementation
- keep a priority queue of timer events, nearest deadlines first
- the head of the queue determines the
select()
time-out
- on
select()
time-out, deal with the time-out event
- time-out events are function pointers.
- interface
- schedule a function call to occur
- cancel a scheduled function call
- respond to the time-out
This page last modified on 10 April 2001.