<?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; amit.dalal</title>
	<atom:link href="https://www.emblogic.com/blog/author/amit-dalal/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>memory management concept</title>
		<link>https://www.emblogic.com/blog/03/memory-management-concept/</link>
		<comments>https://www.emblogic.com/blog/03/memory-management-concept/#comments</comments>
		<pubDate>Fri, 21 Mar 2014 06:46:13 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Linux Internals and System Programming]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9199</guid>
		<description><![CDATA[Memory Management The memory management subsystem is one of the most important parts of the operating system. Since the early days of computing, there has been a need for more memory than exists physically in a system. Strategies have been &#8230; <a href="https://www.emblogic.com/blog/03/memory-management-concept/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Memory Management</p>
<p>The memory management subsystem is one of the most important parts of the operating system. Since the early days of computing, there has been a need for more memory than exists physically in a system. Strategies have been developed to overcome this limitation and the most successful of these is virtual memory. Virtual memory makes the system appear to have more memory than is physically present by sharing it among competing processes as they need it.</p>
<p>Virtual memory does more than just make your computer&#8217;s memory go farther. The memory management subsystem provides:</p>
<p>&nbsp;</p>
<dl>
<dt><strong>Large Address Spaces</strong></dt>
<dd>The operating system makes the system appear as if it has a larger amount of memory than it actually has. The virtual memory can be many times larger than the physical memory in the system.&nbsp;</p>
</dd>
<dt><strong>Protection</strong></dt>
<dd>Each process in the system has its own virtual address space. These virtual address spaces are completely separate from each other and so a process running one application cannot affect another. Also, the hardware virtual memory mechanisms allow areas of memory to be protected against writing. This protects code and data from being overwritten by rogue applications.&nbsp;</p>
</dd>
<dt><strong>Memory Mapping</strong></dt>
<dd>Memory mapping is used to map image and data files into a process&#8217; address space. In memory mapping, the contents of a file are linked directly into the virtual address space of a process.&nbsp;</p>
</dd>
<dt><strong>Fair Physical Memory Allocation</strong></dt>
<dd>The memory management subsystem allows each running process in the system a fair share of the physical memory of the system.&nbsp;</p>
</dd>
<dt><strong>Shared Virtual Memory</strong></dt>
<dd>Although virtual memory allows processes to have separate (virtual) address spaces, there are times when you need processes to share memory. For example there could be several processes in the system running the <span>bash</span> command shell. Rather than have several copies of <span>bash</span>, one in each process&#8217;s virtual address space, it is better to have only one copy in physical memory and all of the processes running <span>bash</span> share it. Dynamic libraries are another common example of executing code shared between several processes.Shared memory can also be used as an Inter Process Communication (IPC) mechanism, with two or more processes exchanging information via memory common to all of them. Linux supports the Unix System V shared memory IPC.</p>
<p>Virtual Memory</p>
<p>&nbsp;</p>
<h3>An Abstract Model of Virtual Memory</h3>
<p>&nbsp;</p>
<p><img src="http://linuxtutorial.info/Linux_Tutorial/The_Operating_System/The_Kernel/Memory_Management/vm.gif" alt="" />s</p>
<p>Figure: Abstract model of Virtual to Physical address mapping</p>
<p>&nbsp;</p>
<p>Before considering the methods that Linux uses to support virtual memory it is useful to consider an abstract model that is not cluttered by too much detail.</p>
<p>As the processor executes a program it reads an instruction from memory and decodes it. In decoding the instruction, the processor may need to fetch or store the contents of a location in memory. The processor then executes the instruction and moves on to the next instruction in the program. In this way the processor is always accessing memory either to fetch instructions or to fetch and store data.</p>
<p>In a virtual memory system all of these addresses are virtual addresses and not physical addresses. These virtual addresses are converted into physical addresses by the processor based on information held in a set of tables maintained by the operating system.</p>
<p>To make this translation easier, virtual and physical memory are divided into handy sized chunks called <em>pages</em>. These pages are all the same size. They need not be but if they were not, the system would be very hard to administer. Linux on Alpha AXP systems uses 8 Kbyte pages and on Intel x86 systems it uses 4 Kbyte pages. Each of these pages is given a unique number: the page frame number (PFN).</p>
<p>In this paged model, a virtual address is composed of two parts: an offset and a virtual page frame number. If the page size is 4 Kbytes, bits 1-10 of the virtual address contain the offset and bits 12 and above are the virtual page frame number. The processor extracts the virtual page frame number and offset from a virtual address every time it encounters one. Then it matches the virtual page frame number to a physical page and uses the offset to specify how far to go into the page. The processor uses <em>page tables</em> to match the virtual page frame number to the physical page.</p>
<p>The figure above shows the virtual address spaces of two processes, process <em>X</em> and process <em>Y</em>, each with their own page tables. These page tables map each process&#8217; virtual pages into physical pages in memory. This shows that process <em>X&#8217;s</em> virtual page frame number 0 is mapped into memory in physical page frame number 1 and that process <em>Y&#8217;s</em> virtual page frame number 1 is mapped into physical page frame number 4. Each entry in the page table contains the following information:</p>
<p>&nbsp;</p>
<ul>
<li>Valid flag. This indicates if this page table entry (PTE) is valid,</li>
<li>The physical page frame number that this entry describes</li>
<li>Access control information. This describes how the page may be used. Can it be written to? Does it contain executable code?</li>
</ul>
<p>The page table is accessed using the virtual page frame number as an offset. Virtual page frame 5 would be the 6th element of the table (0 is the first element).</p>
<p>To translate a virtual address into a physical one, the processor must first work out the virtual address&#8217; page frame number and the offset within that virtual page. By making the page size a power of 2 this can be easily done by masking and shifting. Looking again at the figures and assuming a page size of <em>0&#215;2000</em> bytes (which is decimal 8192) and an address of <em>0&#215;2194</em> in process <em>Y&#8217;s</em> virtual address space then the processor would translate that address into offset <em>0&#215;194</em> into virtual page frame number 1.</p>
<p>The processor uses the virtual page frame number as an index into the process&#8217; page table to retrieve its page table entry. If the page table entry at that offset is valid, the processor takes the physical page frame number from this entry. If the entry is invalid, the process has accessed a non-existent area of its virtual memory. In this case, the processor cannot resolve the address and must pass control to the operating system so that it can fix things up.</p>
<p>Just how the processor notifies the operating system that the correct process has attempted to access a virtual address for which there is no valid translation is specific to the processor. However the processor delivers it, this is known as a <em>page fault</em> and the operating system is notified of the faulting virtual address and the reason for the page fault.</p>
<p>For a valid page table entry, the processor takes that physical page frame number and multiplies it by the page size to get the address of the base of the page in physical memory. Finally, the processor adds in the offset to the instruction or data that it needs.</p>
<p>Using the above example again, process <em>Y&#8217;s</em> virtual page frame number 1 is mapped to physical page frame number 4 which starts at<em>0&#215;8000</em> (4 x <em>0&#215;2000</em>). Adding in the <em>0&#215;194</em> byte offset gives us a final physical address of <em>0&#215;8194</em>.</p>
<p>By mapping virtual to physical addresses this way, the virtual memory can be mapped into the system&#8217;s physical pages in any order. In the figure above, process <em>X&#8217;s</em> virtual page frame number 0 is mapped to physical page frame number 1, whereas virtual page frame number 7 is mapped to physical page frame number 0 although it is higher in virtual memory than virtual page frame number 0. This demonstrates an interesting byproduct of virtual memory; the pages of virtual memory do not have to be present in physical memory in any particular order.</p>
<p>&nbsp;</p>
<h3>Shared Virtual Memory</h3>
<p>Virtual memory makes it easy for several processes to share memory. All memory access are made via page tables and each process has its own separate page table. For two processes sharing a physical page of memory, its physical page frame number must appear in a page table entry in both of their page tables.</p>
<p>The figure above shows two processes that each share physical page frame number 4. For process <em>X</em> this is virtual page frame number 4 whereas for process <em>Y</em> this is virtual page frame number 6. This illustrates an interesting point about sharing pages: the shared physical page does not have to exist at the same place in virtual memory for any or all of the processes sharing it.</p>
<p>&nbsp;</p>
<h3>Physical and Virtual Addressing Modes</h3>
<p>It does not make much sense for the operating system itself to run in virtual memory. This would be a nightmare situation where the operating system must maintain page tables for itself. Most multi-purpose processors support the notion of a physical address mode as well as a virtual address mode. Physical addressing mode requires no page tables and the processor does not attempt to perform any address translations in this mode. The Linux kernel is linked to run in physical address space.</p>
<p>The Alpha AXP processor does not have a special physical addressing mode. Instead, it divides up the memory space into several areas and designates two of them as physically mapped addresses. This kernel address space is known as KSEG address space and it encompasses all addresses upwards from <em>0xfffffc0000000000</em>. In order to execute from code linked in KSEG (by definition, kernel code) or access data there, the code must be executing in kernel mode. The Linux kernel on Alpha is linked to execute from address<em>0xfffffc0000310000</em>.</p>
<p>&nbsp;</p>
<h3>Access Control</h3>
<p>The page table entries also contain access control information. As the processor is already using the page table entry to map a process&#8217; virtual address to a physical one, it can easily use the access control information to check that the process is not accessing memory in a way that it should not.</p>
<p>There are many reasons why you would want to restrict access to areas of memory. Some memory, such as that containing executable code, is naturally read only memory; the operating system should not allow a process to write data over its executable code. By contrast, pages containing data can be written to, but attempts to execute that memory as instructions should fail. Most processors have at least two modes of execution: <em>kernel</em> and <em>user</em>. This adds a level of security to your operating system. Because it is the core of the operating system and therefore can do most anything, kernel code is only run when the CPU is in kernel mode. You would not want kernel code executed by a user or kernel data structures to be accessible except when the processor is running in kernel mode.</p>
<p>1. What is the difference between Swapping and Paging?</p>
<div>
<p>&nbsp;</p>
<p><strong>Swapping</strong>: Whole process is moved from the swap device to the main memory for execution. Process size must be less than or equal to the available main memory. It is easier to implementation and overhead to the system. Swapping systems does not handle the memory more flexibly as compared to the paging systems.</p>
<p><strong>Paging</strong>: Only the required memory pages are moved to main memory from the swap device for execution. Process size does not matter. Gives the concept of the virtual memory. It provides greater flexibility in mapping the virtual address space into the physical memory of the machine. Allows more number of processes to fit in the main memory simultaneously. Allows the greater process size than the available physical memory. Demand paging systems handle the memory more flexibly.</p>
<div>
<p><strong> 3.What is the main goal of the Memory Management?</strong></p>
<div>
<p>&nbsp;</p>
<ol>
<li>It decides which process should reside in the main memory,</li>
<li>Manages the parts of the virtual address space of a process which is non-core resident,</li>
<li>Monitors the available main memory and periodically write the processes into the swap device to provide more processes fit in the main memory simultaneously.</li>
</ol>
<p>&nbsp;</p>
</div>
</div>
<div>
<p>4. What is a Map?</p>
<div>
<p>&nbsp;</p>
<p>A Map is an Array, which contains the addresses of the free space in the swap device that are allocatable resources, and the number of the resource units available there.</p>
<p>Address Units<br />
1     10,000</p>
<p>This allows First-Fit allocation of contiguous blocks of a resource. Initially the Map contains one entry &#8211; address (block offset from the starting of the swap area) and the total number of resources.</p>
<p>Kernel treats each unit of Map as a group of disk blocks. On the allocation and freeing of the resources Kernel updates the Map for accurate information.</p>
<p><strong>5. What is a Region?</strong></p>
<div>
<p>A Region is a continuous area of a process&#8217;s address space (such as text, data and stack). The kernel in a &#8220;Region Table&#8221; that is local to the process maintains region. Regions are sharable among the process.</p>
<p><strong> What is Fork swap?</strong></p>
<div>
<p>&#8220;fork()&#8221; is a system call to create a child process. When the parent process calls &#8220;fork()&#8221; system call, the child process is created and if there is short of memory then the child process is sent to the read-to-run state in the swap device, and return to the user state without swapping the parent process. When the memory will be available the child process will be swapped into the main memory.</p>
</div>
</div>
</div>
</div>
</div>
</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/memory-management-concept/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>static and shared libraries</title>
		<link>https://www.emblogic.com/blog/03/static-and-shared-libraries/</link>
		<comments>https://www.emblogic.com/blog/03/static-and-shared-libraries/#comments</comments>
		<pubDate>Thu, 13 Mar 2014 07:38:35 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Linux Internals and System Programming]]></category>
		<category><![CDATA[Project 00: Linux System / Network Administration]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9051</guid>
		<description><![CDATA[When a C program is compiled, the compiler generates object code. After generating the object code, the compiler also invokes linker. One of the main tasks for linker is to make code of library functions (eg printf(), scanf(), sqrt(), ..etc) &#8230; <a href="https://www.emblogic.com/blog/03/static-and-shared-libraries/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>When a C program is compiled, the compiler generates object code. After generating the object code, the compiler also invokes linker. One of the main tasks for linker is to make code of library functions (eg printf(), scanf(), sqrt(), ..etc) available to your program. A linker can accomplish this task in two ways, by copying the code of library function to your object code, or by making some arrangements so that the complete code of library functions is not copied, but made available at run-time.</p>
<p><strong>Static Linking and Static Libraries</strong> is the result of the linker making copy of all used library functions to the executable file. Static Linking creates larger binary files, and need more space on disk and main memory. Examples of static libraries (libraries which are statically linked) are, <strong><em>.a</em></strong> files in Linux and <strong><em>.lib </em></strong>files in Windows.</p>
<p><strong>Steps to create a static library</strong> Let us create and use a Static Library in UNIX or UNIX like OS.<br />
<strong>1.</strong> Create a C file that contains functions in your library.</p>
<div>
<div>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>
<div><code>/* Filename: lib_mylib.c */</code></div>
<div><code>#include &lt;stdio.h&gt;</code></div>
<div><code>void</code> <code>fun(</code><code>void</code><code>)</code></div>
<div><code>{</code></div>
<div><code>  </code><code>printf</code><code>(</code><code>"fun() called from a static library"</code><code>);</code></div>
<div><code>}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>We have created only one file for simplicity. We can also create multiple files in a library.</p>
<p><strong>2.</strong> Create a header file for the library</p>
<div>
<div>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>
<div><code>/* Filename: lib_mylib.h */</code></div>
<div><code>void</code> <code>fun(</code><code>void</code><code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>3. </strong>Compile library files.</p>
<pre> gcc -c lib_mylib.c -o lib_mylib.o</pre>
<p><strong>4. </strong> Create static library. This step is to bundle multiple object files in one static library (see <a href="http://en.wikipedia.org/wiki/Ar_%28Unix%29">ar </a>for details). The output of this step is static library.</p>
<pre> ar rcs lib_mylib.a lib_mylib.o</pre>
<p><strong>5. </strong>Now our static library is ready to use. At this point we could just copy lib_hello_static.a somewhere else to use it. For demo purposes, let us keep the library in the current directory.</p>
<p><strong>Let us create a driver program that uses above created static library</strong>.<br />
<strong>1.</strong> Create a C file with main function</p>
<div>
<div>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>
<div><code>/* filename: driver.c  */</code></div>
<div><code>#include "lib_mylib.h"</code></div>
<div>
<div>
<div>
<div>
<div>
<h2>Static and Dynamic Libraries | Set 1</h2>
</div>
<div>
<p>When a C program is compiled, the compiler generates object code. After generating the object code, the compiler also invokes linker. One of the main tasks for linker is to make code of library functions (eg printf(), scanf(), sqrt(), ..etc) available to your program. A linker can accomplish this task in two ways, by copying the code of library function to your object code, or by making some arrangements so that the complete code of library functions is not copied, but made available at run-time.</p>
<p><strong>Static Linking and Static Libraries</strong> is the result of the linker making copy of all used library functions to the executable file. Static Linking creates larger binary files, and need more space on disk and main memory. Examples of static libraries (libraries which are statically linked) are, <strong><em>.a</em></strong> files in Linux and <strong><em>.lib </em></strong>files in Windows.</p>
<p><strong>Steps to create a static library</strong> Let us create and use a Static Library in UNIX or UNIX like OS.<br />
<strong>1.</strong> Create a C file that contains functions in your library.</p>
<div>
<div>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>
<div><code>/* Filename: lib_mylib.c */</code></div>
<div><code>#include &lt;stdio.h&gt;</code></div>
<div><code>void</code> <code>fun(</code><code>void</code><code>)</code></div>
<div><code>{</code></div>
<div><code>  </code><code>printf</code><code>(</code><code>"fun() called from a static library"</code><code>);</code></div>
<div><code>}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>We have created only one file for simplicity. We can also create multiple files in a library.</p>
<p><strong>2.</strong> Create a header file for the library</p>
<div>
<div>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>
<div><code>/* Filename: lib_mylib.h */</code></div>
<div><code>void</code> <code>fun(</code><code>void</code><code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>3. </strong>Compile library files.</p>
<pre> gcc -c lib_mylib.c -o lib_mylib.o</pre>
<p><strong>4. </strong> Create static library. This step is to bundle multiple object files in one static library (see <a href="http://en.wikipedia.org/wiki/Ar_%28Unix%29">ar </a>for details). The output of this step is static library.</p>
<pre> ar rcs lib_mylib.a lib_mylib.o</pre>
<p><strong>5. </strong>Now our static library is ready to use. At this point we could just copy lib_hello_static.a somewhere else to use it. For demo purposes, let us keep the library in the current directory.</p>
<p><strong>Let us create a driver program that uses above created static library</strong>.<br />
<strong>1.</strong> Create a C file with main function</p>
<div>
<div>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>
<div><code>/* filename: driver.c  */</code></div>
<div><code>#include "lib_mylib.h"</code></div>
<div><code>void</code> <code>main() </code></div>
<div><code>{</code></div>
<div><code>  </code><code>fun();</code></div>
<div><code>}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>2.</strong> Compile the driver program.</p>
<pre>gcc -c driver.c -o driver.o</pre>
<p><strong>3.</strong> Link the compiled driver program to the static library. Note that -L<strong>.</strong> is used to tell that the static library is in current folder (See <a href="http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html" target="_blank">this </a>for details of -L and -l options).</p>
<pre>gcc -o driver driver.o -L. -l_mylib</pre>
<p><strong>4.</strong> Run the driver program</p>
<pre>./driver 
fun() called from a static library</pre>
<p>Following are some important points about static libraries.<br />
<strong>1.</strong> For a static library, the actual code is extracted from the library by the linker and used to build the final executable at the point you compile/build your application.</p>
<p><strong>2. </strong>Each process gets its own copy of the code and data. Where as in case of dynamic libraries it is only code shared, data is specific to each process. For static libraries memory footprints are larger. For example, if all the window system tools were statically linked, several tens of megabytes of RAM would be wasted for a typical user, and the user would be slowed down by a lot of paging.</p>
<p><strong>3.</strong> Since library code is connected at compile time, the final executable has no dependencies on the the library at run time i.e. no additional run-time loading costs, it means that you don’t need to carry along a copy of the library that is being used and you have everything under your control and there is no dependency.</p>
<p><strong>4. </strong>In static libraries, once everything is bundled into your application, you don’t have to worry that the client will have the right library (and version) available on their system.</p>
<p><strong>5.</strong>One drawback of static libraries is, for any change(up-gradation) in the static libraries, you have to recompile the main program every time.</p>
<p><strong>6.</strong> One major advantage of static libraries being preferred even now “is speed”. There will be no dynamic querying of symbols in static libraries. Many production line software use static libraries even today.</p>
<p><strong>Dynamic linking and Dynamic Libraries</strong> Dynamic Linking doesn’t require the code to be copied, it is done by just placing name of the library in the binary file. The actual linking happens when the program is run, when both the binary file and the library are in memory. Examples of Dynamic libraries (libraries which are linked at run-time) are, <strong><em>.so</em></strong> in Linux and <strong><em>.dll</em></strong> in Windows.</p>
<p>We will soon be covering more points on Dynamic Libraries and steps to create them.</p>
<p>This article is compiled by <strong>Abhijit Saha </strong>and reviewed by GeeksforGeeks team. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>2.</strong> Compile the driver program.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/static-and-shared-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>swapping variable different method</title>
		<link>https://www.emblogic.com/blog/03/swapping-variable-different-method/</link>
		<comments>https://www.emblogic.com/blog/03/swapping-variable-different-method/#comments</comments>
		<pubDate>Mon, 10 Mar 2014 11:29:54 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=8973</guid>
		<description><![CDATA[How to swap two numbers without using a temporary variable? Given two variables, x and y, swap two variables without using a third variable. Method 1 (Using Arithmetic Operators) The idea is to get sum in one of the two &#8230; <a href="https://www.emblogic.com/blog/03/swapping-variable-different-method/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h2>How to swap two numbers without using a temporary variable?</h2>
<p><a name="more-612"></a>Given two variables, x and y, swap two variables without using a third variable.</p>
<p><strong>Method 1 (Using Arithmetic Operators)</strong><code><br />
The idea is to get sum in one of the two given numbers. The numbers can then be swapped using the sum and subtraction from sum.</code></p>
<p><code>include &lt;stdio.h&gt;</code></p>
<p><code>int</code> <code>main()</code></p>
<p><code>{</code></p>
<p><code>  </code><code>int</code> <code>x = 10, y = 5;</code></p>
<p>&nbsp;</p>
<p><code>  </code><code>// Code to swap 'x' and 'y'</code></p>
<p><code>  </code><code>x = x + y;  // x now becomes 15</code></p>
<p><code>  </code><code>y = x - y;  // y becomes 10</code></p>
<p><code>  </code><code>x = x - y;  // x becomes 5</code></p>
<p>&nbsp;</p>
<p><code>  </code><code>printf("After Swapping: x = %d, y = %d", x, y);</code></p>
<p>&nbsp;</p>
<p><code>  </code><code>return</code> <code>0;</code></p>
<p><code>}</code></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Output:</p>
<pre><code>After Swapping: x = 5, y = 10</code></pre>
<p><code><strong>Multiplication and division can also be used for swapping. </strong></code></p>
<p><code>include &lt;stdio.h&gt;</code></p>
<p><code>int</code> <code>main()</code></p>
<p><code>{</code></p>
<p><code>  </code><code>int</code> <code>x = 10, y = 5;</code></p>
<p>&nbsp;</p>
<p><code>  </code><code>// Code to swap 'x' and 'y'</code></p>
<p><code>  </code><code>x = x * y;  // x now becomes 50</code></p>
<p><code>  </code><code>y = x / y;  // y becomes 10</code></p>
<p><code>  </code><code>x = x / y;  // x becomes 5</code></p>
<p>&nbsp;</p>
<p><code>  </code><code>printf("After Swapping: x = %d, y = %d", x, y);</code></p>
<p>&nbsp;</p>
<p><code>  </code><code>return</code> <code>0;</code></p>
<p><code>}</code></p>
<p>&nbsp;</p>
<p>Output:</p>
<pre>After Swapping: x = 5, y = 10</pre>
<p><strong>Method 2 (Using Bitwise XOR)</strong><br />
The bitwise XOR operator can be used to swap two variables. The XOR of two numbers x and y returns a number which has all the bits as 1 wherever bits of x and y differ. For example XOR of 10 (In Binary 1010) and 5 (In Binary 0101) is 1111 and XOR of 7 (0111) and 5 (0101) is (0010).</p>
<p><code>#include &lt;stdio.h&gt;</code></p>
<p><code>int</code> <code>main()</code></p>
<p><code>{</code></p>
<p><code>  </code><code>int</code> <code>x = 10, y = 5;</code></p>
<p>&nbsp;</p>
<p><code>  </code><code>// Code to swap 'x' (1010) and 'y' (0101)</code></p>
<p><code>  </code><code>x = x ^ y;  // x now becomes 15 (1111)</code></p>
<p><code>  </code><code>y = x ^ y;  // y becomes 10 (1010)</code></p>
<p><code>  </code><code>x = x ^ y;  // x becomes 5 (0101)</code></p>
<p>&nbsp;</p>
<p><code>  </code><code>printf("After Swapping: x = %d, y = %d", x, y);</code></p>
<p>&nbsp;</p>
<p><code>  </code><code>return</code> <code>0;</code></p>
<p><code>}</code></p>
<p>Output:</p>
<pre>After Swapping: x = 5, y = 10</pre>
<p><strong>Problems with above methods</strong><br />
<strong>1)</strong> The multiplication and division based approach doesn’ work if one of the numbers is 0 as the product becomes 0 irrespective of the other number.</p>
<p><strong>2)</strong> Both Arithmetic solutions may cause arithmetic overflow. If x and y are too large, addition and multiplication may go out of integer range.</p>
<p><strong>3)</strong> When we use pointers to variable and make a function swap, all of the above methods fail when both pointers point to the same variable. Let’s take a look what will happen in this case if both are pointing to the same variable.</p>
<p>// Bitwise XOR based method<br />
x = x ^ x; // x becomes 0<br />
x = x ^ x; // x remains 0<br />
x = x ^ x; // x remains 0</p>
<p>// Arithmetic based method<br />
x = x + x; // x becomes 2x<br />
x = x – x; // x becomes x</p>
<p>x = x – x; // x becomes 0</p>
<p>Let us see the following program.</p>
<h3><code><em>#</em></code><code><em>include &lt;stdio.h&gt;</em></code></h3>
<p><code>void</code> <code>swap(int</code> <code>*xp, int</code> <code>*yp)</code></p>
<p><code>{</code></p>
<p><code>    </code><code>*xp = *xp ^ *yp;</code></p>
<p><code>    </code><code>*yp = *xp ^ *yp;</code></p>
<p><code>    </code><code>*xp = *xp ^ *yp;</code></p>
<p><code>}</code></p>
<p>&nbsp;</p>
<p><code>int</code> <code>main()</code></p>
<p><code>{</code></p>
<p><code>  </code><code>int</code> <code>x = 10;</code></p>
<p><code>  </code><code>swap(&amp;x, &amp;x);</code></p>
<p><code>  </code><code>printf("After swap(&amp;x, &amp;x): x = %d", x);</code></p>
<p><code>  </code><code>return</code> <code>0;</code></p>
<p><code>}</code></p>
<p>Output:</p>
<pre>After swap(&amp;x, &amp;x): x = 0</pre>
<p>Swapping a variable with itself may needed in many standard algorithms. For example see <a href="http://geeksquiz.com/quick-sort/" target="_blank">this </a>implementation of <a href="http://geeksquiz.com/quick-sort/" target="_blank">QuickSort </a>where we may swap a variable with itself. The above problem can be avoided by putting a condition before the swapping.</p>
<p><code>#</code><code>include &lt;stdio.h&gt;</code></p>
<p><code>void</code> <code>swap(int</code> <code>*xp, int</code> <code>*yp)</code></p>
<p><code>{</code></p>
<p><code>    </code><code>if</code> <code>(xp == yp) // Check if the two addresses are same</code></p>
<p><code>      </code><code>return;</code></p>
<p><code>    </code><code>*xp = *xp + *yp;</code></p>
<p><code>    </code><code>*yp = *xp - *yp;</code></p>
<p><code>    </code><code>*xp = *xp - *yp;</code></p>
<p><code>}</code></p>
<p><code>int</code> <code>main()</code></p>
<p><code>{</code></p>
<p><code>  </code><code>int</code> <code>x = 10;</code></p>
<p><code>  </code><code>swap(&amp;x, &amp;x);</code></p>
<p><code>  </code><code>printf("After swap(&amp;x, &amp;x): x = %d", x);</code></p>
<p><code>  </code><code>return</code> <code>0;</code></p>
<p>Output:</p>
<pre>After swap(&amp;x, &amp;x): x = 10</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/swapping-variable-different-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pointer-&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</title>
		<link>https://www.emblogic.com/blog/12/pointer/</link>
		<comments>https://www.emblogic.com/blog/12/pointer/#comments</comments>
		<pubDate>Thu, 05 Dec 2013 12:05:00 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7648</guid>
		<description><![CDATA[Introduction:-&#62;Pointer   A pointer is a variable that contains the address of a variable. Pointers are much used in C, partly because they are sometimes the only way to express a computation, and partly because they usually lead to more &#8230; <a href="https://www.emblogic.com/blog/12/pointer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><strong>Introduction:-&gt;Pointer</strong></p>
<p><strong> </strong></p>
<p>A pointer is a variable that contains the address of a variable. Pointers are much used in C,</p>
<p>partly because they are sometimes the only way to express a computation, and partly because</p>
<p>they usually lead to more compact and efficient code than can be obtained in other ways.</p>
<p>Pointers and arrays are closely related; this chapter also explores this relationship and shows</p>
<p>how to exploit it.</p>
<p>&nbsp;</p>
<p>This is certainly true when they are used carelessly, and it is easy to create pointers that point somewhere unexpected. With discipline, however, pointers can also be used to achieve clarity and simplicity. This is the aspect that we will try to illustrate.</p>
<p>&nbsp;</p>
<p>The main change in ANSI C is to make explicit the rules about how pointers can be</p>
<p>manipulated, in effect mandating what good programmers already practice and good compilers</p>
<p>already enforce. In addition, the type void * (pointer to void) replaces char * as the proper</p>
<p>type for a generic pointer.</p>
<p>&nbsp;</p>
<p><strong>Pointers and Addresses:-</strong></p>
<p><strong> </strong></p>
<p>Let us begin with a simplified picture of how memory is organized. A typical machine has an</p>
<p>array of consecutively numbered or addressed memory cells that may be manipulated</p>
<p>individually or in contiguous groups. One common situation is that any byte can be a char, 4 byte cells can be treated as a short integer, and 8 adjacent bytes form a long. A</p>
<p>pointer is a group of cells (often two or four) that can hold an address.</p>
<p>So if c is a char and p is a pointer that points to it, we could represent the situation this way:</p>
<p>&nbsp;</p>
<p>The unary operator &amp; gives the address of an object, so the statement</p>
<p>&nbsp;</p>
<p>p = &amp;c;</p>
<p>&nbsp;</p>
<p>assigns the address of c to the variable p, and p is said to &#8220;point to&#8221; c. The &amp; operator only</p>
<p>applies to objects in memory: variables and array elements. It cannot be applied to expressions,</p>
<p>constants, or register variables.</p>
<p>The unary operator * is the <em>indirection </em>or <em>dereferencing </em>operator; when applied to a pointer, it</p>
<p>accesses the object the pointer points to. Suppose that x and y are integers and ip is a pointer</p>
<p>to int. This artificial sequence shows how to declare a pointer and how to use &amp; and *:</p>
<p>int x = 1, y = 2, z[10];</p>
<p>int *ip; /* ip is a pointer to int */</p>
<p>ip = &amp;x; /* ip now points to x */</p>
<p>y = *ip; /* y is now 1 */</p>
<p>*ip = 0; /* x is now 0 */</p>
<p>ip = &amp;z[0]; /* ip now points to z[0] */</p>
<p>The declaration of x, y, and z are what we&#8217;ve seen all along.</p>
<p>&nbsp;</p>
<p><strong>Pointers and Arrays:-</strong></p>
<p><strong> </strong></p>
<p>In C, there is a strong relationship between pointers and arrays, strong enough that pointers</p>
<p>and arrays should be discussed simultaneously. Any operation that can be achieved by array</p>
<p>subscripting can also be done with pointers. The pointer version will in general be faster but, at</p>
<p>least to the uninitiated, somewhat harder to understand.</p>
<p>The declaration</p>
<p>int a[10];</p>
<p>defines an array of size 10, that is, a block of 10 consecutive objects named a[0], a[1],</p>
<p>&#8230;,a[9].</p>
<p>&nbsp;</p>
<p>The notation a[i] refers to the i-th element of the array. If pa is a pointer to an integer,</p>
<p>declared as</p>
<p>int *pa;</p>
<p>then the assignment</p>
<p>pa = &amp;a[0];</p>
<p>sets pa to point to element zero of a; that is, pa contains the address of a[0].</p>
<p>Now the assignment</p>
<p>x = *pa;</p>
<p>will copy the contents of a[0] into x.</p>
<p>If pa points to a particular element of an array, then by definition pa+1 points to the next</p>
<p>element, pa+i points i elements after pa, and pa-i points i elements before. Thus, if pa points</p>
<p>to a[0],</p>
<p>*(pa+1)</p>
<p>refers to the contents of a[1], pa+i is the address of a[i], and *(pa+i) is the contents of</p>
<p>a[i].</p>
<p>&nbsp;</p>
<p>These remarks are true regardless of the type or size of the variables in the array a. The</p>
<p>meaning of &#8220;adding 1 to a pointer,&#8221; and by extension, all pointer arithmetic, is that pa+1 points</p>
<p>to the next object, and pa+i points to the i-th object beyond pa.</p>
<p>The correspondence between indexing and pointer arithmetic is very close. By definition, the</p>
<p>value of a variable or expression of type array is the address of element zero of the array. Thus</p>
<p>after the assignment</p>
<p>pa = &amp;a[0];</p>
<p>pa and a have identical values. Since the name of an array is a synonym for the location of the</p>
<p>initial element, the assignment pa=&amp;a[0] can also be written as</p>
<p>pa = a;</p>
<p>Rather more surprising, at first sight, is the fact that a reference to a[i] can also be written as</p>
<p>*(a+i). In evaluating a[i], C converts it to *(a+i) immediately; the two forms are</p>
<p>equivalent. Applying the operator &amp; to both parts of this equivalence, it follows that &amp;a[i] and</p>
<p>a+i are also identical: a+i is the address of the i-th element beyond a. As the other side of this</p>
<p>coin, if pa is a pointer, expressions might use it with a subscript; pa[i] is identical to *(pa+i).</p>
<p>In short, an array-and-index expression is equivalent to one written as a pointer and offset.</p>
<p>There is one difference between an array name and a pointer that must be kept in mind. A</p>
<p>pointer is a variable, so pa=a and pa++ are legal. But an array name is not a variable;</p>
<p>constructions like a=pa and a++ are illegal.</p>
<p>When an array name is passed to a function, what is passed is the location of the initial</p>
<p>element. Within the called function, this argument is a local variable, and so an array name</p>
<p>parameter is a pointer, that is, a variable containing an address. We can use this fact to write</p>
<p>another version of strlen, which computes the length of a string.</p>
<p>/* strlen: return length of string s */</p>
<p>int strlen(char *s)</p>
<p>{</p>
<p>int n;</p>
<p>for (n = 0; *s != &#8221;, s++)</p>
<p>n++;</p>
<p>return n;</p>
<p>}</p>
<p>Since s is a pointer, incrementing it is perfectly legal; s++ has no effect on the character string</p>
<p>in the function that called strlen, but merely increments strlen&#8217;s private copy of the pointer.</p>
<p>That means that calls like</p>
<p>strlen(&#8220;hello, world&#8221;); /* string constant */</p>
<p>strlen(array); /* char array[100]; */</p>
<p>strlen(ptr); /* char *ptr; */</p>
<p>all work.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/12/pointer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>c assignment</title>
		<link>https://www.emblogic.com/blog/09/c-assignment-5/</link>
		<comments>https://www.emblogic.com/blog/09/c-assignment-5/#comments</comments>
		<pubDate>Fri, 27 Sep 2013 19:01:40 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Project 2: Multiple Data Compression and Encryption]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7201</guid>
		<description><![CDATA[working on searching ,sorting and also on string..]]></description>
				<content:encoded><![CDATA[<p>working on searching ,sorting and also on string..</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/09/c-assignment-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>character driver</title>
		<link>https://www.emblogic.com/blog/09/character-driver-12/</link>
		<comments>https://www.emblogic.com/blog/09/character-driver-12/#comments</comments>
		<pubDate>Fri, 27 Sep 2013 18:59:10 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[jasmeen]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7199</guid>
		<description><![CDATA[i have done timer with wait_event_interruptible successfully&#8230;&#8230;]]></description>
				<content:encoded><![CDATA[<p>i have done timer with wait_event_interruptible successfully&#8230;&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/09/character-driver-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>c assignment</title>
		<link>https://www.emblogic.com/blog/08/c-assignment-2/</link>
		<comments>https://www.emblogic.com/blog/08/c-assignment-2/#comments</comments>
		<pubDate>Wed, 07 Aug 2013 19:07:16 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6992</guid>
		<description><![CDATA[Completed 4 assignment]]></description>
				<content:encoded><![CDATA[<p>Completed 4 assignment</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/c-assignment-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DRIVER LOGFILE</title>
		<link>https://www.emblogic.com/blog/08/character-driver-logfile-2/</link>
		<comments>https://www.emblogic.com/blog/08/character-driver-logfile-2/#comments</comments>
		<pubDate>Thu, 01 Aug 2013 13:53:59 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6952</guid>
		<description><![CDATA[RCS file: app11.c,v Working file: app11.c head: 1.2 branch: locks: strict amitdalal: 1.2 access list: symbolic names: keyword substitution: kv total revisions: 2; selected revisions: 2 description: define set_sem_val function define semaphore_p and semaphore_v done this for all 5 applicatin &#8230; <a href="https://www.emblogic.com/blog/08/character-driver-logfile-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: app11.c,v<br />
Working file: app11.c<br />
head: 1.2<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.2<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 2;	selected revisions: 2<br />
description:<br />
define set_sem_val function<br />
define semaphore_p and semaphore_v<br />
done this for all 5 applicatin<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2	locked by: amitdalal;<br />
date: 2013/08/01 01:05:28;  author: amitdalal;  state: Exp;  lines: +29 -1<br />
include some variable<br />
use cmd for resetting all the parameter<br />
use cmd for setting newquantum no.<br />
include header file<br />
use cmd for setting qset no.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/25 23:29:38;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.21<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.21<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 21;	selected revisions: 21<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.21	locked by: amitdalal;<br />
date: 2013/08/01 00:53:49;  author: amitdalal;  state: Exp;  lines: +71 -5<br />
define function for ioctl to control the operation<br />
use cmd SCULL_IOCRESET,SCULL_IOCSQUANTUM,SCULL_IOCQSET,SCULL_IOCDATA,SCULL_IOCDEVICE<br />
USE capability cmd for cheking capability<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.20<br />
date: 2013/07/28 00:07:05;  author: amitdalal;  state: Exp;  lines: +21 -7<br />
create proc_read_entry function inside sculldev loop<br />
define read_proc out side the sculldev  loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.19<br />
date: 2013/07/26 19:26:10;  author: amitdalal;  state: Exp;  lines: +4 -3<br />
use spin_lock_irq before raeding<br />
use spin_unlock_irq func. at the end off writing<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.18<br />
date: 2013/07/26 00:33:49;  author: amitdalal;  state: Exp;  lines: +9 -19<br />
use wait_for_complition in read<br />
use complete_all in write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.17<br />
date: 2013/07/25 23:23:36;  author: amitdalal;  state: Exp;  lines: +9 -8<br />
initialise sem_init again<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.16<br />
date: 2013/07/25 23:02:12;  author: amitdalal;  state: Exp;  lines: +33 -11<br />
initialise two semaphore for read and write in sculldev initialisation<br />
down semaphore in write for write<br />
at the end up semaphore for read<br />
down semaphore in write for read<br />
at the end up semaphore for write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15<br />
date: 2013/07/22 22:47:17;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
initialise the semaphore init in scull_open for kernel level synchronisation<br />
call down_interruptible in open<br />
call up in release function<br />
define trim function<br />
calculate nosqs and noq agin in trim function<br />
memset the quantum_size<br />
to free all quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.14<br />
date: 2013/07/22 22:07:46;  author: amitdalal;  state: Exp;  lines: +102 -40<br />
define fpos variable for  fetching file position in read<br />
add fpos to count to calculate the nosqs and noq<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/17 00:08:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29;  author: amitdalal;  state: Exp;  lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14;  author: amitdalal;  state: Exp;  lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06;  author: amitdalal;  state: Exp;  lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19;  author: amitdalal;  state: Exp;  lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03;  author: amitdalal;  state: Exp;  lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10;  author: amitdalal;  state: Exp;  lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53;  author: amitdalal;  state: Exp;  lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58;  author: amitdalal;  state: Exp;  lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36;  author: amitdalal;  state: Exp;  lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: header.h,v<br />
Working file: header.h<br />
head: 1.10<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.10<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 10;	selected revisions: 10<br />
description:<br />
added asm header .h for copy from user<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10	locked by: amitdalal;<br />
date: 2013/08/01 00:59:39;  author: amitdalal;  state: Exp;  lines: +9 -3<br />
include prototype of ioctl<br />
define ioctl in the file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/28 00:09:43;  author: amitdalal;  state: Exp;  lines: +1 -0<br />
include header file for proc<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/26 19:29:27;  author: amitdalal;  state: Exp;  lines: +3 -1<br />
initialise spinlock_t my_lock in header file<br />
./<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/26 00:38:59;  author: amitdalal;  state: Exp;  lines: +3 -3<br />
define macro for complition in header.h<br />
another way is to define the complition in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/25 23:25:01;  author: amitdalal;  state: Exp;  lines: +9 -3<br />
include struct semaphore rsem and wsem in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/22 22:12:52;  author: amitdalal;  state: Exp;  lines: +3 -1<br />
defined header file for semaphore in kernel level<br />
define semaphore in Sculldev structure<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:38:48;  author: amitdalal;  state: Exp;  lines: +7 -7<br />
include prototype of llseek<br />
define llseek in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:53:32;  author: amitdalal;  state: Exp;  lines: +5 -2<br />
give prototype of llseek<br />
define it in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 17:39:26;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
remove init and cleanup prototype<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:25:25;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: ioctlheader.h,v<br />
Working file: ioctlheader.h<br />
head: 1.1<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.1<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 1;	selected revisions: 1<br />
description:<br />
include all the macro for reseting,setting quantum no.<br />
macro for setting qset no.<br />
macro for setting data no.<br />
macro for setting device no.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1	locked by: amitdalal;<br />
date: 2013/08/01 01:01:24;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: ioctlheader.h,v<br />
Working file: ioctlheader.h<br />
head: 1.1<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.1<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 1;	selected revisions: 1<br />
description:<br />
include all the macro for reseting,setting quantum no.<br />
macro for setting qset no.<br />
macro for setting data no.<br />
macro for setting device no.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1	locked by: amitdalal;<br />
date: 2013/08/01 01:01:24;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/08/character-driver-logfile-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DRIVER</title>
		<link>https://www.emblogic.com/blog/07/character-driver-18/</link>
		<comments>https://www.emblogic.com/blog/07/character-driver-18/#comments</comments>
		<pubDate>Sun, 28 Jul 2013 13:04:06 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6946</guid>
		<description><![CDATA[successfully done proc implimentation&#8230;.. RCS file: amit.c,v Working file: amit.c head: 1.20 branch: locks: strict amitdalal: 1.20 access list: symbolic names: keyword substitution: kv total revisions: 20; selected revisions: 20 description: added function of copy from user printk the no &#8230; <a href="https://www.emblogic.com/blog/07/character-driver-18/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>successfully done proc implimentation&#8230;..</p>
<p>RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.20<br />
branch:<br />
locks: strict<br />
amitdalal: 1.20<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 20; selected revisions: 20<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.20 locked by: amitdalal;<br />
date: 2013/07/28 00:07:05; author: amitdalal; state: Exp; lines: +21 -7<br />
create proc_read_entry function inside sculldev loop<br />
define read_proc out side the sculldev loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.19<br />
date: 2013/07/26 19:26:10; author: amitdalal; state: Exp; lines: +4 -3<br />
use spin_lock_irq before raeding<br />
use spin_unlock_irq func. at the end off writing<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.18<br />
date: 2013/07/26 00:33:49; author: amitdalal; state: Exp; lines: +9 -19<br />
use wait_for_complition in read<br />
use complete_all in write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.17<br />
date: 2013/07/25 23:23:36; author: amitdalal; state: Exp; lines: +9 -8<br />
initialise sem_init again<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.16<br />
date: 2013/07/25 23:02:12; author: amitdalal; state: Exp; lines: +33 -11<br />
initialise two semaphore for read and write in sculldev initialisation<br />
down semaphore in write for write<br />
at the end up semaphore for read<br />
down semaphore in write for read<br />
at the end up semaphore for write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15<br />
date: 2013/07/22 22:47:17; author: amitdalal; state: Exp; lines: +5 -5<br />
initialise the semaphore init in scull_open for kernel level synchronisation<br />
call down_interruptible in open<br />
call up in release function<br />
define trim function<br />
calculate nosqs and noq agin in trim function<br />
memset the quantum_size<br />
to free all quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.14<br />
date: 2013/07/22 22:07:46; author: amitdalal; state: Exp; lines: +102 -40<br />
define fpos variable for fetching file position in read<br />
add fpos to count to calculate the nosqs and noq<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/17 00:08:24; author: amitdalal; state: Exp; lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29; author: amitdalal; state: Exp; lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14; author: amitdalal; state: Exp; lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06; author: amitdalal; state: Exp; lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19; author: amitdalal; state: Exp; lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24; author: amitdalal; state: Exp; lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03; author: amitdalal; state: Exp; lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10; author: amitdalal; state: Exp; lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53; author: amitdalal; state: Exp; lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58; author: amitdalal; state: Exp; lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36; author: amitdalal; state: Exp; lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: header.h,v<br />
Working file: header.h<br />
head: 1.9<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 9; selected revisions: 9<br />
description:<br />
added asm header .h for copy from user<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/28 00:09:43; author: amitdalal; state: Exp; lines: +1 -0<br />
include header file for proc<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/26 19:29:27; author: amitdalal; state: Exp; lines: +3 -1<br />
initialise spinlock_t my_lock in header file<br />
./<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/26 00:38:59; author: amitdalal; state: Exp; lines: +3 -3<br />
define macro for complition in header.h<br />
another way is to define the complition in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/25 23:25:01; author: amitdalal; state: Exp; lines: +9 -3<br />
include struct semaphore rsem and wsem in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/22 22:12:52; author: amitdalal; state: Exp; lines: +3 -1<br />
defined header file for semaphore in kernel level<br />
define semaphore in Sculldev structure<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:38:48; author: amitdalal; state: Exp; lines: +7 -7<br />
include prototype of llseek<br />
define llseek in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:53:32; author: amitdalal; state: Exp; lines: +5 -2<br />
give prototype of llseek<br />
define it in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 17:39:26; author: amitdalal; state: Exp; lines: +5 -5<br />
remove init and cleanup prototype<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:25:25; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-driver-18/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DEVICE DRIVER</title>
		<link>https://www.emblogic.com/blog/07/character-device-driver-2/</link>
		<comments>https://www.emblogic.com/blog/07/character-device-driver-2/#comments</comments>
		<pubDate>Fri, 26 Jul 2013 13:56:18 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6935</guid>
		<description><![CDATA[i have successfully implimented the semaphore in kernel level and complition in kernel level RCS file: app11.c,v Working file: app11.c head: 1.1 branch: locks: strict amitdalal: 1.1 access list: symbolic names: keyword substitution: kv total revisions: 1; selected revisions: 1 &#8230; <a href="https://www.emblogic.com/blog/07/character-device-driver-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>i have successfully implimented the semaphore in kernel level and complition in kernel level</p>
<p>RCS file: app11.c,v<br />
Working file: app11.c<br />
head: 1.1<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.1<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 1;	selected revisions: 1<br />
description:<br />
define set_sem_val function<br />
define semaphore_p and semaphore_v<br />
done this for all 5 applicatin<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1	locked by: amitdalal;<br />
date: 2013/07/25 23:29:38;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.18<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.18<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 18;	selected revisions: 18<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.18	locked by: amitdalal;<br />
date: 2013/07/26 00:33:49;  author: amitdalal;  state: Exp;  lines: +9 -19<br />
use wait_for_complition in read<br />
use complete_all in write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.17<br />
date: 2013/07/25 23:23:36;  author: amitdalal;  state: Exp;  lines: +9 -8<br />
initialise sem_init again<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.16<br />
date: 2013/07/25 23:02:12;  author: amitdalal;  state: Exp;  lines: +33 -11<br />
initialise two semaphore for read and write in sculldev initialisation<br />
down semaphore in write for write<br />
at the end up semaphore for read<br />
down semaphore in write for read<br />
at the end up semaphore for write<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15<br />
date: 2013/07/22 22:47:17;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
initialise the semaphore init in scull_open for kernel level synchronisation<br />
call down_interruptible in open<br />
call up in release function<br />
define trim function<br />
calculate nosqs and noq agin in trim function<br />
memset the quantum_size<br />
to free all quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.14<br />
date: 2013/07/22 22:07:46;  author: amitdalal;  state: Exp;  lines: +102 -40<br />
define fpos variable for  fetching file position in read<br />
add fpos to count to calculate the nosqs and noq<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/17 00:08:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29;  author: amitdalal;  state: Exp;  lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14;  author: amitdalal;  state: Exp;  lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06;  author: amitdalal;  state: Exp;  lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19;  author: amitdalal;  state: Exp;  lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03;  author: amitdalal;  state: Exp;  lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10;  author: amitdalal;  state: Exp;  lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53;  author: amitdalal;  state: Exp;  lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58;  author: amitdalal;  state: Exp;  lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36;  author: amitdalal;  state: Exp;  lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: dd1,v<br />
Working file: dd1<br />
head: 1.5<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.5<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 5;	selected revisions: 5<br />
description:<br />
adding compilation command for reading in script<br />
gcc<br />
./app1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5	locked by: amitdalal;<br />
date: 2013/07/25 23:26:50;  author: amitdalal;  state: Exp;  lines: +16 -2<br />
run the 5 application simutanously<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/18 21:17:28;  author: amitdalal;  state: Exp;  lines: +1 -1<br />
added -lpthread for compilation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:55:17;  author: amitdalal;  state: Exp;  lines: +4 -3<br />
add unlink node<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 06:00:23;  author: amitdalal;  state: Exp;  lines: +2 -2<br />
make another node for reading<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 05:16:48;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: header.h,v<br />
Working file: header.h<br />
head: 1.7<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.7<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 7;	selected revisions: 7<br />
description:<br />
added asm header .h for copy from user<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7	locked by: amitdalal;<br />
date: 2013/07/26 00:38:59;  author: amitdalal;  state: Exp;  lines: +3 -3<br />
define macro for complition in header.h<br />
another way is to define the complition in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/25 23:25:01;  author: amitdalal;  state: Exp;  lines: +9 -3<br />
include struct semaphore rsem and wsem in sculldev<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/22 22:12:52;  author: amitdalal;  state: Exp;  lines: +3 -1<br />
defined header file for semaphore in kernel level<br />
define semaphore in Sculldev structure<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:38:48;  author: amitdalal;  state: Exp;  lines: +7 -7<br />
include prototype of llseek<br />
define llseek in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:53:32;  author: amitdalal;  state: Exp;  lines: +5 -2<br />
give prototype of llseek<br />
define it in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 17:39:26;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
remove init and cleanup prototype<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:25:25;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-device-driver-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DRIVER</title>
		<link>https://www.emblogic.com/blog/07/character-driver-17/</link>
		<comments>https://www.emblogic.com/blog/07/character-driver-17/#comments</comments>
		<pubDate>Tue, 23 Jul 2013 12:18:05 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6930</guid>
		<description><![CDATA[i have successfully implimented the mutex with in the 1 application and semaphore with in the thread for 4 application and done semaphore within the kernel level it is suceesssfully running RCS file: app11.c,v Working file: app11.c head: 1.1 branch: &#8230; <a href="https://www.emblogic.com/blog/07/character-driver-17/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>i have successfully implimented the mutex with in the 1 application and semaphore with in the thread for 4 application and done semaphore within the kernel level it is suceesssfully running</p>
<p>RCS file: app11.c,v<br />
Working file: app11.c<br />
head: 1.1<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 1;	selected revisions: 1<br />
description:<br />
use mutex for inter thread communication<br />
initialise mutex in main app11 function<br />
use mutex_lock<br />
use mutex_unlock for one application app11<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/22 22:16:09;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.15<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.15<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 15;	selected revisions: 15<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.15	locked by: amitdalal;<br />
date: 2013/07/22 22:47:17;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
initialise the semaphore init in scull_open for kernel level synchronisation<br />
call down_interruptible in open<br />
call up in release function<br />
define trim function<br />
calculate nosqs and noq agin in trim function<br />
memset the quantum_size<br />
to free all quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.14<br />
date: 2013/07/22 22:07:46;  author: amitdalal;  state: Exp;  lines: +102 -40<br />
define fpos variable for  fetching file position in read<br />
add fpos to count to calculate the nosqs and noq<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13<br />
date: 2013/07/17 00:08:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29;  author: amitdalal;  state: Exp;  lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14;  author: amitdalal;  state: Exp;  lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06;  author: amitdalal;  state: Exp;  lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19;  author: amitdalal;  state: Exp;  lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24;  author: amitdalal;  state: Exp;  lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03;  author: amitdalal;  state: Exp;  lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10;  author: amitdalal;  state: Exp;  lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53;  author: amitdalal;  state: Exp;  lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58;  author: amitdalal;  state: Exp;  lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36;  author: amitdalal;  state: Exp;  lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>RCS file: dd1,v<br />
Working file: dd1<br />
head: 1.9<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.9<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 5;	selected revisions: 5<br />
description:<br />
adding compilation command for reading in script<br />
gcc<br />
./app1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9	locked by: amitdalal;<br />
date: 2013/07/21 22:56:36;  author: amitdalal;  state: Exp;  lines: +8 -0<br />
added gcc command for 5 application<br />
added executable command for all the 5 application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/18 21:17:28;  author: amitdalal;  state: Exp;  lines: +1 -1<br />
added -lpthread for compilation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/15 21:55:17;  author: amitdalal;  state: Exp;  lines: +4 -3<br />
add unlink node<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 06:00:23;  author: amitdalal;  state: Exp;  lines: +2 -2<br />
make another node for reading<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:16:48;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================<br />
RCS file: dd1,v<br />
Working file: dd1<br />
head: 1.4<br />
branch:<br />
locks: strict<br />
	amitdalal: 1.4<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 4;	selected revisions: 4<br />
description:<br />
adding compilation command for reading in script<br />
gcc<br />
./app1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4	locked by: amitdalal;<br />
date: 2013/07/19 21:17:28;  author: amitdalal;  state: Exp;  lines: +1 -1<br />
added -lpthread for compilation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:55:17;  author: amitdalal;  state: Exp;  lines: +4 -3<br />
add unlink node<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 06:00:23;  author: amitdalal;  state: Exp;  lines: +2 -2<br />
make another node for reading<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 05:16:48;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================<br />
:<br />
RCS file: header.h,v<br />
Working file: header.h<br />
head: 1.5<br />
branch:<br />
locks: strict<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 5;	selected revisions: 5<br />
description:<br />
added asm header .h for copy from user<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/22 22:12:52;  author: amitdalal;  state: Exp;  lines: +3 -1<br />
defined header file for semaphore in kernel level<br />
define semaphore in Sculldev structure<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:38:48;  author: amitdalal;  state: Exp;  lines: +7 -7<br />
include prototype of llseek<br />
define llseek in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:53:32;  author: amitdalal;  state: Exp;  lines: +5 -2<br />
give prototype of llseek<br />
define it in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 17:39:26;  author: amitdalal;  state: Exp;  lines: +5 -5<br />
remove init and cleanup prototype<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:25:25;  author: amitdalal;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-driver-17/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DEVICE DRIVER</title>
		<link>https://www.emblogic.com/blog/07/character-device-driver/</link>
		<comments>https://www.emblogic.com/blog/07/character-device-driver/#comments</comments>
		<pubDate>Mon, 22 Jul 2013 11:45:33 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6921</guid>
		<description><![CDATA[i have implimented the read write close open for 5 application in multithread using semaphore successfully.now i am going to do trim function&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. &#160; RCS file: app.c,v Working file: app.c head: 1.9 branch: locks: strict amitdalal: 1.9 access list: symbolic &#8230; <a href="https://www.emblogic.com/blog/07/character-device-driver/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>i have implimented the read write close open for 5 application in multithread using semaphore successfully.now i am going to do trim function&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..</p>
<p>&nbsp;</p>
<p>RCS file: app.c,v<br />
Working file: app.c<br />
head: 1.9<br />
branch:<br />
locks: strict<br />
amitdalal: 1.9<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 9; selected revisions: 9<br />
description:<br />
extended the message in buff<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9 locked by: amitdalal;<br />
date: 2013/07/21 22:38:57; author: amitdalal; state: Exp; lines: +127 -73<br />
include some header file for ipc semaphore and thread semaphore<br />
give the prototype of set sem_value<br />
give prototype for semaphore_p and semaphore_v<br />
defined union semun structure<br />
created ipc semaphore for ist application<br />
call the function set_sem_value<br />
call the function semaphore _p<br />
call the function semaphore_v at te end of main finction<br />
defined semaphor_p,semaphore_v and set_sem_val function<br />
same step are done for 5 application except calling set_value function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/18 21:16:18; author: amitdalal; state: Exp; lines: +0 -1<br />
added pthread join function<br />
added pthread exit<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/18 21:08:19; author: amitdalal; state: Exp; lines: +94 -41<br />
define the function for open<br />
4 thread created<br />
define the function for write<br />
lssek function after write<br />
define function for read<br />
define function for close<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/17 21:37:34; author: amitdalal; state: Exp; lines: +8 -5<br />
added variable len0,count0 for lseek after write<br />
added lseek after write<br />
again use the write function to append<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/17 00:11:50; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable<br />
use lseek<br />
update write<br />
printk offset value<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:40:05; author: amitdalal; state: Exp; lines: +71 -68<br />
include header file for lseek<br />
set the offset<br />
printf the value of offset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:56:21; author: amitdalal; state: Exp; lines: +52 -15<br />
added lseek for f_pos<br />
printf the newpos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:32:38; author: amitdalal; state: Exp; lines: +1 -1<br />
extended the message to check whether my multiple qset is working or not for above 64 byte<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 00:04:48; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================<br />
RCS file: dd1,v<br />
Working file: dd1<br />
head: 1.5<br />
branch:<br />
locks: strict<br />
amitdalal: 1.5<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 5; selected revisions: 5<br />
description:<br />
adding compilation command for reading in script<br />
gcc<br />
./app1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5 locked by: amitdalal;<br />
date: 2013/07/21 22:56:36; author: amitdalal; state: Exp; lines: +8 -0<br />
added gcc command for 5 application<br />
added executable command for all the 5 application<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/18 21:17:28; author: amitdalal; state: Exp; lines: +1 -1<br />
added -lpthread for compilation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:55:17; author: amitdalal; state: Exp; lines: +4 -3<br />
add unlink node<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 06:00:23; author: amitdalal; state: Exp; lines: +2 -2<br />
make another node for reading<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 05:16:48; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-device-driver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DEVICE DRIVER(ARTICLE)</title>
		<link>https://www.emblogic.com/blog/07/character-device-driverarticle/</link>
		<comments>https://www.emblogic.com/blog/07/character-device-driverarticle/#comments</comments>
		<pubDate>Sun, 21 Jul 2013 20:47:29 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6851</guid>
		<description><![CDATA[ARTICLE ON CHARACTER DRIVER I have been working on character device driver since last two to three weeks and here I am giving you the concept and idea I am using in character driver till now. Let us start with &#8230; <a href="https://www.emblogic.com/blog/07/character-device-driverarticle/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>ARTICLE<br />
ON<br />
CHARACTER DRIVER</p>
<p>I have been working on character device driver since last two to three weeks and here I am<br />
giving you the concept and idea I am  using in character driver till now.</p>
<p>Let us start with the basic idea about character driver before moving on what is happening in architecture which help me to create my device driver.<br />
DEVICE DRIVER  -&gt;  These are loadable kernel modules that can be inserted in kernel at the run time and they provide a well defined interface for hardware to respond to a specific application code that want to communicate with the hardware . user at user level gives some specific code through application and the role of these device driver is to make these command work for hardware.</p>
<p>CHARACTER DRIVER  -&gt; Character driver is driver that access the device character by character  i.e a stream of bytes as in files.</p>
<p>MODULE  -&gt; It is piece of code that is used for communication b/w hardware and software</p>
<p>Device driver concept divided into two basic part.<br />
1.	user level       -&gt;    where your application  reside<br />
2.	kernel level   -&gt;    where your modules and drivers  reside<br />
now question arise how link is created b/w user level and kernel level.<br />
NODE  -&gt;  node created the link b/w user level and kernel level<br />
			                USER SPACE(APPLICATION)<br />
                   					|</p>
<p>			    KERNEL SPACE(MODULES AND DRIVERS)</p>
<p>						|<br />
			 			HARDWARE</p>
<p>There are few structures which were defind in kernel and user space through which we can defined functionality of our device driver<br />
KERNEL DEFINED STRUCTURE :<br />
1.	STRUCT FILE<br />
2.	STRUCT Inode<br />
3.	Cdev<br />
USER DEFINED STRUCTURE:<br />
1.	Struct Sculldev<br />
2.	Struct Scull_qset<br />
3.	Struct file operations</p>
<p>Scull  -&gt;  Scull is a memory space which is allocated in machine memory to your device. in scull we have two vital structure know as struct Sculldev and struct Scull_qset. The former one is the starting point of scull as well as contains data about all the scullqset present in your scull in a way it contains metadata. its member are as fallow-<br />
1.	*scull_qset<br />
2.	Scull qset_size<br />
3.	data_size<br />
4.	quantum_size<br />
5.	device_size.<br />
6.	struct cdev.<br />
struct Sculldev                 		//user defined structure Sculldev<br />
{<br />
	struct Scull_qset *scull_qset;	//pointing to 1st quantum set(Scull_qset structure)<br />
	int quantum_size;				//current quantum size<br />
	int qset_size;				//current array size<br />
	int data_size;				//amount of data stored here<br />
	int device_size;<br />
	int open_count;<br />
	struct cdev var_dev;   //cdev structure defined in  cdev header file<br />
}*sculldev;      			//used for pointing Sculldev</p>
<p>Scull_qset is a structure which store data or information. it mainly has two member:<br />
1.	*next -&gt;   pointer to next scull_qset<br />
2.	**data -&gt; double pointer to your data, means first it will point to an array of pointer known as qset , contains quantum where actually our data is kept.<br />
struct Scull_qset<br />
{<br />
	struct Scull_qset *next;<br />
	void **data;<br />
};</p>
<p>Struct file operations -&gt; It generally defines the behavior of our device. It is used here to map the user level system calls to programmer defined system call.<br />
Some defined system call:<br />
1.	OPEN<br />
2.	CLOSE(RELEASE)<br />
3.	WRITE<br />
4.	READ<br />
5.	LLSEEK<br />
struct file_operations fops=<br />
{<br />
	open:scull_open,<br />
	read:scull_read,<br />
	write:scull_write,<br />
	llseek:scull_llseek,<br />
	release:scull_release</p>
<p>};</p>
<p>Now comes kernel level structures into picture.<br />
 STRUCT INODE -&gt; as we all know that in linux everything is file either it is a text file, some kind of code or any device with each and every file there is an associated inode structure , here we will mainly concentrate and concerned about which is particularly represents our device. “inode” is the only way through which we can or its better to say our application can interact with our device.<br />
main member are:<br />
1.	 i_cev  -&gt;which points to your struct cdev. pointer to file operations.<br />
2.<br />
Struct file -&gt; Members are:<br />
1.	*f_pos :- which takes the account of the cursor in your file. pointer to file operations<br />
2.	*private data :- which will help us to do mapping from your user level to kernal level as its stores the address of your SCULL so we can access all the data which we have stored in quantum part of scullqset from user level. </p>
<p>Struct Cdev—&gt; It mainly has three member:<br />
1.	owner :- which specifies about its owner name<br />
2.	pointer to file operation<br />
3.	 dev which contains major and minor no.</p>
<p>void Sculldev_initialisation(void)<br />
		{<br />
			int a,lv;<br />
	for(lv=0;lv Major no. is a number which is given to each and every device driver we have in our machine<br />
Minor no -&gt; Minor no. is the number which represents your the device associated with that particular device driver. </p>
<p>majorno=MAJOR(dev);	//extract major no.from device number<br />
minorno=MINOR(dev);	//extract minor no.from device number</p>
<p>This is all about the architecture now lets have  look on the operations or working.</p>
<p>STEPS USED IN IMPLIMENTATION OF CHARACTER DRIVER</p>
<p>1.	Insmod -&gt; which will load our module, module is a source code which is loaded on demand.<br />
insmod ./modules/amit.ko </p>
<p>2.	Registration -&gt; register our device driver and device so that DD will get a major number and device gets its own minor number.<br />
ret=alloc_chrdev_region(&amp;dev,minorno,nod,DRIVER_NAME);	//when we are registering one device (for dynamic allocation)</p>
<p>3.Allocation -&gt; Allocate space to Scull in machine memory.<br />
sculldev=kmalloc(sizeof(struct Sculldev)*nod , GFP_KERNEL);	//allocate memory to Sculldev</p>
<p>4.Initialize Scull	–&gt; cdev_init— create link between struct inode and struct cdev… define owner.. cdev_add make attribute of device available to our kernel.<br />
void Sculldev_initialisation(void)<br />
		{<br />
			int a,lv;<br />
	for(lv=0;lv flash data if present in the memory space which is assigned to scull</p>
<p>7.Open -&gt; define open system call.<br />
int scull_open(struct inode *inodep, struct file *filep)<br />
{</p>
<p>	struct Sculldev* pdev;<br />
	printk(KERN_ALERT&#8221;BEGIN:open SUCCESSFULLY :%s\n&#8221;,__func__);</p>
<p>pdev=(struct Sculldev *)container_of(inodep-&gt;i_cdev, struct Sculldev, var_dev);  // map the memeory allocated to Sculldev to VFS which is going to return pointer(A convenience macro that may be used to obtain a pointer to a structure from a pointer to some other structure contained within it.)</p>
<p>filep-&gt;private_data =pdev;	//all information stored in pdev pointer conatining address</p>
<p>	if((filep-&gt;f_flags &amp;&amp; O_ACCMODE) == O_WRONLY)<br />
		{</p>
<p>			printk(KERN_ALERT&#8221;FILE OPEN\n&#8221;);<br />
			scull_trim(pdev);<br />
		}</p>
<p>	printk(KERN_ALERT&#8221;END:open close SUCCESSFULLY: %s\n&#8221;,__func__);<br />
	return 0;<br />
}</p>
<p>8.	Write -&gt;before doing that allocate space to Scullqset then to qset and at last to quantum now we can write data to our quantum, LSEEK if needed.<br />
ssize_t scull_write(struct file *filep,const char __user *buff,size_t count, loff_t *f_pos)<br />
{<br />
struct Sculldev *pdev;<br />
	struct Scull_qset *qset;<br />
	int noq,nosqs,i,j,ret=0,loop=0;			//noq=no.of quantum,nosqs=no. of scull_qset,<br />
	int nobpq,noctw,nocsw,flag=0,bpos=0;		//nocsw=no. of character successfully write<br />
	noq=nosqs=nobpq=noctw=nocsw=0;<br />
	pdev=filep-&gt;private_data;			//fetch the device</p>
<p>	printk(KERN_ALERT&#8221;BEGIN:write open SUCCESSFULLY: %s\n&#8221;,__func__);<br />
	if(!pdev)<br />
		{<br />
			printk(&#8220;no private data&#8221;);<br />
		}</p>
<p>	nosqs=count/(quantum_size*qset_size);	//finding no. of scull_qset required<br />
	if(count % (quantum_size*qset_size))<br />
	nosqs++;<br />
	pdev-&gt;scull_qset=create_scull_qset(nosqs);	//creating scull_qset(Sculldev *pdev pointing towards *scull_qset)<br />
	if(!pdev-&gt;scull_qset)<br />
		{<br />
			printk(&#8220;no scull_qset found\n&#8221;);<br />
		}<br />
	noq=count/quantum_size;<br />
	if(count%quantum_size)<br />
	noq++;</p>
<p>	qset=pdev-&gt;scull_qset;<br />
	create_qset(qset,nosqs);	//creating _qset<br />
	create_quantum(qset,noq);	//creating _quantum<br />
	nobpq=quantum_size;<br />
	nocsw=0;<br />
	noctw=count;<br />
 	int offset=filep-&gt;f_pos;<br />
	printk(KERN_ALERT&#8221;offset=%d\n&#8221;,(int)filep-&gt;f_pos);	//data write in quantum</p>
<p>	while(nosqs)<br />
		{<br />
			if(noq&gt;quantum_size)<br />
				{<br />
					loop=quantum_size;<br />
				}<br />
			else<br />
				{<br />
					loop=noq;<br />
				}<br />
	if(flag==0)<br />
		{<br />
			if(offset&gt;quantum_size)<br />
				{<br />
					j=offset/quantum_size;<br />
					bpos=offset%quantum_size;<br />
					nobpq=quantum_size-bpos;<br />
				}<br />
			else<br />
				{<br />
					j=0;<br />
					nobpq=quantum_size-offset;<br />
					bpos=offset;<br />
				}<br />
	flag=1;<br />
		}<br />
	else<br />
		{<br />
			j=0;<br />
			loop=noq;<br />
			bpos=0;<br />
		}<br />
	for(i=j;idata[i]+bpos,buff+nocsw,nobpq);			//copy data from user space<br />
			printk(KERN_ALERT&#8221;quantum=%d-&gt;write=%s\n&#8221;,i,(char *)qset-&gt;data[i]+bpos);	//data write in quantum<br />
			nocsw=nocsw+(nobpq-ret);<br />
			noctw=noctw-(nobpq-ret);<br />
			if(noctw&gt;quantum_size)<br />
				{<br />
					nobpq=quantum_size;<br />
				}<br />
			else<br />
				{<br />
					nobpq=noctw;<br />
				}<br />
			printk(KERN_ALERT&#8221;no. of byte successfully write=%d\n&#8221;,nocsw);<br />
			printk(KERN_ALERT&#8221;no. of byte not write=%d\n&#8221;,ret);<br />
			bpos=0;<br />
		}<br />
			nosqs&#8211;;<br />
			qset=qset-&gt;next;<br />
			noq=noq-quantum_size;<br />
		}<br />
	printk(KERN_ALERT&#8221;no.of qset=%d\n&#8221;,loop);</p>
<p>	printk(KERN_ALERT&#8221;END:write close SUCCESSFULLY : %s\n&#8221;,__func__);<br />
	return count-ret;<br />
}</p>
<p>9. Read -&gt; read whatever you have written to quantum.<br />
ssize_t scull_read(struct file *filep,char __user *buff,size_t count, loff_t *f_pos)</p>
<p>ret=copy_to_user(buff+nocsr,qset-&gt;data[i]+bpos,nobpq);                     //copy data from user space<br />
10. Release-&gt; de-allocate all the space, unregister your device and DD, remove your module.<br />
int scull_release(struct inode *inodep, struct file *filep)<br />
{<br />
	printk(KERN_ALERT&#8221;BEGIN:OPEN SUCCESSFULLY release: %s\n&#8221;,__func__);<br />
	printk(KERN_ALERT&#8221;END:close SUCCESSFULLY release: %s\n&#8221;,__func__);<br />
	return 0;<br />
}</p>
<p>For unregistering :</p>
<p>static void cleanup(void)<br />
{<br />
	int lv;<br />
	printk(KERN_ALERT &#8220;BEGIN: %s\n&#8221;,__func__);<br />
	printk(KERN_ALERT&#8221;\ngood bye\n&#8221;);<br />
	for(lv=0;lv make<br />
For making node -&gt; mknod node c 249 0</p>
<p>TO remove the driver -&gt; rmmod amit</p>
<p>HERE I AM GIVING YOU THE IMPLIMENTATION PROCEDURE TO CLEARIFY THE ALL  STEP:-</p>
<p>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.</p>
<p>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.</p>
<p> 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.<br />
We can also use register_chrdev() to register the driver if we want to assign the user defined major number.</p>
<p>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”. </p>
<p>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.</p>
<p>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.</p>
<p> 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. </p>
<p>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.</p>
<p>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()”.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-device-driverarticle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DEVICE DRIVER</title>
		<link>https://www.emblogic.com/blog/07/device-driver-7/</link>
		<comments>https://www.emblogic.com/blog/07/device-driver-7/#comments</comments>
		<pubDate>Fri, 19 Jul 2013 10:26:10 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Character Driver]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6832</guid>
		<description><![CDATA[MULTI THREAD(open,write,read,close) amit.c RCS file: amit.c,v Working file: amit.c head: 1.13 branch: locks: strict amitdalal: 1.13 access list: symbolic names: keyword substitution: kv total revisions: 13; selected revisions: 13 description: added function of copy from user printk the no of &#8230; <a href="https://www.emblogic.com/blog/07/device-driver-7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>MULTI THREAD(open,write,read,close)</p>
<p>amit.c</p>
<p>RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.13<br />
branch:<br />
locks: strict<br />
amitdalal: 1.13<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 13; selected revisions: 13<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13 locked by: amitdalal;<br />
date: 2013/07/17 00:08:24; author: amitdalal; state: Exp; lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29; author: amitdalal; state: Exp; lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14; author: amitdalal; state: Exp; lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06; author: amitdalal; state: Exp; lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19; author: amitdalal; state: Exp; lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24; author: amitdalal; state: Exp; lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03; author: amitdalal; state: Exp; lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10; author: amitdalal; state: Exp; lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53; author: amitdalal; state: Exp; lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58; author: amitdalal; state: Exp; lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36; author: amitdalal; state: Exp; lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>app.c</p>
<p>RCS file: app.c,v<br />
Working file: app.c<br />
head: 1.8<br />
branch:<br />
locks: strict<br />
amitdalal: 1.8<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 8; selected revisions: 8<br />
description:<br />
extended the message in buff<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8 locked by: amitdalal;<br />
date: 2013/07/19 21:16:18; author: amitdalal; state: Exp; lines: +0 -1<br />
added pthread join function<br />
added pthread exit<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/19 21:08:19; author: amitdalal; state: Exp; lines: +94 -41<br />
define the function for open<br />
4 thread created<br />
define the function for write<br />
lssek function after write<br />
define function for read<br />
define function for close<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/18 21:37:34; author: amitdalal; state: Exp; lines: +8 -5<br />
added variable len0,count0 for lseek after write<br />
added lseek after write<br />
again use the write function to append<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/17 00:11:50; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable<br />
use lseek<br />
update write<br />
printk offset value<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:40:05; author: amitdalal; state: Exp; lines: +71 -68<br />
include header file for lseek<br />
set the offset<br />
printf the value of offset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:56:21; author: amitdalal; state: Exp; lines: +52 -15<br />
added lseek for f_pos<br />
printf the newpos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:32:38; author: amitdalal; state: Exp; lines: +1 -1<br />
extended the message to check whether my multiple qset is working or not for above 64 byte<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 00:04:48; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>script</p>
<p>RCS file: dd1,v<br />
Working file: dd1<br />
head: 1.4<br />
branch:<br />
locks: strict<br />
amitdalal: 1.4<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 4; selected revisions: 4<br />
description:<br />
adding compilation command for reading in script<br />
gcc<br />
./app1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4 locked by: amitdalal;<br />
date: 2013/07/19 21:17:28; author: amitdalal; state: Exp; lines: +1 -1<br />
added -lpthread for compilation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:55:17; author: amitdalal; state: Exp; lines: +4 -3<br />
add unlink node<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 06:00:23; author: amitdalal; state: Exp; lines: +2 -2<br />
make another node for reading<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 05:16:48; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/device-driver-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CHARACTER DRIVER</title>
		<link>https://www.emblogic.com/blog/07/character-driver-15/</link>
		<comments>https://www.emblogic.com/blog/07/character-driver-15/#comments</comments>
		<pubDate>Wed, 17 Jul 2013 12:59:06 +0000</pubDate>
		<dc:creator><![CDATA[amit.dalal]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[prabjot]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=6734</guid>
		<description><![CDATA[i have done llseek successffully for write and read and now back to assignment sir gave us&#8230; rcs file amit.c RCS file: amit.c,v Working file: amit.c head: 1.13 branch: locks: strict amitdalal: 1.13 access list: symbolic names: keyword substitution: kv &#8230; <a href="https://www.emblogic.com/blog/07/character-driver-15/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>i have done llseek successffully for write and read and now back to assignment sir gave us&#8230;</p>
<p>rcs file</p>
<p>amit.c<br />
RCS file: amit.c,v<br />
Working file: amit.c<br />
head: 1.13<br />
branch:<br />
locks: strict<br />
amitdalal: 1.13<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 13; selected revisions: 13<br />
description:<br />
added function of copy from user<br />
printk the no of byte writen successfully for one quantum<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.13 locked by: amitdalal;<br />
date: 2013/07/17 00:08:24; author: amitdalal; state: Exp; lines: +0 -1<br />
added some variable for write using llseek<br />
added bpos for position update in copy from user<br />
define bpos flag<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.12<br />
date: 2013/07/17 00:07:11; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable bpos for position<br />
use flag and j<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.11<br />
date: 2013/07/17 00:02:29; author: amitdalal; state: Exp; lines: +0 -2<br />
added some variable for reading using llseek<br />
fix the problem related with left out of some first character<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.10<br />
date: 2013/07/16 23:37:14; author: amitdalal; state: Exp; lines: +244 -194<br />
give call to llseek<br />
define function llseek<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.9<br />
date: 2013/07/15 21:52:06; author: amitdalal; state: Exp; lines: +67 -41<br />
added loff_t function to .c file<br />
use f_pos for storing the value of pos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.8<br />
date: 2013/07/11 17:37:19; author: amitdalal; state: Exp; lines: +53 -38<br />
modified code for write to get required no of qset<br />
add lnoq variable<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.7<br />
date: 2013/07/11 06:05:24; author: amitdalal; state: Exp; lines: +0 -1<br />
add loop variable in loop for reading<br />
remove some bug in reading loop<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.6<br />
date: 2013/07/11 05:37:03; author: amitdalal; state: Exp; lines: +4 -4<br />
remove some bug from write function<br />
added loop variable to specify no of quantum in 2nd qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5<br />
date: 2013/07/11 05:18:10; author: amitdalal; state: Exp; lines: +76 -16<br />
creating read function<br />
use copy to user function<br />
modifing the copy to user function<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/11 00:41:53; author: amitdalal; state: Exp; lines: +1 -0<br />
debbuging problem causing kernel crash<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/11 00:19:58; author: amitdalal; state: Exp; lines: +11 -7<br />
added variable loop<br />
use while loop for creating multiple qset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:00:36; author: amitdalal; state: Exp; lines: +25 -4<br />
added the function of quantum written for 8 byte<br />
debugging the problem related to writting of data not 8 byte<br />
fix problem successfully related to written<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:22:34; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================<br />
header.h</p>
<p>RCS file: header.h,v<br />
Working file: header.h<br />
head: 1.4<br />
branch:<br />
locks: strict<br />
amitdalal: 1.4<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 4; selected revisions: 4<br />
description:<br />
added asm header .h for copy from user<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4 locked by: amitdalal;<br />
date: 2013/07/16 23:38:48; author: amitdalal; state: Exp; lines: +7 -7<br />
include prototype of llseek<br />
define llseek in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:53:32; author: amitdalal; state: Exp; lines: +5 -2<br />
give prototype of llseek<br />
define it in file operation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 17:39:26; author: amitdalal; state: Exp; lines: +5 -5<br />
remove init and cleanup prototype<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/10 21:25:25; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
<p>app.c</p>
<p>RCS file: app.c,v<br />
Working file: app.c<br />
head: 1.5<br />
branch:<br />
locks: strict<br />
amitdalal: 1.5<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 5; selected revisions: 5<br />
description:<br />
extended the message in buff<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.5 locked by: amitdalal;<br />
date: 2013/07/17 00:11:50; author: amitdalal; state: Exp; lines: +0 -1<br />
added variable<br />
use lseek<br />
update write<br />
printk offset value<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.4<br />
date: 2013/07/16 23:40:05; author: amitdalal; state: Exp; lines: +71 -68<br />
include header file for lseek<br />
set the offset<br />
printf the value of offset<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.3<br />
date: 2013/07/15 21:56:21; author: amitdalal; state: Exp; lines: +52 -15<br />
added lseek for f_pos<br />
printf the newpos<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2<br />
date: 2013/07/11 00:32:38; author: amitdalal; state: Exp; lines: +1 -1<br />
extended the message to check whether my multiple qset is working or not for above 64 byte<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2013/07/11 00:04:48; author: amitdalal; state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/07/character-driver-15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
