<?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; masoomktr</title>
	<atom:link href="https://www.emblogic.com/blog/author/masoomktr/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>what is a Device Driver</title>
		<link>https://www.emblogic.com/blog/06/what-is-a-device-driver/</link>
		<comments>https://www.emblogic.com/blog/06/what-is-a-device-driver/#comments</comments>
		<pubDate>Thu, 26 Jun 2014 13:37:56 +0000</pubDate>
		<dc:creator><![CDATA[masoomktr]]></dc:creator>
				<category><![CDATA[Device Drivers]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=10673</guid>
		<description><![CDATA[What is a Device Driver? Making hardware work is tedious. To write to a hard disk, for example, requires that you write magic numbers in magic places, wait for the hard drive to say that it is ready to receive &#8230; <a href="https://www.emblogic.com/blog/06/what-is-a-device-driver/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h3>What is a Device Driver?</h3>
<p>Making hardware work is tedious. To write to a hard disk, for example, requires that you write magic numbers in magic places, wait for the hard drive to say that it is ready to receive data, and then feed it the data it wants, very carefully. To write to a floppy disk is even harder, and requires that the program supervise the floppy disk drive almost constantly while it is running.</p>
<p>Instead of putting code in each application you write to control each device, you share the code between applications. To make sure that that code is not compromised, you protect it from users and normal programs that use it. If you do it right, you will be able to add and remove devices from your system without changing your applications at all. Furthermore, you need to be able to load your program into memory and run it, which the operating system also does. So an operating system is essentially a priviledged, general, sharable library of low-level hardware and memory and process control functions and routines.</p>
<p>All versions of Unix have an abstract way of reading and writing devices. By making the devices act as much as possible like regular files, the same calls (<tt>read()</tt>, <tt>write()</tt>, etc.) can be used for devices and files. Within the kernel, there are a set of functions, registered with the filesystem, which are called to handle requests to do I/O on &#8220;device special files,&#8221; which are those which represent devices. (See <tt>mknod(1,2)</tt> for an explanation of how to make these files.)</p>
<p>All devices controlled by the same device driver are given the same <b>major number</b>, and of those with the same major number, different devices are distinguished by different <b>minor numbers</b>. (This is not strictly true, but it is close enough. If you understand where it is not true, you don&#8217;t need to read this section, and if you don&#8217;t but want to learn, read the code for the tty devices, which uses up 2 major numbers, and may use a third and possibly fourth by the time you read this. Also, the &#8220;misc&#8221; major device supports many minor devices that only need a few minor numbers; we&#8217;ll get to that later.)</p>
<p>This chapter explains how to write any type of Linux device driver that you might need to, including character, block, SCSI, and network drivers. It explains what functions you need to write, how to initialize your drivers and obtain memory for them efficiently, and what function are built in to Linux to make your job easier.</p>
<p>Creating device drivers for Linux is easier than you might think. It merely involves writing a few functions and registering them with the Virtual Filesystem Switch (VFS), so that when the proper device special files are accessed, the VFS can call your functions.</p>
<p>However, a word of warning is due here: Writing a device driver <b>is</b> writing a part of the Linux kernel. This means that your driver runs with kernel permissions, and can do anything it wants to: write to any memory, reformat your hard drive, damage your monitor or video card, or even break your dishes, if your dishwasher is controlled by your computer. Be careful.</p>
<p>Also, your driver will run in kernel mode, and the Linux kernel, like most Unix kernels, is non-pre-emptible. This means that if you driver takes a long time to work without giving other programs a chance to work, your computer will appear to &#8220;freeze&#8221; when your driver is running. Normal user-mode pre-emptive scheduling does not apply to your driver.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/06/what-is-a-device-driver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TCP/IP Based client &amp; server using socket</title>
		<link>https://www.emblogic.com/blog/06/tcpip-based-client-server-using-socket/</link>
		<comments>https://www.emblogic.com/blog/06/tcpip-based-client-server-using-socket/#comments</comments>
		<pubDate>Tue, 17 Jun 2014 10:54:20 +0000</pubDate>
		<dc:creator><![CDATA[masoomktr]]></dc:creator>
				<category><![CDATA[Project 04: FTP based Client Server using Threads and Sockets]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=10527</guid>
		<description><![CDATA[Abstract: 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 &#8230; <a href="https://www.emblogic.com/blog/06/tcpip-based-client-server-using-socket/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><span style="color: #800000"><span style="font-size: 16px"><strong><span style="font-family: arial,helvetica,sans-serif">Abstract:</span></strong></span></span></p>
<p style="text-align: justify"><span style="color: #333333"><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;line-height: 18px;text-align: justify">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. 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.</span></span></p>
<p style="font-family: Arial;font-size: 13px;color: #000000;line-height: 18px;text-align: justify;margin-bottom: 0.08in"><span style="color: #333333">Sockets are the fundamental technology for programming software to communicate on TCP/IP networks. A socket provides a bidirectional communication endpoint for sending and receiving data with another socket. Socket connections normally run between two different computers on a LAN or across the Internet, but they can also be used for interprocess communication on a single computer.</span></p>
<p><span style="color: #800000"><span style="font-size: 16px"><strong><span style="font-family: arial,helvetica,sans-serif">Introduction:</span></strong></span></span></p>
<p style="text-align: justify"><span style="color: #333333"><span style="font-size: 14px"><span style="font-family: arial,helvetica,sans-serif">A thread is a semi-process, that has its own stack, and executes a given piece of code. Unlike a real process, the thread normally shares its memory with other threads (where as for processes we usually have a different memory area for each one of them). A Thread Group is a set of threads all executing inside the same process. They all share the same memory, and thus can access the same global variables, same heap memory, same set of file descriptors, etc. All these threads execute in parallel (i.e. using time slices, or if the system has several processors, then really in parallel).</span></span></span></p>
<p style="color: #000000;font-family: 'Times New Roman';font-size: medium;text-align: justify"><span style="color: #333333"><span style="font-size: 14px"><span style="font-family: arial,helvetica,sans-serif">The advantage of using a thread group instead of a normal serial program is that several operations may be carried out in parallel, and thus events can be handled immediately as they arrive (for example, if we have one thread handling a user interface, and another thread handling database queries, we can execute a heavy query requested by the user, and still respond to user input while the query is executed).</span></span></span></p>
<p style="color: #000000;font-family: 'Times New Roman';font-size: medium;text-align: justify"><span style="color: #333333"><span style="font-size: 14px"><span style="font-family: arial,helvetica,sans-serif">The advantage of using a thread group over using a process group is that context switching between threads is much faster then context switching between processes (context switching means that the system switches from running one thread or process, to running another thread or process). Also, communications between two threads is usually faster and easier to implement then communications between two processes.</span></span></span></p>
<p style="color: #000000;font-family: 'Times New Roman';font-size: medium;text-align: justify"><span style="color: #333333"><span style="font-size: 14px"><span style="font-family: arial,helvetica,sans-serif">On the other hand, because threads in a group all use the same memory space, if one of them corrupts the contents of its memory, other threads might suffer as well. With processes, the operating system normally protects processes from one another, and thus if one corrupts its own memory space, other processes won&#8217;t suffer. Another advantage of using processes is that they can run on different machines, while all the threads have to run on the same machine (at least normally).</span></span></span></p>
<p><span style="color: #800000"><span style="font-size: 16px"><strong><span style="font-family: arial,helvetica,sans-serif">Synopsys:</span></strong></span></span></p>
<p><span style="color: #333333"><strong><span style="font-size: 14px"><span style="font-family: arial,helvetica,sans-serif">FTP based Client Server project using sockets and threads</span></span></strong></span></p>
<div style="text-align: justify"><span style="color: #333333"><span style="font-size: 14px"><span style="font-family: arial,helvetica,sans-serif">??Sockets are the fundamental technology for programming software to communicate </span></span></span><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;color: #333333">on TCP/IP networks. A socket provides a bidirectional communication endpoint for </span><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;color: #333333">sending and receiving data with another socket. Socket connections normally run </span><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;color: #333333">between two different computers on a LAN or across the Internet, but they can also be </span><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;color: #333333">used for inter-process communication on a single computer.</span></div>
<div style="text-align: justify"><span style="color: #333333"><span style="font-size: 14px"><span style="font-family: arial,helvetica,sans-serif">It involves the use of Socket Programming. Client creates a local TCP socket specifying </span></span></span><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;color: #333333">the IP and port </span><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;color: #333333">?number of server process , the client’s TCP establishes connection to server’s TCP. </span><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;color: #333333">When contacted by a client, server creates a new socket for server process to </span><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;color: #333333">communicate with client. Client sends a request to the Server and then </span><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;color: #333333"> Server responds to the client . Data Transmission is over TCP/ IP protocol. Data </span><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;color: #333333">exchanging protocol is build by creating our own network protocol stack over the </span><span style="font-family: arial, helvetica, sans-serif;font-size: 14px;color: #333333">socket stack.</span></div>
<p style="text-align: justify"><strong style="font-size: 16px;color: #800000"><span style="font-family: arial,helvetica,sans-serif">Objective:</span></strong></p>
<ul>
<li style="text-align: justify"><span style="color: #333333"><span style="font-size: 14px"><span style="font-family: arial,helvetica,sans-serif">This project is designed to ensure that students of Engineering College with academic capabilities will have the skill set needed to deal with the challenges involved in real-world linux system programming and network programming and associated protocols / technologies to meet the needs of industries both today and in the future.</span></span></span></li>
<li style="text-align: justify"><span style="color: #333333"><span style="font-size: 14px"><span style="font-family: arial,helvetica,sans-serif">The course considers linux based network programming and communication techni</span></span></span></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/06/tcpip-based-client-server-using-socket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Socket using client &amp; server</title>
		<link>https://www.emblogic.com/blog/06/socket-using-client-server/</link>
		<comments>https://www.emblogic.com/blog/06/socket-using-client-server/#comments</comments>
		<pubDate>Fri, 13 Jun 2014 09:19:57 +0000</pubDate>
		<dc:creator><![CDATA[masoomktr]]></dc:creator>
				<category><![CDATA[Project 04: FTP based Client Server using Threads and Sockets]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=10466</guid>
		<description><![CDATA[Most interprocess communication uses the client server model. These terms refer to the two processes which will be communicating with each other. One of the two processes, the client, connects to the other process, the server, typically to make a &#8230; <a href="https://www.emblogic.com/blog/06/socket-using-client-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Most interprocess communication uses the <em>client server model</em>. These terms refer to the two processes which will be communicating with each other. One of the two processes, the <em>client</em>, connects to the other process, the <em>server</em>, typically to make a request for information. A good analogy is a person who makes a phone call to another person.</p>
<p>Notice that the client needs to know of the existence of and the address of the server, but the server does not need to know the address of (or even the existence of) the client prior to the connection being established. Notice also that once a connection is established, both sides can send and receive information.</p>
<p>The system calls for establishing a connection are somewhat different for the client and the server, but both involve the basic construct of a <em>socket</em>. A socket is one end of an interprocess communication channel. The two processes each establish their own socket.</p>
<p>The steps involved in establishing a socket on the <em>client</em> side are as follows:</p>
<ol>
<li>Create a socket with the <code>socket()</code> system call</li>
<li>Connect the socket to the address of the server using the <code>connect()</code> system call</li>
<li>Send and receive data. There are a number of ways to do this, but the simplest is to use the <code>read()</code> and <code>write() </code> system calls.</li>
</ol>
<p>The steps involved in establishing a socket on the <em>server</em> side are as follows:</p>
<ol>
<li>Create a socket with the <code>socket()</code> system call</li>
<li>Bind the socket to an address using the <code>bind()</code> system call. For a server socket on the Internet, an address consists of a port number on the host machine.</li>
<li>Listen for connections with the <code>listen()</code> system call</li>
<li>Accept a connection with the <code>accept()</code> system call. This call typically blocks until a client connects with the server.</li>
<li>Send and receive data</li>
</ol>
<h3>Socket Types</h3>
<p>When a socket is created, the program has to specify the <em> address domain</em> and the <em> socket type</em>. Two processes can communicate with each other only if their sockets are of the same type and in the same domain. There are two widely used address domains, the <em>unix domain</em>, in which two processes which share a common file system communicate, and the <em>Internet domain</em>, in which two processes running on any two hosts on the Internet communicate. Each of these has its own address format.</p>
<p>The address of a socket in the Unix domain is a character string which is basically an entry in the file system.</p>
<p>The address of a socket in the Internet domain consists of the Internet address of the host machine (every computer on the Internet has a unique 32 bit address, often referred to as its IP address). In addition, each socket needs a port number on that host. Port numbers are 16 bit unsigned integers. The lower numbers are reserved in Unix for standard services. For example, the port number for the FTP server is 21. It is important that standard services be at the same port on all computers so that clients will know their addresses. However, port numbers above 2000 are generally available.</p>
<p>There are two widely used socket types, <em>stream sockets</em>, and <em>datagram sockets</em>. Stream sockets treat communications as a continuous stream of characters, while datagram sockets have to read entire messages at once. Each uses its own communciations protocol. Stream sockets use TCP (Transmission Control Protocol), which is a reliable, stream oriented protocol, and datagram sockets use UDP (Unix Datagram Protocol), which is unreliable and message oriented.</p>
<p>The examples in this tutorial will use sockets in the Internet domain using the TCP protocol.</p>
<h3>Sample code</h3>
<p>C code for a very simple client and server are provided for you. These communicate using stream sockets in the Internet domain. The code is described in detail below. However, before you read the descriptions and look at the code, you should compile and run the two programs to see what they do.</p>
<p><a href="http://www.cs.rpi.edu/%7Emoorthy/Courses/os98/Pgms/server.c"><img src="http://www.cs.rpi.edu/%7Emoorthy/Courses/os98/Pgms/redball.gif" alt="" /> Click here for the server program </a></p>
<p><a href="http://www.cs.rpi.edu/%7Emoorthy/Courses/os98/Pgms/client.c"><img src="http://www.cs.rpi.edu/%7Emoorthy/Courses/os98/Pgms/redball.gif" alt="" /> Click here for the client program </a></p>
<p>Download these into files called <code>server.c</code> and <code> client.c</code> and compile them separately into two executables called <code>server</code> and <code>client</code>. They require special compiling flags as stated in their respective progarms.</p>
<p>Ideally, you should run the client and the server on separate hosts on the Internet. Start the server first. Suppose the server is running on a machine called <code>cheerios</code>. When you run the server, you need to pass the port number in as an argument. You can choose any number between 2000 and 65535. If this port is already in use on that machine, the server will tell you this and exit. If this happens, just choose another port and try again. If the port is available, the server will block until it receives a connection from the client. Don&#8217;t be alarmed if the server doesn&#8217;t do anything; it&#8217;s not supposed to do anything until a connection is made. Here is a typical command line:</p>
<pre>server 51717
</pre>
<p>To run the client you need to pass in two arguments, the name of the host on which the server is running and the port number on which the server is listening for connections. Here is the command line to connect to the server described above:</p>
<pre>client cheerios 51717
</pre>
<p>The client will prompt you to enter a message. If everything works correctly, the server will display your message on stdout, send an acknowledgement message to the client and terminate. The client will print the acknowledgement message from the server and then terminate.</p>
<p>You can simulate this on a single machine by running the server in one window and the client in another. In this case, you can use the keyword <code>localhost</code> as the first argument to the client.</p>
<h4>Server code</h4>
<p>The server code uses a number of ugly programming constructs, and so we will go through it line by line.</p>
<p>&nbsp;</p>
<hr />
<p><code> #include &lt;stdio.h&gt;</code></p>
<p><code> </code> This header file contains declarations used in most input and output and is typically included in all C programs.</p>
<p>&nbsp;</p>
<hr />
<p><code> #include &lt;sys/types.h&gt;</code></p>
<p><code> </code> This header file contains definitions of a number of data types used in system calls. These types are used in the next two include files.</p>
<p>&nbsp;</p>
<hr />
<p><code> #include &lt;sys/socket.h&gt;</code></p>
<p><code> </code> The header file <a href="http://www.cs.rpi.edu/%7Emoorthy/Courses/os98/Pgms/socket.h"> <code>socket.h</code> </a> includes a number of definitions of structures needed for sockets.</p>
<p>&nbsp;</p>
<hr />
<p><code> #include &lt;netinet/in.h&gt;</code></p>
<p><code> </code> The header file <a href="http://www.cs.rpi.edu/%7Emoorthy/Courses/os98/Pgms/in.h"><code>netinet/in.h</code></a> contains constants and structures needed for internet domain addresses.</p>
<hr />
<pre>void error(char *msg)
{
    perror(msg);
    exit(1);
}
</pre>
<p>This function is called when a system call fails. It displays a message about the error on <code>stderr</code> and then aborts the program. <a href="http://www.cs.rpi.edu/%7Emoorthy/Courses/os98/Pgms/perror.txt"><img src="http://www.cs.rpi.edu/%7Emoorthy/Courses/os98/Pgms/redball.gif" alt="" /> Click here </a> to see the man page for <code>perror()</code></p>
<hr />
<pre>int main(int argc, char *argv[])
{
     int sockfd, newsockfd, portno, clilen, n;
</pre>
<p><code>sockfd</code> and <code>newsockfd</code> are file descriptors, i.e. array subscripts into the <a href="http://www.cs.rpi.edu/%7Emoorthy/Courses/os98/Pgms/fd.txt">file descriptor table </a>. These two variables store the values returned by the socket system call and the accept system call.</p>
<p><code>portno</code> stores the port number on which the server accepts connections.</p>
<p><code>clilen</code> stores the size of the address of the client. This is needed for the accept system call.</p>
<p><code>n</code> is the return value for the <code>read()</code> and <code>write()</code> calls; i.e. it contains the number of characters read or written.</p>
<hr />
<pre>     char buffer[256];
</pre>
<p>The server reads characters from the socket connection into this buffer.</p>
<hr />
<pre>     struct sockaddr_in serv_addr, cli_addr;
</pre>
<p>A <code>sockaddr_in</code> is a structure containing an internet address. This structure is defined in <code>&lt;netinet/in.h&gt;</code>. Here is the definition:</p>
<pre>struct sockaddr_in {
        short   sin_family;
        u_short sin_port;
        struct  in_addr sin_addr;
        char    sin_zero[8];
};
</pre>
<p>An <code>in_addr</code> structure, defined in the same header file, contains only one field, a unsigned long called <code>s_addr</code>. The variable <code>serv_addr</code> will contain the address of the server, and <code>cli_addr</code> will contain the address of the client which connects to the server.</p>
<hr />
<pre>     if (argc &lt; 2) {
         fprintf(stderr,"ERROR, no port provided\n");
         exit(1);
     }
</pre>
<p>The user needs to pass in the port number on which the server will accept connections as an arg</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/06/socket-using-client-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kernel</title>
		<link>https://www.emblogic.com/blog/06/kernel/</link>
		<comments>https://www.emblogic.com/blog/06/kernel/#comments</comments>
		<pubDate>Thu, 05 Jun 2014 07:49:46 +0000</pubDate>
		<dc:creator><![CDATA[masoomktr]]></dc:creator>
				<category><![CDATA[Embedded Linux]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=10326</guid>
		<description><![CDATA[Kernel Definition &#8211; What does Kernel mean? A kernel is the core component of an operating system. Using interprocess communication and system calls, it acts as a bridge between applications and the data processing performed at the hardware level. When &#8230; <a href="https://www.emblogic.com/blog/06/kernel/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Kernel<br />
Definition &#8211; What does Kernel mean?<br />
A kernel is the core component of an operating system. Using interprocess communication and system calls, it<br />
acts as a bridge between applications and the data processing performed at the hardware level.<br />
When an operating system is loaded into memory, the kernel loads first and remains in memory until the<br />
operating system is shut down again. The kernel is responsible for low-level tasks such as disk management,<br />
task management and memory management.<br />
Techopedia explains Kernel<br />
A computer kernel interfaces between the three major computer hardware components, providing services<br />
between the application/user interface and the CPU, memory and other hardware I/O devices.<br />
The kernel provides and manages computer resources, allowing other programs to run and use these resources.<br />
The kernel also sets up memory address space for applications, loads files with application code into memory,<br />
sets up the execution stack for programs and branches out to particular locations inside programs for<br />
execution.<br />
The kernel is responsible for:<br />
Process management for application execution<br />
Memory management, allocation and I/O<br />
Device management through the use of device drivers<br />
System call control, which is essential for the execution of kernel services<br />
There are five types of kernels:<br />
1. Monolithic Kernels: All operating system services run along the main kernel thread in a monolithic<br />
kernel, which also resides in the same memory area, thereby providing powerful and rich hardware<br />
access.<br />
2. Microkernels: Define a simple abstraction over hardware that use primitives or system calls to<br />
implement minimum OS services such as multitasking, memory management and interprocess<br />
communication.<br />
3. Hybrid Kernels: Run a few services in the kernel space to reduce the performance overhead of<br />
traditional microkernels where the kernel code is still run as a server in the user space.<br />
4. Nano Kernels: Simplify the memory requirement by delegating services, including the basic ones like<br />
interrupt controllers or timers to device drivers.<br />
5. Exo Kernels: Allocate physical hardware resources such as processor time and disk block to other<br />
programs, which can link to library operating systems that use the kernel to simulate operating system</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/06/kernel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to cross-compiling for Linux</title>
		<link>https://www.emblogic.com/blog/04/introduction-to-cross-compiling-for-linux/</link>
		<comments>https://www.emblogic.com/blog/04/introduction-to-cross-compiling-for-linux/#comments</comments>
		<pubDate>Thu, 17 Apr 2014 07:50:16 +0000</pubDate>
		<dc:creator><![CDATA[masoomktr]]></dc:creator>
				<category><![CDATA[Project 9: Embedded Linux on ARM]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9823</guid>
		<description><![CDATA[Host vs Target A compiler is a program that turns source code into executable code. Like all programs, a compiler runs on a specific type of computer, and the new programs it outputs also run on a specific type of &#8230; <a href="https://www.emblogic.com/blog/04/introduction-to-cross-compiling-for-linux/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Host vs Target</p>
<p>A compiler is a program that turns source code into executable code. Like all programs, a compiler runs on a specific type of computer, and the new programs it outputs also run on a specific type of computer.[1]</p>
<p>The computer the compiler runs on is called the host, and the computer the new programs run on is called the target. When the host and target are the same type of machine, the compiler is a native compiler. When the host and target are different, the compiler is a cross compiler.[2]<br />
Why cross-compile?</p>
<p>In theory, a PC user who wanted to build programs for some device could get the appropriate target hardware (or emulator), boot a Linux distro on that, and compile natively within that environment. While this is a valid approach (and possibly even a good idea when dealing with something like a Mac Mini), it has a few prominent downsides for things like a linksys router or iPod:</p>
<p>Speed &#8211; Target platforms are usually much slower than hosts, by an order of magnitude or more. Most special-purpose embedded hardware is designed for low cost and low power consumption, not high performance. Modern emulators (like qemu) are actually faster than a lot of the real world hardware they emulate, by virtue of running on high-powered desktop hardware.[3]</p>
<p>Capability &#8211; Compiling is very resource-intensive. The target platform usually doesn&#8217;t have gigabytes of memory and hundreds of gigabytes of disk space the way a desktop does; it may not even have the resources to build &#8220;hello world&#8221;, let alone large and complicated packages.</p>
<p>Availability &#8211; Bringing Linux up on a hardware platform it&#8217;s never run on before requires a cross-compiler. Even on long-established platforms like Arm or Mips, finding an up-to-date full-featured prebuilt native environment for a given target can be hard. If the platform in question isn&#8217;t normally used as a development workstation, there may not be a recent prebuilt distro readily available for it, and if there is it&#8217;s probably out of date. If you have to build your own distro for the target before you can build on the target, you&#8217;re back to cross-compiling anyway.</p>
<p>Flexibility &#8211; A fully capable Linux distribution consists of hundreds of packages, but a cross-compile environment can depend on the host&#8217;s existing distro from most things. Cross compiling focuses on building the target packages to be deployed, not spending time getting build-only prerequisites working on the target system.</p>
<p>Convenience &#8211; The user interface of headless boxes tends to be a bit crampled. Diagnosing build breaks is frustrating enough as it is. Installing from CD onto a machine that hasn&#8217;t got a CD-ROM drive is a pain. Rebooting back and forth between your test environment and your development environment gets old fast, and it&#8217;s nice to be able to recover from accidentally lobotomizing your test system.</p>
<p>Why is cross-compiling hard?<br />
Portable native compiling is hard.</p>
<p>Most programs are developed on x86 hardware, where they are compiled natively. This means cross-compiling runs into two types of problems: problems with the programs themselves and problems with the build system.</p>
<p>The first type of problem affects all non-x86 targets, both for native and for cross-builds. Most programs make assumptions about the type of machine they run on, which must match the platform in question or the program won&#8217;t work. Common assumptions include:</p>
<p>Word size &#8211; Copying a pointer into an int may lose data on a 64 bit platform, and determining the size of a malloc by multiplying by 4 instead of sizeof(long) isn&#8217;t good either. Subtle security flaws due to integer overflows are also possible, ala &#8220;if (x+y &lt; size) memset(src+x,0,y);&#8221;, which results in a 4 gigabyte memset on 32-bit hardware when x=1000 and y=0xFFFFFFF0&#8230;</p>
<p>Endianness &#8211; Different systems store binary data iternally in different ways, which means that block-reading int or float data from disk or the network may need translation. Type &#8220;man byteorder&#8221; for details.</p>
<p>Alignment &#8211; Some platforms (such as arm) can only read or write ints from addresses that are an even multiple of 4 bytes, otherwise they segfault. Even the ones that can handle arbitrary alignments are slower dealing with unaligned data (they have to fetch twice to get both halves), so the compiler will often pad structures to align variables. Treating structures as a lump of data that can be sent to disk or across the network thus requires extra work to ensure a consistent representation.</p>
<p>Default signedness &#8211; Whether the &#8220;char&#8221; data type defaults to signed or unsigned varies from platform to platform (and in some cases from compiler to compiler), which can cause some really surprising bugs. The easy workaround for this is to provide a compiler argument like &#8220;-funsigned-char&#8221; to force the default to a known value.</p>
<p>NOMMU &#8211; If your target platform doesn&#8217;t have a memory management unit, several things need to change. You need vfork() instead of fork(), only certain types of mmap() work (shared or read only, but not copy on write), and the stack doesn&#8217;t grow dynamically.</p>
<p>Most packages aim to be portable when compiled natively, and will at least accept patches to fix any of the above problems (with the possible exception of NOMMU issues) submitted to the appropriate development mailing list.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/04/introduction-to-cross-compiling-for-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FIFO</title>
		<link>https://www.emblogic.com/blog/03/fifo-6/</link>
		<comments>https://www.emblogic.com/blog/03/fifo-6/#comments</comments>
		<pubDate>Thu, 27 Mar 2014 09:58:14 +0000</pubDate>
		<dc:creator><![CDATA[masoomktr]]></dc:creator>
				<category><![CDATA[Project 03: Client Server Communication using Linux and IPC]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9470</guid>
		<description><![CDATA[DESCRIPTION A FIFO special file (a named pipe) is similar to a pipe, except that it is accessed as part of the filesystem. It can be opened by multiple processes for reading or writing. When processes are exchanging data via &#8230; <a href="https://www.emblogic.com/blog/03/fifo-6/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>DESCRIPTION</p>
<p>A FIFO special file (a named pipe) is similar to a pipe, except that<br />
it is accessed as part of the filesystem. It can be opened by<br />
multiple processes for reading or writing. When processes are<br />
exchanging data via the FIFO, the kernel passes all data internally<br />
without writing it to the filesystem. Thus, the FIFO special file<br />
has no contents on the filesystem; the filesystem entry merely serves<br />
as a reference point so that processes can access the pipe using a<br />
name in the filesystem.</p>
<p>The kernel maintains exactly one pipe object for each FIFO special<br />
file that is opened by at least one process. The FIFO must be opened<br />
on both ends (reading and writing) before data can be passed.<br />
Normally, opening the FIFO blocks until the other end is opened also.</p>
<p>A process can open a FIFO in nonblocking mode. In this case, opening<br />
for read-only will succeed even if no-one has opened on the write<br />
side yet, opening for write-only will fail with ENXIO (no such device<br />
or address) unless the other end has already been opened.</p>
<p>Under Linux, opening a FIFO for read and write will succeed both in<br />
blocking and nonblocking mode. POSIX leaves this behavior undefined.<br />
This can be used to open a FIFO for writing while there are no<br />
readers available. A process that uses both ends of the connection<br />
in order to communicate with itself should be very careful to avoid</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/fifo-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SEMAPHORES</title>
		<link>https://www.emblogic.com/blog/03/semaphores-3/</link>
		<comments>https://www.emblogic.com/blog/03/semaphores-3/#comments</comments>
		<pubDate>Tue, 25 Mar 2014 19:50:56 +0000</pubDate>
		<dc:creator><![CDATA[masoomktr]]></dc:creator>
				<category><![CDATA[Project 03: Client Server Communication using Linux and IPC]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9418</guid>
		<description><![CDATA[Semaphores Semaphores are used to protect critical regions of code or data structures. Remember that each access of a critical piece of data such as a VFS inode describing a directory is made by kernel code running on behalf of &#8230; <a href="https://www.emblogic.com/blog/03/semaphores-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Semaphores</p>
<p>Semaphores are used to protect critical regions of code or data structures. Remember that each access of a critical piece of data such as a VFS inode describing a directory is made by kernel code running on behalf of a process. It would be very dangerous to allow one process to alter a critical data structure that is being used by another process. One way to achieve this would be to use a buzz lock around the critical piece of data that is being accessed, but this is a simplistic approach that would degrade system performance.</p>
<p>Instead Linux uses semaphores to allow just one process at a time to access critical regions of code and data; all other processes wishing to access this resource will be made to wait until it becomes free. The waiting processes are suspended, other processes in the system can continue to run as normal.</p>
<p>A Linux semaphore data structure contains the following information:</p>
<p>count<br />
This field keeps track of the count of processes wishing to use this resource. A positive value means that the resource is available. A negative or zero value means that processes are waiting for it. An initial value of 1 means that one and only one process at a time can use this resource. When processes want this resource they decrement the count and when they have finished with this resource they increment the count,<br />
waking<br />
This is the count of processes waiting for this resource which is also the number of process waiting to be awakened when this resource becomes free,<br />
wait queue<br />
When processes are waiting for this resource they are put onto this wait queue,<br />
lock<br />
A buzz lock used when accessing the waking field.</p>
<p>Suppose the initial count for a semaphore is 1, the first process to come along will see that the count is positive and decrement it by 1, making it 0. The process now &#8220;owns&#8221; the critical piece of code or resource that is being protected by the semaphore. When the process leaves the critical region it increments the semphore&#8217;s count. The most optimal case is where there are no other processes contending for ownership of the critical region. Linux has implemented semaphores to work efficiently for this, the most common case.</p>
<p>If another process wishes to enter the critical region whilst it is owned by a process it too will decrement the count. As the count is now negative (-1) the process cannot enter the critical region. Instead it must wait until the owning process exits it. Linux makes the waiting process sleep until the owning process wakes it on exiting the critical region. The waiting process adds itself to the semaphore&#8217;s wait queue and sits in a loop checking the value of the waking field and calling the scheduler until waking is non-zero.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/semaphores-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pipe</title>
		<link>https://www.emblogic.com/blog/03/pipe/</link>
		<comments>https://www.emblogic.com/blog/03/pipe/#comments</comments>
		<pubDate>Fri, 21 Mar 2014 07:16:22 +0000</pubDate>
		<dc:creator><![CDATA[masoomktr]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=9189</guid>
		<description><![CDATA[DISCRIPTION-&#62; Pipe-&#62; it is a unidirectional channel that is used in inter process commmunication ,in pipe two file discriptor is used these are fd(0)=read &#38; fd(1)=write RETURN VALUE-&#62; on success zero is returned,if error -1 is returned &#160;]]></description>
				<content:encoded><![CDATA[<p>DISCRIPTION-&gt;<br />
Pipe-&gt; it is a unidirectional channel that is used in inter process commmunication ,in pipe two file discriptor is used these are fd(0)=read &amp; fd(1)=write</p>
<p>RETURN VALUE-&gt;<br />
on success zero is returned,if error -1 is returned</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/pipe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic memory allocation</title>
		<link>https://www.emblogic.com/blog/03/dynamic-memory-allocation-2/</link>
		<comments>https://www.emblogic.com/blog/03/dynamic-memory-allocation-2/#comments</comments>
		<pubDate>Mon, 03 Mar 2014 07:14:53 +0000</pubDate>
		<dc:creator><![CDATA[masoomktr]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=8595</guid>
		<description><![CDATA[Malloc-&#62; It is used to allocate memory at run time in to the RAM. The prototype function is used is in stdlib.h, Syntax-&#62; ptr=int * (malloc) (sizeof bytes)]]></description>
				<content:encoded><![CDATA[<p>Malloc-&gt; It is used to allocate memory at run time in to the RAM. The prototype function is used is in stdlib.h,<br />
Syntax-&gt; ptr=int * (malloc) (sizeof bytes)</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/03/dynamic-memory-allocation-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
