<?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; ajay.bhutani</title>
	<atom:link href="https://www.emblogic.com/blog/author/ajay-bhutani/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>Process Management</title>
		<link>https://www.emblogic.com/blog/02/process-management-4/</link>
		<comments>https://www.emblogic.com/blog/02/process-management-4/#comments</comments>
		<pubDate>Tue, 11 Feb 2014 10:14:35 +0000</pubDate>
		<dc:creator><![CDATA[ajay.bhutani]]></dc:creator>
				<category><![CDATA[Project 03: Client Server Communication using Linux and IPC]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=8286</guid>
		<description><![CDATA[Any application that runs on a Linux system is assigned a process ID or PID. This is a numerical representation of the instance of the application on the system. It is used by the system administrator who may have to &#8230; <a href="https://www.emblogic.com/blog/02/process-management-4/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Any application that runs on a Linux system is assigned a process ID or PID. This is a numerical representation of the instance of the application on the system. It is used by the system administrator who may have to debug or terminate processes by referencing the PID. Process Management is the series of tasks a System Administrator completes to monitor, manage, and maintain instances of running applications.</p>
<h2>Multitasking</h2>
<p>Process Management beings with an understanding concept of Multitasking. Linux is what is referred to as a preemptive multitasking operating system. Preemptive multitasking systems rely on a scheduler. The function of the scheduler is to control the process that is currently using the CPU.</p>
<p>so there is parent process and child process. The process which creates another process is called parent process and latter is called child process. And each process has its own PID i.e. process identity number to distinguish the child from the parent.</p>
<p>To get these process IDs, we use following functions</p>
<p>a)      getpid() // to get the current process id</p>
<p>b)      getppid() // to get the creator/ parent process id</p>
<p>There are three methods of creating a process:</p>
<p>a)      Create a process with the use  of loader from file system.</p>
<p>b)      Create a process from the code segment of the current program using system call</p>
<p>c)      Duplication of the program</p>
<p>To create a process using this method (Duplicate) is done by using “fork()”</p>
<p>fork function is a special function use to create a child process from a parent process. Using fork(), child process shares the code segment of its parent but both processes have different physical address. After completion of the child process, child process returns its control to parent and the parent process returns its control to the shell.</p>
<p>child PID= parent PID + 1</p>
<p>PPID of child = PID of parent</p>
<p>fork() function returns three values</p>
<p>a)      0 (zero)    :  if the process is executed by child</p>
<p>b)      +ve value :  means child is created and +ve value is child’s PID</p>
<p>c)      -ve value  :  ERROR…! i.e. child process is not created</p>
<p>and we can use these values to know which process  is executing.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/02/process-management-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interprocess Communication</title>
		<link>https://www.emblogic.com/blog/11/interprocess-communication-4/</link>
		<comments>https://www.emblogic.com/blog/11/interprocess-communication-4/#comments</comments>
		<pubDate>Tue, 26 Nov 2013 15:48:19 +0000</pubDate>
		<dc:creator><![CDATA[ajay.bhutani]]></dc:creator>
				<category><![CDATA[Project 03: Client Server Communication using Linux and IPC]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7582</guid>
		<description><![CDATA[&#8220;A Process is an address space with one or more threads executing within that address space and required system resources for those threads.&#8221; IPC (Inter Process Communicaton) is a set of methods for the exchange of data between multiple threads &#8230; <a href="https://www.emblogic.com/blog/11/interprocess-communication-4/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>&#8220;A Process is an address space with one or more threads executing within that address space and required system resources for those threads.&#8221;</p>
<p>IPC (Inter Process Communicaton) is a set of methods for the exchange of data between multiple threads in one or more processes. Processes may be running on one or more computers connected by a network. There are several methods to do this like:</p>
<p>a) file : A record stored on the disk that can be accessed by name by any process.</p>
<p>b) Signal: A system message sent from one process to another, not usually used to store information but instead give commands.</p>
<p>c) Socket: A data stream sent over a network interface, either to a different process on the same computer or to another computer.</p>
<p>d) Message Queue: An anonymous data stream similar to the pipe, but stores and retrieves information in packets.</p>
<p>e) Pipe: A two-way data stream interfaced through standard input and output and is read character by character.</p>
<p>f) Named Pipe: A pipe implemented through a file on the file system instead of standard input and output.</p>
<p>g) Semaphore: A simple structure that synchronizes threads or processes acting on shared resources.</p>
<p>h) Shared Memory: Multiple processes given access to the same memory, allowing all to change it and read changes made by other processes.</p>
<p>Process table: It is like a data structure describing all of the processes that are currently loaded with their PID, status, command string, and sort of information. Operating system manages processes using their PID&#8217;s. To see the list of processes, we use &#8220;ps&#8221; command.</p>
<p>eg: ps -ax, ps-af, etc</p>
<p>Pipes:</p>
<p>Pipes provide unidirectional flow of communication between processes within the same system. In other words, they are half-duplex, that is, data flows in only one direction. A pipe is created by invoking the pipe system call, which creates a pair of file descriptors. These descriptors point to a pipe inode and the file descriptors are returned through the filedes argument. In the file descriptor pair, filedes[0] is used for reading whereas filedes[1] is used for writing.<br />
One of the major disadvantage of pipes is that the they can not be accesed using their names by any other process other than child and the parent as they do not get listed in the directory tree.</p>
<p>The work around for this porblem is to create a named pipe which is also called as a FIFO, which stands for First in First out, meaning the data that is written into the pipe first will be read out first always.</p>
<p>FIFO: The fifos get listed in the directory tree and any process can access it using its name by providing the approproiate path.</p>
<p>fifo are created using the function mkfifo() which takes as arguments</p>
<p>1. The name of the fifo that has to be created<br />
2. The permissions for the file.</p>
<p>Once the file is created, it needs to be opened using the system call open() and the data can be read and written from the file using read() and write system calls.</p>
<p>One of the examples you can think of using a named pipe is communication between a server and a client. If ther are two fifos one of the server and the other of the client, then the client can send request to the server on the server fifo which the server will read and respond back with the reply on the client&#8217;s fifo.</p>
<p>Another advantage of a fifo over the pipes is that fifo are birectoinal, that is the same fifo can be read from as well and written into.</p>
<p>Shared Memory</p>
<p>Shared memory allows one or more processes to communicate via memory that appears in all of their virtual address space.</p>
<p>shared memory mechanism consisting of four steps. in order of:</p>
<ul>
<li>Creating the segment and connecting -shmget (shared memory get)</li>
<li>Using the pointer to get the shared memory address – shmat (shared memory attach),</li>
<li>Detaching the shared memory area after use – shmdt (shared memory detach) and</li>
<li>Finally using the address to control accesses, permissions, receive information and destroy the shared memory area – shmctl (shared memory control).</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/11/interprocess-communication-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
