brooksmoses: (Default)
[personal profile] brooksmoses
I just wrote my very first multithreaded program using pthreads. A very simple "Hello World" that creates a short array of thread numbers, and then creates a thread for each element in that array; each thread then loads its respective number from the array and prints out, "Hello, I am thread %d!"

Shortly thereafter, I debugged my first race condition in a multithreaded program.

I suppose this is the way of things, then?

Date: 2008-04-29 12:07 am (UTC)
From: [identity profile] technolope.livejournal.com
Are you planning to do complicated stuff with threads? Because OpenMP is a CFD programmer's best friend. (IMHO)

Of course, it doesn't help that classic old libraries like FishPak aren't thread-safe, no matter what OpenMP tricks you pull.

Date: 2008-04-29 12:19 am (UTC)
From: [identity profile] technolope.livejournal.com
OK. I always pictured OpenMP as the easy way to go multithreaded, and pthreads to be the backup method if OMP can't do what you want.

If you're going to be doing a lot of parallel programming in the future, I'd suggest the book "Patterns for Parallel Programming" as a good intro to the concepts and to OMP/MPI (the two methods that all the big labs use).

Date: 2008-04-29 09:59 am (UTC)
From: [identity profile] elisteran.livejournal.com
If you're going to be using shared memory, perhaps you can do it in terms of shared mmap regions and separate processes instead? One of the things about pthreads is how easy it is for separate threads to be modifying shared state.

Date: 2008-04-29 11:59 am (UTC)
From: [identity profile] bungo.livejournal.com
Heh. I wrote a hello world with pthreads just the other week, after fooling around with MPI years ago. I think I'd rather stick with some higher-level message passing than splash around in the racy deeps. Good luck.

pthreads

Date: 2008-07-15 11:41 pm (UTC)
From: [identity profile] peoppenheimer.livejournal.com
Welcome to the wacky world of asynchronous processes!
Page generated Jan. 20th, 2026 04:25 pm
Powered by Dreamwidth Studios