EmbLogic's Blog

Using the /proc Filesystem

The /proc filesystem is a special, software-created filesystem that is used by the ker-
nel to export information to the world. Each file under /proc is tied to a kernel func-
tion that generates the file’s “contents” on the fly when the file is read. We have
already seen some of these files in action; /proc/modules, for example, always returns
a list of the currently loaded modules.
/proc is heavily used in the Linux system. Many utilities on a modern Linux distribu-
tion, such as ps, top, and uptime, get their information from /proc. Some device driv-
ers also export information via /proc, and yours can do so as well. The /proc
filesystem is dynamic, so your module can add or remove entries at any time.
Fully featured /proc entries can be complicated beasts; among other things, they can
be written to as well as read from. Most of the time, however, /proc entries are read-
only files.

Posted in Uncategorized | Leave a comment

Code that uses AF_UNIX address family to implement chatting between a single client and server.

RCS file: server.c,v
Working file: server.c
head: 1.12
branch:
locks: strict
root: 1.12
access list:
symbolic names:
keyword substitution: kv
total revisions: 12;    selected revisions: 12
description:
Code to demonstrate how a server accepts connections from a client on the same computer that is not networked.This code uses AF_UNIX address family for supporting chatting.
—————————-
revision 1.12    locked by: root;
date: 2014/02/04 23:26:15;  author: root;  state: Exp;  lines: +5 -3
prototypes of the writer and reader threads are changed.Client socket file descriptor is passed to both the threads function.
Both the reader writer threads in client and server are working properly.
Chatting program is successfully implemented.
—————————-
revision 1.11
date: 2014/02/04 16:14:36;  author: root;  state: Exp;  lines: +36 -15
The arguments inside the thread functions are changed but not inside the prototypes.
Fixing the error.
—————————-
revision 1.10
date: 2014/02/04 15:36:07;  author: root;  state: Exp;  lines: +2 -0
Prototypes of the two functions used by thread after they are created is declared.
Defining the body now………
—————————-
revision 1.9
date: 2014/02/04 15:31:51;  author: root;  state: Exp;  lines: +14 -0
Two threads:writer and reader are created using pthread_create().If unsuccessful an error message is displayed.
Header file:<pthread.h> is included to support thread related functions.
Declaring prototypes and defining the body of the functions…..
—————————-
revision 1.8
date: 2014/02/04 15:01:39;  author: root;  state: Exp;  lines: +1 -0
unlink() system call is used to remove the socket if present previously.
—————————-
revision 1.7
date: 2014/02/04 14:59:44;  author: root;  state: Exp;  lines: +1 -1
A small bug fixed.
Issue:Misspelled client_sockfd.
—————————-
revision 1.6
date: 2014/02/04 14:57:08;  author: root;  state: Exp;  lines: +8 -0
accept() system call is used to make the server wait for incoming connection requests from clients.
Checking…….
—————————-
revision 1.5
date: 2014/02/04 14:52:12;  author: root;  state: Exp;  lines: +6 -0
Socket queue creation is done using listen() system call.
An error message is displayed on error.
—————————-
revision 1.4
date: 2014/02/04 14:48:30;  author: root;  state: Exp;  lines: +11 -1
Naming of a socket is done using bind() system call.After the successfull execution
of the system call the server will create a socket named “socket”.An error message is displayed on error.
Checking………………..
—————————-
revision 1.3
date: 2014/02/04 14:37:12;  author: root;  state: Exp;  lines: +3 -0
Header file:<sys/socket.h> and <sys/types.h> are included to support socket related functions.
Now comiling the program to check……
—————————-
revision 1.2
date: 2014/02/04 14:33:38;  author: root;  state: Exp;  lines: +1 -0
Header file:<stdlib.h> is included to support exit() function.
Socket is created using socket() system call and an error message is displayed on error.
—————————-
revision 1.1
date: 2014/02/04 14:32:48;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: client.c,v
Working file: client.c
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
Code to demonstrate how client sends a request to get connect to a client.
After connection is established chatting is done between client and server.
—————————-
revision 1.3
date: 2014/02/04 23:32:14;  author: root;  state: Exp;  lines: +10 -6
Client successfully connects to the server and chatting between both is taking place correctly.
—————————-
revision 1.2
date: 2014/02/04 16:04:39;  author: root;  state: Exp;  lines: +36 -1
two threads are created namely reader and writer threads.
The functions for reader and writer threads are implemented.
Checking……
—————————-
revision 1.1
date: 2014/02/04 15:13:35;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Project 04: FTP based Client Server using Threads and Sockets | Leave a comment

