POSIX Threads and Joins – Parallel Programming – PART 1

During a long time we were “blessed” with computers that had only single CPU. The single CPU usually had a mediocre single core and thread. All software developed on that time executed sequential processing.

However, multi-cores and multi-threads processors were introduced in the market but if you do not develop your software trying to explore the hardware advantages your software might have the same performance if running in a single cpu machine.

You need to think also if you software will run in a computer isolated or if your software will be able to run in multiple computers sharing a common network and organize different tasks to resolve a common problem.

Today, I will write this post for my own reference using the POSIX threads and how to have the best usage of joins and mutex implementation. I am running in a ubuntu 10.04 but if you are running Windows you can use these examples installing the POSIX win32 compatibility module or installing Cygwin to simulate a linux shell.

Code compilation

All codes on this post were compiled using gcc and invoking the POSIX libraries thru command like under ubuntu 10.04. For example you can use:

gcc -pthread <my source code.c>

Threads

The first code is related to a model where we do not share the same memory space and there is no policy regarding the thread priorities or resources access management (although the threads runs in the same process sharing the same memory space this first example to resource are conflicted).

It is a simple code that creates 3 threads, passes arguments to them using strings and integers and then they are terminated.

Take a look in the code below:

Continue reading

I love a Duck! Why DuckDuckGo search engine is better than Google ?

I am kind of person – or alien as they call me in USA even being from Brazil not Mars :), that usually try different ways to improve how I study or work. I am using a new search engine and I am really loving it! Click in DuckDuckGo.com and try yourself.

Why DuckDuckGo ?

The quality of results and how you can filter are much more better than google search engine. Google already recognized them as a real competitor and looks like Mr Larry Page not dared to say “really bad job” as he did with new facebook graphic search.

Done based in github, perl5 and other open softwares, I will tell you why this search really rocks!

What they do ?

  1. do not track you !! it means privacy! Your personal information is safe!
  2. do not use bubble-filter !! Oh yeah this really makes different because I can have different type of results not based what the system “think” compatible with my profile
  3. They have a feature called !bang. Bangs are very cool.. if you wanna have all searches in a specific site you only add “!” following the site.. for example if you type in the search box “stamps!ebay” the search goes directly to ebay showing the search you did!!! The same can be done with facebook, amazon, and multiples sites.. some sites you have option to use bang with few words, for example, you can use “asus!a” to search in amazon.
  4. When you make a search if have a list with results and in front of each link there is a icon related to the site you searched. If you click in the icon instead the link, the engine re-searches and give you more results related to that site!
  5. There is not “NEXT PAGE”.. Only scroll and the new searches will be automatically loaded

Newton Raphson C++ class for float division and other functions

Some months ago when I was searching for a job, a company asked to write a class to evaluate float divisions and find srq() of a number using Microsoft Visual C++. But the challenge was in create a class to perform this operations avoiding the division operator “/”.

I decided to use a old methodology I learnt when I was in college, more specifically in the computer methods. The name of method is Newton Raphson.

About the Newton-Raphson’s Method

The idea is very simple… given a function you guess a initial x0. Then you evaluate the tangent function on that point using derivative function. You will have x1… then you do the same with x1, and even so… Continue reading

Booting…

My name is Manoel Ramon and I am addicted in software programming… this first post is a testimony about myself…

I was something around 10 years old when my cousin broke up with her boyfriend and he decided to try to reconnect with her thru me… well.. bad mistake 🙂
He showed up in my home with a personal computer.. it was a TK85 with amazing ROM 8Kb and RAM 16Kb based in Z80 processor… I could see loading programs using a regular tape (cassette) using a tape player and some wires..

After some minutes, the computer loaded a game in my TV !!! That was really cool!!! So, he left the computer with me and I started to read a BASIC MANUAL.

This was the first problem of my life:

10 PRINT "MANOEL RAMON"
20 GOTO 10

Then I typed “RUN” following ENTER

After this… I was totally addicted.. See the machine doing something that I created was fantastic.. Then, every morning I woke up at 7:00AM to watch a TV series called “Bits & Bytes” in the TV Cultura Brasil. This was a canadian TV series teaching people what is a personal computer, a processor, a interpreter, a computer program, how the memory works, etc.

After couple years I bough a revolutionary micro-computer called HOTBIT MSX Continue reading