Client Server Model and Software Design - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Client Server Model and Software Design

Description:

... executes, it contacts a server, sends a request, and awaits a response. Clients are often easier to build than servers, and usually require no special ... – PowerPoint PPT presentation

Number of Views:183
Avg rating:3.0/5.0
Slides: 17
Provided by: PROFE172
Category:

less

Transcript and Presenter's Notes

Title: Client Server Model and Software Design


1
Client Server Model and Software Design
  • TCP/IP allows a programmer to establish
    communication between two application and to pass
    data back and forth.
  • Application can execute on the same machine or on
    different machines.
  • One organizational method dominates the use of
    TCP/IP is known as the client-server paradigm.

2
Terminology and concept
  • Client an application that initiates
    peer-to-peer communication is called client
  • Each time a client application executes, it
    contacts a server, sends a request, and awaits a
    response.
  • Clients are often easier to build than servers,
    and usually require no special system privileges
    to operate

3
  • Server is any program that waits for incoming
    communication requests from a client. The server
    receives a clients request, performs the
    necessary computation, and returns the result to
    the client.
  • Privilege and complexity
  • Servers must contain code that handles the issues
    of Authentication, Authorization, data security,
    privacy and protection

4
Parameterization of Clients
  • Some client software provides more generality
    than others. In particular, some client software
    allows the user to specify both remote machine on
    which a server operates and the protocol port
    number at which the server is listening.

5
Connectionless vs. connection-oriented servers
  • When programmers design client-server software,
    they must choose between two types of
    interaction a connectionless or a
    connection-oriented style.
  • TCP connection-oriented. It provides all the
    reliability needed to communicate across an
    internet.
  • Verifies data arrives, automatically retransmits
  • Compute checksum over data.
  • Automatically delete duplicated package
  • UDP User datagram protocol.connectionless. No
    guarantees about reliable delivery.

6
Chapter 3 Concurrent Processing in Client-Server
Software
  • The term concurrency refers to real or apparent
    simultaneous computing.
  • Concurrent processing is fundamental to
    distributed computing and occurs in many forms
  • Many pairs of application programs can
    communicate concurrently, sharing the network
    that interconnects them
  • Concurrency can occur within a given computer
    system. Multiple users on a timesharing system
  • Set of all clients on a set of machines can
    execute concurrently
  • Concurrency in server. A single server program
    must handle incoming requests concurrently

7
Programs vs. processes
  • Process defines the fundamental unit of
    computation( some system use the terms task, job,
    or thread instead of process)
  • A process differs from a program because the
    process concept includes only the active
    execution of a computation, not the code.
  • After the code has been loaded into a computer,
    the operating system allows multiple processes to
    execute the same piece of code at the same time

8
  • For( I 1, Ilt10 I)
  • printf(d\n, I)
  • If two or more processes execute the code segment
    concurrently, one of them may be on the sixth
    iteration when other starts the first iteration
  • When multiple processes execute a piece of code
    concurrently, each process has its own,
    independent copy of the variables associated with
    the code

9
Procedure call
  • The run-time system for procedure-oriented
    programming languages uses a stack mechanism to
    handle procedure calls. The run-time system
    pushes a procedure activation record on the stack
    whenever it makes a procedure call.
  • When multiple procedures execute a piece of code
    concurrently, each has its own run-time stack of
    procedure activation records

10
An example of concurrent process creation
  • includeltstdlib.hgt
  • includeltstdio.hgt
  • Int sum
  • Main()
  • int I
  • sum 0
  • for ( I 1 I lt 5 I)
  • printf(The value of I is d\n,I)
  • fflush(stdout) / flush the buffer/
  • sum I
  • printf(The sum is d\n, sum)
  • Exit(0)

11
A concurrent version
  • To create a new process in UNIX, a program calls
    the system function fork.
  • fork divides the running program into two
    identical processes, both executing at the same
    place in the same code.
  • The two processed continue just as if two users
    had simultaneously started two copies of the
    application.

12
  • includeltstdlib.hgt
  • includeltstdio.hgt
  • int sum
  • main()
  • int I
  • sum 0
  • fork() / create a new process/
  • for( I 1 I lt5 I)
  • printf(The value of I is d\n, I)
  • fflush(stdout)
  • sum I
  • printf(The sume is d \n, sum)
  • exit(0)

13
  • To understand the fork function, imagine that
    fork causes the operating system to make a copy
    of the executing program and allows both copies
    to run at the same time

Output The value of I is 1 The value of I is
2 The value of I is 3 The value of I is 4 The
value of I is 5 The sum is 15 The value of I is
1 The value of I is 2 The value of I is 3 The
value of I is 4 The value of I is 5 The sum is 15
The first process executed so rapidly that it was
able to complete execution before the second
process ran at all
14
timeslicing
  • The operating system allocates the available CPU
    power to each process for a short time before
    moving on to the next. We use term timeslicing to
    describe system that share the available CPU
    among several processes concurrently
  • To see the effect of timeslicing, extend the
    concurrent program to iterate 10,000 times
    instead 5 times

15
Process identifier or process id
  • In practice, the process created by fork is not
    absolutely identical to the original process it
    differs in one small detail.fork is a function
    that returns a value to its caller.
  • in the original process, fork returns a small
    positive integer that identifies the newly
    created process
  • In the newly created process, the fork returns
    zero

16
  • includeltstdlib.hgt
  • int sum
  • main()
  • int pid
  • sum 0
  • pid fork()
  • if (pid ! 0) / original process /
  • printf(The original process prints this.\n)
  • else / newly created process/
  • printf(The new process print this\n)
  • exit(0)
Write a Comment
User Comments (0)
About PowerShow.com