.: Most Read :.

Join Churp Churp

Join Churp Churp
Click on the image to find out more
Showing posts with label Academic. Show all posts
Showing posts with label Academic. Show all posts

Friday, November 08, 2013

pthread and C program in Linux (Basic)

This example is suitable for those who are very new to pthread in C in Linux. You will learn on how to use pthread in C program. There is an additional code to be included during compiling the source code.

REQUIREMENT

  1. Linux Machine
  2. gcc
  3. pthread header file

Pthread header file is a standard file. You can just download from the internet from any sources available. (the file name is usually pthread.h)

STEPS

create a new directory, pthreadProgram

mkdir pthreadProgram

Go into the directory that you have created.

cd pthreadProgram

Place your downloaded pthread header file (pthread.h) into this directory.

now, create a new c file

vi tprog1.c

Write down the following codes:

//Program Name: tprog1
//PThread
#include <pthread.h>
#include <stdio.h>
#define NUM_THREADS 5
void *PrintHello(void *threadid)
{
    long tid;
    tid = (long)threadid;
    printf("Hello World! It's me, thread #%ld!\n", tid);
    pthread_exit(NULL);
}
int main (int argc, char *argv[])
{
    pthread_t threads[NUM_THREADS];
    int rc;
    long t;
    for(t=0; t<NUM_THREADS; t++){
        printf("In main: creating thread %ld\n", t);
        rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
        if (rc){
            printf("ERROR; return code from pthread_create() is %d\n", rc);
           
        }
    }
    /* Last thing that main() should do */
    pthread_exit(NULL);
}

Done with writing the source code.

Press Esc

Then :wq [write and quit vi tool]

In this example, we have fix the number of threads to be 5. You can adjust the

To compile, you can do this in many ways. For this time, we are going to use direct compilation method.

gcc -pthread tprog1.c -o tprog1

Note that you need to include “-pthread” option during compiling the program.

If there is no error, you may now execute your program

./tprog1

Thursday, November 07, 2013

Tutorial: Simple C in Linux (Ubuntu)

Create, and compile simple C file on Linux terminal.

Requirement:

You have updated and upgraded your Linux OS.

sudo apt-get update

sudo apt-get upgrade

Installed gcc

sudo apt-get install gcc

Installed make (optional)

sudo apt-get install make

 

Steps:

Login to your Linux machine.

vi sampleC.c

Press I to enter Insert mode.

Type the following C source code:

#include<stdio.h>

void main(void)

{

printf("Hello world\n");

}

Done with writing the source code.

Press Esc

Then :wq [write and quit vi tool]

To compile, you can do this in many ways;

Method 1 – direct compilation

gcc sampleC.c -o sampleC

or

Method 2 – compile using makefile

create a new make file

vi sampleMakefile

Type the following commands in makefile:

#applicationFile

all: sampleC

#.o file

   sampleC: sampleC.o

   gcc -o sampleC.o

#.c file

   sampleC.o: sampleC.c

   gcc -o sampleC.c

Done with writing the commands in makefile.

Note:

You may replace “sampleC” by using your own filename.

# is used for command.

Press Esc

Then :wq [write and quit vi tool]

Execute the make file

make -f sampleMakefile

Make sure there is no error.

Now, your program is ready to be executed.

./sampleC

Sample output:

Hello world

Wednesday, December 12, 2012

12-12-12 12:12

Wahai anak cucu ku,

Mak/Nenek nak bagi tau yang nenek dulu penah hidup pada tarikh 12-12-2012, 12:12pm. Masa ni mak/nenek berumur 24 tahun.

Masa ni, mak/nenek baru habis mengajar subject System Administration di Universiti Tenaga Nasional. Harap2 uni ni masih wujud pada zaman korang nanti.

Sekian.

Tuesday, October 09, 2012

Thermos Mug for Me and My Brother

I don’t know why I become a Starbucks-maniac recently. Their coffee does really works on me – hyperactive.

Back to the topic – thermos.

Last month I did get myself a thermos mug from Parkson. Alaaa tak nak la mahal2 yang sampai beratus2 and dalam kaca. Yang tu memang la panas. Hot drinks macam green tea and coffee are my favorites. Lepas 3 minggu pakai thermos tu… cap (penutup) plastik tu dah bengkok. – frustrated! 3 weeks! masak la nak beli for every month kan.

