Saturday, 8 August 2015

Types of IPC's in Linux

Inter-Process-Communication (or IPC for short) are mechanisms provided by the kernel to allow processes to communicate with each other. On modern systems, IPCs form the web that bind together each process within a large scale software architecture.
The Linux kernel provides the following IPC mechanisms:
Signals 
Anonymous Pipes 
Named Pipes or FIFOs 
SysV Message Queues 
POSIX Message Queues 
SysV Shared memory 
POSIX Shared memory 
SysV semaphores 
POSIX semaphores 
FUTEX locks 
File-backed and anonymous shared memory using mmap 
UNIX Domain Sockets 
Netlink Sockets 
Network Sockets

Usage of Linux Signal handler

Definition 
• A signal is an asynchronous event which is delivered to a process. 
• Asynchronous means that the event can occur at any time 
- may be unrelated to the execution of the process 
- E.g. user types ctrl-C or the modem hangs
Name Description Default Action 
SIGINT Interrupt character typed terminate process 
SIGQUIT Quit character typed (^\) create core image 
SIGKILL kill -9 terminate process 
SIGSEGV Invalid memory reference create core image 
SIGPIPE Write on pipe but no reader terminate process 
SIGALRM alarm() clock ‘rings’ terminate process 
SIGUSR1 user-defined signal type terminate process 
SIGUSR2 user-defined signal type terminate process
Generating a Signal 
• Use the UNIX command: 
$ kill -KILL 4481 
– send a SIGKILL signal to pid 4481 
– check 
? ps –l 
– to make sure process died 
• kill is not a good name; send....
Please look more at below link...
http://www.epistemesoft.com/Ariticle%20more.aspx…

Types of Linux Sockets

Sockets allow communication between two different processes on the same or different machines. To be more precise, it's a way to talk to other computers using standard Unix file descriptors. In Unix, every I/O action is done by writing or reading a file descriptor. A file descriptor is just an integer associated with an open file and it can be a network connection, a text file, a terminal, or something else.
To a programmer, a socket looks and behaves much like a low-level file descriptor. This is because commands such as read() and write() work with sockets in the same way they do with files and pipes.
Where is Socket Used?
A Unix Socket is used in a client-server application framework. A server is a process that performs some functions on request from a client. Most of the application-level protocols like FTP, SMTP, and POP3 make use of sockets to establish connection between client and server and then for exchanging data.
Syntax:
int socket(int domain, int type, int protocol)

Here., Domain refers to: Socket Family
Ex:AF_UNIX,AF_INET ,AF_NETLINK etc.
Protocol refers to: The type of Protocol we want to use
Ex:TCP,UDP,ICMP etc.
Type refers to: Socket Service Type

Socket Service Types:

The following socket types are.....
http://www.epistemesoft.com/Ariticle%20more.aspx…

Linux Process Management

Process Descriptors:
• The kernel maintains info about each process in a 
• process descriptor, of type task_struct. 
• See include/linux/sched.h 
• Each process descriptor contains info such as run-state of process, address space, list of open files, process priority etc...
Content of Process Descriptors:
struct task_struct 
{ 
volatile long state; /* -1unrunnable, 0runnable, >0 stopped */ 
unsigned long flags; /* per process flags */ 
mm_segment_t addr_limit; /* thread address space: 0-0xBFFFFFFF for user-thread 
0-0xFFFFFFFF for kernel-thread */ 
struct exec_domain *exec_domain; 
long need_resched; 
long counter; 
long priority; 
/* SMP and runqueue state */ 
struct task_struct *next_task, *prev_task; 
struct task_struct *next_run, *prev_run; 
... 
/* task state */ 
/* limits */ 
/* file system info */ 
/*ipc stuff */ 
/*tss for this task */ 
/*filesystem information */ 
/* open file information */ 
/* memory management info */ 
/* signal handlers */
... 
}
Process State:
Consists of an array of mutually exclusive flags* 
*at least true for 2.2.x kernels.....
Look more at below link......
http://www.epistemesoft.com/Ariticle%20more.aspx…

