05 Jun, 2007, Ugha wrote in the 1st comment:
Votes: 0
I'm not much of a linux guru… especially on the development side of things.

During my years as a mud coder, I've basicly only learned what I needed about linux
to keep the mud up and running… so I've got massive holes in my knowledge of
the operating system.

I know how DOS programming works… I know how Windows programming works (god
I hate microsoft) but I'm a little vague on linux.

The major thing I'm wondering is… how important is multithreading to Linux and
how is it done in C?
05 Jun, 2007, Tyche wrote in the 2nd comment:
Votes: 0
Ugha said:
The major thing I'm wondering is… how important is multithreading to Linux and
how is it done in C?


I can answer the latter. It works pretty much the same as it does in Windows except different named functions and locking primatives. I wrote an example mutlithreaded example server in C++, Paradigm 3, which ought to compile both in Windows and Unix. That it's C++ shouldn't present an obstacle as you'd do it the same way in C for the most part.
18 Oct, 2008, Runter wrote in the 3rd comment:
Votes: 0
If you happen to be using C++ you might look into the boost::thread library. It makes doing multiple threads for anything just about as easy as it gets for C or C++:

#include <boost/thread/thread.hpp>
#include <stdio.h>
using namespace boost;

void hello_world() {
printf("Hello world.\n");
}

int main(int argc, char* argv[]) {
thread t(&hello_world);

t.join();
return 0;
}


The above code will create a new thread and run our hello_world function in it.
join() simply waits for the thread in question to finish execution.
18 Oct, 2008, elanthis wrote in the 4th comment:
Votes: 0
Ugha said:
The major thing I'm wondering is… how important is multithreading to Linux and
how is it done in C?


It's just as important (or unimportant) as it is anywhere else. Chances are, if you think you need threading, you're doing something wrong. It's getting a little more important with multi-core systems, but the vast majority of applications have absolutely no need for threading and trying to use it will only make your application significantly more difficult to develop and maintain. Unless you actually have a workload that's pegging out an entire core, you don't need threads.

So far as how it's done, you want to look up "pthreads."

https://computing.llnl.gov/tutorials/pth...

If you want to learn advanced Linux/UNIX programming, I'd just suggest buying a book. Linux Application Development, Advanced UNIX Programming, etc. There are a number of decent books that cover the entirely of the Linux/UNIX development systems. Go to a bookstore, browse through books on the topic until you find one you find easy to read, and buy it. It won't be cheap, but I highly recommend it.

http://www.danlj.org/lad/ <– kinda basic, this is the one I started with years and years ago, now with a second edition
http://basepath.com/aup/ <– very in-depth, covers everything, but a bit obtuse for beginners in places
18 Oct, 2008, David Haley wrote in the 5th comment:
Votes: 0
Yay for thread necromancy :smile:

elanthis said:
Unless you actually have a workload that's pegging out an entire core, you don't need threads.

I'd add to this that threading will only help you if your workload is actually parallelizable. There's no point putting in threads if your task is inherently sequential.

Also as we said in the other thread (no pun intended), threading can help if you need to be able to react to events during some long, blocking computation.
18 Oct, 2008, Vassi wrote in the 6th comment:
Votes: 0
elanthis said:
There are a number of decent books that cover the entirely of the Linux/UNIX development systems. Go to a bookstore, browse through books on the topic until you find one you find easy to read, and buy it.


Just wanted to add that this is getting more and more difficult to do, every Barnes and Noble in my area - for instance - has reduced their tech-book section from 3-4 shelves to a single side of one shelf, half of which is usually Javascript something or other. Occasionally you'll find a Borders or something that has a huge selection but usually you have to buy online, which is unfortunate because I like to check the writer's style and the quality of the code samples before buying. I much prefer a book to a PDF.

On the flip-side, some of the big publishers have online libraries now where you can preview tech books as they're being written or take a look through some sample chapters. I'd still take the bookstore any day, though.
13 Nov, 2008, Kelvin wrote in the 7th comment:
Votes: 0
Just to echo what has already been said, it's definitely true that for most text-based games, threading is absolutely unnecessary if the developer approaches things with some semblance of planning and sane design. Unless you're doing some really odd stuff, you'll make your life much easier avoiding threads.

They're definitely good things to learn and use when appropriate, though. People just often use them when they are not in fact appropriate :)
13 Nov, 2008, David Haley wrote in the 8th comment:
Votes: 0
There was considerable discussion of multithreading and so forth in this forum thread.
0.0/8