Wednesday, June 9, 2010

ATI Mobility Radeon HD 5xxx Series in Linux (kernel 2.6.34)

The aim of this writting is to show how I got to install the ATI driver in Linux, using kernel 2.6.34.

First of all, I tried to download the driver from http://ati.amd.com/support/driver.HTML. Although there is not any driver for 5xxx series, we can use the 4xxx series driver: http://support.amd.com/us/gpudownload/linux/Pages/radeon_linux.aspx?type=2.4.2&product=2.4.2.3.32&lang=English

After downloaded the driver I gave execution permissions to the driver and just in case, put out xserver:

$ chmod +x ati-driver-installer-10-5-x86.x86_64.run
$/etc/init.d/gdm stop


Friday, May 14, 2010

MySQL fast configuration

Creating User:

create user pron@192.168.1.13 identified by 'pass';

This will create an user called pron that could connect from the host 192.168.1.13 to the MySQL server.

If we want to create an user that could connect only from localhost, we won't espicify the IP address.

Creating DataBase:

create database mydb;

Adding user to DataBase:

grant all on mydb.* to pron@192.168.1.13;

Monday, January 11, 2010

Pointers to functions in C

I'm going to show a silly example to describe how to use pointers to functions. They are very usefull. Imagine that you are in a loop and want to execute a function when the index's are odd numbers and another function in even numbers.

#include 
#include

void (*fp)(int);
void fun1(int a);
void fun2(int a);


main () {
int i=0;
fp=&fun1;
for(i;i<5;i++) {
(*fp)(i);
}
}


void fun1(int a) {
printf("Even number: %d\n",a);
fp=fun2;
}

void fun2(int a) {
printf("Odd number: %d\n",a);
fp=fun1;
}


Output:
Even number: 0
Odd number: 1
Even number: 2
Odd number: 3
Even number: 4


In the main method we set the first function to use. Then when we call a function, each function changes the function address to the other function. This way, we can avoid and if condition inside the loop.