Usage of a Pointer in C

HOW TO DECLARE A POINTER ?
A pointer is declared as : 
< pointer type > * < pointer-name > 
In the above declaration : 
1. pointer-type : It specifies the type of pointer. It can be int,char, float etc. This type specifies the type of variable whose address this pointer can store. 
2. pointer-name : It can be any name specified by the user. Professionally, there are some coding styles which every code follows. The pointer names commonly start with ‘p’ or end with ‘ptr’ 
An example of a pointer declaration can be : 
char *chptr; 
In the above declaration, ‘char’ signifies the pointer type, chptr is the name of the pointer while the asterisk ‘*’ signifies that ‘chptr’ is a pointer variable.
How to initialize a Pointer? 
A pointer is initialized in the following way : 
< pointer declaration(except semicolon) > = < address of a variable >
OR
< pointer declaration > 
< name-of-pointer > = < address of a variable > 
Note that the type of variable above...

Embedded Systems Articles-4


Overview of Linux Process:
-----------------------------------------------
A Process is one of the most important fundamental concepts of the Linux operating system. This article focuses on the basics of Linux processes.
Process
A process is an instance of a program running in Linux. This is the basic definition that you might have heard before. Though its simple enough to understand bu

See More at below link
http://www.epistemesoft.com/Articles.aspx

Data Structures and it's types in C:
-----------------------------------------------
It is a logical way of storing data and it is also define mechanism of retrieving data. To construct an abstract software model of a collection, we start by building the formal specification. The first component of this is the name of a data type this is the type of objects that belong to the collection class. In C, we

See More at below link
http://www.epistemesoft.com/Articles.aspx

Protocols used every day for Internet Browsing:
-----------------------------------------------
Communication on the Internet network is governed by various protocols. These protocols, or rules, spell out how the participants in various network processes should behave. Application protocol is one such protocol.
Application Protocol
Application protocols govern various processes, such as the process for download

See More at below link
http://www.epistemesoft.com/Articles.aspx

Predefined and User defined Functions:
-----------------------------------------------
Function is a block of codes which do a specific task. When we have a large line of code, developed for a real time application we divide the program in to small blocks called functions. Every program has minimum 1 function which is our main() function. Every code starts executing from the main() function .
Function

See More at below link
http://www.epistemesoft.com/Articles.aspx

Connectionless-mode Network Protocol (CLNP):
-----------------------------------------------
Is an OSI protocol deployment. CLNS is the service provided by the Connectionless-mode Network Protocol (CLNP). CLNP is widely used in many telecommunications networks around the world because IS-IS (an OSI routing protocol) is mandated by the ITU-T as the protocol for management of Synchronous Digital Hierarchy (SDH)

See More at below link
http://www.epistemesoft.com/Articles.aspx

Function call in C from Main:
-----------------------------------------------
All C functions can be called either with arguments or without arguments in a C program. These functions may or may not return values to the calling function. Now, we will see the types of calling.
1. C function with arguments (parameters) and with return value
2. C function with arguments (parameters) and without r

See More at below link
http://www.epistemesoft.com/Articles.aspx

What is file transfer protocol FTP:
-----------------------------------------------
The file transfer protocol (FTP) is a standard network protocol used to transfer computer files from one host to another host over a TCP-based network, such as the internet
1. FTP is built on a client-server architecture and uses separate control and data connections between the clien

See More at below link
http://www.epistemesoft.com/Articles.aspx

What is a Pointer in C:
-----------------------------------------------
C Pointer is a variable that stores/points the address of another variable.C Pointer is used to allocate memory dynamically i.e. at run time. The pointer variable might be belonging to any of the data type such as int, float, char, double, short etc.
Syntax : data_type *variableName;
Example : int *p;

See More at below link
http://www.epistemesoft.com/Articles.aspx

Command to See Processes and Threads in Linux:
-----------------------------------------------
How do I see all running process in Linux operating systems using command line or GUI options?
You need to use the ps command. It provide information about the currently running processes, including their process identification numbers (PIDs). Both Linux and UNIX support the ps command to display information about a



