<?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; kpuja.dimple06</title>
	<atom:link href="https://www.emblogic.com/blog/author/kpuja-dimple06/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>SHARED MEMORY</title>
		<link>https://www.emblogic.com/blog/05/10172/</link>
		<comments>https://www.emblogic.com/blog/05/10172/#comments</comments>
		<pubDate>Thu, 22 May 2014 07:06:18 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=10172</guid>
		<description><![CDATA[Shared memory allows one or more processes to communicate via memory that appears in all of their virtual address spaces. The pages of the virtual memory is referenced by page table entries in each of the sharing processes&#8217; page tables. &#8230; <a href="https://www.emblogic.com/blog/05/10172/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p class="pagetitle" style="font-weight: bold;color: #000000">Shared memory allows one or more processes to communicate via memory that appears in all of their virtual address spaces. The pages of the virtual memory is referenced by page table entries in each of the sharing processes&#8217; page tables. It does not have to be at the same address in all of the processes&#8217; virtual memory. As with all System V IPC objects, access to shared memory areas is controlled via keys and access rights checking. Once the memory is being shared, there are no checks on how the processes use it. They must rely on other mechanisms, for example System V semaphores, to synchronize access to the memory.</p>
<p style="color: #000000"><img src="http://www.linux-tutorial.info/Linux_Tutorial/The_Operating_System/Interprocess_Communication/shm.gif" alt="" /></p>
<p style="color: #000000">System V IPC Shared Memory</p>
<p style="color: #000000">Each newly created shared memory area is represented by a <tt>shmid_ds</tt> data structure. These are kept in the <tt>shm_segs</tt> vector.</p>
<p style="color: #000000">The <tt>shmid_ds</tt> data structure decribes how big the area of shared memory is, how many processes are using it and information about how that shared memory is mapped into their address spaces. It is the creator of the shared memory that controls the access permissions to that memory and whether its key is public or private. If it has enough access rights it may also lock the shared memory into physical memory.</p>
<p style="color: #000000">Each process that wishes to share the memory must attach to that virtual memory via a system call. This creates a new<tt>vm_area_struct</tt> data structure describing the shared memory for this process. The process can choose where in its virtual address space the shared memory goes or it can let Linux choose a free area large enough. The new <tt>vm_area_struct</tt> structure is put into the list of <tt>vm_area_struct</tt> pointed at by the <tt>shmid_ds</tt>. The <tt>vm_next_shared</tt> and <tt>vm_prev_shared</tt> pointers are used to link them together. The virtual memory is not actually created during the attachment; it happens when the first process attempts to access it.</p>
<p style="color: #000000">The first time that a process accesses one of the pages of the shared virtual memory, a page fault will occur. When Linux fixes up that page fault it finds the <tt>vm_area_struct</tt> data structure describing it. This contains pointers to handler routines for this type of shared virtual memory. The shared memory page fault handling code looks in the list of page table entries for this <tt>shmid_ds</tt> to see if one exists for this page of the shared virtual memory. If it does not exist, it will allocate a physical page and create a page table entry for it.</p>
<p style="color: #000000">This entry is saved in the current process&#8217; page tables and the <tt>shmid_ds</tt>.. Consequently, when the next process that attempts to access this memory gets a page fault, the shared memory fault handling code will use this newly created physical page for that process too. So, the first process that accesses a page of the shared memory causes it to be created and thereafter access by the other processes cause that page to be added into their virtual address spaces.</p>
<p style="color: #000000">When processes no longer wish to share the virtual memory, they detach from it. So long as other processes are still using the memory the detach only affects the current process. Its <tt>vm_area_struct</tt> is removed from the <tt>shmid_ds</tt> data structure and deallocated. The current process&#8217;s page tables are updated to invalidate the area of virtual memory that it once shared. When the last process sharing the memory detaches from it, the pages of the shared memory current in physical memory are freed, as is the<tt>shmid_ds</tt> data structure for this shared memory.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/05/10172/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>program for simple queue</title>
		<link>https://www.emblogic.com/blog/04/program-for-simple-queue/</link>
		<comments>https://www.emblogic.com/blog/04/program-for-simple-queue/#comments</comments>
		<pubDate>Mon, 21 Apr 2014 12:08:51 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9890</guid>
		<description><![CDATA[@this a program for simple queue to push pop and display the elements of the queue @ 1.1 log @Initial revision @ text @#include&#8221;header.h&#8221; int main() { void *queue; int f,r; f=r=-1; int ch; do { printf(&#8220;1:push\n&#8221;); printf(&#8220;2:pop\n&#8221;); printf(&#8220;3:display\n&#8221;); printf(&#8220;4:exit\n&#8221;); &#8230; <a href="https://www.emblogic.com/blog/04/program-for-simple-queue/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>@this a program for simple queue to push pop and display the elements of the queue<br />
@</p>
<p>1.1<br />
log<br />
@Initial revision<br />
@<br />
text<br />
@#include&#8221;header.h&#8221;<br />
int main()<br />
{<br />
void *queue;<br />
int f,r;<br />
f=r=-1;<br />
int ch;<br />
do<br />
{<br />
printf(&#8220;1:push\n&#8221;);<br />
printf(&#8220;2:pop\n&#8221;);<br />
printf(&#8220;3:display\n&#8221;);<br />
printf(&#8220;4:exit\n&#8221;);<br />
printf(&#8220;enter your choice\n&#8221;);<br />
scanf(&#8220;%d&#8221;,&amp;ch);<br />
switch(ch)<br />
{<br />
case 1: push(&amp;queue,&amp;f,&amp;r);<br />
break;<br />
case 2: pop(&amp;queue,&amp;f,&amp;r);<br />
break;<br />
case 3: display(&amp;queue,&amp;f,&amp;r);<br />
break;<br />
default: printf(&#8220;wrong choice\n&#8221;);<br />
}<br />
}while(ch != 4);<br />
return 0;<br />
}</p>
<p>#include&#8221;header.h&#8221;<br />
static char ch=1;<br />
int push(void **qa,int *fa,int *ra)<br />
{<br />
if(*ra &gt;= MAX-1)<br />
{<br />
printf(&#8220;queue overflow\n&#8221;);<br />
return -1;<br />
}<br />
if(*fa ==-1 &amp;&amp; *ra == -1)<br />
{<br />
*qa=(char *)malloc(1);<br />
(*fa)++;<br />
(*ra)++;<br />
*(char *)(*qa + *ra)=ch;<br />
ch++;<br />
return 0;<br />
}<br />
*qa=(char *)realloc(*qa, (*ra)+2);<br />
(*ra)++;<br />
*(char *)(*qa + *ra)=ch;<br />
ch++;<br />
return 0;<br />
}</p>
<p>int pop(void **qa,int *fa,int *ra)<br />
{<br />
if(*fa &gt;= MAX)<br />
{<br />
printf(&#8220;queue underflow\n&#8221;);<br />
return -1;<br />
}<br />
printf(&#8220;the %d popped element is %d\n&#8221;,*fa, *(char *)(*qa + *fa));<br />
(*fa)++;<br />
return 0;<br />
}<br />
void display(void **qa,int *fa,int *ra)<br />
{<br />
int i;<br />
for(i= *fa; i &lt;= *ra ; i++)<br />
{<br />
printf(&#8220;the %d element is %d\n&#8221;,i,*(char *)(*qa + i));<br />
}<br />
}</p>
<p>@</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/04/program-for-simple-queue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>program to reverse link list using three pointers</title>
		<link>https://www.emblogic.com/blog/03/program-to-reverse-link-list-using-three-pointers/</link>
		<comments>https://www.emblogic.com/blog/03/program-to-reverse-link-list-using-three-pointers/#comments</comments>
		<pubDate>Sat, 29 Mar 2014 11:15:53 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9659</guid>
		<description><![CDATA[#include #include #include struct node { int a; struct node *next; }; struct node * create_ll(); void display(struct node *); void rev(struct node *); int main() { struct node *start ,*temp,*temp1; int i,n; start=create_ll(); temp=start; printf(&#8220;enter node\n&#8221;); scanf(&#8220;%d&#8221;,&#38;n); for(i = &#8230; <a href="https://www.emblogic.com/blog/03/program-to-reverse-link-list-using-three-pointers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>#include<br />
#include<br />
#include<br />
struct node<br />
{<br />
	int a;<br />
	struct node *next;<br />
};<br />
struct node * create_ll();<br />
void display(struct node *);<br />
void rev(struct node *);<br />
int main()<br />
{<br />
	struct node *start ,*temp,*temp1;<br />
	int i,n;<br />
	start=create_ll();<br />
	temp=start;<br />
	printf(&#8220;enter node\n&#8221;);<br />
	scanf(&#8220;%d&#8221;,&amp;n);<br />
	for(i = 0; i next=temp1;<br />
		temp=temp-&gt;next;<br />
	}<br />
	display(start);<br />
	rev(start);<br />
	return 0;<br />
}<br />
struct node *create_ll()<br />
{<br />
	struct node *start;<br />
	start=malloc(sizeof(struct node));<br />
	printf(&#8220;enter data&#8221;);<br />
	scanf(&#8220;%d&#8221;,&amp;start-&gt;a);<br />
	start-&gt;next=NULL;<br />
	return start;<br />
}<br />
void display(struct node *start)<br />
{<br />
	struct node *temp;<br />
	temp=start;<br />
	while(temp!=NULL)<br />
	{<br />
	printf(&#8220;data is %d\n&#8221;,temp-&gt;a);<br />
	temp=temp-&gt;next;<br />
	}<br />
}<br />
void rev(struct node *start)<br />
{<br />
	struct node *temp,*temp1;<br />
	temp=start;<br />
	temp1=start;<br />
	while(temp1-&gt;next != NULL)<br />
	{<br />
		temp=temp1-&gt;next;<br />
		temp1-&gt;next=temp1-&gt;next-&gt;next;<br />
		temp-&gt;next=start;;<br />
		start=temp;<br />
	}<br />
	printf(&#8220;the reversed list is ::::::::\n&#8221;);<br />
	while(start!=NULL)<br />
	{<br />
 		printf(&#8220;data is %d\n&#8221;,start-&gt;a);<br />
		start=start-&gt;next;<br />
	}<br />
}	</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/program-to-reverse-link-list-using-three-pointers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>implementation of stack using pointers</title>
		<link>https://www.emblogic.com/blog/03/implementation-of-stack-using-pointers/</link>
		<comments>https://www.emblogic.com/blog/03/implementation-of-stack-using-pointers/#comments</comments>
		<pubDate>Sat, 29 Mar 2014 11:11:35 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9376</guid>
		<description><![CDATA[head 1.1; access; symbols; locks; strict; comment @ * @; 1.1 date 2014.03.29.11.10.17; author emblogic; state Exp; branches; next ; desc @this is a program of stack implementation using poimters @ 1.1 log @Initial revision @ text @#include&#8221;header.h&#8221; int main() &#8230; <a href="https://www.emblogic.com/blog/03/implementation-of-stack-using-pointers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>head	1.1;<br />
access;<br />
symbols;<br />
locks; strict;<br />
comment	@ * @;</p>
<p>1.1<br />
date	2014.03.29.11.10.17;	author emblogic;	state Exp;<br />
branches;<br />
next	;</p>
<p>desc<br />
@this is a program of stack implementation using poimters<br />
@</p>
<p>1.1<br />
log<br />
@Initial revision<br />
@<br />
text<br />
@#include&#8221;header.h&#8221;<br />
int main()<br />
{<br />
	void *stack;<br />
	int ch,top=-1;<br />
	do<br />
	{<br />
		printf(&#8220;1: push\n&#8221;);<br />
		printf(&#8220;2: pop\n&#8221;);<br />
		printf(&#8220;3: display\n&#8221;);<br />
		printf(&#8220;enter your choice\n&#8221;);<br />
		scanf(&#8220;%d&#8221;,&amp;ch);<br />
		switch(ch)<br />
		{<br />
			case 1:<br />
				push(&amp;stack,&amp;top);<br />
				break;<br />
			case 2:<br />
				pop(&amp;stack,&amp;top);<br />
				break;<br />
			case 3:<br />
				display(&amp;stack,&amp;top);<br />
				break;<br />
			defautl:<br />
				printf(&#8220;wrong choice\n&#8221;);<br />
		}<br />
	}while(ch != 4);<br />
}	</p>
<p>@<br />
@#include&#8221;header.h&#8221;<br />
int push(void **astack,int *atop)<br />
{<br />
	static char ch=1;</p>
<p>	if( *atop &gt;= MAX-1)<br />
	{<br />
		printf(&#8220;stack overflow\n&#8221;);<br />
		return -1;<br />
	}<br />
	if( *atop &lt; 0)<br />
	{<br />
		*astack=(char *)malloc(1);<br />
		(*atop)++;<br />
		*(char *)(*astack + *atop)=ch;<br />
		ch++;<br />
		return 0;<br />
	}<br />
	(*atop)++;<br />
	*astack=(char *)realloc(*astack, (*atop)+1);<br />
	*(char *)(*astack + *atop)=ch;<br />
	ch++;</p>
<p>	return 0;<br />
}<br />
int pop(void **astack,int *atop)<br />
{<br />
	if(*atop=0; i&#8211;)<br />
	{<br />
		printf(&#8220;the element at loc %d is = %d\n&#8221;,i, *(char *)(*astack + i));<br />
	}<br />
}	</p>
<p>@</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/implementation-of-stack-using-pointers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>program of linked list</title>
		<link>https://www.emblogic.com/blog/03/program-of-linked-list/</link>
		<comments>https://www.emblogic.com/blog/03/program-of-linked-list/#comments</comments>
		<pubDate>Tue, 25 Mar 2014 09:12:09 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9174</guid>
		<description><![CDATA[head 1.1; access; symbols; locks Emblogic:1.1; strict; comment @ * @; 1.1 date 2014.03.25.09.08.55; author Emblogic; state Exp; branches; next ; desc @this is a program of linked list to insert the node at beginning,position and end to delete the &#8230; <a href="https://www.emblogic.com/blog/03/program-of-linked-list/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>head	1.1;<br />
access;<br />
symbols;<br />
locks<br />
	Emblogic:1.1; strict;<br />
comment	@ * @;</p>
<p>1.1<br />
date	2014.03.25.09.08.55;	author Emblogic;	state Exp;<br />
branches;<br />
next	;</p>
<p>desc<br />
@this is a program of linked list<br />
to insert the node at beginning,position and end<br />
to delete the node at begining,position,end<br />
to dispay the linked list<br />
@</p>
<p>1.1<br />
log<br />
@Initial revision<br />
@<br />
text<br />
@#include<br />
#include<br />
struct node<br />
{<br />
	int data;<br />
	struct node *next;<br />
};<br />
struct node * create_node();<br />
struct node * insert_node(struct node *);<br />
struct node * delete_node(struct node *);<br />
void display(struct node *);<br />
struct node * insert_beg(struct node *);<br />
struct node * insert_pos(struct node *);<br />
struct node * insert_end(struct node *);<br />
struct node * delete_beg(struct node *);<br />
struct node * delete_pos(struct node *);<br />
struct node * delete_end(struct node *);</p>
<p>int main()<br />
{<br />
	struct node *start;<br />
	int ch;<br />
	do<br />
	{<br />
		printf(&#8220;1: create_node\n&#8221;);<br />
		printf(&#8220;2: insert_node\n&#8221;);<br />
		printf(&#8220;3: delete_node\n&#8221;);<br />
		printf(&#8220;4: display\n&#8221;);<br />
		printf(&#8220;5: exit\n&#8221;);<br />
		printf(&#8220;enter your choice\n&#8221;);<br />
		scanf(&#8220;%d&#8221;,&amp;ch);<br />
		switch(ch)<br />
		{<br />
			case 1:<br />
				start=create_node();<br />
				break;<br />
			case 2:<br />
				start=insert_node(start);<br />
				break;<br />
			case 3:<br />
				start=delete_node(start);<br />
				break;<br />
			case 4:<br />
				display(start);<br />
				break;<br />
			case 5:<br />
				break;<br />
		}	</p>
<p>	}while(ch != 5);	</p>
<p>}<br />
struct node * create_node()<br />
{<br />
	struct node *start;<br />
	start=malloc(sizeof(struct node));<br />
	printf(&#8221;      enter data\n&#8221;);<br />
	scanf(&#8220;%d&#8221;,&amp;start-&gt;data);<br />
	start-&gt;next= NULL;<br />
	return start;<br />
}	</p>
<p>struct node * insert_node(struct node *start)<br />
{<br />
	int ch;<br />
	printf(&#8220;1: insert at begining\n&#8221;);<br />
	printf(&#8220;2: insert at position\n&#8221;);<br />
	printf(&#8220;3: insert at end\n&#8221;);<br />
	printf(&#8220;enter your choice\n&#8221;);<br />
	scanf(&#8220;%d&#8221;,&amp;ch);</p>
<p>	switch(ch)<br />
	{<br />
		case 1:<br />
			start=insert_beg(start);<br />
			break;<br />
		case 2:<br />
			start=insert_pos(start);<br />
			break;<br />
		case 3:<br />
			start=insert_end(start);<br />
			break;<br />
	}<br />
		return start;	</p>
<p>}</p>
<p>struct node * delete_node(struct node *start)<br />
{<br />
	int ch;<br />
	printf(&#8220;1: delete at begining\n&#8221;);<br />
	printf(&#8220;2: delete at position\n&#8221;);<br />
	printf(&#8220;3: delete at end\n&#8221;);<br />
	printf(&#8220;enter your choice\n&#8221;);<br />
	scanf(&#8220;%d&#8221;,&amp;ch);</p>
<p>	switch(ch)<br />
	{<br />
		case 1:<br />
			start=delete_beg(start);<br />
			break;<br />
		case 2:<br />
			start=delete_pos(start);<br />
			break;<br />
		case 3:<br />
			start=delete_end(start);<br />
			break;<br />
	}<br />
	return start;</p>
<p>}</p>
<p>void display(struct node *start)<br />
{<br />
	struct node *temp;<br />
	temp=start;<br />
	while(temp != NULL)<br />
	{<br />
		printf(&#8220;the data is %d&#8221;,temp-&gt;data);<br />
		temp=temp-&gt;next;<br />
	}<br />
}</p>
<p>struct node * insert_beg(struct node *start)<br />
{<br />
	struct node *temp;<br />
	temp=start;<br />
	start=create_node();<br />
	start-&gt;next=temp;<br />
	return start;<br />
}<br />
struct node * insert_pos(struct node *start)<br />
{<br />
	struct node *temp, *new;<br />
	int n,i;<br />
	temp=start;<br />
	printf(&#8220;enter the position\n&#8221;);<br />
	scanf(&#8220;%d&#8221;,&amp;n);<br />
	for(i=0; i next;<br />
	}<br />
	new=create_node();<br />
	new-&gt;next=temp-&gt;next;<br />
	temp-&gt;next=new;<br />
	return start;<br />
}<br />
struct node * insert_end(struct node *start)<br />
{<br />
	struct node *temp,*new;<br />
	temp=start;<br />
	while(temp != NULL)<br />
	{<br />
		temp=temp-&gt;next;<br />
	}<br />
	new=create_node();<br />
	temp-&gt;next=new;<br />
	new-&gt;next= NULL;<br />
	return start;<br />
}	</p>
<p>struct node * delete_beg(struct node *start)<br />
{<br />
	struct node *temp;<br />
	temp= start;<br />
	start=start-&gt;next;<br />
	free(temp);<br />
	return start;<br />
}<br />
struct node * delete_pos(struct node *start)<br />
{<br />
	struct node *temp, *prev;<br />
	int n,i;<br />
	temp=start;<br />
	printf(&#8220;enter the position\n&#8221;);<br />
	scanf(&#8220;%d&#8221;,&amp;n);<br />
	for(i=0; i next;<br />
	}<br />
	prev-&gt;next=temp-&gt;next;<br />
	free(temp);<br />
	return start;<br />
}<br />
struct node * delete_end(struct node *start)<br />
{<br />
	struct node *temp,*prev;<br />
	temp=start;<br />
	while(temp-&gt;next != NULL)<br />
	{<br />
		prev=temp;<br />
		temp=temp-&gt;next;<br />
	}<br />
	free(temp);<br />
	prev-&gt;next= NULL;<br />
	return start;<br />
}<br />
@</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/program-of-linked-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>structure padding</title>
		<link>https://www.emblogic.com/blog/03/structure-padding/</link>
		<comments>https://www.emblogic.com/blog/03/structure-padding/#comments</comments>
		<pubDate>Sat, 22 Mar 2014 16:05:25 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9273</guid>
		<description><![CDATA[Most processors require specific memory alignment on variables certain types. Normally the minimum alignment is the size of the basic type in question, fo instance this is common &#160; char variables can be byte aligned and appear at any byte &#8230; <a href="https://www.emblogic.com/blog/03/structure-padding/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Most processors require specific memory alignment on variables certain types. Normally the minimum alignment is the size of the basic type in question, fo instance this is common</p>
<p>&nbsp;</p>
<p>char variables can be byte aligned and appear at any byte boundary</p>
<p>&nbsp;</p>
<p>short (2 byte) variables must be 2 byte aligned, they can appear at any even byte boundary. This means that 0&#215;10004567 is not a valid location for a short variable but 0&#215;10004566 is.</p>
<p>&nbsp;</p>
<p>long (4 byte) variables must be 4 byte aligned, they can only appear at byte boundarys that are a multiple of 4 bytes. This means that 0&#215;10004566 is not a valid location for a long variable but 0&#215;10004568 is.</p>
<p>&nbsp;</p>
<p>Structure padding occurs because the members of the structure must appear at the correect byte boundary, to achieve this the compiler puts in padding bytes (or bits if bit fields are in use) so that the structure members appear in the correct location. Additionally the size of the structure must be such that in an array of the structures all the structures are correctly aligned in memory so there may be padding bytes at the end of the structure too</p>
<p>&nbsp;</p>
<p>struct example {</p>
<p>char c1;</p>
<p>short s1;</p>
<p>char c2;</p>
<p>long l1;</p>
<p>char c3;</p>
<p>}</p>
<p>&nbsp;</p>
<p>In this structure, assuming the alignment scheme I have previously stated then</p>
<p>&nbsp;</p>
<p>c1 can appear at any byte boundary, however s1 must appear at a 2 byte boundary so there is a padding byte between c1 and s1.</p>
<p>&nbsp;</p>
<p>c2 can then appear in the available memory location, however l1 must be at a 4 byte boundary so there are 3 padding bytes between c2 and l1</p>
<p>&nbsp;</p>
<p>c3 then appear in the available memory location, however because the structure contains a long member the structure must be 4 byte aligned and must be a multiple of 4 bytes in size. Therefore there are 3 padding bytes at the end of the structure. it would appear in memory in this order</p>
<p>&nbsp;</p>
<p>c1</p>
<p>padding byte</p>
<p>s1 byte 1</p>
<p>s1 byte 2</p>
<p>c2</p>
<p>padding byte</p>
<p>padding byte</p>
<p>padding byte</p>
<p>l1 byte 1</p>
<p>l1 byte 2</p>
<p>l1 byte 3</p>
<p>l1 byte 4</p>
<p>c3</p>
<p>padding byte</p>
<p>padding byte</p>
<p>padding byte</p>
<p>&nbsp;</p>
<p>The structure would be 16 bytes long.</p>
<p>&nbsp;</p>
<p>re-written like this</p>
<p>&nbsp;</p>
<p>struct example {</p>
<p>long l1;</p>
<p>short s1;</p>
<p>char c1;</p>
<p>char c2;</p>
<p>char c3;</p>
<p>}</p>
<p>&nbsp;</p>
<p>Then l1 appears at the correct byte alignment, s1 will be correctly aligned so no need for padding between l1 and s1. c1, c2, c3 can appear at any location. The structure must be a multiple of 4 bytes in size since it contains a long so 3 padding bytes appear after c3</p>
<p>&nbsp;</p>
<p>It appears in memory in the order</p>
<p>&nbsp;</p>
<p>l1 byte 1</p>
<p>l1 byte 2</p>
<p>l1 byte 3</p>
<p>l1 byte 4</p>
<p>s1 byte 1</p>
<p>s1 byte 2</p>
<p>c1</p>
<p>c2</p>
<p>c3</p>
<p>padding byte</p>
<p>padding byte</p>
<p>padding byte</p>
<p>&nbsp;</p>
<p>and is only 12 bytes long.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/structure-padding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>this is a program tyo copy the contents of one file into another</title>
		<link>https://www.emblogic.com/blog/03/this-is-a-program-tyo-copy-the-contents-of-one-file-into-another/</link>
		<comments>https://www.emblogic.com/blog/03/this-is-a-program-tyo-copy-the-contents-of-one-file-into-another/#comments</comments>
		<pubDate>Thu, 20 Mar 2014 10:46:40 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9172</guid>
		<description><![CDATA[RCS file: 8p7.c,v Working file: 8p7.c head: 1.1 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 1; selected revisions: 1 description: this is a program to copy the contents of one file to another &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision &#8230; <a href="https://www.emblogic.com/blog/03/this-is-a-program-tyo-copy-the-contents-of-one-file-into-another/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: 8p7.c,v<br />
Working file: 8p7.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 />
this is a program to copy the contents of one file to another<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/03/20 10:47:06;  author: emblogic;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/this-is-a-program-tyo-copy-the-contents-of-one-file-into-another/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>this is a program to convert the contents of a file into uppercaseand then write it to another file</title>
		<link>https://www.emblogic.com/blog/03/this-is-a-program-to-convert-the-contents-of-a-file-into-uppercaseand-then-write-it-to-another-file/</link>
		<comments>https://www.emblogic.com/blog/03/this-is-a-program-to-convert-the-contents-of-a-file-into-uppercaseand-then-write-it-to-another-file/#comments</comments>
		<pubDate>Thu, 20 Mar 2014 10:44:17 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9134</guid>
		<description><![CDATA[RCS file: 8p4.c,v Working file: 8p4.c head: 1.1 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 1; selected revisions: 1 description: this is a program to convert the contents of a file into upper case and &#8230; <a href="https://www.emblogic.com/blog/03/this-is-a-program-to-convert-the-contents-of-a-file-into-uppercaseand-then-write-it-to-another-file/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: 8p4.c,v<br />
Working file: 8p4.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 />
this is a program to convert the contents of a file into upper case<br />
and write it to another file<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/03/20 10:42:22;  author: emblogic;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/this-is-a-program-to-convert-the-contents-of-a-file-into-uppercaseand-then-write-it-to-another-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>program to check if both files are equal or not</title>
		<link>https://www.emblogic.com/blog/03/program-to-check-if-both-files-are-equal-or-not/</link>
		<comments>https://www.emblogic.com/blog/03/program-to-check-if-both-files-are-equal-or-not/#comments</comments>
		<pubDate>Wed, 19 Mar 2014 09:36:48 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9149</guid>
		<description><![CDATA[RCS file: 8p3.c,v Working file: 8p3.c head: 1.1 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 1;    selected revisions: 1 description: this is a program to check if two files are same or not by comparing &#8230; <a href="https://www.emblogic.com/blog/03/program-to-check-if-both-files-are-equal-or-not/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: 8p3.c,v<br />
Working file: 8p3.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 />
this is a program to check if two files are same or not<br />
by comparing each char of both files<br />
till EOF of both files donot occur<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/03/19 22:32:31;  author: emblogic;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/program-to-check-if-both-files-are-equal-or-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>this is a program to read the last n char from the file using fseek()</title>
		<link>https://www.emblogic.com/blog/03/this-is-a-program-to-read-the-last-n-char-from-the-file-using-fseek/</link>
		<comments>https://www.emblogic.com/blog/03/this-is-a-program-to-read-the-last-n-char-from-the-file-using-fseek/#comments</comments>
		<pubDate>Wed, 19 Mar 2014 09:12:09 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9135</guid>
		<description><![CDATA[&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision 1.1 date: 2014/03/19 22:12:05;  author: emblogic;  state: Exp; Initial revision =============================================================================]]></description>
				<content:encoded><![CDATA[<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/03/19 22:12:05;  author: emblogic;  state: Exp;<br />
Initial revision<br />
=============================================================================</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/this-is-a-program-to-read-the-last-n-char-from-the-file-using-fseek/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>this is a program to copy the contents of one file to another using fputc()</title>
		<link>https://www.emblogic.com/blog/03/this-is-a-program-to-copy-the-contents-of-one-file-to-another-using-fputc/</link>
		<comments>https://www.emblogic.com/blog/03/this-is-a-program-to-copy-the-contents-of-one-file-to-another-using-fputc/#comments</comments>
		<pubDate>Wed, 19 Mar 2014 08:28:16 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9132</guid>
		<description><![CDATA[&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision 1.1 date: 2014/03/19 21:16:30; author: emblogic; state: Exp; Initial revision]]></description>
				<content:encoded><![CDATA[<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/03/19 21:16:30;  author: emblogic;  state: Exp;<br />
Initial revision</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/this-is-a-program-to-copy-the-contents-of-one-file-to-another-using-fputc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>this is a program to copy the contents of one file to another using fputc() and fgetc()</title>
		<link>https://www.emblogic.com/blog/03/this-is-a-program-to-copy-the-contents-of-one-file-to-another-using-fputc-and-fgetc/</link>
		<comments>https://www.emblogic.com/blog/03/this-is-a-program-to-copy-the-contents-of-one-file-to-another-using-fputc-and-fgetc/#comments</comments>
		<pubDate>Wed, 19 Mar 2014 08:26:03 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9130</guid>
		<description><![CDATA[&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision 1.1 date: 2014/03/19 21:16:30; author: emblogic; state: Exp; Initial revision]]></description>
				<content:encoded><![CDATA[<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/03/19 21:16:30;  author: emblogic;  state: Exp;<br />
Initial revision</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/this-is-a-program-to-copy-the-contents-of-one-file-to-another-using-fputc-and-fgetc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>this is a program to copy contents of one file to another using fputc() and fgetc()</title>
		<link>https://www.emblogic.com/blog/03/this-is-a-program-to-copy-contents-of-one-file-to-another-using-fputc-and-fgetc/</link>
		<comments>https://www.emblogic.com/blog/03/this-is-a-program-to-copy-contents-of-one-file-to-another-using-fputc-and-fgetc/#comments</comments>
		<pubDate>Wed, 19 Mar 2014 08:22:19 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9124</guid>
		<description><![CDATA[&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision 1.1 date: 2014/03/19 21:16:30; author: emblogic; state: Exp; Initial revision]]></description>
				<content:encoded><![CDATA[<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/03/19 21:16:30;  author: emblogic;  state: Exp;<br />
Initial revision</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/this-is-a-program-to-copy-contents-of-one-file-to-another-using-fputc-and-fgetc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>program to count the no. of positive no.s in the array and exit if any element is zero</title>
		<link>https://www.emblogic.com/blog/03/program-to-count-the-no-of-positive-no-s-in-the-array-and-exit-if-any-element-is-zero/</link>
		<comments>https://www.emblogic.com/blog/03/program-to-count-the-no-of-positive-no-s-in-the-array-and-exit-if-any-element-is-zero/#comments</comments>
		<pubDate>Sun, 16 Mar 2014 14:08:16 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=8959</guid>
		<description><![CDATA[&#62;&#62; this is the program using pointers &#62;&#62; in which we count the positive no.s in array and exit when zero is found &#62;&#62; there must b atleast one zero in the array &#62;&#62; . initial revision: 1.1 done [root@localhost &#8230; <a href="https://www.emblogic.com/blog/03/program-to-count-the-no-of-positive-no-s-in-the-array-and-exit-if-any-element-is-zero/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>&gt;&gt; this is the program using pointers<br />
&gt;&gt; in which we count the positive no.s in array and exit when zero is found<br />
&gt;&gt; there must b atleast one zero in the array<br />
&gt;&gt; .<br />
initial revision: 1.1<br />
done<br />
[root@localhost puja]# rlog vim 7p8.c,v<br />
rlog: RCS/vim,v: No such file or directory</p>
<p>RCS file: 7p8.c,v<br />
Working file: 7p8.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 />
this is the program using pointers<br />
in which we count the positive no.s in array and exit when zero is found<br />
there must b atleast one zero in the array<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/03/08 10:29:51;  author: emblogic;  state: Exp;<br />
Initial revision</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/program-to-count-the-no-of-positive-no-s-in-the-array-and-exit-if-any-element-is-zero/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>program to print the first byte of each element in integer array using pointers</title>
		<link>https://www.emblogic.com/blog/03/program-to-print-the-first-byte-of-each-element-in-integer-array-using-pointers/</link>
		<comments>https://www.emblogic.com/blog/03/program-to-print-the-first-byte-of-each-element-in-integer-array-using-pointers/#comments</comments>
		<pubDate>Sun, 16 Mar 2014 14:05:15 +0000</pubDate>
		<dc:creator><![CDATA[kpuja.dimple06]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=8963</guid>
		<description><![CDATA[&#62;&#62; this is a program to print the first byte of each element from an integer array &#62;&#62; using pointers &#62;&#62; . initial revision: 1.1 done [root@localhost puja]# rlog vim 7p7.c,v rlog: RCS/vim,v: No such file or directory RCS file: &#8230; <a href="https://www.emblogic.com/blog/03/program-to-print-the-first-byte-of-each-element-in-integer-array-using-pointers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>&gt;&gt; this is a program to print the first byte of each element from an integer array<br />
&gt;&gt; using pointers<br />
&gt;&gt; .<br />
initial revision: 1.1<br />
done<br />
[root@localhost puja]# rlog vim 7p7.c,v<br />
rlog: RCS/vim,v: No such file or directory</p>
<p>RCS file: 7p7.c,v<br />
Working file: 7p7.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 />
this is a program to print the first byte of each element from an integer array<br />
using pointers<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/03/08 10:39:55;  author: emblogic;  state: Exp;<br />
Initial revision</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/program-to-print-the-first-byte-of-each-element-in-integer-array-using-pointers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