Code that uses AF_INET address family to implement chatting between client and server through loopback address.

RCS file: server.c,v
Working file: server.c
head: 1.15
branch:
locks: strict
root: 1.15
access list:
symbolic names:
keyword substitution: kv
total revisions: 15;    selected revisions: 15
description:
Code to demonstrate how a server accepts connections from a client on the same computer that is not networked.
This code uses AF_INET address family to implement a chatting between client and server through loopback address.
—————————-
revision 1.15    locked by: root;
date: 2014/02/05 23:03:13;  author: root;  state: Exp;  lines: +2 -2
Compilation error fixed.
Issue:Wrongly spelled function.
—————————-
revision 1.14
date: 2014/02/05 22:59:13;  author: root;  state: Exp;  lines: +1 -0
Header file:<pthread.h> is included to support pthread related function calls.
Checking……
—————————-
revision 1.13
date: 2014/02/05 22:58:09;  author: root;  state: Exp;  lines: +10 -0
Outside main(),the functionality of the reader thread is implemented.
Checking……
—————————-
revision 1.12
date: 2014/02/05 22:55:49;  author: root;  state: Exp;  lines: +9 -0
The functionality of the writer thread is implemented.
Now doing the same for reader thread……….
—————————-
revision 1.11
date: 2014/02/05 22:51:23;  author: root;  state: Exp;  lines: +2 -1
The prototypes of the two functions are declared that will be executed by the created threads.
Defining their body………….
—————————-
revision 1.10
date: 2014/02/05 22:48:42;  author: root;  state: Exp;  lines: +10 -1
Two threads are created using pthread_create() system call.The client_sockfd is passed as an argument.
—————————-
revision 1.9
date: 2014/02/05 22:03:58;  author: root;  state: Exp;  lines: +1 -1
Declaration error fixed.
Issue:Client_sockfd variable that will store the client socket descriptor is not declared.
Bugs fixed.
—————————-
revision 1.8
date: 2014/02/05 22:02:43;  author: root;  state: Exp;  lines: +1 -1
A logical error fixed.
Issue:Too many arguments are passed inside the bind() system call.
—————————-
revision 1.7
date: 2014/02/05 22:01:27;  author: root;  state: Exp;  lines: +3 -0
Header files:types.h , in.h and socket.h are included to support socket related functions.
—————————-
revision 1.6
date: 2014/02/05 21:58:47;  author: root;  state: Exp;  lines: +8 -2
accept() system call is used to accept the connection request from the client.
On error an error will get displayed on the screen.On success a client socket descriptor gets returned.
Checking ……
—————————-
revision 1.5
date: 2014/02/05 21:54:51;  author: root;  state: Exp;  lines: +7 -1
A socket queue is created for the incoming connection requests from the clients.
On error:a message will get displayed on the screen.
—————————-
revision 1.4
date: 2014/02/05 21:52:57;  author: root;  state: Exp;  lines: +1 -0
Header file:<stdlib.h> is included to support exit() function.
—————————-
revision 1.3
date: 2014/02/05 21:50:19;  author: root;  state: Exp;  lines: +11 -1
bind() system call is used to bind a name to socket.
If error occurs then an error message will get displayed.
—————————-
revision 1.2
date: 2014/02/05 21:41:39;  author: root;  state: Exp;  lines: +3 -1
A structure variable of type sockaddr_in is declared.
Previously,socket() system call is used that will return the socket descriptor.
Now making the bind call……
—————————-
revision 1.1
date: 2014/02/05 21:39:43;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: client.c,v
Working file: client.c
head: 1.7
branch:
locks: strict
root: 1.7
access list:
symbolic names:
keyword substitution: kv
total revisions: 7;    selected revisions: 7
description:
Code for the client program that requests a server for the connection.
—————————-
revision 1.7    locked by: root;
date: 2014/02/05 23:07:24;  author: root;  state: Exp;  lines: +3 -3
Several logical bugs fixed.
Issue:Wrongly placed variables.
—————————-
revision 1.6
date: 2014/02/05 23:00:22;  author: root;  state: Exp;  lines: +1 -0
Header file:<pthread.h> is included to support thread related functions.
—————————-
revision 1.5
date: 2014/02/05 22:53:05;  author: root;  state: Exp;  lines: +2 -2
The prototypes of the functions are changed.
—————————-
revision 1.4
date: 2014/02/05 22:42:00;  author: root;  state: Exp;  lines: +18 -0
The function that will be executed by the reader and writer threads are defined.
Checking the functionality……..
—————————-
revision 1.3
date: 2014/02/05 22:34:58;  author: root;  state: Exp;  lines: +5 -2
Prototypes of the two functions that will be used by the reader and writer threads are declared.
—————————-
revision 1.2
date: 2014/02/05 22:31:05;  author: root;  state: Exp;  lines: +9 -1
Two threads:namely reader and writer threads are declared of pthread_t.
pthread_create() is used to create the thread.
Using pthread_join to make the main thread to wait for the two child threads.
—————————-
revision 1.1
date: 2014/02/05 22:25:41;  author: root;  state: Exp;
Initial revision
=============================================================================

 