See More at below link
http://www.epistemesoft.com/Articles.aspx



Embedded Systems Articles-3


Dynamic Allocation and Pointer:
-----------------------------------------------
What Are Pointers
Pointers are basically the same as any other variable. However, what is different about them is that instead of containing actual data, they contain a pointer to the memory location where information can be found. This is a very important concept. Many programs and ideas rely on pointers as the basis

See More at below link
http://www.epistemesoft.com/Articles.aspx

Array Of Structures:
-----------------------------------------------
C Structure is collection of different datatypes ( variables ) which are grouped together. Whereas, array of structures is nothing but collection of structures. This is also called as structure array in C.
Example:
This program is used to store and access “id, name and percentage” for 3 students. Structure array

See More at below link
http://www.epistemesoft.com/Articles.aspx

Socket System Calls:
-----------------------------------------------
Let’s look at a call to socket() (the includes required are sys/types.h and sys/socket.h):
int socket(int domain, int type, int protocol);
A successful call to socket() returns a descriptor that will be used for end-point communication. The first argument, domain, specifies a communication domain — the protocol famil

See More at below link
http://www.epistemesoft.com/Articles.aspx

While Loop:
-----------------------------------------------
/*C program to demonstrate the working of while loop*/
#include <stdio.h>
int main()
{
int number,factorial;
printf("Enter a number.\n");
scanf("%d",&number);
factorial=1;
while (number>0)
{
factorial=factorial*number;
--number

See More at below link
http://www.epistemesoft.com/Articles.aspx

A Small notes on Internet Protocol (IP):
-----------------------------------------------
TCP/IP includes a wide range of protocols which are used for a variety of purposes on the network. The set of protocols that are a part of TCP/IP is called the TCP/IP protocol stack or the TCP/IP suite of protocols. The Network layer is also know as the internet layer. The internet layer is a group of internetworking m

See More at below link
http://www.epistemesoft.com/Articles.aspx

Linux Process creation:
-----------------------------------------------
Process Descriptors:
The kernel maintains info about each process in a process descriptor, of type task_struct.
See include/linux/sched.h
Each process descriptor contains info such as run-state of process, address space, list of open files, process priority etc…
Process State:
Consists of an array of mutually ex

See More at below link
http://www.epistemesoft.com/Articles.aspx

A small note on Protocol:
-----------------------------------------------
Application layer is the top most layer in OSI and TCP/IP layered model. This layer exists in both layered Models because of its significance, of interacting with user and user applications. This layer is for applications which are involved in communi

See More at below link
http://www.epistemesoft.com/Articles.aspx

A small note on Linux Kernel:
-----------------------------------------------
kernel is the innermost portion of the operating system, where user interface is the outer portion. kernel is the core internal, the software that provides the basic services for all the other parts of the system, manage hardware and distributes system resources.
applications running on the system communicate with th

See More at below link
http://www.epistemesoft.com/Articles.aspx

C Structure in Detail:
-----------------------------------------------
C Structure is a collection of different data types which are grouped together and each element in a C structure is called member.
• If you want to access structure members in C, structure variable should be declared.
• Many structure variables can be declared for same structure and memory will be allocated for each

See More at below link
http://www.epistemesoft.com/Articles.aspx

C Pointers in Detail:
-----------------------------------------------
Pointers have many but easy concepts and they are very important to C programming. There are following few important pointer concepts which should be clear to a C programmer:
Passing pointers to functions in C:
C programming language allows you to pass a pointer to a function. To do so, simply declare the function pa

See More at below link
http://www.epistemesoft.com/Articles.aspx

A note on Linux Signal:
-----------------------------------------------
signal:
Signals are software interrupts.
A robust program need to handle signals. This is because signals are a way to deliver asynchronous events to the application.
A user hitting ctrl+c, a process sending a signal to kill another process etc are all such cases where a process needs to do
signal handling.
Li

See More at below link
http://www.epistemesoft.com/Articles.aspx