COP4600_24-5 - COP 4600 24-5-10 Processes & threads...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 4600 24-5-10 Writing servers: 3 approaches The server as a single threaded process * can handle 1 connection at a time - no parallelism - blocking systems are OK Single threaded FSM [Finite State Machine] * can handle multiple connections at a time - parallelism (with handling of connections, but not over multiple CPUs) - requires non -blocking system calls - when a service is not ready, preserve the state of the current connection and switch to handling a different connection - interrupts Multithreaded server * can handle multiple connections at a time - parallelism (with handling of connections, and over multiple CPU's) - blocking system calls are OK - if a thread handling a connection blocks, then run a different thread * simple example (one thread per connection model) dispatcher_thread() { for (;;) { new HandlerThread( acceptJob() ).start(); } } acceptThread() probably supposed to be acceptJob() is a blocking call (the dispatcher thread blocks until function returns); it returns a task/connection that a newly spun HandlerThread will handle Threaded system types What mechanism does the system have for supporting threads * kernel threads * user threads * hybrids <Digression>
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
traditional, non- threaded threaded system threaded system system
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

COP4600_24-5 - COP 4600 24-5-10 Processes &amp; threads...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online