Thursday, December 9, 2010

Patch files

During our work on linux environment, we might often come across the situation of updating the source files we work on using patch files. That is, the need for updating the source files for changes.

The patch files have the differences between the source (say X) that is to be updated and the updated version of that source (X).

So how to create a patch file? or how to patch up a source with the provided patch file? These are very well explained under Tools and Techniques.

Monday, December 6, 2010

Installing windows - Could not load CD/DVD drive

"Hey, I have a problem with installing windows 7 on my laptop. Could you please help me out." said my colleague. He got the laptop from US. It was gifted to him by his elder brother who was there for an on-site assignment. The laptop is a make of HP (Pavilion dv4-2173nr) and had windows 7 installed. Wishing to have a linux distribution on the laptop he lost his windows 7 installation.

Now on trying to install the windows 7 he encounters the following error:

Windows Install could not load the CD/DVD drive that contains the installation media.  Please provide the necessary drive or controller device drivers provided by your manufacturer.

The error message doesn't help at all. The actual problem is that the windows 7 installation media doesn't have a driver for the hard disk available with the laptop.

Searched and downloaded the driver for the hard disk (of Pavilion dv4-2173nr) from the HP site.

Loaded the driver into USB memory stick and used it during the installation. The installation was successful.

Thursday, November 11, 2010

Data manipulation across spreadsheets

There may come situations, you require to get the values from two or more spreadsheets and use those values in a separate spreadsheet.

This can be easily done in MS Excel. Assume that there are three spreadsheets A.xls, B.xls, and C.xls. Each spreadsheet has their own sheet as A_sheet1, B_sheet1 and C_sheet1 respectively.

Now we are to create new spreadsheet ABC.xls that would use the values from cell 'C16' of sheets A_sheet1, B_sheet1 and C_sheet1. To access the cell 'C16' from each spreadsheet, use the following formula in the spreadsheet ABC.xls.

  1. To access the values from cell 'C16' of sheet A_sheet1 of A.xls:
    • ='D:\[A.xls]A_sheet1'!C16
  2. To access the values from cell 'C16' of sheet B_sheet1 of B.xls:
    • ='D:\[B.xls]B_sheet1'!C16
  3. To access the values from cell 'C16' of sheet C_sheet1 of C.xls:
    • ='D:\[C.xls]C_sheet1'!C16

Sunday, October 24, 2010

DivX Player Compatible AVI video files

Recently I bought a DivX player provided with USB connection. I tried to play few .avi files from the memory stick. The DivX player isn't playing those .avi files saying invalid format.

Searched for a DivX converter from net. The platform is Ubuntu. Got a DivX converter and converted the .avi files to DivX Player Compatible AVI video format files. Now my DivX player is able to play those files.

Download: DivX Converter

Monday, September 27, 2010

Internationalization of glibc

Internationalization of a software refers to the process of making that software to adapt the user's favorite conventions. So internationalization of glibc means programming glibc to adapt the user's favorite conventions.

In glibc, internationalization is done using locales. Locales are collection of conventions. Locales should be specified via environment variables. There are standard locales such as 'C' and 'POSIX' that are supported by all operating systems (OS).

The glibc features that should be internationalized are categorized. Each category can be specified separately with a locale as the user wishes. The environment variable corresponding to each category should be defined for the same. The list of such environment variables are as follows:
  1. LC_COLLATE
  2. LC_CTYPE
  3. LC_MONETRY
  4. LC_NUMERIC
  5. LC_TIME
  6. LC_MESSAGES


If the user prefers to specify a single locale for all categories, then the user can use the environment variable 'LC_ALL'.

Failing to define locale may end up with error on running the glibc test-suites via 'make check'.

Skype on Ubuntu 10.04 LTS

In Ubuntu 10.04 LTS, skype is part of canonical partner repository. Hence the repository should be enabled to install skype.

Canonical partner repository shall be enabled using synaptic package manager.


Select the repository menu of synaptic package manager.


Select the 'other software' tab of repository. And enable the canonical partner repository.


Now open the Ubuntu software center.


Search for skype and install it.

Monday, September 20, 2010

Wireless network access in DELL VOSTRO 3400 with UBUNTU 10.04 OS

Enabling wireless access in DELL VOSTRO 3400 with UBUNTU 10.04 OS requires the Broadcom STA wireless proprietary driver. The driver can be installed as follows:

Go to System->Administration->Hardware Drivers



The proprietary drivers will be searched automatically.



The Broadcom STA wireless driver will be listed for activation.



On activation, the driver will be downloaded and installed.



The driver will be in use and the wireless networks can be accessed.

Thursday, September 2, 2010

Testsuite for gcc-2.95.3

I was supposed to run the gcc testsuite for verifying the gnu toolchain we are maintaining. The gcc version we use is a very old one (gcc-2.95.3). To my surprise, I found that the testsuite folder of gcc-2.95.3 is empty. I checked the previous versions of gcc-2.95.3 (gcc-2.9.2, gcc-2.9.2.1) also. Those versions has a folder for testsuite under gcc-2.95.x.x/gcc. But there is no test files within it.

On surfing, I found that during the time of gcc-2.95, testsuites weren't part of the release. They have used the c-torture testsuite which was maintained separately from gcc. Only from gcc-3.0 the testsuites are part of the gcc release.


And the tests with gcc-3.0 cannot be used for the versions earlier to it. This is because, from version 3.0 gcc conforms to c99 specification. Versions earlier to it don't follow the c99 specification. So, many tests written for gcc-3.0 would fail for the versions earlier to it. For example, tests with gcc-3.0 may fail for gcc-2.95.3 since it (2.95.3) doesn't follow c99 specification.


So for testing gcc-2.95.3, I used the c-torture testsuite which were once used for gcc-2.95. The c-torture testsuite itself has the scripts to run the tests. The readme file explains on running the tests. For cross compilers, the script to run the executable tests should be modified to generate the binaries of the tests. Then the binaries shall be loaded into the appropriate system for execution.

Thursday, August 19, 2010

Dhrystone and Whetstone

Dhrystone and whetstone are open source synthetic benchmark programs. These benchmarks are used in the following cases:
  • to measure and compare the performance of two different processors
  • to measure the performance of compilers for a processor

What is benchmark?

Benchmark is the standard based on which the performance is measured. Benchmarking is the act of measuring the performance of a system against a standard.

Benchmark programs are the set of programs which are used to assess the relative performance of a system. The benchmark programs are written such that they impose a particular type of workload on a system. And provide the metrics on the system performance for the workload imposed.

One way of writing the benchmark program is to first take the statistics of all the operations from various application program. Then, get the proportion of each operation and write the program based on the derived proportion. Thus created benchmark programs are called synthetic benchmark programs.


Dhrystone:

Dhrystone is the indicator of integer arithmetic performance. It stresses the ALU. Dhrystone doesn't contain any floating point operations. The name dhrystone is a pun on the name of another benchmark program "whetstone" (which is for floating point operations).

Dhrystone measures the performance in "Dhrystone per second". "Dhrystone per second" implies the number of times the program can run in a second.

Dhrystone doesn't provide the result in number of instructions per second. There is reason. Assume a task say 'x'. In a RISC machine, to accomplish this tasks it requires 2 instructions. Whereas the CISC machine requires 1 instruction. But the task 'x' is done faster in RISC machine than the CISC machine. So, here the performance measure in instruction count fails. Hence dhrystone performs the calculation in a machine specific way (of counting the number of program completion per second).

The main drawback of dhrystone is in most cases it is not the representation of the real-life programs. Also Dr. Reinhold Weicker who created Dhrystone says that “Although the Dhrystone benchmark that I published in 1984 was useful at the time, it cannot claim to be useful for modern workloads and CPUs because it is so short, it fits in on‐chip caches, and fails to stress the memory system. Also, because it is so short and does not read from an input file, special compiler optimizations can benefit Dhrystone performance more than normal program performance.”



Whetstone:

Whetstone is the indicator of floating point arithmetic performance. It stresses the FPU. Whetstone measures the performance in MWIPS (Million Whetstone Instructions Per Second). Whetstone is named after the town Whetstone in England where it was designed.

Whetstone mostly contains the floating point data and operations. In general, whetstone can be defined as the mix of operations that are typically performed in scientific applications.

The drawback of whetstone is, it doesn't show-up the advantages of architectures such as RISC. This is because, most of the variables in whetstone are global. Whereas, the large amount of processor registers that are available with RISC architectures would get exploited only for handling the local variables.


References:
http://en.wikipedia.org/wiki/Dhrystone
http://www.johnloomis.org/NiosII/dhrystone/ECLDhrystoneWhitePaper.pdf
http://dhrystone-benchmark.downloadaces.com/
http://www.dell.com/downloads/global/products/pedge/en/guide_to_server_benchmarks.pdf
http://www.keil.com/benchmarks/whetstone.asp
http://www.cse.dmu.ac.uk/~bb/Teaching/ComputerSystems/SystemBenchmarks/BenchMarks.html#whetstone
http://homepage.virgin.net/roy.longbottom/whetstone.htm
http://homepage.virgin.net/roy.longbottom/whetstone.pdf

Wednesday, August 18, 2010

My first usage of GTK!

Today I used the GTK for the first time. So what is GTK? GTK expands to GIMP ToolKit. GTK is the library to build graphical user interfaces. It is called GIMP ToolKit because, originally it was developed for the program GIMP (GNU Image Manipulation Program). Now many programs are using it.

I installed GTK in my ubuntu-9.10 desktop. With build essentials already with my system, I issued the following command at the terminal to install GTK+-2.0:

sudo apt-get install libgtk2.0-dev libgtk2.0-doc devhelp

libgtk2.0-dev installs the GTK library. libgtk2.0-doc and devhelp installs the documents of GTK and the browser for the documents respectively.

I wrote a simple hello world program. The program was written to create a window with a button on it. The button would have the label "Hello, World! Bye...". And once the button is clicked, the application would quit.

Download: helloworld_gtk.c

Compiled the hello world program and built the executable for the same by issuing the following command at the terminal:

gcc helloworld_gtk.c -o helloworld `pkg-config --cflags --libs gtk+-2.0`

Here,
  1. pkg-config is the program that reads the .pc which comes with GTK to determine what compiler switches are needed to compile programs that use GTK.
  2. pkg-config --cflags gtk+-2.0 will output a list of include directories for the compiler to look in
  3. pkg-config --libs gtk+-2.0 will output the list of libraries for the compiler to link with and the directories to find them in.

Monday, February 1, 2010

A study on genericizer in GCC

The need for genericizer in GCC depends on how well GENERIC can be made to match up with the source language that is supported in GCC front-end.

I.e. In GCC, if the parser for a language uses GENERIC as intermediate language representation, then a genericizer is not required. If the parser language uses any other intermediate language representation, then a genericizer is required to convert that intermediate language representation to GENERIC.

Note: Any intermediate language representation that seems appropriate for a language can be used. [Ref: Page 93 of GCC Internals for GCC version 4.4.0].


Hence there are following two cases:
  • Case1: Parser uses GENERIC as intermediate language representation
  • Case2: Parser uses any other intermediate language representation


Case1: Parser uses GENERIC as intermediate language representation


In this case, the language parser uses GENERIC and some language specific trees as intermediate language representation. [Ref: Page 93 of GCC Internals for GCC version 4.4.0]. The Gimplifier (which belongs to 'language-independent portions of the compiler') is called directly for the GENERIC representation generated by the parser.

The language specific trees which is generated along with the GENERIC by the parser would be converted into GIMPLE as follows [Ref: Page 201 of GCC Internals for GCC version 4.4.0]:

  1. Convert the language specific trees to GENERIC. And then provide the GENERIC to the Gimplifier to generate GIMPLE.
  2. Convert the language specific trees to GIMPLE straightly.
The above two tasks would be done by the gimplifier hooks [Ref: Page 199 of GCC Internals for GCC version 4.4.0]. Gimplifier hooks are the one that are used to over-ride the standard functions of Gimplifier. This over-riding of standard functions is required because of language specific trees generated as intermediate represenation by parser.

Example:

For C, the language specific trees are converted into GIMPLE straightly (without converting into GENERIC) by the gimplifier hooks [Ref: Page 201of GCC Internals for GCC version 4.4.0].



Case2: Parser uses any other intermediate language representation



In this case, the language parser uses its own intermediate language representation [Ref: Page 93 of GCC Internals for GCC version 4.4.0]. And for this intermediate language representation to be used by Gimplifier (which belongs to 'language-independent portions of the compiler'), it should be converted to GENERIC. For this we require a 'Genericizer'. Genericizer converts the intermediate language representation generated by the parser to the GENERIC form. Hence the genericizer would be the language dependent portion of the compiler.

Thus generated GENERIC is given to the gimplifier.

Example: