<?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; Jatinder Kumar</title>
	<atom:link href="https://www.emblogic.com/blog/author/jatinder-kumar/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>Mutexes provide a high level of safety for mutual exclusion</title>
		<link>https://www.emblogic.com/blog/01/mutexes-provide-a-high-level-of-safety-for-mutual-exclusion/</link>
		<comments>https://www.emblogic.com/blog/01/mutexes-provide-a-high-level-of-safety-for-mutual-exclusion/#comments</comments>
		<pubDate>Fri, 10 Jan 2014 08:35:42 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Linux Internals and System Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=8075</guid>
		<description><![CDATA[Unbounded Priority Inversion Problem with using counting or binary semaphores for controlling access to critical resources is called unbounded priority inversion. Priority inversion occurs when a low-priority task owns a semaphore, and a high-priority task is forced to wait on &#8230; <a href="https://www.emblogic.com/blog/01/mutexes-provide-a-high-level-of-safety-for-mutual-exclusion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><strong>Unbounded Priority Inversion</strong><br />
Problem with using counting or binary semaphores for controlling access to critical resources is called unbounded priority inversion. Priority inversion occurs when a low-priority task owns a semaphore, and a high-priority task is forced to wait on the semaphore until the low-priority task releases it. If, prior to releasing the semaphore, the low priority task is preempted by one or more mid-priority tasks, then unbounded priority inversion has occurred because the delay of the high-priority task is no longer predictable</p>
<p>Sharing a critical resource between high and low priority tasks is not a desirable design practice.It is better to share a resource only among equal priority tasks or to limit resource accesses to a single resource server task.</p>
<p><strong>Priority Inheritance</strong><br />
The most common approach is priority inheritance. Since the mutex knows its current owner, it is possible to promote the priority of the owner whenever a higher-priority task starts waiting on the mutex. The current owner temporarily assumes the priority of the highest priority taskwaiting on the mutex. This allows the owner to resume running if it was preempted by a mid-priority task,When theowner releases the mutex, it drops back to its original priority.</p>
<p>Problems with Priority Inheritance<br />
1.Since promotion of low-priority tasks to higher priority levels is caused by random sequences of events, it is not possible to predict how long mid-priority tasks will be<br />
blocked by lower-priority promoted tasks<br />
2.Priority inheritance can cause extra task switching.<br />
3.Priority inheritance increases the likelihood of deadlocks, because priorities change unpredictably.</p>
<p><strong>Priority Ceiling Promotion</strong><br />
An alternative to priority inheritance is priority ceiling promotion. With it, a priority<br />
ceiling is specified for a mutex, when it is created. The ceiling is set equal to the priority<br />
of the highest-priority task that is expected to get the mutex. When a lower-priority task<br />
obtains the mutex, its priority is immediately boosted to the mutex’s ceiling. Hence, a<br />
mid-priority task cannot preempt as long as the low-priority task owns the mutex, nor can<br />
any other task preempt that wants the mutex. Interestingly, priority ceiling is a simply an<br />
automatic method for forcing tasks to be of the same priority while using a resource.</p>
<p>Problems with Priority Ceiling Promotion<br />
1.If the high-priority task seldom uses the resource and the low-priority task frequently uses the resource, this needlessly blocks mid-priority tasks from running. In this situation, priority inheritance is more attractive<br />
2. A mutex ceiling is static. It is possible that a user task may have had its priority increased by the programmer, or increased dynamically, to a value above the mutex’s ceiling. Then priority ceiling promotion would not be working fully and some priority inversion could occur.</p>
<p><strong>Summary of Methods for Mutual Exclusion</strong><br />
1. Counting Semaphore. Adequate for minimal systems, but has the following limitations: protection failure due to spurious signals, task lockup, premature release, and unbounded priority inversion.<br />
2. Binary Semaphore. Better because it ignores spurious signals, but it still has these limitations: task lockup, premature release, and unbounded priority inversion.</p>
<p>3. Simple Mutex. Permits nesting, but does not deal with priority inversion.<br />
4. Priority Inheritance Mutex. Less blocking of mid-priority tasks than priority ceiling, but can lead to excessive task switches, thus increasing overhead.<br />
5. Priority Ceiling Mutex. Less task switches than inheritance, but may block mid-priority tasks too much. Provides a good method to prevent deadlocks</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/01/mutexes-provide-a-high-level-of-safety-for-mutual-exclusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Article:Description of USB Device Enumeration</title>
		<link>https://www.emblogic.com/blog/12/articledescription-of-usb-device-enumeration/</link>
		<comments>https://www.emblogic.com/blog/12/articledescription-of-usb-device-enumeration/#comments</comments>
		<pubDate>Thu, 05 Dec 2013 11:47:22 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7633</guid>
		<description><![CDATA[Introduction USB Enumeration is the process of detecting, identifying and loading drivers for a USB device.This involves a mixture of hardware techniques for detecting something is present and software to identify what has been connected. The purpose of this article &#8230; <a href="https://www.emblogic.com/blog/12/articledescription-of-usb-device-enumeration/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><strong>Introduction</strong><br />
USB Enumeration is the process of detecting, identifying and loading drivers for a USB device.This involves a mixture of hardware techniques for detecting something is present and software to identify what has been connected.<br />
The purpose of this article is to provide an overview of the mechanics of the process<br />
<strong>Detecting a Device has been Connected</strong></p>
<p>A USB interface consists of 4 wires. Power, Ground, Data Plus (USBDP) and Data Minus (USBDM). A USB host port with no devices connected uses 15kohm resistors to connect both USB DP and USB DM to GND. When a USB device (sometimes referred to as a slave) is plugged into a USB host there is a change on these USB data lines. It is this change that the USB host uses to detect a device has been connected.This change is also used to identify the speed of device attached.</p>
<p><strong>Determining the Device Speed</strong><br />
A low speed USB device (1.5Mbps) uses a 1k5 pull-up resistor to VCC on the USB DM signal line.<br />
A full speed USB device (12Mbps) uses a 1k5 pull-up resistor to VCC on the USB DP signal line.<br />
A high speed USB device (480Mbps) will initially appear as a full speed device to the host. The first thing the USB host does is to attempt to send /receive packets at high speed to the USB device. This is known as J and K chirp and if communication is successful it will be assumed that the USB device is a high speed device. If this initial communication fails then the USB host assumes that the device is a full speed  device. This means a high speed device has a 1k5 pull up resistor on USB DP that can be switched in / out of circuit</p>
<p><strong>Determining What Device is Attached (Device Descriptor)</strong><br />
Devices are identified by descriptors. Once the USB host has established a USB device is connected, and at what speed it should communicate,then the host will reset the USB device and attempt to read the descriptors to identify the USB device using a default address.<br />
This basically follows a question and answer process. The USB host will send a Get_Device_Descriptor command and then receive a packet of bytes with the descriptor length and the actual descriptor. At the completion of this stage the device is reset and given a unique address before getting the configuration and interface descriptors.</p>
<p><strong>bLength.</strong><br />
All USB devices have descriptors and the first key one is the Device Descriptor. The length is 18 bytes<br />
and it is bDdescriptorType is type 1. </p>
<p><strong>bcdUSB.</strong><br />
This is used to identify the device as a USB 1.0, USB 1.1 or USB 2.0 compliant device</p>
<p><strong>bDeviceClass, bDeviceSubClass and bProtocol</strong><br />
The bDeviceClass of device defines the device type e.g. a USB Mouse is a Human Interface Device (HID)<br />
class device. This is given a hex value of 0&#215;03.More complex devices such as Communication Device Class (CDC) may also use a sub class to break down the device type into a smaller group.</p>
<p><strong>bMaxPacketSize</strong><br />
This defines the maximum number of bytes in a packet from an endpoint</p>
<p><strong>idVendor and idProduct</strong><br />
The idVendor (VID) is assigned to a company by the USB Implementers Forum. An idProduct (PID) is used with this value to help associate a device with a manufacturer and product. It is also used to help link the hardware with a specific driver.<br />
<strong>iManufacturer, iProduct and iSerialNumber</strong><br />
These values are indexes to the Manufacturer string, the Product name string, and the Serial Number strings. These descriptors help make the identifiers more human readable and can be of variable length.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/12/articledescription-of-usb-device-enumeration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jatinder Kumar:</title>
		<link>https://www.emblogic.com/blog/10/jatinder-kumar-2/</link>
		<comments>https://www.emblogic.com/blog/10/jatinder-kumar-2/#comments</comments>
		<pubDate>Fri, 18 Oct 2013 08:47:56 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Block Driver]]></category>
		<category><![CDATA[Device Drivers]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7323</guid>
		<description><![CDATA[Successfully implemented Basic Block driver. From registeration to alloc_dsik, add_disk, request and transfer function.Completed documentations also]]></description>
				<content:encoded><![CDATA[<p>Successfully implemented Basic Block driver. From registeration to alloc_dsik, add_disk, request and transfer function.Completed documentations also</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/10/jatinder-kumar-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Olinuxino:</title>
		<link>https://www.emblogic.com/blog/10/olinuxino/</link>
		<comments>https://www.emblogic.com/blog/10/olinuxino/#comments</comments>
		<pubDate>Sat, 12 Oct 2013 06:29:59 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[pravjot sir]]></category>
		<category><![CDATA[Siddharth Sir. Varun sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7318</guid>
		<description><![CDATA[How can i install flex2bin in my host? I tried but getting error in installiation of the this tooll.]]></description>
				<content:encoded><![CDATA[<p>How can i install flex2bin in my host? I tried but getting error in installiation of the this tooll. </p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/10/olinuxino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jatinder Kumar : Porting</title>
		<link>https://www.emblogic.com/blog/10/jatinder-kumar-porting/</link>
		<comments>https://www.emblogic.com/blog/10/jatinder-kumar-porting/#comments</comments>
		<pubDate>Thu, 10 Oct 2013 06:00:32 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Project 9: Embedded Linux on ARM]]></category>
		<category><![CDATA[pravjot sir]]></category>
		<category><![CDATA[Siddharth Sir. Varun sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7266</guid>
		<description><![CDATA[can anyone tell me how can i set console during loading rootfile system via NFS . I compiled my kernel and set the commandline string as root=/dev/nfs rootwait console=ttyS0,115200n8 and i also try bootargs environment varible of u boot but &#8230; <a href="https://www.emblogic.com/blog/10/jatinder-kumar-porting/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>can anyone tell me how can i set console during loading rootfile system via NFS . I compiled my kernel and set the commandline string  as root=/dev/nfs rootwait console=ttyS0,115200n8<br />
and i also try bootargs environment varible of u boot<br />
but i am still struck in the same problem.<br />
i know the kernel is booting but i can&#8217;t see the output on my console.<br />
I tried to understand JTAG but still confused that if i need extra hardware for it or not</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/10/jatinder-kumar-porting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jatinder Kumar :c</title>
		<link>https://www.emblogic.com/blog/10/jatinder-kumar-c/</link>
		<comments>https://www.emblogic.com/blog/10/jatinder-kumar-c/#comments</comments>
		<pubDate>Thu, 03 Oct 2013 17:48:29 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Dheeraj sir]]></category>
		<category><![CDATA[jasmees ma'am]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7210</guid>
		<description><![CDATA[how can i use qsort? and how can i use pragma more efiiciently and what are the set of pragma in gcc as allcomplier has it won set of pragma and hoe can i used pragma in c?]]></description>
				<content:encoded><![CDATA[<p>how  can i use qsort?<br />
and how can i use pragma more efiiciently and what are the set of pragma in gcc as allcomplier has it won set of pragma and hoe can i used pragma in c?</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/10/jatinder-kumar-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jatinder Kumar :Beaglebone</title>
		<link>https://www.emblogic.com/blog/10/jatinder-kumar-beaglebone/</link>
		<comments>https://www.emblogic.com/blog/10/jatinder-kumar-beaglebone/#comments</comments>
		<pubDate>Tue, 01 Oct 2013 05:37:44 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7208</guid>
		<description><![CDATA[Successfully load uImage from tftp server to beaglebone. and bringup the board.]]></description>
				<content:encoded><![CDATA[<p>Successfully load uImage from tftp server to beaglebone. and bringup the board.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/10/jatinder-kumar-beaglebone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C: JATINDER KUMAR</title>
		<link>https://www.emblogic.com/blog/09/c-jatinder-kumar-3/</link>
		<comments>https://www.emblogic.com/blog/09/c-jatinder-kumar-3/#comments</comments>
		<pubDate>Sun, 01 Sep 2013 11:57:00 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7166</guid>
		<description><![CDATA[What is the difference between a deep copy and a shallow copy?]]></description>
				<content:encoded><![CDATA[<p>What is the difference between a deep copy and a shallow copy?</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/09/c-jatinder-kumar-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C: JATINDER KUMAR</title>
		<link>https://www.emblogic.com/blog/08/c-jatinder-kumar-2/</link>
		<comments>https://www.emblogic.com/blog/08/c-jatinder-kumar-2/#comments</comments>
		<pubDate>Tue, 20 Aug 2013 16:35:22 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7112</guid>
		<description><![CDATA[Which code will run faster for(i=0;i&#60;100;i++) for(j=0;j&#60;10;j++) a[i][j]=0; OR for(j=0;j&#60;10;j++) for(i=0;i&#60;100;i++) a[i][j]=0;]]></description>
				<content:encoded><![CDATA[<p>Which code will run faster</p>
<p>for(i=0;i&lt;100;i++)<br />
for(j=0;j&lt;10;j++)<br />
a[i][j]=0;</p>
<p>OR</p>
<p>for(j=0;j&lt;10;j++)<br />
for(i=0;i&lt;100;i++)<br />
a[i][j]=0;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/c-jatinder-kumar-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jatinder Kumar</title>
		<link>https://www.emblogic.com/blog/08/jatinder-kumar/</link>
		<comments>https://www.emblogic.com/blog/08/jatinder-kumar/#comments</comments>
		<pubDate>Fri, 16 Aug 2013 17:15:37 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7105</guid>
		<description><![CDATA[done C test paper 2nd and 7th &#8230; by doing this learn more new thing&#8230;.]]></description>
				<content:encoded><![CDATA[<p><em> done <strong>C test paper 2nd and 7th </strong>&#8230;<br />
by doing this learn more new thing&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/jatinder-kumar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>c: JATINDER KUMAR</title>
		<link>https://www.emblogic.com/blog/08/c-jatinder-kumar/</link>
		<comments>https://www.emblogic.com/blog/08/c-jatinder-kumar/#comments</comments>
		<pubDate>Fri, 16 Aug 2013 12:04:49 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7103</guid>
		<description><![CDATA[#include static unsigned char h[5] = {1,2,3,4,5}; int main() { struct ad { unsigned short a; unsigned short b; }; struct ad *it; it = (struct ad *)h; printf(&#8220;%d &#8220;,it-&#62;a); printf(&#8220;%d &#8220;,it-&#62;b); } what will be the output and whyu????]]></description>
				<content:encoded><![CDATA[<p>#include</p>
<p>  static unsigned char h[5] = {1,2,3,4,5};</p>
<p>   int main()<br />
   {<br />
           struct ad<br />
           {<br />
                 unsigned short a;<br />
                 unsigned short b;<br />
        };<br />
        struct ad *it;</p>
<p>         it = (struct ad *)h;</p>
<p>         printf(&#8220;%d &#8220;,it-&gt;a);<br />
         printf(&#8220;%d &#8220;,it-&gt;b);<br />
}<br />
what will  be the output and  whyu????</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/c-jatinder-kumar/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>C ASSIGNMENT :jatinder kumar</title>
		<link>https://www.emblogic.com/blog/08/c-assignment-jatinder-kumar/</link>
		<comments>https://www.emblogic.com/blog/08/c-assignment-jatinder-kumar/#comments</comments>
		<pubDate>Sat, 10 Aug 2013 03:34:56 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7083</guid>
		<description><![CDATA[did higl level file i/o assignment]]></description>
				<content:encoded><![CDATA[<p>did higl level file i/o assignment </p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/c-assignment-jatinder-kumar/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-3/</link>
		<comments>https://www.emblogic.com/blog/08/c-assignment-status-3/#comments</comments>
		<pubDate>Wed, 07 Aug 2013 10:48:23 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7024</guid>
		<description><![CDATA[Completed 43 question of c assignment.]]></description>
				<content:encoded><![CDATA[<p>Completed 43 question of c assignment.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/c-assignment-status-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>30.1.30: Jatinder Kumar</title>
		<link>https://www.emblogic.com/blog/07/30-1-30-jatinder-kmau/</link>
		<comments>https://www.emblogic.com/blog/07/30-1-30-jatinder-kmau/#comments</comments>
		<pubDate>Sat, 20 Jul 2013 16:26:46 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[Device Drivers]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6879</guid>
		<description><![CDATA[From last two weeks i am working on Character Driver. What is device driver and need of driver? From my knowledge device driver is nothing but piece of code that runs the device . Every device need that code to &#8230; <a href="https://www.emblogic.com/blog/07/30-1-30-jatinder-kmau/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>From last two weeks i am working on Character Driver.</p>
<p>What is  device driver and need of driver?<br />
From my knowledge device driver is nothing but piece of code that runs the device . Every device need that code to run ,without driver device is dead, to make device alive we have to provide that code.<br />
This code is nothing but the driver.<br />
When the driver sit in the hardware permanently that that driver is called firmware , when this driver set the rule how the system boot up then this driver know as BIOS.<br />
So i can conclude that every device need a piece of software to run the device. Driver not also run the device but it also decide that what will do i the device is on ,running and shutdown. From booting of the device to shutdown device need the support of the driver.</p>
<p>Types of device driver:<br />
1. Character driver<br />
2.  block driver<br />
3. Network driver/pipe driver</p>
<p>In this article i will talk about character driver.  Character-driven drivers are device drivers that operate on characters (bytes) as the basic unit of input and<br />
 output. They are accessed in a sequential, nonrandom manner.<br />
 We can access the device as the file and operation of file like read, write ,open close and lseek.</p>
<p>Linux kernel have feature that we can add functionality when the system is being running and similarly we can remove some functionality. We can add or remove functionality by mean of piece of code and that piece of code is nothing but the module. When the module is inserted then it works as the part of the Linux kernel. </p>
<p>In short we can add or remove the module. For adding the module i used insmod command and for removing it i used rmmod command.<br />
By doing insmode we can see our module is inserted in the kernel to cross check i used lsmod command and i saw that my module was i the list. As soon as i do rmmod i saw that my module was not there.</p>
<p>Now question comes what is moudle?<br />
As i already told that module in nothing but the piece of code. Every module as at-least two function initialization function and cleanup function.<br />
When the module is inserted by insmode the initialization function does it work and this function is initialized by a macro module_init().<br />
And when we do rmmode the cleanup function does its job and this function is invoked by the module_exit() function .<br />
And one thing we should keep in mind that what we have did in the initialization function we have do remove that in revere order int the cleanup function.<br />
After inserted the module in the kernel i register the my module first by older way register_chrdev(), this function takes three argument major no, driver_name, and a pointer to struct file operations . By giving major number as 0 we do let the kernel to choose the lowest available major number  and for unregistering  the  module i used unregister_chrdev(). It takes two argumnet major number and same device_name.<br />
This method is now obsolete. Now a days developer used new method for registration and unregistration. But if we dig out the code of the old driver we still found that this method is being used.</p>
<p>The newer function to registering the device is alloc_chrdev_region and register_chrdev_region.<br />
The alloc_chardev_region register the module by taking three argument first one is a pointer of dev_t and first minor no which is always 0 third argument is integer number and fourth is the deive name. By using this function we let the kernel to choice available major number.<br />
Same thing is done by register_chrdev_region function  but in this we have to provide the major number. It is always advisable that not to choose the major number statically because that major may also be used by the some other driver so a good developer pick the major number dynamically by using alloc_chrdev_region() for very first time . I also used alloc_chredv_region() for the first time and when i get the major number i used that major number in the second function  and the number of node (ie how many i want to register the device for that particular driver/module  ). The second one also prevent the registration of the same module in the kernel .</p>
<p>Then i declared a user defined structure struct ScullDev{}; this structure has initially it has two member  first is pointer to struct scullqset and a varible of type struct cdec.</p>
<p>And the struct ScullQset has the the various member like a void pointer , a pointer itself and lot more like device size,qset size ,quantum size. The void pointer has the that address where our data actually reside.</p>
<p>Next i used cdev_init() and cdev_add() functionn. By using cdev_intit function i initialized the chracter device and by using cdev_add() i inform the kernel.<br />
Before going on this step i understand the some structure  like file structure , inode structure, file_operations structure and relation between them. </p>
<p>Then i made a simple application for testing the driver. In which i simply used open ,write,read and close command.</p>
<p>In my driver i mapped the open command to my own open routine same i did for read,write ,close and lseek . And made nod by using mknod of type c and provide this mode major and minor number which i got for the alloc_chrdev_region. By doing this when i run my application using this node and when my application try to open the device it open the device according to my routine. </p>
<p>I made my open routine  , close routine and  read and write . In this routine i used my own algorithm  to read and write and trim .<br />
In write function and also used kmallc function to allocate the memory from kernel space  which is physical memory and cop_from_user macro. </p>
<p>And in read routine i track the quantum which is created and used copy_to_user macro.</p>
<p>In open routine i used container_of macro .</p>
<p>Until now i successfully implemented open ,write,read,release ,lseek<br />
 and application open the device in write only mode it first to trim. And open the driver after writing some data it will trim all the data and also implemented the driver for other version of read in which it free that quantum that  is read. </p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/30-1-30-jatinder-kmau/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>30.1.30: JATINDER KUNAR</title>
		<link>https://www.emblogic.com/blog/07/30-1-30-jatinder-kunar/</link>
		<comments>https://www.emblogic.com/blog/07/30-1-30-jatinder-kunar/#comments</comments>
		<pubDate>Thu, 11 Jul 2013 16:52:22 +0000</pubDate>
		<dc:creator><![CDATA[Jatinder Kumar]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[Device Drivers]]></category>
		<category><![CDATA[to pravjot sir]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6707</guid>
		<description><![CDATA[Implemented the driver fror n number of byte reading and n number of byte writing. Now going to sleep as provjot sir said today &#8230;. go to bed on time. good night. RCS file: lkm.c,v Working file: lkm.c head: 1.17 &#8230; <a href="https://www.emblogic.com/blog/07/30-1-30-jatinder-kunar/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Implemented the driver fror n number of byte reading and n number of byte writing. Now going to sleep as provjot sir said today &#8230;. go to bed on time. good night.<br />
RCS file: lkm.c,v<br />
Working file: lkm.c<br />
head: 1.17<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 17;    selected revisions: 17<br />
description:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.17<br />
date: 2013/07/11 16:39:20;  author: jatinder;  state: Exp;  lines: +44 -5<br />
Ipmelemented Scull_read ().<br />
Successfully aabled to read n bytes of data by my driver.<br />
the read algo is same a that of in scull_write.<br />
app successfully read and write via node to drive.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.16<br />
date: 2013/07/11 15:25:43;  author: jatinder;  state: Exp;  lines: +49 -2<br />
fial to open scull_read.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15<br />
date: 2013/07/11 10:12:17;  author: jatinder;  state: Exp;  lines: +44 -16<br />
Implemented the write for multiple scullqset successfully.<br />
counted lnoq for inner loop for according to remaining bytes.<br />
SO that inner loop never run more then 8 bytes ie onlu for 1 scullqset.<br />
for next scullqset i used my own alogrithim.<br />
preserved size in fnobtw , updted fnobtm and fnobsw .<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.14<br />
date: 2013/07/11 06:39:26;  author: jatinder;  state: Exp;  lines: +11 -4<br />
Implemented copy_from_user fro n number of quauntum .<br />
for this we made our own algorithm.<br />
/.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/11 06:03:50;  author: jatinder;  state: Exp;  lines: +64 -14<br />
implemented copy_from_user for 1 quantum .<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/09 10:17:35;  author: jatinder;  state: Exp;  lines: +66 -6<br />
implemented the create_qset for n number of qsets.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/09 07:34:52;  author: jatinder;  state: Exp;  lines: +25 -11<br />
Implemented create_scullqset() for nosqs .<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/09 07:18:15;  author: jatinder;  state: Exp;  lines: +61 -0<br />
calculated the no of quantum  and no of scullqset.<br />
implemented the create_scullqset() for creatinf 1 scullqset.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/08 08:31:27;  author: jatinder;  state: Exp;  lines: +28 -2<br />
Gave the declartion of scull_read() and scull_write().<br />
and in header mapped the read and write funtion to scull_read and sucll_write .<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/08 07:32:22;  author: jatinder;  state: Exp;  lines: +19 -3<br />
in sucll_trim function we checked for fsculldev and fscullded-&gt;sucllqet that is is NULL or have some value.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/04 06:51:41;  author: jatinder;  state: Exp;  lines: +61 -15<br />
decaled lsculldev in open routine.<br />
used container_of macro.<br />
save the information given by container_of macro in struct inode&#8217;s private_data member.<br />
call the scull_trim function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6</p>
<p>date: 2013/07/03 09:27:59;  author: jatinder;  state: Exp;  lines: +57 -1<br />
gave defination of sucll_open() and scull_realse() .<br />
intialized variable od sculldev for number of nod.<br />
scucessfully opend the file from my driver.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/03 07:42:02;  author: jatinder;  state: Exp;  lines: +32 -25<br />
used loop scull_setupfunction to add nod number of device<br />
in clenup_func() used nod number of time cdev_del().<br />
and save the major and minor number in tmp.<br />
pssed this tmp in unregister_chrdev_region for unregister the driver<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/03 06:57:12;  author: jatinder;  state: Exp;  lines: +54 -0<br />
declared scull_setup function.<br />
used cdev_init and cdev_add() in this function.<br />
initialized the members of struct cdev.<br />
in cleanup routine used cdev_del() function .<br />
in cleanup routine always do things in the reverse order wrt initialization routine.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/03 06:02:39;  author: jatinder;  state: Exp;  lines: +13 -0<br />
used kmalloc for number of node.<br />
and used kfree function in cleanup module.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/03 05:30:46;  author: jatinder;  state: Exp;  lines: +24 -9<br />
used register_chrdev_region function.<br />
call param_module<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/02 19:45:49;  author: jatinder;  state: Exp;<br />
Initial revision<br />
=============================================================================<br />
                                                                                                                                  105,1         Bot</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/30-1-30-jatinder-kunar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
