Computer Scientist

Friday, 22 June 2012

Linux driver for the wifi on P8Z77-V-Deluxe

On Asus P8Z77 motherboard, a powerful wireless network card is provided. It is a dual wireless 802.11 a/b/g/n network card and is more powerful than that is provided by the pro version board, which is a single one with only one antenna without blue tooth. A fabulous set of drivers and utilities is included in the ASUS driver disk for Windows system. However, there is nothing coming with the package even a simple driver to Linux. I cannot found any thing in ASUS website, either.

It is not impossible to drive the wifi on P8Z77 in Linux. I got a box with the latest Fedora 17 32-bit installed. The kernel is 3.4.3 .

I installed a USB wireless card from Cisco Linksys AE1000 on my previous Linux box without too much difficulties. It is not hard to find some articles on the Internet to teach you to install it because the Linux driver is available to the public. The only troublesome task is to identify the correct chipset of the device, which is usually also the most basic and important task to install a device driver in Linux. The AE1000 uses the Ralink's chipset RT3572 according to a website. The Internet is a good tool to save me a lot of time and works to disassemble the network card, which would be a really massive task. Fortunately, the Ralink's official Linux driver is all over the Internet. Downloading, Unpacking and Installing will easily accomplish the task.

My sanguine about the Linux driver of the ASUS wifi go's card keeps until I saw someone's thread saying that the Deluxe version of p8z77 got a wireless network card from broadcom with very limited Linux drivers available on the Internet, especially the official Linux driver. I happened to find an official Linux version driver for broadcom chipset in the official website of the broadcom. However, for some reasons, it cannot be installed correctly because the compilation process is ending with an error message. Fortunately, I found another forum thread representing another method to install this driver.

The chip in the ASUS's board is BCM43228 according to the 'lspci' command in Linux. The only available method to drive this wireless card is to install the official Linux driver which is mentioned above. But, if the RPM fusion is installed in the system, the installation process can be accomplished by a yum installation command, which would be much more reliable. But bear in mind that, the non free repository of RPM fusion should also be installed. The name of package is 'kmod-wl'. However, it cannot be used in my case because I have upgraded my Linux kernel to 3.4.3. The kernel version of both kmod-wl and kmod-wl-PAE require some specific kernel version such as 3.4.2. So I have to use the last one 'akmod-wl', which is kernel version independent. I have successfully installed the driver of the network card by using this method.

In order to find much more information for the wireless network card with broadcom chip installation on Linux you should refer to:
http://forums.fedoraforum.org/showthread.php?t=239922
This guy maintained a very comprehensive article for broadcom chip's Linux installation.

Tuesday, 12 June 2012

How to estimate the order of magnitude of Factorial product

The Factorial of a number usually denotes a very big order of magnitude, especially for the computer world. In order to approximate the magnitude of the factorial of a number, it is necessary to find a method to represent the factorial of a number and to keep it into the computer memory. In my example, I am estimating the factorial of 200 which exceeds much more than the capability of any type of C programming language to keep it. An uniform method to represent this big number is important during the estimation. The only way to represent this gigantic big number is by using some smaller numbers that are with in the capability of a C compiler.

My method to represent a number is to use the prime numbers that is smaller that this number. The big number can be factorised into these prime number, so the big number can easily represented the some powers of these prime numbers. For example:

10! = 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10
      = 1 x 2 x 3 x ( 2 x 2 ) x 5 x ( 2 x 3 ) x 7 x ( 2 x 2 x 2 ) x ( 3 x 3 ) x ( 2 x 5 )
      = 28 x 34 x 52 x 7

In this case, the factorial of 10 can be represented by these four much smaller prime numbers: 2, 3, 5, 7 with their exponential numbers. Although it is difficult to reproduce the similar procedure for the factorial of 200 by sketching on the paper, the result of the factorial of 200 is not difficult to estimate, because the only difference of the factorial of 200 and that of 10 is the number of prime numbers involved. According to the prime number list referring to the wikipedia page, there are only 47 prime numbers smaller than 200. The factorial of 200 is easily represented by these prime numbers with their exponential numbers. The problem of finding all of the prime numbers smaller than a number is out of discussion of this thread. I will discuss it in more details in another thread.

When we've got the prime-numbers representation of the factorial number, the next task should be concerned is how to estimate its magnitude using this prime_number representation.

As the scientific representation is used to represent a big number, what we concern is the number zeros following the number if the first radix point is placed immediately after the first significant digit, for example, 1.23456 x 1020. The magnitude of this number is ten raised to power of 20. In other words, we are counting the number of zeros when we are talking about the magnitude of a number. The example mentioned above is for decimal number. As for the binary number, zero should still be the digit to be counted, but with different means.

