EmbLogic's Blog

Server process handling the requests of multiple clients using Shared memory IPC mechanism.

RCS file: server.c,v
Working file: server.c
head: 1.15
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 15;    selected revisions: 15
description:
Code of the server process that will handle multiple requests from the clients.
In this version,shared memory segment is created and a message is displayed to the user
if there is any error in creating the shared memory segment.
—————————-
revision 1.15
date: 2014/01/26 21:23:11;  author: root;  state: Exp;  lines: +7 -2
Synchronization between the clients is achieved using semaphore and sleep() system call.
The result is gettting displayed for both the clients.
But the problem is that the code is slow due to excessive use of sleep() system call.
—————————-
revision 1.14
date: 2014/01/26 20:18:25;  author: root;  state: Exp;  lines: +80 -77
The server process is calculating the requests infinite times.
Issue:Inside the while loop.
Checking….
—————————-
revision 1.13
date: 2014/01/26 20:08:25;  author: root;  state: Exp;  lines: +31 -2
The result is getting displayed for only a single client.
Logical error present.
Checking…..
—————————-
revision 1.12
date: 2014/01/26 19:18:08;  author: root;  state: Exp;  lines: +1 -0
The result is getting displayed inside the server as well as inside the client.
Coding is correct.
Now making the code work for more than one client.
—————————-
revision 1.11
date: 2014/01/26 16:21:03;  author: root;  state: Exp;  lines: +2 -0
The result is read inside the server correctly.
But the client is not able to read the result.
Logical error fixed.
This is due to the result is not written inside the shared memory segment.
—————————-
revision 1.10
date: 2014/01/26 16:12:15;  author: root;  state: Exp;  lines: +2 -1
Compilation error fixed.
Issue:Address is not passed inside the read() system call.
—————————-
revision 1.9
date: 2014/01/26 15:51:06;  author: root;  state: Exp;  lines: +31 -3
Inside the switch case,if operand is ‘+’ then fork and execl is done.
The data is passed to the processing client.
The result is received from the processing client but only for the addition operation.
—————————-
revision 1.8
date: 2014/01/26 15:02:22;  author: root;  state: Exp;  lines: +12 -1
Creating a switch case that will create a pipe for every request from a client.
—————————-
revision 1.7
date: 2014/01/26 05:18:59;  author: root;  state: Exp;  lines: +1 -1
Declaration error fixed.
Issue:Typing mistake.
—————————-
revision 1.6
date: 2014/01/26 05:02:07;  author: root;  state: Exp;  lines: +7 -0
Semaphore value is set using the semctl() system call.
—————————-
revision 1.5
date: 2014/01/26 04:56:03;  author: root;  state: Exp;  lines: +7 -0
A semaphore is created before creating the shared memory segment.
Initializing the semaphore inside the server…..
—————————-
revision 1.4
date: 2014/01/26 04:52:03;  author: root;  state: Exp;  lines: +8 -1
After storing the address at which the shared memory segment is attached.
The operands are fetched inside the server.
—————————-
revision 1.3
date: 2014/01/26 04:26:58;  author: root;  state: Exp;  lines: +8 -0
The size of the shared memory segment is checked using shmctl.
—————————-
revision 1.2
date: 2014/01/26 04:01:32;  author: root;  state: Exp;  lines: +6 -0
Shared memory segment is attached to the program’s address space using the shmat() system call.
If unsuccessfull a message is displayed to the user.
—————————-
revision 1.1
date: 2014/01/26 03:57:30;  author: root;  state: Exp;
Initial revision
=================================================================
RCS file: client1.c,v
Working file: client1.c
head: 1.12
branch:
locks: strict
root: 1.12
access list:
symbolic names:
keyword substitution: kv
total revisions: 12;    selected revisions: 12
description:
This is the client that requests the addition operation.
In this revision:shared memory segment is obtained inside the client,that is created by the server.
—————————-
revision 1.12    locked by: root;
date: 2014/01/26 16:24:28;  author: root;  state: Exp;  lines: +4 -2
The result is not collected from the shared memory segment inside the client.
Bug fixed.
Checking the final result inside the client process….
—————————-
revision 1.11
date: 2014/01/26 14:07:08;  author: root;  state: Exp;  lines: +15 -2
The result is read inside the client1 inside the sum variable.
After reading the result,shared memory segment is detached.
The code will display an error message if there is problem in detaching the shared memory segment.
—————————-
revision 1.10
date: 2014/01/26 05:21:47;  author: root;  state: Exp;  lines: +1 -1
Logical error fixed.
Inside the shmat(),few arguments are passed.
—————————-
revision 1.9
date: 2014/01/26 05:17:45;  author: root;  state: Exp;  lines: +1 -0
operand is written to the shared memory segment by type casting.
—————————-
revision 1.8
date: 2014/01/26 05:13:21;  author: root;  state: Exp;  lines: +12 -1
The definitions of the acquire and release semaphores are given.
—————————-
revision 1.7
date: 2014/01/26 05:06:23;  author: root;  state: Exp;  lines: +10 -0
Prototypes of the functions that will acquire and release semaphore are added.
The critical section region is defined.
Defining the body of the acquire and release functions……
—————————-
revision 1.6
date: 2014/01/26 04:46:12;  author: root;  state: Exp;  lines: +5 -1
Variables are stored in the shared memory segment and they will be available to the server.
—————————-
revision 1.5
date: 2014/01/26 04:42:39;  author: root;  state: Exp;  lines: +7 -0
Semaphore is obtained using the semget() system call.
—————————-
revision 1.4
date: 2014/01/26 04:36:46;  author: root;  state: Exp;  lines: +2 -1
A temporary variable is used to store the address at which the shared memory segment is attached.
—————————-
revision 1.3
date: 2014/01/26 04:34:06;  author: root;  state: Exp;  lines: +10 -1
The numbers are initialized with values and operator + is used to tell the server
that do the addition operation.
—————————-
revision 1.2
date: 2014/01/26 04:24:40;  author: root;  state: Exp;  lines: +7 -1
Shared memory segment is attached to the client’s address space,if there is an error
a message will get displayed.
—————————-
revision 1.1
date: 2014/01/26 04:21:03;  author: root;  state: Exp;
Initial revision
=========================================================================================
RCS file: header.h,v
Working file: header.h
head: 1.5
branch:
locks: strict
root: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;    selected revisions: 5
description:
The main header file is header.h
This includes all the required header files.
—————————-
revision 1.5    locked by: root;
date: 2014/01/26 15:07:59;  author: root;  state: Exp;  lines: +1 -0
header file:<unistd.h> is included to support pipe functions.
—————————-
revision 1.4
date: 2014/01/26 05:20:06;  author: root;  state: Exp;  lines: +1 -0
Header file:<sys/sem.h> is included to support the semaphore functions.
—————————-
revision 1.3
date: 2014/01/26 05:01:26;  author: root;  state: Exp;  lines: +4 -0
A union is declared inside this file.
—————————-
revision 1.2
date: 2014/01/26 05:00:30;  author: root;  state: Exp;  lines: +1 -0
Header file:stdlib.h is added to support exit().
—————————-
revision 1.1
date: 2014/01/26 03:48:37;  author: root;  state: Exp;
Initial revision
=============================================================================

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>