Posted in Project 04: FTP based Client Server using Threads and Sockets | Leave a comment

Code that takes a username and password from the user as an input,matches it with the master database file to find whether it is correct or not.

RCS file: username_password.c,v
Working file: username_password.c
head: 1.7
branch:
locks: strict
root: 1.7
access list:
symbolic names:
keyword substitution: kv
total revisions: 7;    selected revisions: 7
description:
Code that takes a specific username and password from a user.Matches it with a master database.
—————————-
revision 1.7    locked by: root;
date: 2014/02/03 23:50:19;  author: root;  state: Exp;  lines: +1 -2
The program is working as expected.
Code is optimized by removing any redundant statements.
—————————-
revision 1.6
date: 2014/02/03 23:41:30;  author: root;  state: Exp;  lines: +25 -3
After the username is found to be correct and the user enters his/her password.
A comparison is made using strcmp() to find out whether the two strings match or not.
If successfull a message is displayed to the user saying that u are authorized.
—————————-
revision 1.5
date: 2014/02/03 22:23:42;  author: root;  state: Exp;  lines: +4 -2
If the username is correct the program asks the user to enter the password.
Checking….
—————————-
revision 1.4
date: 2014/02/03 22:07:54;  author: root;  state: Exp;  lines: +1 -1
New line character is inserted to see the output more clearly.
Now modifying the code to compare the password.
—————————-
revision 1.3
date: 2014/02/03 22:03:42;  author: root;  state: Exp;  lines: +44 -2
Output is coming as expected.
Inside the while loop use of memset function is done which fills the first n bytes to \o character.
The program is displaying the message if the username is there in the database otherwise it will display not present.
—————————-
revision 1.2
date: 2014/02/03 15:19:45;  author: root;  state: Exp;  lines: +2 -0
Header file:<stdlib.h> is included to support exit() function.
—————————-
revision 1.1
date: 2014/02/03 15:18:09;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Code for a client/server application that uses AF_INET address family for IP sockets.

