Title: Concurrent Processing in ClientServer Software
1Lecture 3
- Concurrent Processing in Client/Server Software
2Overview
- Introduction
- Concurrency in Networks
- Concurrency in Servers
- Terminology and Concepts
- Process Concept
- Processes vs. Programs
- Procedure Calls
- Concurrent Process Creation
- Time-slicing
- Process Divergence
- Context Switching
- Concurrency and Asynchronous I/O
- Summary
3Introduction
- Client/Server paradigm as it relates to
concurrency - Provides much of the power between client/server
interactions - Makes the software difficult to design and build
- Facilities provided by the operating system to
support concurrent process execution
4Concurrency in Networks
- The term concurrency refers to real or apparent
simultaneous computing - Time-sharing
- Multiprocessing
- Concurrent processing is fundamental to
distributed computing - Concurrency among multiple process on separate
machines - Concurrency among a single computer system
- Concurrency among a set of clients on a single
machine
5Client Concurrency
- Client software does not require any special
effort to make it concurrent - The client program is designed without regard to
concurrency - Concurrency among client programs occurs
automatically because the operating system
supports simultaneous program execution
6Concurrency Among Client Programs
C1
C4
Internet
C2
C3
7Concurrency in Servers
- Unlike concurrent client software, concurrent
server software requires significant effort - Why is server concurrency important
- Concurrent client access
- Throughput
- Response Time
8Concurrent Server
C2
server
C1
Internet
C3
C4
9Process Concept
- Process abstraction defines the fundamental unit
of computation - Address space and at least one thread of
execution - Essential process information
- Instruction pointer
- Process Id
- Executing program
- Program text and data areas (memory locations)
10Local vs. Global Variables
- A single threaded program doesnt need to worry
about concurrent access to variables. - Multiple threaded programs need their own copy of
the variables -
11Procedure Calls
Thread 2
- Concurrent programming systems provide separation
between procedure calls in executing threads - When multiple threads execute a piece of code
concurrently, each has its own run-time stack
Thread 1
Procedure A
Procedure B
Procedure C
12Concurrent Process Creation
A Sequential C Example include
ltstdio.hgt include ltstdlib.hgt int sum int main()
int I sum 0 for (i 1 i lt 5
i) printf(The value of i is d \n,
i) fflush(stdout) sum i
printf(The sum is d \n, sum) exit(0)
13Concurrent Process Creation
A Concurrent Version include ltstdio.hgt int
sum int main() int i sum 0
fork( ) / Create a new process / for (i
1 i lt 5 i) printf(The value of i
is d \n, i) fflush(stdout) sum i
printf(The sum is d \n, sum)
exit(0)
14Timeslicing
- Timeslicing attempts to allocate the CPU equally
among all threads - If there are N threads executing, each thread
receives 1/N of the CPU - All threads appear to proceed at an equal rate
- Many threads executing the rate is low with few
the rate is high
15Context Switching Protocol Software Design
- Concurrent processing makes programs more
powerful but it adds computational overhead - A context switch occurs when the operating system
switches from one thread to another - Context switching is pure overhead needed to
support concurrent processing - Protocol software should be designed to minimize
context switching - Benefits of concurrency needs to outweigh the
costs of switching contexts
16Concurrency Asynchronous I/O
- Some operating systems allow an application to
control concurrent input and output operations - The select system call provides a fundamental
operation to manage concurrent I/O
17Summary
- Concurrency is fundamental to TCP/IP applications
- Concurrency in client applications results in
multiple clients executing at the same time - Concurrency in server applications is more
difficult because concurrency has to be handled
explicitly. - In Unix/Linux systems additional processes are
created by using the fork system call - Concurrency generates system resource overhead
- The select system call allows a process to manage
concurrent I/O