<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EmbLogic &#187; Rahul Attreja</title>
	<atom:link href="https://www.emblogic.com/blog/author/rahul-20/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.emblogic.com/blog</link>
	<description>Embedded System and ARM Training</description>
	<lastBuildDate>Tue, 03 Mar 2020 13:00:06 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>Article on Inter Process Communication Part 1</title>
		<link>https://www.emblogic.com/blog/12/article-on-inter-process-communication-part-1/</link>
		<comments>https://www.emblogic.com/blog/12/article-on-inter-process-communication-part-1/#comments</comments>
		<pubDate>Thu, 05 Dec 2013 12:35:09 +0000</pubDate>
		<dc:creator><![CDATA[Rahul Attreja]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7660</guid>
		<description><![CDATA[Project Name: Inter Process Communication Scope: To setup the communication link between two or more processes so as to transfer data to and fro in between the processes. Description: We have many IPC techniques in Linux like PIPE, FIFO, Shared &#8230; <a href="https://www.emblogic.com/blog/12/article-on-inter-process-communication-part-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p align="JUSTIFY"><strong>Project Name: </strong>Inter Process Communication</p>
<p align="JUSTIFY"><strong>Scope: </strong>To setup the communication link between two or more processes so as to transfer data to and fro in between the processes.</p>
<p align="JUSTIFY"><strong>Description: </strong>We have many IPC techniques in Linux like PIPE, FIFO, Shared Memory, Message Queue. We will start this article from our first topic i.e. PIPE.</p>
<p align="JUSTIFY">PIPE is a stream or we can say a path from where we transfer the data from one process to another. For creating a pipe we us system call “<em>PIPE()</em>”. This call will create a stream between two processes and will return two file descriptors. The two file descriptors returned are connected in a special way. Any data written to file_descriptor[1] can be read back from file_descriptor[0]. The data is processed in a first in, first out basis, usually abbreviated to FIFO. This means that if you write the bytes 1, 2, 3 to file_descriptor[1], reading from file_descriptor[0] will produce 1, 2, 3. This is different from a stack, which operates on a last in, first out basis, usually abbreviated to LIFO. As this stream is unnamed, hence it is visible to only those processes in which one process act as parent and another process act as a child. Now the question arises – What is a child process &amp; Parent process.</p>
<p align="JUSTIFY">We have a system call as “<em>fork()</em>”, this call will create process from main process. The created process is called as child and the main process will be named as parent. After creation of child process, we will send the file descriptors to that child process by calling a call “<em>exec()</em>”. This “exec()” call will create a new process and will replace it with the process from which this was called. Child process generated by the fork() call uses same process context but PCB is different. This replace process created by exec() call will have everything different i.e PCB &amp; process context are different. Now this new process and the parent process both are having the file descriptors and with the help of these descriptors these two processes will share data with each other. Important topics here we have are “<em>Orphan Process</em>” &amp; “<em>Zombies</em>”.</p>
<p align="JUSTIFY"><strong>Orphan Process </strong>- After a call to fork(), generally its the child process that get time slice to execute. Now say of parent process terminates for some reason before child process, we will have a orphan process as it parent process have died. As every child process have some parent this must be made child of some process, in this condition Dispatcher i.e. Process with PID 1 is automatically made its parent.</p>
<p align="JUSTIFY"><strong>Zombies – </strong>If for some reason a process is dead but haven&#8217;t been removed from the process table it is called as Zombie process. Now this can happen in situation when a child process has terminated and parent process gas gone in some kind of infinite loop which don&#8217;t allow child process to exit.</p>
<p align="JUSTIFY"> In the next article we will briefly discuss about other IPC techniques – FIFO, Shared memory and Message queue.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/12/article-on-inter-process-communication-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Article on Client Server Communication</title>
		<link>https://www.emblogic.com/blog/11/article-on-client-server-communication/</link>
		<comments>https://www.emblogic.com/blog/11/article-on-client-server-communication/#comments</comments>
		<pubDate>Mon, 25 Nov 2013 11:58:58 +0000</pubDate>
		<dc:creator><![CDATA[Rahul Attreja]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7458</guid>
		<description><![CDATA[Project Name: Client Server Communication Using Threads And Sockets. Scope: This project is used to setup communication between server and client. With the help of this we can send and receive data from one client to another or between server &#8230; <a href="https://www.emblogic.com/blog/11/article-on-client-server-communication/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p align="JUSTIFY"><strong>Project Name:</strong> Client Server Communication Using Threads And Sockets.</p>
<p align="JUSTIFY">
<p align="JUSTIFY"><strong>Scope: </strong>This project is used to setup communication between server and client. With the help of this we can send and receive data from one client to another or between server and client.</p>
<p align="JUSTIFY">
<p align="JUSTIFY"><strong>Description: </strong>We<strong> </strong>have done this project in phases -</p>
<p align="JUSTIFY">Phase – I: <span style="text-decoration: underline">One server One client</span></p>
<p align="JUSTIFY">At the server end we have created one socket which will help to communicate with the client. After creating the socket using command <em>“socket()”</em>, we named it using command <em>“bind()”</em>. Naming the socket will give the easy access to the client as this socket will be visible to the client.</p>
<p align="JUSTIFY">
<p align="JUSTIFY">If we are performing this communication within the system/computer, then we will use AF_UNIX to name the socket.(Here we can give any alpha or alphanumeric name). Other wise, if we are establishing between two networks the we use AF_INET. In this we have to mention the port number and IP address of the server). We have used TCP/IP protocol for our project.</p>
<p align="JUSTIFY"><strong>Note:</strong> we will never give name to the socket of client, we always give name to the socket of server which is visible to all the client.</p>
<p align="JUSTIFY">
<p align="JUSTIFY">Simultaneously, at the client end we have created a socket through which it will communicate with the server. After that client sent a request to the server to get connected using command <em>“connect()”</em>. At the server end, server will listen the request sent from the client using command <em>“listen()”</em> and it will create a<em> </em>queue. (<strong>Note:</strong> If in the mean time another client wants to connect with the server, the 2<sup>nd</sup> client request will go to the queue.) After getting the request from the client , server will accept the request using command <em>“accept()”</em>and this command will return a file descriptor (a stream) through which client will send and receive data to and from the server respectively.</p>
<p align="JUSTIFY">
<p align="JUSTIFY">At end of data transfer client will close the socket and simultaneously server will delete the stream connected to the particular client.</p>
<p align="JUSTIFY">
<p align="JUSTIFY">Phase – II: <span style="text-decoration: underline">One server </span><span style="text-decoration: underline">several</span><span style="text-decoration: underline"> client</span><span style="text-decoration: underline">s</span></p>
<p align="JUSTIFY">The procedure for this second phase is almost same as phase I. In the same way as mentioned above, we will create many clients which will send requests to the server to communicate simultaneously. Server will create a queue to manage the request .</p>
<p align="JUSTIFY">
<p align="JUSTIFY">Phase – III: <span style="text-decoration: underline">One server </span><span style="text-decoration: underline">several</span><span style="text-decoration: underline"> client</span><span style="text-decoration: underline">s using threads</span></p>
<p align="JUSTIFY">In this phase we have many clients who wants to communicate with the server. Every client will send request to the server, and at the server end queue is created (as explained above). One by one server will except the request and will assign the work to different functions. Here instead of calling different functions we have used concept of threads. Server will create threads on every receipt of request from the client end.</p>
<p align="JUSTIFY">
<p align="JUSTIFY">With the help of these threads the process time of the server is reduced as it is distributing its workload within threads.</p>
<p align="JUSTIFY">
<p align="JUSTIFY"><strong>Functionality: </strong></p>
<p align="JUSTIFY"><strong>1. </strong>This basic project will help to reduce the process timing of client. If client wants to process some data, it will send the raw data to the server and server will send back the processed output to the client.</p>
<p align="JUSTIFY"><strong>2.</strong> Planning for phase IV. In this phase we will establish the link between different clients through one server. In this project clients will communicate with themselves or we can say these clients will share data with each other.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/11/article-on-client-server-communication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C assignment status</title>
		<link>https://www.emblogic.com/blog/08/c-assignment-status-8/</link>
		<comments>https://www.emblogic.com/blog/08/c-assignment-status-8/#comments</comments>
		<pubDate>Sun, 18 Aug 2013 08:57:51 +0000</pubDate>
		<dc:creator><![CDATA[Rahul Attreja]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7093</guid>
		<description><![CDATA[completed first 6 assignments. Currently working on function&#8217;s 4th question&#8230;&#8230;.]]></description>
				<content:encoded><![CDATA[<p>completed first 6 assignments.<br />
Currently working on function&#8217;s 4th question&#8230;&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/c-assignment-status-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C assignments status</title>
		<link>https://www.emblogic.com/blog/08/c-assignments-status-2/</link>
		<comments>https://www.emblogic.com/blog/08/c-assignments-status-2/#comments</comments>
		<pubDate>Sat, 10 Aug 2013 12:42:46 +0000</pubDate>
		<dc:creator><![CDATA[Rahul Attreja]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7023</guid>
		<description><![CDATA[Done more 10 questions &#8230;&#8230;&#8230;.Total questions done is 66 now&#8230;.. Still waiting for the suggesions on below question – “write a program to printa cycle of cosine, sine wave”…. Kindly advice what to do in this??]]></description>
				<content:encoded><![CDATA[<p>Done more 10 questions &#8230;&#8230;&#8230;.Total questions done is 66 now&#8230;..</p>
<p>Still waiting for the suggesions on below question –<br />
“write a program to printa cycle of cosine, sine wave”….</p>
<p>Kindly advice what to do in this??</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/c-assignments-status-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C assignment status</title>
		<link>https://www.emblogic.com/blog/08/c-assignment-status/</link>
		<comments>https://www.emblogic.com/blog/08/c-assignment-status/#comments</comments>
		<pubDate>Wed, 07 Aug 2013 09:48:48 +0000</pubDate>
		<dc:creator><![CDATA[Rahul Attreja]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6990</guid>
		<description><![CDATA[Done first 56 questions of C assignments&#8230;. Kindly help me to understand the below question &#8211; &#8220;write a program to printa cycle of cosine, sine wave&#8221;&#8230;.]]></description>
				<content:encoded><![CDATA[<p>Done first 56 questions of  C assignments&#8230;.</p>
<p>Kindly help me to understand the below question &#8211;<br />
&#8220;write a program to printa cycle of cosine, sine wave&#8221;&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/c-assignment-status/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Char Driver Logfile</title>
		<link>https://www.emblogic.com/blog/08/char-driver-logfile-3/</link>
		<comments>https://www.emblogic.com/blog/08/char-driver-logfile-3/#comments</comments>
		<pubDate>Thu, 01 Aug 2013 13:06:02 +0000</pubDate>
		<dc:creator><![CDATA[Rahul Attreja]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6988</guid>
		<description><![CDATA[RCS file: first_driver.c,v Working file: first_driver.c head: 2.23 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 33; selected revisions: 33 description: base prog. able to register the device through old method. &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision 2.23 date: 2013/08/01 &#8230; <a href="https://www.emblogic.com/blog/08/char-driver-logfile-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: first_driver.c,v<br />
Working file: first_driver.c<br />
head: 2.23<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 33;	selected revisions: 33<br />
description:<br />
base prog.<br />
able to register the device through old method.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.23<br />
date: 2013/08/01 11:53:49;  author: rahul;  state: Exp;  lines: +7 -6<br />
done with proc<br />
able to creat pages.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.22<br />
date: 2013/08/01 11:00:22;  author: rahul;  state: Exp;  lines: +78 -35<br />
done with ioctl command<br />
created scull_ioctl function.<br />
able to change the quantum size.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.21<br />
date: 2013/07/26 11:08:11;  author: rahul;  state: Exp;  lines: +108 -11<br />
implemented spin_lock()<br />
implemented completion()<br />
but to implement syncro between writes of two diffrent applications &amp; reads of two diffrent applications, we have to use semaphore between application.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.20<br />
date: 2013/07/22 14:04:17;  author: rahul;  state: Exp;  lines: +26 -26<br />
faced problem with trim function again.<br />
previous ligic was not correct.<br />
used data_size which was declared in struct sculldev.<br />
working fine<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.19<br />
date: 2013/07/22 12:22:22;  author: rahul;  state: Exp;  lines: +57 -9<br />
done with semaphores in device driver.<br />
used call sema_init().<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.18<br />
date: 2013/07/21 20:05:01;  author: rahul;  state: Exp;  lines: +40 -13<br />
done with multi thread 5 applications<br />
.syncro done with the help of semaphores.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.17<br />
date: 2013/07/20 13:24:29;  author: rahul;  state: Exp;  lines: +173 -104<br />
done with lseek.<br />
first write then lseek then write.<br />
done for within one quantum.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.16<br />
date: 2013/07/19 06:54:18;  author: rahul;  state: Exp;  lines: +4 -3<br />
able to use multi thread application.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.15<br />
date: 2013/07/18 10:09:58;  author: rahul;  state: Exp;  lines: +1 -1<br />
ok for lseek before write.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.14<br />
date: 2013/07/17 10:03:13;  author: rahul;  state: Exp;  lines: +40 -26<br />
done with lseek before write &amp; after write.<br />
complete for seek till 8 bytes only.<br />
now working with multiple quantums.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.13<br />
date: 2013/07/16 12:31:05;  author: rahul;  state: Exp;  lines: +75 -7<br />
inserted function for llseek.<br />
able to seek before write operation.<br />
next step to use lseek after the write operation.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.12<br />
date: 2013/07/14 06:21:44;  author: rahul;  state: Exp;  lines: +57 -19<br />
added informations of the read function.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.11<br />
date: 2013/07/13 11:36:53;  author: rahul;  state: Exp;  lines: +24 -29<br />
done with read &amp; write.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.10<br />
date: 2013/07/13 08:15:40;  author: rahul;  state: Exp;  lines: +132 -29<br />
m happy now&#8230;&#8230; after 24 hours i am able debug my program&#8230;.. now ir is able to write &amp; read even for more then 64 bytes&#8230;<br />
bug was with memory allocation&#8230;.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.9<br />
date: 2013/07/11 12:59:35;  author: rahul;  state: Exp;  lines: +30 -20<br />
done with multiple qset entry.<br />
added while loop along with the if ele condition.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.8<br />
date: 2013/07/11 11:15:03;  author: rahul;  state: Exp;  lines: +21 -6<br />
done with multiple quantums.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.7<br />
date: 2013/07/11 08:14:55;  author: rahul;  state: Exp;  lines: +9 -4<br />
able to write from user buffer to quantum. but only for 1 quantum.<br />
now tring for multiple quantums.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.6<br />
date: 2013/07/11 07:54:58;  author: rahul;  state: Exp;  lines: +66 -31<br />
able to create quantum.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.5<br />
date: 2013/07/10 09:34:52;  author: rahul;  state: Exp;  lines: +52 -8<br />
created function for quantum creation.<br />
testing ok.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.4<br />
date: 2013/07/09 11:51:18;  author: rahul;  state: Exp;  lines: +54 -6<br />
created scullqset function.<br />
allocated memory for sculqset using kmalloc.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.3<br />
date: 2013/07/08 11:48:32;  author: rahul;  state: Exp;  lines: +25 -3<br />
mapped scull_read &amp; scull_wrrite function with open call.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.2<br />
date: 2013/07/08 08:33:04;  author: rahul;  state: Exp;  lines: +11 -10<br />
initialises the value of open count in struct scull dev.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.1<br />
date: 2013/07/05 07:23:17;  author: rahul;  state: Exp;  lines: +12 -11<br />
done with looping also.<br />
dev value at unregistration should be major no and 0.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.0<br />
date: 2013/07/04 11:50:08;  author: rahul;  state: Exp;  lines: +4 -4<br />
*** empty log message ***<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/04 11:41:53;  author: rahul;  state: Exp;  lines: +31 -12<br />
done for single device again<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/04 08:24:47;  author: rahul;  state: Exp;  lines: +49 -20<br />
inserted function for scull_trim.<br />
done preservation of private data in struct file.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/02 13:49:48;  author: rahul;  state: Exp;  lines: +23 -24<br />
done for 10 devices<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/02 13:10:25;  author: rahul;  state: Exp;  lines: +2 -2<br />
*** empty log message ***<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/02 13:09:23;  author: rahul;  state: Exp;  lines: +5 -4<br />
final with single devices.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/02 12:40:45;  author: rahul;  state: Exp;  lines: +14 -14<br />
done for one number of device.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/02 08:58:15;  author: rahul;  state: Exp;  lines: +65 -8<br />
done with scull initialisation scull_init().<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/01 11:10:21;  author: rahul;  state: Exp;  lines: +32 -5<br />
inserted for loop for calculating diffrnt minor numbers against one major numbr.<br />
otherwise it is working fine.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/01 07:24:56;  author: rahul;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/char-driver-logfile-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Article &#8211; Character Driver</title>
		<link>https://www.emblogic.com/blog/07/article-character-driver/</link>
		<comments>https://www.emblogic.com/blog/07/article-character-driver/#comments</comments>
		<pubDate>Sun, 21 Jul 2013 17:48:22 +0000</pubDate>
		<dc:creator><![CDATA[Rahul Attreja]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6830</guid>
		<description><![CDATA[With the help of this article I am going to brief the basics of character driver &#38; the work done by me till date. First of all few questions arises in our mind that what is a driver &#38; what &#8230; <a href="https://www.emblogic.com/blog/07/article-character-driver/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>With the help of this article I am going to brief the basics of character driver &amp; the work done by me till date.<br />
First of all few questions arises in our mind that what is a driver &amp; what is the need of driver in OS?. In general, driver is used to run or drive something. Here we are using driver(set of codes) to setup communication between the Hardware Device and the Operating System, so that our OS can drive nothing but access the device with the help of the “Device Driver”.<br />
Device Drivers are also described as Loadable Kernel Modules (LKM), as these modules are loaded when ever &amp; where ever used. This concept of using drivers increases the run-time efficiency of the Kernel.<br />
We are right now working on the project i.e. “Development of one of the driver named as  Character Driver “.<br />
Character Driver operates on the basis of transferring the data character by character. In our project we are dealing with one application running on the user space &amp; our Device Driver running on Kernel space. Till date we are working on creation of Multi Threaded Application in our Char Driver coding which consists of follow steps &#8211;<br />
Initialization of driver -&gt; Mapping of system calls from application to the driver -&gt; open call -&gt; Mapping of memory on to the device (including trim function) -&gt; Write call -&gt; Read call -&gt; Seek call -&gt;use of multi threaded application.<br />
We have used command “insmod” to call the initialization macro i.e. module_init() which will insert the driver into the list of modules &amp; “rmmod” to call the cleanup macro i.e. module_exit() which will remove the driver from the list. Driver starts with the registration using alloc_chrdev_region(). This  registration (using alloc_chrdev_region()) is done so as to get the major number dynamically for the driver. Correspondingly a minor number is generated for the first device. We can also use register_chrdev() to register the driver if we want to assign the user defined major number.<br />
After registration we got a 32 bit number stored in “dev” which is of “dev_t” type. First 12 bits will give major number by using macro “MAJOR” &amp; remaining 20 bits will give the minor number by using macro “MINOR”. After getting the major &amp; minor number, now its time to initialize the SCULL i.e. Simple character utility for loading localities. SCULL is a char driver that acts on the memory area as though it was a device.  This SCULL is defined by a structure “Sculldev” contains blocks of memory called scullqsets which are also called as items and each item contains qsets which are nothing but array of pointers pointing to specific locations known as quantums. The scullqset or item can handle data maximum upto the data equal to product of qset_size and quantum size. Further each quantum can store maximum of bytes equal to quantum_size defined by the developer. We can calculate the number of scullqsets and number of quantums required for storing given number of bytes. One thing which is very important that these “items” or we can say that “scullqsets” should be linked like “link list” so as to store the data in quantums of different scullqsets.<br />
After initializing the structure Sculldev, now we have to initialize the structure C_dev which will give the information of our device i.e. Owner of the device, Major &amp; Minor numbers, operations that our device can perform etc. After this its time to map the system calls to the corresponding functions defined in the driver.  As the mapping is done so now from the application end we will call the open system call which will call our defined function in driver. In normal routine open call creates a stream     and after handing over of the stream this call terminates. For our driver we have written our own routines. In our open function we have used a macro “container_of” to map the memory allocated for scull from RAM to the device &amp; along with the link of “Structure inode” with “Structure C_dev &amp; SCULL. This mapping will return the starting address of the SCULL which we will store into the “private data” of the “Structure file”. When ever &amp; where ever if we want to access the sculldev we will fetch the private data. After sending the address of Sculldev we will call the trim function. If we want to write on to the device, we have to check whether the device is having something onto its memory or not. If we found anything in quantums, we first trim the data nothing but flushing out the previously written bytes.<br />
After trimming we will call write from the application. This write system call will call the write function which we have in our driver as we have already mapped all the operations to be performed by the applications in “Structure file_operations”. Writing here means getting the data from the user buffer &amp; writing it on the quantums present in the SCULL i.e. Memory of device. In the starting of write function we will fetch the private data so as to get the address of SCULL. For writing we will use “Copy_from_user()”. Before writing we will calculate the number of items (scullqsets) to be created along with the number of quantums. Now we want to read what we have written earlier in the quantums. For this we will call the read function. This means reading the data from the quantums &amp; passing it to the user buffer which we will receive in our application. For this we will use “Copy_to_user()”.<br />
We have also done with seek function. Seeking means changing the position where we want to read or write. After seeking Multi Threaded Function is also created. Testing of is new threaded application is done &amp; its working fine.<br />
In linux everything is a file, whenever you connect a device it is treated as a file and an inode is created for that file. The communication between application and kernel is carried out using “node(named pipe)” created using command “mknod”. The application cannot access beyond this node. This node is the only medium from which the application will interact with the device driver.</p>
<p>This is all about what I have done till date in character driver coding.</p>
<p>Thanks<br />
Rahul Attreja</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/article-character-driver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Char Driver Logfile</title>
		<link>https://www.emblogic.com/blog/07/char-driver-logfile-2/</link>
		<comments>https://www.emblogic.com/blog/07/char-driver-logfile-2/#comments</comments>
		<pubDate>Wed, 17 Jul 2013 12:58:15 +0000</pubDate>
		<dc:creator><![CDATA[Rahul Attreja]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6798</guid>
		<description><![CDATA[RCS file: first_driver.c,v Working file: first_driver.c head: 2.12 branch: locks: strict rahul: 2.12 access list: symbolic names: keyword substitution: kv total revisions: 22; selected revisions: 22 description: base prog. able to register the device through old method. &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision 2.12 &#8230; <a href="https://www.emblogic.com/blog/07/char-driver-logfile-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: first_driver.c,v<br />
Working file: first_driver.c<br />
head: 2.12<br />
branch:<br />
locks: strict<br />
	rahul: 2.12<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 22;	selected revisions: 22<br />
description:<br />
base prog.<br />
able to register the device through old method.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.12	locked by: rahul;<br />
date: 2013/07/14 06:21:44;  author: rahul;  state: Exp;  lines: +57 -19<br />
added information of the read function.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.11<br />
date: 2013/07/13 11:36:53;  author: rahul;  state: Exp;  lines: +24 -29<br />
done with read &amp; write.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.10<br />
date: 2013/07/13 08:15:40;  author: rahul;  state: Exp;  lines: +132 -29<br />
m happy now&#8230;&#8230; after 24 hours i am able debug my program&#8230;.. now it is able to write &amp; read even for more then 64 bytes&#8230;<br />
bug was with memory allocation&#8230;.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.9<br />
date: 2013/07/11 12:59:35;  author: rahul;  state: Exp;  lines: +30 -20<br />
done with multiple qset entry.<br />
added while loop along with the if ele condition.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.8<br />
date: 2013/07/11 11:15:03;  author: rahul;  state: Exp;  lines: +21 -6<br />
done with multiple quantums.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.7<br />
date: 2013/07/11 08:14:55;  author: rahul;  state: Exp;  lines: +9 -4<br />
able to write from user buffer to quantum. but only for 1 quantum.<br />
now tring for multiple quantums.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.6<br />
date: 2013/07/11 07:54:58;  author: rahul;  state: Exp;  lines: +66 -31<br />
able to create quantum.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.5<br />
date: 2013/07/10 09:34:52;  author: rahul;  state: Exp;  lines: +52 -8<br />
created function for quantum creation.<br />
testing ok.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.4<br />
date: 2013/07/09 11:51:18;  author: rahul;  state: Exp;  lines: +54 -6<br />
created scullqset function.<br />
allocated memory for sculqset using kmalloc.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.3<br />
date: 2013/07/08 11:48:32;  author: rahul;  state: Exp;  lines: +25 -3<br />
mapped scull_read &amp; scull_wrrite function with open call.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.2<br />
date: 2013/07/08 08:33:04;  author: rahul;  state: Exp;  lines: +11 -10<br />
initialises the value of open count in struct scull dev.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.1<br />
date: 2013/07/05 07:23:17;  author: rahul;  state: Exp;  lines: +12 -11<br />
done with looping also.<br />
dev value at unregistration should be major no and 0.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 2.0<br />
date: 2013/07/04 11:50:08;  author: rahul;  state: Exp;  lines: +4 -4<br />
*** empty log message ***<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/04 11:41:53;  author: rahul;  state: Exp;  lines: +31 -12<br />
done for single device again<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/04 08:24:47;  author: rahul;  state: Exp;  lines: +49 -20<br />
inserted function for scull_trim.<br />
done preservation of private data in struct file.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/02 13:49:48;  author: rahul;  state: Exp;  lines: +23 -24<br />
done for 10 devices<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/02 13:10:25;  author: rahul;  state: Exp;  lines: +2 -2<br />
*** empty log message ***<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/02 13:09:23;  author: rahul;  state: Exp;  lines: +5 -4<br />
final with single devices.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/02 12:40:45;  author: rahul;  state: Exp;  lines: +14 -14<br />
done for one number of device.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/02 08:58:15;  author: rahul;  state: Exp;  lines: +65 -8<br />
done with scull initialisation scull_init().<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/01 11:10:21;  author: rahul;  state: Exp;  lines: +32 -5<br />
inserted for loop for calculating diffrnt minor numbers against one major numbr.<br />
otherwise it is working fine.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/01 07:24:56;  author: rahul;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/char-driver-logfile-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Character Driver Logfile</title>
		<link>https://www.emblogic.com/blog/07/character-driver-logfile/</link>
		<comments>https://www.emblogic.com/blog/07/character-driver-logfile/#comments</comments>
		<pubDate>Tue, 16 Jul 2013 11:59:30 +0000</pubDate>
		<dc:creator><![CDATA[Rahul Attreja]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6800</guid>
		<description><![CDATA[]]></description>
				<content:encoded><![CDATA[
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-driver-logfile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