RCS file: server.c,v
Working file: server.c
head: 1.6
branch:
locks: strict
root: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
Program to demonstrate how a connection oriented server creates a IP socket to accept client requests and uses AF_INET address family.
—————————-
revision 1.6    locked by: root;
date: 2014/01/31 02:00:34;  author: root;  state: Exp;  lines: +6 -0
accept() function is added inside the server to accept an incoming connection request.
—————————-
revision 1.5
date: 2014/01/31 01:57:23;  author: root;  state: Exp;  lines: +9 -0
Socket queue is created using listen() system call.
If queue does not get created then an error message will be displayed.
—————————-
revision 1.4
date: 2014/01/31 01:31:46;  author: root;  state: Exp;  lines: +4 -0
Comilation errors fixed.
Header file:<stdlib.h> is included to support exit(),<socket.h> is included to support socket related functions.
—————————-
revision 1.3
date: 2014/01/31 01:29:18;  author: root;  state: Exp;  lines: +9 -1
Lots of compilation errors.
Issue:Some header files are not included.
Checking….
—————————-
revision 1.2
date: 2014/01/31 01:21:23;  author: root;  state: Exp;  lines: +9 -0
A socket is created using socket() system call.
If successfull then the address family AF_INET with stream SOCK_STREAM will be used.
Else a message displayed on the screen.
—————————-
revision 1.1
date: 2014/01/31 01:16:15;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: client.c,v
Working file: client.c
head: 1.8
branch:
locks: strict
root: 1.8
access list:
symbolic names:
keyword substitution: kv
total revisions: 8;    selected revisions: 8
description:
Code to demonstrate how a connection-oriented client creates a socket to send a request to the server.
—————————-
revision 1.8    locked by: root;
date: 2014/01/31 02:29:34;  author: root;  state: Exp;  lines: +2 -0
The client sends a character ‘a’ to the server,after receiving the character the server converts it into uppercase.
—————————-
revision 1.7
date: 2014/01/31 02:22:25;  author: root;  state: Exp;  lines: +3 -2
Logical error fixed.
Issue:& operator is placed inside the connect() system call.
—————————-
revision 1.6
date: 2014/01/31 02:19:02;  author: root;  state: Exp;  lines: +1 -1
Declaration error fixed.
Issue:ret_value is variable is undeclared.
—————————-
revision 1.5
date: 2014/01/31 02:17:49;  author: root;  state: Exp;  lines: +3 -0
Header files:in.h,socket.h and types.h are included to support various socket types and functions.
—————————-
revision 1.4
date: 2014/01/31 02:16:05;  author: root;  state: Exp;  lines: +1 -0
Header file:<stdlib.h> is included to support exit() function.
—————————-
revision 1.3
date: 2014/01/31 02:14:56;  author: root;  state: Exp;  lines: +11 -2
connect system call is used to connect to the server.
Checking the client’s program….
—————————-
revision 1.2
date: 2014/01/31 02:10:04;  author: root;  state: Exp;  lines: +8 -1
A socket is created using socket() system call.
An error message will be displayed if the socket creation is failed.
—————————-
revision 1.1
date: 2014/01/31 02:07:36;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Project 04: FTP based Client Server using Threads and Sockets | Leave a comment

Master array implementation project01

RCS file: mcdc.c,v
Working file: mcdc.c
head: 1.1
branch:
locks: strict
Emblinux: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:

Posted in Uncategorized | Leave a comment

MODULE FIRST PROGRAM DEVICE DRIVER

head    1.1;
2 access;
3 symbols;
4 locks
5         emblogic:1.1; strict;
6 comment @ * @;
7
8
9 1.1
10 date    2014.02.04.04.44.59;    author emblogic;        state Exp;
11 branches;
12 next    ;
13
14
15 desc
16 @this is the header file of first module driver program
17 @
18
19
20 1.1
21 log
22 @Initial revision
23 @
—————————————————————————————————————————-

head    1.1;
2 access;
3 symbols;
4 locks
5         emblogic:1.1; strict;
6 comment @ * @;
7
8
9 1.1
10 date    2014.02.04.04.44.21;    author emblogic;        state Exp;
11 branches;
12 next    ;
13
14
15 desc
16 @this is the exit.c to remove the module
17 @
18
19
20 1.1
21 log
22 @Initial revision
23 @
———————————————————————————————————————————————————–head    1.1;
2 access;
3 symbols;
4 locks
5         emblogic:1.1; strict;
6 comment @ * @;
7
8
9 1.1
10 date    2014.02.04.04.41.13;    author emblogic;        state Exp;
11 branches;
12 next    ;
13
14
15 desc
16 @this is the initialization file init.c
17 @
18
19
20 1.1
21 log
22 @Initial revision
23 @

 

Posted in Project 11: A Character Device Drivers Based Project | Leave a comment

Code for a client/server application that uses AF_UNIX address family for local sockets.

RCS file: simple_c_s_app.c,v
Working file: simple_c_s_app.c
head: 1.10
branch:
locks: strict
root: 1.10
access list:
symbolic names:
keyword substitution: kv
total revisions: 10;    selected revisions: 10
description:
A simple client/server application in which a server waits for client requests.
—————————-
revision 1.10    locked by: root;
date: 2014/01/30 16:43:52;  author: root;  state: Exp;  lines: +9 -0
unlink() system call is used to delete any old socket with name “socket”.
accept() system call is used to accept a connection.The accept() will block indefinitely waiting for incoming requests to arrive.
The program is running as per expectations.
—————————-
revision 1.9
date: 2014/01/30 16:33:04;  author: root;  state: Exp;  lines: +1 -0
A socket is created with name “socket”.
Preciously it was not getting created because its name is not given sun_path and the length of the address
structure is also not given.Now the socket is getting created.
—————————-
revision 1.8
date: 2014/01/30 16:29:33;  author: root;  state: Exp;  lines: +3 -0
Header file:<string.h> is included to support strcpy() function.
—————————-
revision 1.7
date: 2014/01/30 16:02:36;  author: root;  state: Exp;  lines: +7 -0
A socket queue of 5 is created using listen system call.
A message will be displayed if the socket queue creation failed.
—————————-
revision 1.6
date: 2014/01/30 15:54:15;  author: root;  state: Exp;  lines: +1 -0
Header file:<sys/un.h> is added to include a structure describing the address of AF_UNIX socket.
—————————-
revision 1.5
date: 2014/01/30 15:50:35;  author: root;  state: Exp;  lines: +2 -0
Header file:<sys/types.h> and <sys/socket.h> is included to support bind() and socket() functions.
—————————-
revision 1.4
date: 2014/01/30 15:47:41;  author: root;  state: Exp;  lines: +10 -1
bind() system call is used to make the socket created by using socket() system call to be available to others.
A message will be displayed if the naming failed.
—————————-
revision 1.3
date: 2014/01/30 15:37:45;  author: root;  state: Exp;  lines: +1 -0
Header file:<stdlib.h> is included to support exit() function.
,
—————————-
revision 1.2
date: 2014/01/30 15:34:31;  author: root;  state: Exp;  lines: +11 -1
A socket is created using socket() system call and a message is displayed if the socket creation failed.
—————————-
revision 1.1
date: 2014/01/30 15:30:01;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: client.c,v
Working file: client.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
Client program that sends a requests to server.
socket() system call is used to create a socket and display an error message if there is any issue.
—————————-
revision 1.3    locked by: root;
date: 2014/01/30 17:09:47;  author: root;  state: Exp;  lines: +4 -0
Header files:<sys/un.h>,<sys/types.h> and <sys/socket.h> is included.
—————————-
revision 1.2
date: 2014/01/30 17:07:49;  author: root;  state: Exp;  lines: +11 -1
connect() system call is used to send a request to the server.
A message will be displayed if there is an error.
Checking,,,,.
—————————-
revision 1.1
date: 2014/01/30 16:56:32;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Project 04: FTP based Client Server using Threads and Sockets | Leave a comment

Code to demonstrate how to register a signal handler using sigaction() for SIGINT signal.

RCS file: sigaction.c,v
Working file: sigaction.c
head: 1.5
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;    selected revisions: 5
description:
Code to establish a simple handler for termination signals using sigaction.
The signal handler will identify the action to be taken with the specified signal.
—————————-
revision 1.5
date: 2014/02/02 13:31:05;  author: root;  state: Exp;  lines: +1 -1
All the errors are fixed.
Issue:Header file is not included.
The program is working appropriately and in a way that is expected.
—————————-
revision 1.4
date: 2014/02/02 13:25:40;  author: root;  state: Exp;  lines: +1 -0
Header file:<signal.h> is included to support signal related functions….
—————————-
revision 1.3
date: 2014/02/02 13:21:51;  author: root;  state: Exp;  lines: +9 -0
Inside the body of the signal handler a message will be displayed that tells the user that SIGINT signal is received.
Checking….
—————————-
revision 1.2
date: 2014/02/02 13:17:07;  author: root;  state: Exp;  lines: +3 -0
Two structure variables are declared of type sigaction.
Signal handler is registered using sigaction() system call.
Defining the body of the signal handler……..
—————————-
revision 1.1
date: 2014/02/02 13:11:02;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Project 03: Client Server Communication using Linux and IPC | Leave a comment

how to install applications using .tar file ??

Posted in Uncategorized | Leave a comment

Implementation of MASTER ARRAY

Implementation of Master array. A special type of array without repetition of elements. —————————- revision 1.2 locked by: akshat; date: 2014/01/29 04:22:44; author: akshat; state: Exp; lines: +3 -3 implementation of master array using concept of pointers. —————————- revision 1.1 date: 2014/01/29 04:21:03; author: akshat; state: Exp; Initial revision =============================================================================

Posted in Uncategorized | Leave a comment

Implementing Semaphore in a single process by setting its initial value to ZERO

  • RCS file: test1.c,v
    Working file: test1.c
    head: 1.6
    branch:
    locks: strict
    raghav: 1.6
    access list:
    symbolic names:
    keyword substitution: kv
    total revisions: 6;    selected revisions: 6
    description:
    Implementing semaphore in a single process to check what if …we set the value of a semaphore directly to 0.
    —————————-
    revision 1.6    locked by: raghav;
    date: 2014/01/28 14:42:29;  author: raghav;  state: Exp;  lines: +3 -1
    Run the program and analyse its output by changing the semaphore from 0 to 1.
    —————————-
    revision 1.5
    date: 2014/01/28 14:36:22;  author: raghav;  state: Exp;  lines: +19 -0
    now. . write two statements in a program.. one before using the wait function and one after using the wait function.
    print the value of semaphore using GETVAL before using wait function.
    and print the value of semaphore using GETVAL after using wait function i.e. in critical reigon.
    make sure one thing if you’ve set the initial value of semaphore to ZERO, then it will not enter the critical region.
    —————————-
    revision 1.4
    date: 2014/01/28 14:16:51;  author: raghav;  state: Exp;  lines: +7 -1
    after creating the semaphore : set its value to 0(zero)
    —————————-
    revision 1.3
    date: 2014/01/28 10:39:02;  author: raghav;  state: Exp;  lines: +4 -0
    Second use a semctl function to set its value to 0 rather than 1, because we are checking what will happen if we directly set its value to 0
    —————————-
    revision 1.2
    date: 2014/01/28 10:37:18;  author: raghav;  state: Exp;  lines: +9 -0
    First creating a semaphore using a semget function .
    —————————-
    revision 1.1
    date: 2014/01/28 10:34:38;  author: raghav;  state: Exp;
    Initial revision
    =============================================================================
Posted in Uncategorized | Leave a comment

Charact. Device Driver- Synchronization Techniques

Completed Synchronizations Technique:

1. Semaphore

2. Mutex

3. RW_Semaphore

4. Completion

5. Spinlock

Posted in Character Driver | Tagged , | Leave a comment

process management

Assignment to Create a file ,Write into it, fork a child process , Use execl in the child process to call a new process , Read from the file in new process .

Status– Execution Successful

Posted in Uncategorized | Leave a comment

Testing Pipeling flow and wait command

Program is created. Forked the process . Goes to parent first , execute its command , WAIT system call used to go into child process. Child prints the system time and returns back to parent ending the wait status. preventing orphan situation. Program ended.

Testing Success!!

Posted in Uncategorized | Leave a comment