EmbLogic's Blog

logfile for mdc till 25 june 2015

RCS file: mdc.c,v
3 Working file: mdc.c
4 head: 1.5
5 branch:
6 locks: strict
7 access list:
8 symbolic names:
9 keyword substitution: kv
10 total revisions: 5;     selected revisions: 5
11 description:
12 Unique array and codelength areprinted using functions.
13 Functions are created using pointer
14 Memory is allocated using malloc.
15 Compression() not working
16 header.h is created.
17 —————————-
18 revision 1.5
19 date: 2015/06/26 13:10:19;  author: emblogic;  state: Exp;  lines: +3 -1
20 Recreate the master array using realloc().
21 —————————-
22 revision 1.4
23 date: 2015/06/26 12:44:33;  author: emblogic;  state: Exp;  lines: +11 -11
24 compression function is made a comment.
25 —————————-
26 revision 1.3
27 date: 2015/06/26 11:41:54;  author: emblogic;  state: Exp;  lines: +3 -3
28 Unique array is save using command line.
29 —————————-
revision 1.2
31 date: 2015/06/26 11:37:13;  author: emblogic;  state: Exp;  lines: +7 -7
32 Command line argument of file1 created
33 —————————-
34 revision 1.1
35 date: 2015/06/26 11:26:27;  author: emblogic;  state: Exp;
36 Initial revision
37 =============================================================================

Posted in Data Structures with C | Leave a comment

MDC project

Working file: comperession.c
head: 1.1
branch:
locks: strict
emblogic-19: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;     selected revisions: 1
description:
compress the master array
—————————-
revision 1.1    locked by: emblogic-19;
date: 2002/01/01 03:35:03;  author: emblogic-19;  state: Exp;
Initial revision

 

 

RCS file: mdc.c,v
Working file: mdc.c
head: 1.2
branch:
locks: strict
emblogic-19: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;     selected revisions: 2
description:
creating master arrary using pointer
—————————-
revision 1.2    locked by: emblogic-19;
date: 2002/01/01 03:33:08;  author: emblogic-19;  state: Exp;  lines: +21 -18
capturing the compression file
—————————-
revision 1.1
date: 2002/01/01 01:23:25;  author: emblogic-19;  state: Exp;
Initial revision

 

 

RCS file: header.h,v
Working file: header.h
head:
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 0
description:
enter the all prototype

Posted in Project 2: Multiple Data Compression and Encryption | Leave a comment

MDC project work

RCS file: mdc.c,v
Working file: mdc.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
implemented using pointes,but without using functions.
—————————-
revision 1.3    locked by: root;
date: 2015/06/25 11:59:18;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.2
date: 2015/06/25 11:19:40;  author: root;  state: Exp;  lines: +1 -1
taking input via command line arguments.
—————————-
revision 1.1
date: 2015/06/25 10:39:09;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

MDC Project

Learnt to use GDB debugger and source code control commands – RCS. Also we got to know that how to include an externally defined function into the main file

Posted in Project 2: Multiple Data Compression and Encryption, Uncategorized | Leave a comment

pointer

difference b\w *a[5]&*(a[5])?

 

 

Posted in Uncategorized | Leave a comment

pointer

I am enjoying  to attempt my pointer assignment.

Posted in Uncategorized | Leave a comment

Array

Arrray is containe multiple value with same data type and contain continuous address.
E.g.if we consider a[10] then it take 0 to 9 continuous address.

Posted in Uncategorized | Leave a comment

mdc project

we discuss in class about the  multiple data compression  project with revision control  system & gbd.

Posted in Uncategorized | Leave a comment

MDCAEUIT

Created masterarray and found the code length for the text file.

Posted in Uncategorized | Leave a comment

Semaphore Vs Mutex

Mutex is locking mechanism used to synchronize access to a resource. Only one task ( thread or process ) can acquire the mutex. It means there will be ownership associated with mutex, and only the owner can release the lock. Mutex is a key to a changing room. One person can have the key occupy the changing room at the time. When finished, the person gives (release) the key to the next person in the queue.

Semaphore is wait signal mechanism. A semaphore is a way to limit the number of tasks that can simultaneously operate on a shared resource. Semaphores is the number of identical room keys.we have four room with identical locks and keys. The semaphore count , the count of keys is set to 4 at beginning (all four rooms are free), then the count value is decremented as people are coming in. If all rooms are full, there are no free keys left, the semaphore count is 0. Now, when one person leaves the room, semaphore is increased to 1 (one free key), and given to the next person in the queue.

Posted in Uncategorized | Leave a comment

Socket

Socket is an end point communication between two systems on a network. Socket is a combination of IP address an port on one system.

socket(int domain, int type, int protocol) => creates an unnamed socket inside the kernel and returns an integer known as socket descriptor.

1st arg. – takes domain/family for internet family of IPv4 addresses. we use AF_INET.

2nd arg. – they are of two types -

SOCK_STREAM

SOCK_DGRAM

3rd arg. – generally left ’0′. to let the kernel decides the default protocol to use for this connection.

Various system calls used in socket() are :

bind(int sockfd, const struct sockaddr *addr,  socklen_t addrlen);

listen(int sockfd, int backlog);

connect(int sockfd, const struct sockaddr *addr,  socklen_t addrlen);

accept(int sockfd, const struct sockaddr *addr,  socklen_t addrlen);

bind(), connect() and accept() are same but there is a difference i.e. :

bind() and connect() have server sockfd and server address

accept() have server sockfd and client address

 

Posted in Uncategorized | Leave a comment

Socket

Socket is a communication mechanism between two process.These process could be in the same system or different system.It is also known as end point of networking.
Socket provide interfacing between the network and the application on the system.Socket is very similar to the pipe,But PIPE has file descriptor on both side,whereas Socket has file descriptor on one end and Network interface on the other side.Socket file descriptor can not be shared with other process.Also,Pipe is used to provide communication between the two process on the same system.
There are two types of Socket:
1.SOCK_STREAM:
*It is reliable.
*Connection oriented.
*Guarantee data transfer.
*Maximum data transfer.

2.SOCK_DGRAM:
*Not reliable.
*Connectionless.
*Short data transfer.
*Data may be lost.

Various system call used in socket are:
int socket(int domain,int type,int protocol);
int bind(int sockfd,(struct sockaddr *)&addr,size_t addr_len);
int listen(int sockfd,int backlog);
int accept(int sockfd,struct sockaddr *addr,size_t *addrlen);
int connect(int sockfd,struct sockaddr *addr,size_t addr_len);

Posted in Uncategorized | Leave a comment

POSIX THREADS: BRIEF INTRODUCTION

Threads,Like processes are a mechanism to allow a program to do more than one thing at a time.As with processes,threads appear to run concurrently;the linux kernel schedules them asynchronously,interrupting each thread from time to time to give others a chance to execute.We can control the threads using various mechanism which we will discuss later.

Conceptually,a thread exists within a process.When we invoke a program,Linux creates a new process and in that process creates a single thread,which runs the program sequentially.That thread can create additional threads ; all these threads run the same program in the same process,but each thread may be executing a different part of the program at any given time.We can say sequence of execution is a thread.

When a program creates another thread,the creating and the created thread share the same memory space,file descriptors except a local stack is created for individual threads. If one thread changes the value of a variable ,for instance,the other thread subsequently will see the modified value.If one thread closes file descriptor the other threads may not be able to write or read to that file descriptor.If any thread inside a process calls one of the exec functions,all the other threads are ended(the new program may,of course create new threads).

The pthread_create() function creates a new thread.You can refer to man pages about pthread_create().We have to include <pthread.h> header file .A call to pthread_create() returns immediately and the original thread continues executing the instructions following the call.Meanwhile , the new thread begins executing the thread function.Linux schedules both threads asynchronously.

Under normal circumstances, a thread exits in one othe two ways.One way is by returning from the thread function.The return value from the thread function is taken to the return value of the thread.Alternatively,a thread can exit explicitly by calling pthread_exit().This function may be called form within the thread function.The argument to pthread_exit() is the thread’s return value.