I will give the method for decimal number magnitude estimation, firstly. In order to count the number zero which means a ten (10), we need to make a logarithm to the original number. Using the prime-number representation will make a more convenient way to calculate.

log10(10!) = log10(28 x 34 x 52 x 7)
                  = log(28) + log10(34) + log10(52) + log10(7)
                  = 8 x log10(2) + 4 x log10(3) + 2 x log10(5) + log10(7)

These much smaller prime-numbers logarithm is easily to be calculated. Then the number of zeros ( x 10) can be evaluated form this method.

As for a binary number the log2() should be used to calculate the number twos.

Tuesday, 8 May 2012

Using boost regular expression

It is really painful if you have tested the POSIX's regular expression functions with quite a lot of limitations. The good news is that I am not going to walk on the pure C programming for a further long time. Some C++ library's may save me at this point. The performance of my experiment monitor program is my most concern in the first place. It is not any more when I move to C++. There are two candidates that can be used as the regular experiment tool in my C++ programs: boost regex and TR1's regex. Maybe they share the same sources which is not my concerned; and I did not investigate that. According to my initial testing, they have different features during the development by using them.

Boost have a good compatibility across different present platforms: Windows, Linux and so on. The bad feature is that it requires to be linked against the boost_regex library which is different from most boost tools.

I have not looked into more details of TR1's regular expression. My insight told me that maybe it is still not exist in my system yet because it is a module of cxx11 standard. Really advanced and just don't use it.

If I got time, I will go back to do some investigation on these two tools with more sophisticated testing !!!

Friday, 27 April 2012

Chaos of the 'Places' menu

Today, the items in the menu of 'Places' on the above title bar of Fedora 14 are almost all lost from where they are, after I deleted everything in my home directory. Even after I copy back them from somewhere else, the items seems are lost completely without any recovery.

Google is the best way to solve problems. The config file to control these items are in the home directory named, '.config/user-dirs.dirs'. Each items are changed to be $HOME/. After the manual modifications on these incorrect config, Everything is back.

Monday, 16 April 2012

BE CAUTIONS: when you are using 'strncpy'

In my experiment results, an random error happened quite frequently. But it is not show itself in each time's experiment. It makes me be really frustrated as it is shown in a experiment. The PROBLEM is: an additional extra number always suffix the real number. Due to it happened randomly, which means that no patterns can be found from the situations it is shown, it is difficult to spot the problem's root cause.

What can I do at this point is to skim through the code where it probably happened from. Because this code is written with pure C instead of C++, the most possible reason should be the wrong memory pointer.

After the searching of man docs of the Linux, the reason is found --- the using of 'strncpy'.

When we copy a group of characters to a destination C-type string, a null-termination will be added to the destination automatically as 'strcpy' (without the 'n') is used. There are no problems at all.

However, the 'strncpy' is used, we need to think about the null-termination problem. As the statement of warning in the man doc, if the first 'n' characters of source C-type string have not null-termination in it. This function will not append the '\0' termination to the end of destination string automatically. This is not related to the size of destination string. We only need to be bare in mind the size of n and the first n characters of source string.

SOLUTION: add the '\0' termination to the destination string manually.

Wednesday, 28 March 2012

Stop auto clean the Fedora's /tmp directory

In Fedora, the files that stored in /tmp directory seems would be removed after a certain period of time without operation on it. Which kind of time (last modification time, create time or read time) can be set using different parameters when invoke a program named tmpwatch. Beware in mind, this works only in Fedora series. I am not sure for other Linux distributions.

The tmpwatch is a watching program that is invoked daily-based by cron. A script is also called tmpwatch is in /etc/cron.daily/ directory to invoke the program in /sbin directory.

In my case, I want to keep my file in /tmp directory without bothering with the tmpwatch's auto-removing. So I am able to set myself to be a exclude user by -U parameter for tmpwatch in shell scripts in cron directory.

And it should be work.

Friday, 2 March 2012

Add column to existing table

mysql how to add columnMany ways to add column to existing table in MySQL. If you r using GUI tools, add column to table in MySQL is easy. If you are using CLI, then here’s the command to add column in MySQL table.
To add column in existing table, you may refer to the 2 examples below:-
Example I: Add new varchar column to the end of the table
ALTER TABLE `tablename_here` ADD `new_column_name` VARCHAR( 255 ) NOT NULL ;
Example II: Add new integer column after an existing column in table
ALTER TABLE `tablename_here` ADD `new_column_name` INT NOT NULL AFTER `existing_column` ;
It’s simple to add column to existing table right? :)