Masuk je gaji, I have decided to get a starbucks’ thermos for myself, and the other one for my brother – dia pernah cakap he wants thermos from Starbucks – tak nak from parkson. “demand!” – I replied.

B0812

Do you know that Starbucks ada card… macam touch n go card?

  • Bila register – dpt one complementary drink.
  • Bila beli thermos ni (melalui starbucks’ card – topup with minimum RM50) -  1 free drink for one thermos.
  • Discount RM2.00 for a drink if you bring your own starbucks cup/mug/thermos.

A lot more offers when you’ve registered your starbucks’ card.

Thursday, April 12, 2012

Morning call

8.20am

phone is ringing

Caller: "How are you doing?" bla.. bla... bla... "I want you to study about scientific LINUX"... "probably with MPI"

Of course no problem... my former supervisor who's going to be my future-colleague! I am glad you did tell me earlier.


will say hello to these monsters again.

Bismillah.

Wednesday, March 21, 2012

Open Day UNITEN 2012

poster Open day uniten

Hari ni keputusan SPM kan? How’s yours?

Mesti ramai tengah tengok2 IPT mana nak masuk lepas ni.

Jom weekend ni (24 March 2012) kita beramai-ramai ke UNITEN for UNITEN’s OPEN DAY. Ada College of Engineering, College of Information Technology, and also College of Business Administration. Not to forget, College of Graduate Studies (untuk masters and phd). Tengok the facilities and tenaga pengajar di UNITEN.

image

Source: http://www.uniten.edu.my/newhome/content_list.asp?Catid=364

Untuk college of IT, Untung2… next semester dapat belajar dengan saya. InshaAllah.

Mahal? In the middlelah sebab ada lagi uni yg 1 sem RM14K! Yuran in UNITEN is around RM6-7K for a semester. But I heard that budak tajaan YTN, MARA and JPA poket kencang. Siap ada elaun bulanan. (zaman aku dulu mana ada semua ni. Harap YTN n PTPTN jela)

You pay… for the quality. Memang quality pelajar UNITEN selalunya better than some of the other unis.

Ehhhhhh sape ntah yg kat tengah dalam poster tu?

;)

Laku lagi la muka ni untuk dijadikan poster. Nanti masa registration ada picture/poster lain lagi.

*wink 2 times*

IMG_3685

Location: TNB Bangsar

Wednesday, February 29, 2012

Big Smile

B0533

Status: Bergraduan

Program: Master of Information Technology

(^____^)

Tuesday, February 28, 2012

Parallel execution of distributed SVM using MPI (CoDLib)

That is the title of our (me, supervisor and co-supervisor) conference paper. Alhamdulillah ada jugak nama dalam IEEE Xplore. This paper has been presented in 2011 ICIMu International Conference. The journey is not easy. We took months to write it… and the conference fees is not cheap. Thank Allah all of the efforts (fees, review, ‘add-some-peppers’) in publishing this paper is mainly made by my supervisor and co-supervisor. Yes, thanks also to one of my loyal proof-read-friend, Nur Syahinaz. Her english (or anglais – French) is great. Stay loyal my dear. A lot more papers are coming.

imagehttp://ieeexplore.ieee.org/xpl/freeabs_all.jsp?reload=true&arnumber=6122723

Okay. What this paper is all about?

Support Vector Machine (SVM) is an efficient data mining approach for data classification. However, SVM algorithm requires very large memory requirement and computational time to deal with very large dataset. To reduce the computational time during the process of training the SVM, a combination of distributed and parallel computing method, CoDLib have been proposed. Instead of using a single machine for parallel computing, multiple machines in a cluster are used. Message Passing Interface (MPI) is used in the communication between machines in the cluster. The original dataset is split and distributed to the respective machines. Experiments results shows a great speed up on the training of the MNIST dataset where training time has been significantly reduced compared with standard LIBSVM without affecting the quality of the SVM.

Too technical? Let me explain in a simpler way.

There is an approach in data classification – SVM. But this method performs quite slow when dealing with large number of input (dataset). Due to that, we have proposed a combination of distributed and parallel computing method – CoDLib. By using this method, we used a cluster – consists of multiple computers. In the end, the training time taken the results give huge speed up compare to the original sequential program.

I am happy. Really happy. and of course my family will so proud of me. And this makes me nak write more conference paper in the future. I hope Allah will gives me a great team again.