Dec 26, 2011

git tutorial. Use git locally or with Dropbox

I have been working on a project for which I need to restore to different state of the project. I searched and I got an elegant solution.

Oct 30, 2011

A problem; what is the difference between signed and unsigned ?

I was looking at the disassembled code of 2 programs compiled with gcc. In one program I initialised an unsigned variable and in the next program I initialised the same variable as signed.

Oct 27, 2011

Static and Shared libraries with C

This post explains how to use static and shared libraries with C. My platform is gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5).

Oct 12, 2011

Install basic required applications in Ubuntu 10.04 LTS - Lucid Lynx

LTS means long term support. So this version of Ubuntu is  a nice flavor. But the main problem with open source OS is it will be just an OS without the some good applications.

Aug 27, 2011

C programs and Makefile, sources, objects, libraries!!?

If we have a number of C sources and header files then how to create an executable from all these. This post is a template for that concept. This post contains a Makefile which is a simple but standard makefile which can be used as a template. I thought of writting this when I started working on embedded programs with C.This post not explains shared library concept.


Take the simplest case, a single main.c file.


#include <stdio.h>


int main ( void )
{
   printf("This is a test\n");
   return 0;
}
compile it: $gcc -o main main.c
$./main will print the result.

Consider another situation where we have functions defined in different files/directories. Then how to compile to create an executable. Here comes -c, -o options and object file concepts.

I am not writting any explenation for this. Create the following files in a directory and experiment.
Consider we have three functions and a header file another.c  define.h  functions.c  main.c

main.c
--------
#include <stdio.h>

int main ( void )
{
printf ( "%s\n", "This is a printf from main function" );
function_one();
return 0;
}
functions.c
--------------
#include <stdio.h>
#include <define.h>

void function_one ( void )
{
printf("function_one has been executed. The defnition is: %d\n", NUMBER );
another_fun();
}

void function_two ( void )
{
printf("function_two has been executed.\n");
}
another.c
-----------
#include <stdio.h>

void another_fun ( void )
{
printf ( "Another function\n" );
}
define.h
-----------
#define NUMBER 142

Makefile
-----------
CC := gcc 

OBJECTS := functions.o main.o another.o

INC1 := ./
INCLUDES := -I$(INC1)

bin: $(OBJECTS)
$(CC) $(OBJECTS) -o bin 

functions.o: functions.c
$(CC) $(INCLUDES) -c functions.c -o functions.o

main.o: main.c
$(CC) -c main.c -o main.o

another.o: another.c
$(CC) -c another.c -o another.o


clean:
rm -rf bin *.o

Jul 30, 2011

Why virtual machine for in-mobile applications ?


Why mobile phones, tablets, etc.. runs Java applications ? Okey, Java is good for web development, but why they are preferring Java for in-mobile applications ?
When we think about virtual machine what comes to our mind is Java or Java Virtual Machine. It has the advantage of 'compile once' and use it on any computer architecture without compilation, i.e platform independent. That is good from developer point of view, but what ever these Java guys claims, it is slower than any direct executable applications developed in C/C++.


Consider the case of Android running devices like Tablets, Mobiles. With the release of android each and every mobile manufacturers are now migrating to Android OS. A very good OS, I could say. But all applications on the android are running  on android on the top of Dalvik Virtual Machine (Just another virtual machine like JVM). 
This is a very good business model. Because any one can write application for android and that will run on any android based mobile devices independent of hardware. So the popularity of Android OS increases and that is what the OS vendors want. From the user point of view, he can install and run any applications on mobile, but it will be slow. This is the problem, the applications will be horribly slow.

Make applications fast is very simple. Say bye to this virtual machine methodology in in-mobile apps. Get the plain GNU/Linux as it is and port it into the tablet PC. It is not as easy as I said, I know :). But if H/W vendors collaborate with Linux to port it into Tablet PC, then open source applications can run directly on the top of Linux running in the mobile/Tablet. May be we would have to compile the source to install applications on the PC. May be it is cumbersome, but in the long run what matters is the speed. Wouldn't it be nice to be able to run applications in Tablets in Desktop speed.
There are cases in which java/virtual machine based systems are inevitable. For example: web applications, where platform independent codes has to co-exist together. A solution to this is an integrated system in PDAs where java and direct executable binaries  ( which developed in C ) work together.
With broad range of mobile phone vendors' count, I know that it is not going to be easy to make this possible but vendors like Apple or Blackberry can think of it as they have very limited number of hardware verities available.
When I browsed for this topic I came across a tablet PC developed by India. I think a collaboration with manufacturers like them can bring up research on this field and come out with applications runs directly on Linux based Tablet.

References:
Java Trap by Richard Stallman : http://www.gnu.org/philosophy/java-trap.html
India unveils Tablet PC : http://www.youtube.com/watch?v=lj4Cb3Jya2Q

Jul 7, 2011

Cross compile gcc source for arm-cortex-m3 (I am using LPC1343) in Ubuntu/BOSS

This post includes methods to cross compile gcc source against ARM-Cortex-M3 target and use it to compile a program to blink LED in an LPC1343 board. The environment I used is Ubuntu 10. It may work with other platforms also. I tested this in Ubuntu lucid lynx and BOSS-2.6.22-3-486 ( Bharat Operating System Solutions ). This I tried referring this blog post.

Apr 30, 2011

Scanner tutorial in java

Scanner object can be used to get inputs from keyboard in java. It is analogous to cin or scanf in C/C++. The Source code is given below. Here it will come out from the loop when you press 0. the code will wait in scanner.hasnext() function for an entry and "Enter" key.

Apr 10, 2011

Virtual memory and memory management unit

This post is incomplete. Would update later... ;)

Address space of a process can exceed physical memory using virtual memory.
I can use the addresses in the secondary memory for realisation of a memory space bigger than that is available in terms of SDRAM on the embedded system.
Multiple processes resides in main memory, each process with its own address space.
Only active code and data is actually in the memory
Another property provided through that of virtual memory is protection. One process should not interfere with another process. Because they operate in different address spaces. This we can make sure once we have implemented virtual memory. Because then we have a clear partitioning of address spaces of different processes.

Feb 14, 2011

How to write an IEEE paper or journal in in latex.


Formatting IEEE papers in MS-Word is cumbersome.  So here I briefs my experience with writing an IEEE journal using latex. I am working in Ubuntu(10.04). So the procedure starting from installation is given below.

For Web Developer

  open -a "Google Chrome" --args --disable-web-security