EmbLogic's Blog

Character Device Driver : Semaphore

implementation of  semaphore in kernel.

There are using three application at user level.

In 1st application three threads using for Open,Write and close.

in 2nd application three threads using for Open,read and close.

And last application is same as 2nd app.

thread semaphore is also used for synchronize the operation in every single application.

At Kernel level: when file open in Read-only mode it wait for completion of write operation then after semaphore release to access by both reader.

 

 

Posted in Uncategorized | Leave a comment

pipe-string of data is read.

RCS file: ./writer.c,v
Working file: ./writer.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
pipe is created.
child process is generated by using fork().
—————————-
revision 1.3    locked by: root;
date: 2014/03/07 12:56:56;  author: root;  state: Exp;  lines: +4 -5
now string is written into the parent process.
replaced %c to %s.
—————————-
revision 1.2
date: 2014/03/07 12:34:24;  author: root;  state: Exp;  lines: +3 -1
written a character into parent process.
—————————-
revision 1.1
date: 2014/03/07 12:31:35;  author: root;  state: Exp;
Initial revision
RCS file: ./reader.c,v
Working file: ./reader.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
fd is passed from parent to child.
—————————-
revision 1.3    locked by: root;
date: 2014/03/07 12:58:09;  author: root;  state: Exp;  lines: +3 -3
reading a string from the parent process.
replaced %c to %s in printf statement.
—————————-
revision 1.2
date: 2014/03/07 12:35:23;  author: root;  state: Exp;  lines: +0 -1
read a character from the parent process.
c
—————————-
revision 1.1
date: 2014/03/07 12:32:20;  author: root;  state: Exp;
Initial revision

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

Pipes

RCS file: ./writer.c,v
Working file: ./writer.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
pipe is created.
child process is generated by using fork().
—————————-
revision 1.2    locked by: root;
date: 2014/03/07 12:34:24;  author: root;  state: Exp;  lines: +3 -1
written a character into parent process.
—————————-
revision 1.1
date: 2014/03/07 12:31:35;  author: root;  state: Exp;
Initial revision
RCS file: ./reader.c,v
Working file: ./reader.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
fd is passed from parent to child.
—————————-
revision 1.2    locked by: root;
date: 2014/03/07 12:35:23;  author: root;  state: Exp;  lines: +0 -1
read a character from the parent process.
c
—————————-
revision 1.1
date: 2014/03/07 12:32:20;  author: root;  state: Exp;
Initial revision
RCS file: ./reader.c,v
Working file: ./reader.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
fd is passed from parent to child.
—————————-
revision 1.2    locked by: root;
date: 2014/03/07 12:35:23;  author: root;  state: Exp;  lines: +0 -1
read a character from the parent process.
c
—————————-
revision 1.1
date: 2014/03/07 12:32:20;  author: root;  state: Exp;
Initial revision

 

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

Creating a pipe

RCS file: ser.c,v
Working file: ser.c
head: 1.5
branch:
locks: strict
akshat: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5; selected revisions: 5
description:
IPC- INTERPROCESS COMMUNICATION, communication btw two processes invoking a fork call and then hijacking that child process for one way communication.
—————————-
revision 1.5 locked by: akshat;
date: 2014/03/07 16:47:34; author: akshat; state: Exp; lines: +6 -6
using wait statement for parent, process not hanged.
pipe created successfully.
—————————-
revision 1.4
date: 2014/03/07 16:43:15; author: akshat; state: Exp; lines: +11 -7
its working, but process hangs.
checking for it.
—————————-
revision 1.3
date: 2014/03/07 16:31:13; author: akshat; state: Exp; lines: +4 -2
lets see if its working
—————————-
revision 1.2
date: 2014/03/07 16:28:02; author: akshat; state: Exp; lines: +9 -3
pipe is formed.
client is formed by hijacking the child.
—————————-
revision 1.1
date: 2014/03/07 15:21:25; author: akshat; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Rotating a single linked list by k-nodes in counter-clockwise direction in C language.

RCS file: rotate_linked_list.c,v
Working file: rotate_linked_list.c
head: 1.14
branch:
locks: strict
root: 1.14
access list:
symbolic names:
keyword substitution: kv
total revisions: 14;    selected revisions: 14
description:
Code to demonstrate how to rotate the single linked list counter clockwise by k-nodes.
—————————-
revision 1.14    locked by: root;
date: 2014/03/07 15:23:54;  author: root;  state: Exp;  lines: +2 -1
Status : Rotating a single linked list in the counter-clockwise direction by k-nodes where k is any number less than the total number of nodes in the linked list is implemented successfully.

Previous Issues:
1.After rotating the list by k-nodes the last node is not getting displayed because the start node is not returned and collected correctly.
2.Prototype mismatch.
All these issues are identified and fixed.
—————————-
revision 1.13
date: 2014/03/07 15:14:58;  author: root;  state: Exp;  lines: +25 -5
Implemented the rotate_list() function and fixed the errors by changing the prototype.
—————————-
revision 1.12
date: 2014/03/07 14:54:00;  author: root;  state: Exp;  lines: +12 -2
Changed the prototype of the display_nodes() function to int.A count variable is used to count the number of nodes in the linked list.
—————————-
revision 1.11
date: 2014/03/07 14:50:07;  author: root;  state: Exp;  lines: +1 -0
Gave prototype of the rotate_list() function.
—————————-
revision 1.10
date: 2014/03/07 14:35:45;  author: root;  state: Exp;  lines: +10 -0
Status : display_nodes() function is working fine.
Added \n to make the output of the display_nodes() function more readable.
—————————-
revision 1.9
date: 2014/03/07 14:30:05;  author: root;  state: Exp;  lines: +7 -0
Gave prototype of the display_nodes() function.Before calling the display_nodes() function a check is made to ensure whether linked list already exists or not.
Implementing the display_nodes() function…….
—————————-
revision 1.8
date: 2014/03/07 14:25:56;  author: root;  state: Exp;  lines: +1 -0
Logical error fixed.
Issue:A pointer variable of type struct node is not declared but used.
—————————-
revision 1.7
date: 2014/03/07 14:24:15;  author: root;  state: Exp;  lines: +25 -0
Gave prototype for insert_node() function.Also gave the definition of the insert_node() function which will insert the node at the end of the single linked list.
—————————-
revision 1.6
date: 2014/03/07 14:16:54;  author: root;  state: Exp;  lines: +21 -2
Gave definition of the create_list() function.Declared a flag variable that on creation of a start node is set to 1 and thus it avoids to create the start node again in case the user accidently chooses the create_list option again.
—————————-
revision 1.5
date: 2014/03/07 14:12:30;  author: root;  state: Exp;  lines: +11 -0
Declared two pointer variables of type struct node.
—————————-
revision 1.4
date: 2014/03/07 14:10:12;  author: root;  state: Exp;  lines: +1 -0
Gave prototype for create_list() function.
Defining the body of the create_list() function…..
—————————-
revision 1.3
date: 2014/03/07 14:08:18;  author: root;  state: Exp;  lines: +17 -0
exit() function is used to assist in ending the program.
Also included header file:<stdlib.h> to support exit() function.
—————————-
revision 1.2
date: 2014/03/07 14:01:19;  author: root;  state: Exp;  lines: +12 -1
Created a main menu for the user to assist him/her in performing the operations on a single linked list.
—————————-
revision 1.1
date: 2014/03/07 13:29:12;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C | Leave a comment

Implementation of a generic double linked list in C.

RCS file: generic_double_linkedlist.c,v
Working file: generic_double_linkedlist.c
head: 1.15
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 15;    selected revisions: 15
description:
Code to demonstrate how to implement create , insert , display and delete operations in a double linked list.
—————————-
revision 1.15
date: 2014/03/07 12:33:11;  author: root;  state: Exp;  lines: +2 -0
Status : Double linked list implementation is done successfully.
—————————-
revision 1.14
date: 2014/03/07 12:30:01;  author: root;  state: Exp;  lines: +1 -1
Syntax error fixed.
—————————-
revision 1.13
date: 2014/03/07 12:28:13;  author: root;  state: Exp;  lines: +25 -1
Implemented delete_nodes() function that will delete the entire double linked list.
Checking…
—————————-
revision 1.12
date: 2014/03/07 04:04:35;  author: root;  state: Exp;  lines: +6 -0
A check is made by printing an appropriate message in case the user chooses the display_nodes() function while there is no nodes in the double linked list.
—————————-
revision 1.11
date: 2014/03/07 04:01:33;  author: root;  state: Exp;  lines: +4 -0
Optimized the code by performing a break in the display_nodes when end->prev==NULL
Implementing the code to delete all the nodes in the double linked list.
—————————-
revision 1.10
date: 2014/03/07 03:57:33;  author: root;  state: Exp;  lines: +34 -2
display_nodes() function implemented for a double linked list.The display_nodes() function asks the user to print the nodes in the double linked list in forward order using the start pointer and it also asks the user to print the nodes in the double linked list in reverse order using the new poiner which always points to the lst node of the double linked list.
Status : display_nodes() function is implemented successfully.
—————————-
revision 1.9
date: 2014/03/07 03:17:03;  author: root;  state: Exp;  lines: +3 -3
Prototype mismatch error occured , bug fixed.
—————————-
revision 1.8
date: 2014/03/07 03:09:10;  author: root;  state: Exp;  lines: +25 -0
Gave prototypes for insert_info() and insert_node() functions.After calling the insert_node() function a node gets created and is inserted at the end of the list.
—————————-
revision 1.7
date: 2014/03/07 03:00:11;  author: root;  state: Exp;  lines: +8 -0
gave definition of the create_list() function.
Status:The start node of the double linked list is created successfully.
—————————-
revision 1.6
date: 2014/03/07 02:52:13;  author: root;  state: Exp;  lines: +1 -0
Gave prototype for create_list() function.
—————————-
revision 1.5
date: 2014/03/07 02:49:53;  author: root;  state: Exp;  lines: +18 -1
Declared two variables of type struct node and both are initialized to NULL.
Also called the create_list() function to create the start node of the double linked list.
—————————-
revision 1.4
date: 2014/03/07 02:44:08;  author: root;  state: Exp;  lines: +6 -0
A structure called node is defined with three member fields namely :
1.info part,
2.a pointer to the next node of type struct node
3.a pointer to the previous node.
—————————-
revision 1.3
date: 2014/03/07 02:42:07;  author: root;  state: Exp;  lines: +20 -0
Header file:<stdlib.h> is included to support exit() function.
—————————-
revision 1.2
date: 2014/03/07 02:36:55;  author: root;  state: Exp;  lines: +9 -0
A layout is prepared for the user that will help in selecting a specific task on a double linked list.
—————————-
revision 1.1
date: 2014/03/07 01:56:03;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Data Structures with C | Leave a comment

Insertion Sort Algo

RCS file: prog7.c,v
Working file: prog7.c
head: 1.7
branch:
locks: strict
akshat: 1.7
access list:
symbolic names:
keyword substitution: kv
total revisions: 7;    selected revisions: 7
description:
Insertion sorting
One element is taken and compared with other elements of sorted array, its position is given accordingly.
—————————-
revision 1.7    locked by: akshat;
date: 2014/03/07 05:14:36;  author: akshat;  state: Exp;  lines: +1 -1
Insertion done at first point also.
—————————-
revision 1.6
date: 2014/03/07 04:12:43;  author: akshat;  state: Exp;  lines: +9 -6
*** empty log message ***
—————————-
revision 1.5
date: 2014/03/07 03:58:20;  author: akshat;  state: Exp;  lines: +16 -7
checking for correct logic.
—————————-
revision 1.4
date: 2014/03/07 02:22:32;  author: akshat;  state: Exp;  lines: +2 -1
yeah! its working with 5 3 4 12 8 10
—————————-
revision 1.3
date: 2014/03/07 02:14:56;  author: akshat;  state: Exp;  lines: +2 -5
insertion sort is one in which element before entering in sorted array is compared with values present inside the array and placed accordingly.
—————————-
revision 1.2
date: 2014/03/07 02:03:31;  author: akshat;  state: Exp;  lines: +4 -0
malloc library warning.
—————————-
revision 1.1
date: 2014/03/07 02:02:14;  author: akshat;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Waiting for a process by giving atexit is done.

RCS file: ./wait1.c,v
Working file: ./wait1.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
waiting for a process is done successfuly.
—————————-
revision 1.3    locked by: root;
date: 2014/03/06 18:46:20;  author: root;  state: Exp;  lines: +1 -0
syntax error is removed.
—————————-
revision 1.2
date: 2014/03/06 18:44:07;  author: root;  state: Exp;  lines: +5 -0
atexit is called by function name ruchi.
—————————-
revision 1.1
date: 2014/03/06 18:38:15;  author: root;  state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

fork

fork is an operation or a process which creates a copy of itself. It is usually a system call, implemented in the kernel. Fork is the primary method of process creation on Unix-like operating systems.

  • If fork() returns a negative value, the creation of a child process was unsuccessful.
  • fork() returns a zero to the newly created child process.
  • fork() returns a positive value, the process ID of the child process, to the parent. The returned process ID is of type pid_t defined in sys/types.h. Normally, the process ID is an integer. Moreover, a process can use function getpid() to retrieve the process ID assigned to this process.

Due to the fact that the CPU scheduler will assign a particular time to each process, the parent or the child process will run for some time.After the calling of system call FORK the program counter of both will run simultaneously.

Posted in Data Structures with C | Leave a comment

Fork duplicacy

RCS file: 1.c,v
Working file: 1.c
head: 1.20
branch:
locks: strict
akshat: 1.20
access list:
symbolic names:
keyword substitution: kv
total revisions: 20;    selected revisions: 20
description:
IPC process basic.
Working of fork.
—————————-
revision 1.20    locked by: akshat;
date: 2014/03/06 06:19:38;  author: akshat;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.19
date: 2014/03/06 06:08:13;  author: akshat;  state: Exp;  lines: +25 -36
exit function call for controlling orphan.
—————————-
revision 1.18
date: 2014/03/06 05:55:18;  author: akshat;  state: Exp;  lines: +28 -3
Exit call to check status value and use of macros.
—————————-
revision 1.17
date: 2014/03/06 05:24:24;  author: akshat;  state: Exp;  lines: +1 -1
exit code defined.
—————————-
revision 1.16
date: 2014/03/06 05:14:24;  author: akshat;  state: Exp;  lines: +2 -3
wait call worked, child is under control of parent.
—————————-
revision 1.15
date: 2014/03/06 05:03:29;  author: akshat;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.14
date: 2014/03/06 04:58:20;  author: akshat;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.13
date: 2014/03/06 04:57:17;  author: akshat;  state: Exp;  lines: +1 -0
library sys/wait used.
—————————-
revision 1.12
date: 2014/03/06 04:51:06;  author: akshat;  state: Exp;  lines: +3 -2
pid_wait pauses the parent process until child process finishes executing.
pid_wait return pid of child process that is terminated.
it contains a pointer that points to the location where exit code is returned and stored.
—————————-
revision 1.11
date: 2014/03/06 04:44:25;  author: akshat;  state: Exp;  lines: +2 -2
zombie and orphan process should be avoided.
wait statement is used.
—————————-
revision 1.10
date: 2014/03/06 04:40:58;  author: akshat;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.9
date: 2014/03/06 04:39:50;  author: akshat;  state: Exp;  lines: +1 -1
sleep(1) for giving 1 sec delay.
—————————-
revision 1.8
date: 2014/03/06 04:39:26;  author: akshat;  state: Exp;  lines: +0 -1
*** empty log message ***
—————————-
revision 1.7
date: 2014/03/06 04:38:43;  author: akshat;  state: Exp;  lines: +2 -0
pause of 1 sec given.
—————————-
revision 1.6
date: 2014/03/06 04:31:39;  author: akshat;  state: Exp;  lines: +2 -2
Fork is used to provide duplicacy.
—————————-
revision 1.5
date: 2014/03/06 04:23:37;  author: akshat;  state: Exp;  lines: +1 -0
Zombie process is one in which child is terminated earlier.
Orphan process is one in which parent is terminated earlier. In orphan process child has no pa.
adopted by init1.
—————————-
revision 1.4
date: 2014/03/06 04:22:19;  author: akshat;  state: Exp;  lines: +4 -4
checking of zombie or orphan process.
—————————-
revision 1.3
date: 2014/03/06 04:21:26;  author: akshat;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.2
date: 2014/03/06 04:20:38;  author: akshat;  state: Exp;  lines: +1 -0
Lets see if its working.
—————————-
revision 1.1
date: 2014/03/06 04:19:57;  author: akshat;  state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

Function is invoked on process exit time using at_exit().

RCS file: ./atexit.c,v
Working file: ./atexit.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
function is invoked on process exit time using at_exit().
—————————-
revision 1.1    locked by: root;
date: 2014/03/05 16:34:21;  author: root;  state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

Duplicating a process

RCS file: ./message.c,v
Working file: ./message.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
duplicating of a process.
—————————-
revision 1.1    locked by: root;
date: 2014/03/05 15:40:46;  author: root;  state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

Module code showing the difference between *loff and filep->f_pos when multiple write() system calls are issued by the application.

 

Difference between loff_t *loff and filep->f_pos:

When an application issues write() system call , chardev_write() function is called because it is mapped to (*write) function pointer.chardev_write() function contains 4 arguments namely:

1. A pointer to the struct file structure.

2.A pointer to the buffer in the user space.

3.Size of the data

4.Used for internal book-keeping.

Initially both filep->f_pos and *loff are 0.Only  *loff is updated with the number of characters successfully written whereas filep->f_pos remains at position 0.Now whenever an application issues another write() call without closing the file , the value of *loff is copied to filep->f_pos.After the file is closed both the filep->f_pos and the *loff are set to 0.
RCS file: writef.c,v
Working file: writef.c
head: 1.40
branch:
locks: strict
root: 1.40
access list:
symbolic names:
keyword substitution: kv
total revisions: 40;    selected revisions: 40
description:
chardev_write() function reside here.
—————————-
revision 1.40    locked by: root;
date: 2014/03/05 14:15:21;  author: root;  state: Exp;  lines: +6 -1
Updated loff while changing the nocsw.
Status : loff is getting updated successfully and is pointing to the current position.
—————————-
revision 1.39
date: 2014/03/05 14:10:54;  author: root;  state: Exp;  lines: +1 -1
Fixed the warning by typecasting loff_t to int.
—————————-
revision 1.38
date: 2014/03/05 14:08:44;  author: root;  state: Exp;  lines: +7 -2
Gave two printk() statements to check the starting values of filep->f_pos and loff.
Checking………….
—————————-
revision 1.37
date: 2014/03/04 18:55:04;  author: root;  state: Exp;  lines: +0 -21
Status : Writing in multiple qsets is successfully implemented.

Issue:The data pointer to the qset array was updated to point to the last qset array.Because of this reason the crash is taking place.
Bug fixed.
—————————-
revision 1.36
date: 2014/03/04 18:43:52;  author: root;  state: Exp;  lines: +18 -4
Input/output crash is taking place.
Debugging…..
—————————-
revision 1.35
date: 2014/03/04 07:36:31;  author: root;  state: Exp;  lines: +3 -1
Logical error fixed.
Issue : flag variable is not set to 1 due to which it is not able to link the scullqsets.
—————————-
revision 1.34
date: 2014/03/04 07:21:30;  author: root;  state: Exp;  lines: +7 -2
Declared a count variable inside create_scullqset() function too to make sure that exactly how many scullqsets are created.
The number of scullqsets are properly created inside the create_scullqset() function,but inside the chardev_write() it is showing 1 only same is the case with qset_arrays.
—————————-
revision 1.33
date: 2014/03/04 07:16:19;  author: root;  state: Exp;  lines: +10 -6
The messages inside two error conditions are changed to make them more meaningful.Also declared a count variable to make sure exactly how many qset arrays are exactly created by the create_qset() function.
—————————-
revision 1.32
date: 2014/03/04 07:10:31;  author: root;  state: Exp;  lines: +5 -1
Kernel crash taking place.The second qset array is not getting created or linked properly.
Debugging….
—————————-
revision 1.31
date: 2014/03/04 07:05:36;  author: root;  state: Exp;  lines: +30 -33
Properly placing the debugging statements to help finding out the error quickly.
—————————-
revision 1.30
date: 2014/03/03 23:19:07;  author: root;  state: Exp;  lines: +33 -2
Logical error fixed.
Issue:Kernel is crashing while running the module code.The problem lies in the check statement where the dereferencing of NULL pointer is taking placing.
—————————-
revision 1.29
date: 2014/03/03 22:58:55;  author: root;  state: Exp;  lines: +5 -2
Declared a pointer variable of type struct Scullqset to verify whether the number of scullqsets , qset arrays and quantums are actually created or not.
—————————-
revision 1.28
date: 2014/03/03 22:22:42;  author: root;  state: Exp;  lines: +11 -1
A check is made to move to the next lscullqset when the loop variable i equals to 7.Also a loop variable j is used to break the loop when the j becomes equal to noq variable.
Checking………….
—————————-
revision 1.27
date: 2014/03/03 22:17:47;  author: root;  state: Exp;  lines: +9 -6
Optimized the code by allocating the exact number of bytes required for each quantum.
—————————-
revision 1.26
date: 2014/03/03 21:58:52;  author: root;  state: Exp;  lines: +34 -10
Modified the create_qset() function to create the required number of qset arrays.
—————————-
revision 1.25
date: 2014/03/03 21:05:42;  author: root;  state: Exp;  lines: +3 -0
Declared a variable lscullqset of type struct Scullqset and it is initialized with fsculldev->scullqset.
This is done inside create_qset().
—————————-
revision 1.24
date: 2014/03/03 20:59:42;  author: root;  state: Exp;  lines: +2 -1
Logical error fixed.
Issue:kernel crash is taking place because the starting address of the lscullqset is not saved inside fsculldev->scullqset due to which while creating qset arrays it is not getting updated lscullqset address from fsculldev->scullqset.
—————————-
revision 1.23
date: 2014/03/03 20:53:32;  author: root;  state: Exp;  lines: +1 -1
While compilation a warning is coming indicating mixed declerations.
fixed the warning by placing all the declerations above the initializations.
—————————-
revision 1.22
date: 2014/03/03 20:52:17;  author: root;  state: Exp;  lines: +15 -0
Linking between lscullqsets is done.
Checking………….
—————————-
revision 1.21
date: 2014/03/03 20:44:14;  author: root;  state: Exp;  lines: +19 -11
Modifying the code so that writing in multiple qset arrays can be performed.
A flag variable is used to keep track on the number of scullqsets and with the help of this variable linking in lscullqset is also done.
—————————-
revision 1.20
date: 2014/03/03 20:38:05;  author: root;  state: Exp;  lines: +3 -0
Declared a structure variable lscullqset of type struct Scullqset.
—————————-
revision 1.19
date: 2014/03/03 19:00:50;  author: root;  state: Exp;  lines: +2 -2
Status : Writing in multiple quantums is successfully done.

Previous Issues:
1.Allocating memory for qset array incorrectly.
2.Wrongly calculating the number of qset arrays.
Such logical errors are identified and corrected successfully.
—————————-
revision 1.18
date: 2014/03/03 18:55:17;  author: root;  state: Exp;  lines: +13 -13
Corrected the argument inside kmalloc().The size of the qset array is calculated by multiplying the qset size with the size of the pointer.
Also modified a message to display how many qset arrays are created.
—————————-
revision 1.17
date: 2014/03/01 21:01:35;  author: root;  state: Exp;  lines: +2 -2
Status : Writing in multiple quantums successfully implemented.
—————————-
revision 1.16
date: 2014/03/01 20:53:57;  author: root;  state: Exp;  lines: +20 -10
Modifying the code to work for writing in more than one quantums.
—————————-
revision 1.15
date: 2014/03/01 11:19:07;  author: root;  state: Exp;  lines: +5 -0
One printk statement is added to test whether the data is actually copied into the kernel buffer or not.
Testing……….
—————————-
revision 1.14
date: 2014/03/01 11:13:18;  author: root;  state: Exp;  lines: +15 -7
The copy_from_user() function is used to copy a block of data from user space into the kernel buffer.copy_from_user() function contains 3 arguments:
1.A destination buffer,
2.A source buffer,and
3.length in bytes.
—————————-
revision 1.13
date: 2014/03/01 11:06:21;  author: root;  state: Exp;  lines: +2 -1
Done memset().
Testing the code…..
—————————-
revision 1.12
date: 2014/03/01 11:01:16;  author: root;  state: Exp;  lines: +54 -5
Implemented the create_quantums() function that will create the required number of quantums.
Kmalloc() is used to allocate memory for each quantum.
Filling the memory allocated using kmalloc() with memset() so that it does not contain any garbage.
—————————-
revision 1.11
date: 2014/03/01 10:39:39;  author: root;  state: Exp;  lines: +1 -0
memset() function is used to fill the memory allocated for the qset array to ”.
—————————-
revision 1.10
date: 2014/03/01 10:36:59;  author: root;  state: Exp;  lines: +14 -4
Using kmalloc() memory is allocated to the required number of qsets.
Checking whether it is working fine or not.
—————————-
revision 1.9
date: 2014/03/01 10:26:27;  author: root;  state: Exp;  lines: +36 -2
Implemented create_scullqset() function.Now checking the number of qsets that needs to created by using the size argument of the chardev_write().After determining the number of qsets that needs to be created create_qset() function is called.
—————————-
revision 1.8
date: 2014/03/01 10:07:44;  author: root;  state: Exp;  lines: +2 -1
memset() function is used to fill the memory allocated using kmalloc() with ” .
—————————-
revision 1.7
date: 2014/03/01 10:04:21;  author: root;  state: Exp;  lines: +10 -0
Allocating memory for 1 scullqset to check whether the create_scullqset() function is working properly or not.
—————————-
revision 1.6
date: 2014/03/01 09:56:22;  author: root;  state: Exp;  lines: +22 -2
After finding out the number of scullqsets,create_scullqset() function is called to create the specified number of scullqsets.
Checking whether the function calling is taking place or not……
—————————-
revision 1.5
date: 2014/03/01 09:47:56;  author: root;  state: Exp;  lines: +19 -0
The size argument that specifies the size of the buffer pointed to by ubuff is used to find the number of scullqsets that needs to be created.
After finding out the exact number of scullqsets that needs to be created,the number of scullqsets are printed.
Creating scullqsets…….
—————————-
revision 1.4
date: 2014/03/01 09:32:34;  author: root;  state: Exp;  lines: +1 -1
Fixed the warning by type-casting size_t to int.
—————————-
revision 1.3
date: 2014/03/01 09:28:31;  author: root;  state: Exp;  lines: +6 -1
Checking whether the ubuff pointer is actually pointing to the buffer in the application.Also checking the size field inside the 3rd argument of chardev_write().
—————————-
revision 1.2
date: 2014/03/01 09:20:00;  author: root;  state: Exp;  lines: +9 -1
Printing the address inside filep->private_data to check whether it matches with the address returned by container_of() macro.
A local variable of type Sculldev is declared which will store the address that is present inside filep->private_data.
—————————-
revision 1.1
date: 2014/02/28 21:33:05;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Character Driver, Device Drivers | Leave a comment

Module code to show how to perform read operation in multiple qset arrays.

RCS file: readf.c,v
Working file: readf.c
head: 1.18
branch:
locks: strict
root: 1.18
access list:
symbolic names:
keyword substitution: kv
total revisions: 18;    selected revisions: 18
description:
chardev_read() function reside here which is responsible for performing the read operation.
—————————-
revision 1.18    locked by: root;
date: 2014/03/05 08:19:18;  author: root;  state: Exp;  lines: +1 -1
Modified the return value of the chardev_read() function to nocsr.This return value becomes the return type of the read() system call in the application.

Status : Read operation in multiple qset arrays is implemented successfully.
—————————-
revision 1.17
date: 2014/03/05 08:13:05;  author: root;  state: Exp;  lines: +1 -1
Changed quantum_size to qset_size inside the loop.
Checking……..
—————————-
revision 1.16
date: 2014/03/05 08:10:38;  author: root;  state: Exp;  lines: +13 -3
Declared a variable j to keep track on how many quantums read operation is already performed.When it is equal to the number of quantums then break.
Also a condition is included in which the variable i is set to 0 and lscullqset is updated when the i equals qset_size.
—————————-
revision 1.15
date: 2014/03/05 08:06:46;  author: root;  state: Exp;  lines: +2 -1
Declared a local pointer variable to point to a structure of type struct Scullqset.
Extending the code further so that read can be performed in multiple qset arrays.
—————————-
revision 1.14
date: 2014/03/04 22:36:51;  author: root;  state: Exp;  lines: +3 -2
Status : Read operation from multiple quantums is implemented successfully.

All logical errors are fixed.
To calculate the number of characters to read size argument is used instead of the data_size to ensure that always the size number of bytes.
—————————-
revision 1.13
date: 2014/03/04 22:29:49;  author: root;  state: Exp;  lines: +1 -0
Logical mistake,the number of characters successfully read was not updated.
Fixed the bug.
Checking…………
—————————-
revision 1.12
date: 2014/03/04 22:15:25;  author: root;  state: Exp;  lines: +21 -3
Implemented the logic for copy_to_user() function for the multiple quantums.
After reading the entire data from quantums,it is stored inside rbuff pointer.
Checking……
—————————-
revision 1.11
date: 2014/03/04 21:02:53;  author: root;  state: Exp;  lines: +8 -1
Calculated the required number of quantums based on the data size.
After calculating the number of quantums the number of quantums are printed.
—————————-
revision 1.10
date: 2014/03/04 20:57:26;  author: root;  state: Exp;  lines: +1 -1
Bug fixed.
Issue : Incorrect spelling of noqsa.
—————————-
revision 1.9
date: 2014/03/04 20:54:34;  author: root;  state: Exp;  lines: +8 -0
Added the logic to find out the number of qset arrays that are required using the data_size.
After calculating the number of qset arrays are printed.
—————————-
revision 1.8
date: 2014/03/04 20:49:58;  author: root;  state: Exp;  lines: +16 -2
Logic to find the number of scullqset required is added.The total number of scullqsets will depend on the data_size.
After calculating the number of scullqsets required,the number of scullqsets are printed using printk() statements.
—————————-
revision 1.7
date: 2014/03/04 20:15:29;  author: root;  state: Exp;  lines: +2 -0
Another variable is added using extern called data_size which actually stores how much data is written to the quantums.
—————————-
revision 1.6
date: 2014/03/04 20:14:01;  author: root;  state: Exp;  lines: +4 -0
Three variables are added namely:quantum_size , qset_size and device_size using extern.
—————————-
revision 1.5
date: 2014/03/04 20:11:21;  author: root;  state: Exp;  lines: +8 -0
Declared two variables i and noq.The variable is used to run the loop and the variable noq is used to store the number of quantums.
Calculating the number of quantums….
—————————-
revision 1.4
date: 2014/03/04 20:08:36;  author: root;  state: Exp;  lines: +2 -0
Declared a pointer to a structure of type struct Sculldev,inside which the filep->private_data is stored.
—————————-
revision 1.3
date: 2014/03/04 20:04:39;  author: root;  state: Exp;  lines: +8 -1
Gave two printk() statements to mark the beginning and end of the chardev_read() function.
—————————-
revision 1.2
date: 2014/03/04 20:02:14;  author: root;  state: Exp;  lines: +8 -0
The prototype of the chardev_read() function is added here using extern.
Defining the body of the chardev_read() function…..
—————————-
revision 1.1
date: 2014/03/04 19:30:01;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Character Driver, Device Drivers | Leave a comment

Module code to show how to perform read operation in multiple quantums.

RCS file: readf.c,v
Working file: readf.c
head: 1.14
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 14;    selected revisions: 14
description:
chardev_read() function reside here which is responsible for performing the read operation.
—————————-
revision 1.14
date: 2014/03/04 22:36:51;  author: root;  state: Exp;  lines: +3 -2
Status : Read operation from multiple quantums is implemented successfully.

All logical errors are fixed.
To calculate the number of characters to read size argument is used instead of the data_size to ensure that always the size number of bytes.
—————————-
revision 1.13
date: 2014/03/04 22:29:49;  author: root;  state: Exp;  lines: +1 -0
Logical mistake,the number of characters successfully read was not updated.
Fixed the bug.
Checking…………
—————————-
revision 1.12
date: 2014/03/04 22:15:25;  author: root;  state: Exp;  lines: +21 -3
Implemented the logic for copy_to_user() function for the multiple quantums.
After reading the entire data from quantums,it is stored inside rbuff pointer.
Checking……
—————————-
revision 1.11
date: 2014/03/04 21:02:53;  author: root;  state: Exp;  lines: +8 -1
Calculated the required number of quantums based on the data size.
After calculating the number of quantums the number of quantums are printed.
—————————-
revision 1.10
date: 2014/03/04 20:57:26;  author: root;  state: Exp;  lines: +1 -1
Bug fixed.
Issue : Incorrect spelling of noqsa.
—————————-
revision 1.9
date: 2014/03/04 20:54:34;  author: root;  state: Exp;  lines: +8 -0
Added the logic to find out the number of qset arrays that are required using the data_size.
After calculating the number of qset arrays are printed.
—————————-
revision 1.8
date: 2014/03/04 20:49:58;  author: root;  state: Exp;  lines: +16 -2
Logic to find the number of scullqset required is added.The total number of scullqsets will depend on the data_size.
After calculating the number of scullqsets required,the number of scullqsets are printed using printk() statements.
—————————-
revision 1.7
date: 2014/03/04 20:15:29;  author: root;  state: Exp;  lines: +2 -0
Another variable is added using extern called data_size which actually stores how much data is written to the quantums.
—————————-
revision 1.6
date: 2014/03/04 20:14:01;  author: root;  state: Exp;  lines: +4 -0
Three variables are added namely:quantum_size , qset_size and device_size using extern.
—————————-
revision 1.5
date: 2014/03/04 20:11:21;  author: root;  state: Exp;  lines: +8 -0
Declared two variables i and noq.The variable is used to run the loop and the variable noq is used to store the number of quantums.
Calculating the number of quantums….
—————————-
revision 1.4
date: 2014/03/04 20:08:36;  author: root;  state: Exp;  lines: +2 -0
Declared a pointer to a structure of type struct Sculldev,inside which the filep->private_data is stored.
—————————-
revision 1.3
date: 2014/03/04 20:04:39;  author: root;  state: Exp;  lines: +8 -1
Gave two printk() statements to mark the beginning and end of the chardev_read() function.
—————————-
revision 1.2
date: 2014/03/04 20:02:14;  author: root;  state: Exp;  lines: +8 -0
The prototype of the chardev_read() function is added here using extern.
Defining the body of the chardev_read() function…..
—————————-
revision 1.1
date: 2014/03/04 19:30:01;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: decleration.h,v
Working file: decleration.h
head: 1.10
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 10;    selected revisions: 10
description:
All the variable declerations are done inside this header file.
—————————-
revision 1.10
date: 2014/03/04 01:27:07;  author: root;  state: Exp;  lines: +1 -0
Gave prototype for chardev_read() function.
—————————-
revision 1.9
date: 2014/02/28 21:40:24;  author: root;  state: Exp;  lines: +1 -0
Gave prototype for chardev_write() function .
—————————-
revision 1.8
date: 2014/02/28 20:28:24;  author: root;  state: Exp;  lines: +1 -0
Gave prototype for chardev_release() function.
—————————-
revision 1.7
date: 2014/02/28 18:48:17;  author: root;  state: Exp;  lines: +2 -0
Gave prototype of chardev_open() function.
—————————-
revision 1.6
date: 2014/02/28 17:05:32;  author: root;  state: Exp;  lines: +1 -0
A variable of type dev_t is declared that is used to store the updated device number obtained from mkdev.
—————————-
revision 1.5
date: 2014/02/28 16:59:40;  author: root;  state: Exp;  lines: +3 -0
Two variables are declared inside this file that will hold the information about major and minor numbers.
—————————-
revision 1.4
date: 2014/02/28 16:39:07;  author: root;  state: Exp;  lines: +4 -0
Variables quantum_size,qset_size,data_size and device_size are declared that will get initialized by the macros defined in header.h.
—————————-
revision 1.3
date: 2014/02/28 15:30:46;  author: root;  state: Exp;  lines: +1 -0
A variable of type Sculldev is declared in this file.
—————————-
revision 1.2
date: 2014/02/27 20:06:26;  author: root;  state: Exp;  lines: +1 -0
A variable of type int is declared representing the number of devices.
—————————-
revision 1.1
date: 2014/02/27 19:30:54;  author: root;  state: Exp;
Initial revision
=============================================================================

 

Posted in Character Driver, Device Drivers | Leave a comment