We can retrieve the thread exit status using pthread_join().The pthread_join() function shall suspend execution of the calling thread until the target thread terminates, unless the target thread has already terminated. On return from a successful pthread_join(),  the value passed to pthread_exit() by the terminating thread shall be made available in the location referenced to pthread_join().When a pthread_join() returns successfully, the target thread has been terminated.

There are signals to control the threads.The pthread_kill() function requests that the signal to be delivered to the specified thread. The signal to be sent is specified by signal number and is either zero or one of the signals from the list of defined signals in the <signal.h> header file. If signal number is zero, error checking is performed, but no signal is sent to the target thread.

It returns 0 on success and a non zero value if pthread_kill() is unsuccessful.That non zero value is to check the error condition.One thing has to be made sure that the signal registration should be done in both the threads i.e the thread which is giving the signal and the target thread which will be killed.

P.S: Refer to man pages related to the arguments and the return values of the functions listed above.

Posted in Uncategorized | Leave a comment

Create the node, open it and open & release the devices

RCS file: header.h,v
Working file: header.h
head: 1.14
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 14; selected revisions: 14
description:
this is basic header file
—————————-
revision 1.14
date: 2015/05/07 07:48:45; author: root; state: Exp; lines: +1 -1
gave the prototype for scull_trim()
—————————-
revision 1.13
date: 2015/05/07 07:47:51; author: root; state: Exp; lines: +1 -1
declare the prototype for open_dev & close_dev
—————————-
revision 1.12
date: 2015/05/06 13:59:14; author: root; state: Exp; lines: +31 -35
*** empty log message ***
—————————-
revision 1.11
date: 2015/05/06 11:32:13; author: root; state: Exp; lines: +2 -2
*** empty log message ***
—————————-
revision 1.10
date: 2015/05/06 11:29:40; author: root; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.9
date: 2015/05/06 11:26:56; author: root; state: Exp; lines: +9 -0
*** empty log message ***
—————————-
revision 1.8
date: 2015/04/27 10:24:14; author: root; state: Exp; lines: +21 -0
declare marcos for quantum size, qset size, data size, device size
also declare these variables in struct Dev
—————————-
revision 1.7
date: 2015/04/24 13:43:07; author: root; state: Exp; lines: +1 -0
*** empty log message ***
—————————-
revision 1.6
date: 2015/04/24 13:38:51; author: root; state: Exp; lines: +1 -0
*** empty log message ***
—————————-
revision 1.5
date: 2015/04/24 13:32:14; author: root; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.4
date: 2015/04/24 12:55:42; author: root; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.3
date: 2015/04/24 12:52:22; author: root; state: Exp; lines: +14 -0
declare struct Qset, struct Dev
—————————-
revision 1.2
date: 2015/04/24 11:42:31; author: root; state: Exp; lines: +20 -1
included moduleparan.h & slab.h
—————————-
revision 1.1
date: 2015/04/24 05:20:37; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: file_operations.h,v
Working file: file_operations.h
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
this is basic header file for file operations
—————————-
revision 1.3
date: 2015/05/07 08:05:53; author: root; state: Exp; lines: +1 -1
map close_dev with release
—————————-
revision 1.2
date: 2015/05/07 08:04:10; author: root; state: Exp; lines: +1 -1
declare a structure struct file_operations
map open_dev with open
—————————-
revision 1.1
date: 2015/05/07 08:03:44; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: init.c,v
Working file: init.c
head: 1.12
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 12; selected revisions: 12
description:
this is driver intialisation file
—————————-
revision 1.12
date: 2015/05/06 13:59:15; author: root; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.11
date: 2015/04/27 10:36:47; author: root; state: Exp; lines: +2 -2
*** empty log message ***
—————————-
revision 1.10
date: 2015/04/27 10:34:46; author: root; state: Exp; lines: +2 -1
*** empty log message ***
—————————-
revision 1.9
date: 2015/04/27 10:25:49; author: root; state: Exp; lines: +46 -17
for new device use register_chrdev_region()
intialize all device i.e. nod=20
add all device
—————————-
revision 1.8
date: 2015/04/24 13:40:59; author: root; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.7
date: 2015/04/24 13:32:16; author: root; state: Exp; lines: +6 -1
*** empty log message ***
—————————-
revision 1.6
date: 2015/04/24 12:52:59; author: root; state: Exp; lines: +11 -0
allocating memory using kmalloc()
—————————-
revision 1.5
date: 2015/04/24 11:58:00; author: root; state: Exp; lines: +1 -1
use module parameter using module_param()
—————————-
revision 1.4
date: 2015/04/24 11:43:06; author: root; state: Exp; lines: +14 -2
intialise driver using alloc_chrdev_region()
—————————-
revision 1.3
date: 2015/04/24 05:32:26; author: root; state: Exp; lines: +3 -3
register the driver
—————————-
revision 1.2
date: 2015/04/24 05:24:42; author: root; state: Exp; lines: +3 -3
intialize driver using __init func
—————————-
revision 1.1
date: 2015/04/24 05:20:49; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: clean.c,v
Working file: clean.c
head: 1.7
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 7; selected revisions: 7
description:
this is driver cleanup file
—————————-
revision 1.7
date: 2015/04/27 10:27:17; author: root; state: Exp; lines: +8 -2
clean all devices
—————————-
revision 1.6
date: 2015/04/24 13:32:17; author: root; state: Exp; lines: +1 -0
*** empty log message ***
—————————-
revision 1.5
date: 2015/04/24 12:53:37; author: root; state: Exp; lines: +1 -0
free memory using kfree()
—————————-
revision 1.4
date: 2015/04/24 11:44:00; author: root; state: Exp; lines: +1 -1
unregister the driver using unregister_chrdev_region()
—————————-
revision 1.3
date: 2015/04/24 05:33:04; author: root; state: Exp; lines: +1 -1
unregister the driver
—————————-
revision 1.2
date: 2015/04/24 05:25:51; author: root; state: Exp; lines: +1 -1
cleanup the driver using __exit func
—————————-
revision 1.1
date: 2015/04/24 05:21:08; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: writer.c,v
Working file: writer.c
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
—————————-
revision 1.2
date: 2015/05/07 08:35:22; author: root; state: Exp; lines: +1 -1
this program deals with application
here we can open the node using open command to get the fd
—————————-
revision 1.1
date: 2015/05/06 11:27:09; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: open_dev.c,v
Working file: open_dev.c
head: 1.4
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 4; selected revisions: 4
description:
—————————-
revision 1.4
date: 2015/05/07 08:26:22; author: root; state: Exp; lines: +0 -1
call a func scull_trim to flush the data from device
—————————-
revision 1.3
date: 2015/05/07 08:15:24; author: root; state: Exp; lines: +0 -1
this is the program for open the devices
points the scull_dev * to offset of 2nd device
—————————-
revision 1.2
date: 2015/05/06 13:59:16; author: root; state: Exp; lines: +7 -6
*** empty log message ***
—————————-
revision 1.1
date: 2015/05/06 11:27:13; author: root; state: Exp;
Initial revision
=============================================================================

RCS file: close_dev.c,v
Working file: close_dev.c
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
—————————-
revision 1.3
date: 2015/05/07 07:51:41; author: root; state: Exp; lines: +1 -1
this is a simple program for closing the device
—————————-
revision 1.2
date: 2015/05/06 13:59:17; author: root; state: Exp; lines: +2 -2
*** empty log message ***
—————————-
revision 1.1
date: 2015/05/06 11:27:14; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Character Driver, Device Drivers | Leave a comment

Quick Sort using recursion

RCS file: quick_sort.c,v
Working file: quick_sort.c
head: 1.2
branch:
locks: strict
vishal: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
Sorting the array using quick sort technique and recursive function.
—————————-
revision 1.2 locked by: vishal;
date: 2015/05/01 07:33:45; author: vishal; state: Exp; lines: +36 -29
Change the pivot index, make it constant with default value init.
Also change the temination condition of the recursion.
That is if last is less then or equal to init function will return value.
—————————-
revision 1.1
date: 2015/04/28 15:18:30; author: vishal; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment