Friday, August 20, 2010

Text mode Web Browsers in Ubuntu

Ubuntu Linux has Mozilla Firefox as its default web browser. But, I feel among the modern web-broswers, Chromium Web Browser (Google Chrome) works better than Firefox as far as Ubuntu is concerned. Mozilla Firefox gives slow Internet on Lucid Lynx (Ubuntu 10.04). However, this problem seems to be solved as Maverick Meerkat (Ubuntu 10.10) has come up with a nice fast Internet. Now, coming to the actual discussion, Ubuntu has two types of web-browsers predominantly which are listed below:
  1. Graphical-based Web Browsers
  2. Text-based Web Browsers
There are two text based web browsers that I mainly used:
  1. ELinks Web Browser
  2. Links Web Browser 

ELinks Web Browser:


The ELinks Web Browser supports only text based browsing and pictures are not displayed. ELinks is a feature-rich program for browsing the web in text mode.  It is like enhanced Lynx and Links. The navigation of the web pages is done through space (Page Down) and b (Page Up); Up and down arrows predominantly. Remember that this browser accommodates the contents of a website much like the "more" in UNIX. The URL of the currently viewed web page is not seen anywhere in the browser. When you click on the upper part of the Browser you get the menu bar.




Links Web Browser:


Links is a graphics and text mode WWW browser, similar to Lynx. It displays tables, frames, downloads on background, uses HTTP/1.1 keepalive connections. In graphics mode it displays PNG, JPEG, GIF, TIFF, and XBM pictures, runs external bindings on other types, and features anti-aliased font, smooth image zooming, 48-bit dithering, and gamma and aspect ratio correction. But the content is not well-organized a handicap when compared to the contemporary Web Browsers. The navigation is similar to the way as it is in other web browsers. The URL is shown at the top-right of the window. Take a look at the Yahoo home page viewed in the Links Web Browser.

Thursday, August 19, 2010

Switching between the X Window mode and the Command-line mode

Not many would like to work with the command-line in Linux (Ubuntu), but there may be a few geeks who want to try the command-line to really learn the commands. The third type of users want to use both the X-Window mode and the Command-line mode. The present post is specially targeted to such a kind of users.

To go to the command-line mode from the X window system, press the keys Ctrl+Alt+(F1-F6). Any one of the Function keys in between F1 and F6 is alright. Now for suppose, you want to switch to the graphical mode (X Window system) for some purpose, you can do with an easy shortcut Ctrl+Alt+F7.
   Switching from X window mode to command-line mode -- Ctrl+Alt+(F1-F6).
   Switching from command-line mode to X window mode -- Ctrl+Alt+F7.

main() function called inside main() definition --- C Language

Many think that when the main() function call inside the main(), recursion goes on infinite times. But it is not true as such. It is always  important to know how function calling and recursion works. The function calls work with the help of a stack by PUSHing all the functions to a stack and POPing the functions from the stack when they are executed. The following figure gives the complete picture of this working. When a function "func1()" is called from within the "main()" method, the "func1()" is PUSHed onto the stack. Similar is the case with the function "func2()". When the function "func2()" gets completed, it is POPed from the stack. The function calls take place until the stack overflow occurs, that is until the stack is completely filled with the functions. This implies that the recursion without a suitable condition takes place not infinite times but stack size times.
   

This particular experiment when conducted, compiles successfully but it suffers from a run time error.

Lets have a look at the functionality of this entire concept and thus decide the output of the program. We also experiment on the number of times the function is called. The entire simulation is with the help of a simple program as given below:

#include "stdio.h"
int i=0;
int main()
{
            i++;
            printf(" %d\n",i);
            main();           /* Call main() inside main() */
            return 0;
}

Now,in the above program the value of "i" signifies the number of times the function is called.

First, I considered running this program on Turbo C on Windows platform, where the size of a variable of type "int" is 2 bytes. When I ran this program, the function got called around 15000 times and then the compiler crashed with the error message in the image shown below:
The next time I tried the same program on GNU C compiler on Ubuntu 10.04, where the size of a variable of type "int" is 4 bytes. Now when the program is compiled, it returned successful compilation.



But when it is run, a runtime error was issued as "Segmentation fault". The error message in the dialog box for Turbo C also indicated the same thing.

Now what is this segmentation fault? It is an error that occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed. It occurred in this case due to the stack overflow. So, main() called inside main() gives segmentation fault.

The number of times the function call took place varies continuously between two executions of the program. In Turbo C, the number of times the function call took place is around 16000 while in GNU C Compiler, this figure is around 327000.
Related Posts Plugin for WordPress, Blogger...