<?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; sprashant678</title>
	<atom:link href="https://www.emblogic.com/blog/author/sprasshant678/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>POSIX thread (pthread) libraries</title>
		<link>https://www.emblogic.com/blog/06/posix-thread-pthread-libraries/</link>
		<comments>https://www.emblogic.com/blog/06/posix-thread-pthread-libraries/#comments</comments>
		<pubDate>Thu, 05 Jun 2014 08:21:58 +0000</pubDate>
		<dc:creator><![CDATA[sprashant678]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=10335</guid>
		<description><![CDATA[The POSIX thread libraries are a standards based thread API for C/C++. It allows one to spawn a new concurrent process flow. It is most effective on multi-processor or multi-core systems where the process flow can be scheduled to run &#8230; <a href="https://www.emblogic.com/blog/06/posix-thread-pthread-libraries/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h1></h1>
<p>The POSIX thread libraries are a standards based thread API for C/C++. It allows one to spawn a new concurrent process flow. It is most effective on multi-processor or multi-core systems where the process flow can be scheduled to run on another processor thus gaining speed through parallel or distributed processing. Threads require less overhead than &#8220;forking&#8221; or spawning a new process because the system does not initialize a new system virtual memory space and environment for the process. While most effective on a multiprocessor system, gains are also found on uniprocessor systems which exploit latency in I/O and other system functions which may halt process execution. (One thread may execute while another is waiting for I/O or some other system latency.) Parallel programming technologies such as MPI and PVM are used in a distributed computing environment while threads are limited to a single computer system. All threads within a process share the same address space. A thread is spawned by defining a function and its arguments which will be processed in the thread. The purpose of using the POSIX thread library in your software is to execute software faster.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/06/posix-thread-pthread-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thread</title>
		<link>https://www.emblogic.com/blog/06/thread/</link>
		<comments>https://www.emblogic.com/blog/06/thread/#comments</comments>
		<pubDate>Tue, 03 Jun 2014 06:49:41 +0000</pubDate>
		<dc:creator><![CDATA[sprashant678]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=10271</guid>
		<description><![CDATA[RCS file: thrd.c,v Working file: thrd.c head: 1.1 branch: locks: strict root: 1.1 access list: symbolic names: keyword substitution: kv total revisions: 1;     selected revisions: 1 description: creating the thread &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision 1.1    locked by: root; date: 2014/06/03 06:37:40;  author: &#8230; <a href="https://www.emblogic.com/blog/06/thread/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: thrd.c,v<br />
Working file: thrd.c<br />
head: 1.1<br />
branch:<br />
locks: strict<br />
root: 1.1<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 1;     selected revisions: 1<br />
description:<br />
creating the thread<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1    locked by: root;<br />
date: 2014/06/03 06:37:40;  author: root;  state: Exp;<br />
Initial revision<br />
=============================================================================<br />
RCS file: thrd.c,v<br />
Working file: thrd.c<br />
head: 1.1<br />
branch:<br />
locks: strict<br />
root: 1.1<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 1;     selected revisions: 1<br />
description:<br />
creating the thread<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1    locked by: root;<br />
date: 2014/06/03 06:37:40;  author: root;  state: Exp;<br />
Initial revision<br />
=============================================================================<br />
#include&lt;stdio.h&gt;<br />
//#include&lt;string.h&gt;<br />
#include&lt;unistd.h&gt;<br />
#include&lt;pthread.h&gt;<br />
//#include&lt;sys/ipc.h&gt;</p>
<p>void *thread_function(void *arg);<br />
char mssg[]=&#8221;hi there&#8221;;<br />
int main()<br />
{<br />
pthread_t var[20];<br />
void *thrd_rslt;<br />
int ret = pthread_create(&amp;var[20],NULL,thread_function,(void *)mssg);<br />
if(ret!=0)<br />
{<br />
perror(&#8220;creation failed&#8221;);<br />
//              exit(EXIT_FAILURE);<br />
return -1;<br />
}<br />
printf(&#8221; i got it&#8230;&#8230;\n&#8221;);<br />
printf(&#8220;thred created&#8230;&#8230;\n&#8221;);<br />
printf(&#8220;waiting for thread to finish&#8230;&#8230;&#8230;&gt;&gt;&gt;&gt;&gt;&gt;&gt;\n&#8221;);<br />
ret=pthread_join(var[20],&amp;thrd_rslt);<br />
if(ret!=0)<br />
{<br />
perror(&#8220;joining failed&#8221;);<br />
//exit(EXIT_FAILURE);<br />
return -1;<br />
}<br />
printf(&#8220;thread join returned %s\n&#8221;,(char *)thrd_rslt);<br />
printf(&#8220;now message is %s\n&#8221;,mssg);<br />
//exit(EXIT_SUCCESS);<br />
return 0;<br />
}<br />
void *thread_function(void *arg)<br />
{<br />
printf(&#8220;thread function is running with arg %s\n&#8221;,(char*)arg);<br />
sleep(2);<br />
strcpy(mssg,&#8221;bye&#8221;);<br />
pthread_exit(&#8220;thanks for cpu time&gt;&gt;&gt;&gt;&gt;&gt;&gt;\n&#8221;);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/06/thread/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>character driver</title>
		<link>https://www.emblogic.com/blog/05/character-driver-28/</link>
		<comments>https://www.emblogic.com/blog/05/character-driver-28/#comments</comments>
		<pubDate>Sun, 11 May 2014 11:36:40 +0000</pubDate>
		<dc:creator><![CDATA[sprashant678]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9956</guid>
		<description><![CDATA[W’s of character drivers We already know what drivers are, and why we need them. What is so special about character drivers? If we write drivers for byte-oriented operations (or, in C lingo, character-oriented operations), then we refer to them &#8230; <a href="https://www.emblogic.com/blog/05/character-driver-28/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h2>W’s of character drivers</h2>
<p>We already know what drivers are, and why we need them. What is so special about character drivers? If we write drivers for byte-oriented operations (or, in C lingo, character-oriented operations), then we refer to them as character drivers. Since the majority of devices are byte-oriented, the majority of device drivers are character device drivers.</p>
<p>Take, for example, serial drivers, audio drivers, video drivers, camera drivers, and basic I/O drivers. In fact, all device drivers that are neither storage nor network device drivers are some type of a character driver. Let’s look into the commonalities of these character drivers, and how Shweta wrote one of them.</p>
<h2>The complete connection</h2>
<p>&nbsp;</p>
<p><a href="http://www.opensourceforu.com/wp-content/uploads/2011/02/figure_7_character_driver_overview.png"><img class="size-large wp-image-7963" title="Character driver overview" src="http://www.opensourceforu.com/wp-content/uploads/2011/02/figure_7_character_driver_overview-590x331.png" alt="Character driver overview" width="590" height="331" /></a></p>
<p>As shown in Figure 1, for any user-space application to operate on a byte-oriented device (in hardware space), it should use the corresponding character device driver (in kernel space). Character driver usage is done through the corresponding character device file(s), linked to it through the virtual file system (VFS). What this means is that an application does the usual file operations on the character device file. Those operations are translated to the corresponding functions in the linked character device driver by the VFS. Those functions then do the final low-level access to the actual device to achieve the desired results.</p>
<p>Note that though the application does the usual file operations, their outcome may not be the usual ones. Rather, they would be as driven by the corresponding functions in the device driver. For example, a write followed by a read may not fetch what has just been written to the character device file, unlike for regular files. Remember that this is the usual expected behaviour for device files. Let’s take an audio device file as an example. What we write into it is the audio data we want to play back, say through a speaker. However, the read would get us audio data that we are recording, say through a microphone. The recorded data need not be the played-back data.</p>
<p>In this complete connection from the application to the device, there are four major entities involved:</p>
<ol>
<li>Application</li>
<li>Character device file</li>
<li>Character device driver</li>
<li>Character device</li>
</ol>
<p>The interesting thing is that all of these can exist independently on a system, without the other being present. The mere existence of these on a system doesn’t mean they are linked to form the complete connection. Rather, they need to be explicitly connected. An application gets connected to a device file by invoking the open system call on the device file.</p>
<p>Device file(s) are linked to the device driver by specific registrations done by the driver. The driver is linked to a device by its device-specific low-level operations. Thus we form the complete connection. With this, note that the character device file is not the actual device, but just a place-holder for the actual device.</p>
<h2>Major and minor numbers</h2>
<p>The connection between the application and the device file is based on the name of the device file. However, the connection between the device file and the device driver is based on the number of the device file, not the name. This allows a user-space application to have any name for the device file, and enables the kernel-space to have a trivial index-based linkage between the device file and the device driver. This device file number is more commonly referred to as the <code>&lt;major, minor&gt;</code> pair, or the major and minor numbers of the device file.</p>
<p>Earlier (till kernel 2.4), one major number was for one driver, and the minor number used to represent the sub-functionalities of the driver. With kernel 2.6, this distinction is no longer mandatory; there could be multiple drivers under the same major number, but obviously, with different minor number ranges.</p>
<p>However, this is more common with the non-reserved major numbers, and standard major numbers are typically preserved for single drivers. For example, 4 for serial interfaces, 13 for mice, 14 for audio devices, and so on. The following command would list the various character device files on your system:</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/05/character-driver-28/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pipes</title>
		<link>https://www.emblogic.com/blog/03/pipes-5/</link>
		<comments>https://www.emblogic.com/blog/03/pipes-5/#comments</comments>
		<pubDate>Tue, 25 Mar 2014 09:55:21 +0000</pubDate>
		<dc:creator><![CDATA[sprashant678]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9386</guid>
		<description><![CDATA[Creating &#8220;pipelines&#8221; with the C programming language can be a bit more involved than our simple shell example. To create a simple pipe with C, we make use of the pipe() system call. It takes a single argument, which is &#8230; <a href="https://www.emblogic.com/blog/03/pipes-5/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Creating &#8220;pipelines&#8221; with the C programming language can be a bit more involved than our simple shell example. To create a simple pipe with C, we make use of the pipe() system call. It takes a single argument, which is an array of two integers, and if successful, the array will contain two new file descriptors to be used for the pipeline. After creating a pipe, the process typically spawns a new process (remember the child inherits open file descriptors).</p>
<p>SYSTEM CALL: pipe();</p>
<p>PROTOTYPE: int pipe( int fd[2] );<br />
RETURNS: 0 on success<br />
-1 on error: errno = EMFILE (no free descriptors)<br />
EMFILE (system file table is full)<br />
EFAULT (fd array is not valid)</p>
<p>NOTES: fd[0] is set up for reading, fd[1] is set up for writing</p>
<p>The first integer in the array (element 0) is set up and opened for reading, while the second integer (element 1) is set up and opened for writing. Visually speaking, the output of fd1 becomes the input for fd0. Once again, all data traveling through the pipe moves through the kernel.</p>
<p>#include<br />
#include<br />
#include</p>
<p>main()<br />
{<br />
int fd[2];</p>
<p>pipe(fd);<br />
.<br />
.<br />
}</p>
<p>Remember that an array name in C decays into a pointer to its first member. Above, fd is equivalent to &amp;fd[0]. Once we have established the pipeline, we then fork our new child process:</p>
<p>#include<br />
#include<br />
#include</p>
<p>main()<br />
{<br />
int fd[2];<br />
pid_t childpid;</p>
<p>pipe(fd);</p>
<p>if((childpid = fork()) == -1)<br />
{<br />
perror(&#8220;fork&#8221;);<br />
exit(1);<br />
}<br />
.<br />
.<br />
}</p>
<p>If the parent wants to receive data from the child, it should close fd1, and the child should close fd0. If the parent wants to send data to the child, it should close fd0, and the child should close fd1. Since descriptors are shared between the parent and child, we should always be sure to close the end of pipe we aren&#8217;t concerned with. On a technical note, the EOF will never be returned if the unnecessary ends of the pipe are not explicitly closed.</p>
<p>#include<br />
#include<br />
#include</p>
<p>main()<br />
{<br />
int fd[2];<br />
pid_t childpid;</p>
<p>pipe(fd);</p>
<p>if((childpid = fork()) == -1)<br />
{<br />
perror(&#8220;fork&#8221;);<br />
exit(1);<br />
}</p>
<p>if(childpid == 0)<br />
{<br />
/* Child process closes up input side of pipe */<br />
close(fd[0]);<br />
}<br />
else<br />
{<br />
/* Parent process closes up output side of pipe */<br />
close(fd[1]);<br />
}<br />
.<br />
.<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/pipes-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ipc</title>
		<link>https://www.emblogic.com/blog/03/ipc-9/</link>
		<comments>https://www.emblogic.com/blog/03/ipc-9/#comments</comments>
		<pubDate>Tue, 25 Mar 2014 09:42:38 +0000</pubDate>
		<dc:creator><![CDATA[sprashant678]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9384</guid>
		<description><![CDATA[RCS file: server.c,v Working file: server.c head: 1.2 branch: locks: strict root: 1.2 access list: symbolic names: keyword substitution: kv total revisions: 2; selected revisions: 2 description: make the server for a requesting client &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision 1.2 locked by: root; &#8230; <a href="https://www.emblogic.com/blog/03/ipc-9/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: server.c,v<br />
Working file: server.c<br />
head: 1.2<br />
branch:<br />
locks: strict<br />
        root: 1.2<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 2;     selected revisions: 2<br />
description:<br />
make the server for a requesting client<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2    locked by: root;<br />
date: 2014/03/22 06:44:10;  author: root;  state: Exp;  lines: +17 -4<br />
data recieved in client<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/03/21 07:42:00;  author: root;  state: Exp;<br />
Initial revision</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/ipc-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ipc</title>
		<link>https://www.emblogic.com/blog/03/ipc-8/</link>
		<comments>https://www.emblogic.com/blog/03/ipc-8/#comments</comments>
		<pubDate>Tue, 25 Mar 2014 09:41:57 +0000</pubDate>
		<dc:creator><![CDATA[sprashant678]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9310</guid>
		<description><![CDATA[RCS file: server.c,v Working file: server.c head: 1.2 branch: locks: strict root: 1.2 access list: symbolic names: keyword substitution: kv total revisions: 2; selected revisions: 2 description: make the server for a requesting client &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- revision 1.2 locked by: root; &#8230; <a href="https://www.emblogic.com/blog/03/ipc-8/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>RCS file: server.c,v<br />
Working file: server.c<br />
head: 1.2<br />
branch:<br />
locks: strict<br />
        root: 1.2<br />
access list:<br />
symbolic names:<br />
keyword substitution: kv<br />
total revisions: 2;     selected revisions: 2<br />
description:<br />
make the server for a requesting client<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.2    locked by: root;<br />
date: 2014/03/22 06:44:10;  author: root;  state: Exp;  lines: +17 -4<br />
data recieved in client<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
revision 1.1<br />
date: 2014/03/21 07:42:00;  author: root;  state: Exp;<br />
Initial revision</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/ipc-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function in c</title>
		<link>https://www.emblogic.com/blog/02/function-in-c-2/</link>
		<comments>https://www.emblogic.com/blog/02/function-in-c-2/#comments</comments>
		<pubDate>Tue, 25 Feb 2014 04:31:19 +0000</pubDate>
		<dc:creator><![CDATA[sprashant678]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=8598</guid>
		<description><![CDATA[DIFINATION-it is a block of code that has a property that it is reusable.it may be executed from many different point in c program. Name of the function is globaly decleared therefore it can be accesed from anywhere in the &#8230; <a href="https://www.emblogic.com/blog/02/function-in-c-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><strong>DIFINATION</strong>-it is a block of code that has a property that it is reusable.it may be executed from many different point in c program.</p>
<p>Name of the function is globaly decleared therefore it can be accesed from anywhere in the program.<br />
Use of functions reduce the complexity of the c program and it gives the return type, function name, passing arguments.All the c program have a function &#8216;main&#8217;.</p>
<p><strong><em>STRUCTURE OF FUNCTION&#8211;</em></strong>-</p>
<p>There are three parts of function.</p>
<p><strong>1.FUNCTION PROTOTYPE</strong><br />
<strong> 2.FUNCTION CALL</strong><br />
<strong> 3.FUNCTION DEFINITION</strong></p>
<p><strong><em>FUNCTION PROTOTYPE&#8211;&gt;</em></strong>Function prototype gives the return type ,function name and the data type of the arguments that is to be passed.</p>
<p>Return_type Function_name(data type of arguments);<br />
eg- int fun_name(int , int);<br />
Note-In prototype only the data type is define.And the order of the arguement will do matter.<br />
and the prototype will be define globally.</p>
<p><strong>FUNCTION CALL-&gt;</strong> Function call will be define in main.In the call function argument will be pass, according to the reqirment of the program.It will declear the element which is about to pass.<br />
And if we want to return a value from defination then store the value in different variable.<br />
There are tthree different way to passing an argument.<br />
a.Pass by value<br />
b.Pass by reference<br />
c.Passing a array<br />
=&gt;In pass by value:-value of deta type will be pass to a function.<br />
=&gt;In pass by reference:-Address of the data type will be pass.<br />
=&gt;In pass by array:-Name and the size of array will be pass to afunction.</p>
<p>eg- function_name(i , j);</p>
<p>//where iand j are the variables,here when we pass the address of the i and j ,then it will be the pass by reference.</p>
<p>function_name(size , name of the array); // pass by array</p>
<p><strong>FUNCTION DEFINITION&#8211;&gt;</strong></p>
<p>it gives the return type ,function name and the passing argument with the data type and the body of the difinition is&#8212;-</p>
<p>return_type function _name(passed argument with their data types)<br />
{<br />
statements<br />
&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/02/function-in-c-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
