Maku Times
Monday, April 25, 2005
  RE: This will THREAD your brains... Hi,

Finally, i finished this bare-bones implementation on the THREAD'ed problem. You can find the tarball here.

Unzip it & follow whats inside README. This is my interpretation of the result...

//pthread_join(thread_1, NULL);
//pthread_join(thread_2, NULL);

Since i dont allowed the threads to finish (as the problem didn't mentioned it), the value of "integer"...

//global variable
int integer=0;

...varies between 0 to 8. Most of the time, its zero as the "main" thread finishes before any of the children threads. If the first thread gets CPU, the value goes to 3 & in the best case, it goes to 8.

BUT, it does not goes beyond 8.

### Outputs ###
Makentoo thread # ./plusplus
Value of Integer before creating threads = 0
Creating Thread-1
Creating Thread-2
Inside Thread 1, integer = 1, loop=1
Inside Thread 1, integer = 2, loop=2
Inside Thread 1, integer = 3, loop=3
Value of Integer after creating threads = 3

Makentoo thread # ./plusplus
Value of Integer before creating threads = 0
Creating Thread-1
Creating Thread-2
Value of Integer after creating threads = 0

Makentoo thread # ./plusplus
Value of Integer before creating threads = 0
Creating Thread-1
Creating Thread-2
Value of Integer after creating threads = 0


...thats it!


For any comments/suggestions/flames...
http://makuchaku.blogspot.com
mayank[dot]gnu[at]gmail[dot]com 
Comments:
We supply new custom classic car seats for your classic sportscar in various configurations and designs. Whether you need a quality seat for a classic car restoration, a custom seat for a luxurious upgrade, or a high performance seat to meet the demands of racing or offroad motorsports we have the perfect seat for you. Get your classic car seats at http://www.classiccarseats.com.
 
Post a Comment

<< Home
Cut me... and I'll bleed Linux!






Name: makuchaku

Have a message?




Creator of the Linux Kernel

The man who started it all...
Hats off to you, Sir Torvalds!



My Piddi


Link IT Up Bloggers!
MakuChaku@Livejournal
Amritha
Saandu Bhai
AnkiPanki
HIM
D A Y A N I K A
Harpic
Manuj


I Support...
Get Firefox!   
My Browser

 Use OpenOffice.org
My Office App

My Distro


My Desktop

Powered by Blogger
My Blog


ARCHIVES
November 2004 / December 2004 / January 2005 / February 2005 / March 2005 / April 2005 / April 2007 /