Threads for beginers

I’m just new in all *nix.
And I don’t know if this is an OFF-TOPIC

I’m porting a game I made (Just begin to do) in Dos/Windows to Linux
(More posibilities and a lot of learning)
but I’m stalled with some questions:

Any good docs about threads, and SDL threads and handling?

Any good docs about X enviroment?

If I make all graphics in 800x600x16 and want others depths and
resolutions. Should I do this by scaling and
converting the pictures, or is better include pictures on others res?

Thanks very much

Any good docs about threads, and SDL threads and handling?

There are several sources on multithreaded process design. You won’t need
to learn all of it because, as yet, SDL does not support one of the basic
tennants of a multithreaded design: conditional variables. (I am looking
into the best way to integrate this into SDL because it’s something I
would like to see.)

What SDL supports is the creation of threads and handling of shared data
through mutexes. Windows supports these ideas as well, so it’s not just a
Unix thing.

Anyway, one of the main things to remember is that data available before a
thread is created is available to all threads created afterwords.
Global variables, passed-in data, etc. Multiple thread can read and write
to this at any time. That’s why mutexes exist. They ensure that no two
threads can do the same thing at the same time. (Assuming you use them
right.)

There is a newgroup called comp.programming.threads which deals directly
with these issues. Two web sites which can get you started are:

http://www.serpentine.com/~bos/threads-faq
http://www.LambdaCS.com

Hope these resources get you started.

Paul Braman
@Paul_BramanOn Wed, 15 Dec 1999, Gonzalo Aguilar Delgado wrote:

Datum: Mittwoch, 15. Dezember 1999 03:36

What SDL supports is the creation of threads and handling of shared data
through mutexes. Windows supports these ideas as well, so it’s not just a

What exactly is a mutex?Von: Paul Braman
An: Librerma SDL mail-list
Betreff: Re: [SDL] Threads for beginers

Greetings,

Christian Biesinger wrote:

Datum: Mittwoch, 15. Dezember 1999 03:36

What SDL supports is the creation of threads and handling of shared data
through mutexes. Windows supports these ideas as well, so it’s not just a

What exactly is a mutex?

A MUTually EXclusive lock. Mutexes provide one way of sharing data
between threads without corruption.

Regards,

Vee Schade
vschade at mindless.com> Von: Paul Braman

An: Librerma SDL mail-list
Betreff: Re: [SDL] Threads for beginers

Christian Biesinger wrote:

What exactly is a mutex?

A MUTually EXclusive lock. Mutexes provide one way of sharing data
between threads without corruption.

Essentially, when you have a piece of data, like a variable, that can be
access by multiple threads simultaneously, you use a mutex to make sure
only one thread accesses it at any one time.

lock_mutex()
do something
unlock_mutex()

Since only one thread can lock a mutex (all other threads that try to
lock it will wait until it is unlocked) only one thread can do the
"something" that is so important.

Consider a producer/consumer example. A producer thread puts a widget out
to be consumed and increments a counter. The consumer grabs the widget
and decrements the counter. If the producer and consumer access the
counter at the same time you can have race conditions and the like. A
mutex allows the “placing of widget and increment of counter” to be an
atomic operation with respect to other threads.

Paul Braman
@Paul_BramanOn Wed, 15 Dec 1999, Tony Cook wrote:

Gonzalo Aguilar Delgado wrote:

I’m just new in all *nix.
And I don’t know if this is an OFF-TOPIC

I’m porting a game I made (Just begin to do) in Dos/Windows to Linux
(More posibilities and a lot of learning)
but I’m stalled with some questions:

Any good docs about threads, and SDL threads and handling?

Any good OS book should have a chapter or two on threads and
interprocess communication (IPC). The latter is a far more important
topic, you’re going to find, once you start programming threads in
earnest, because they’re the means by which you control the threads. My
personal favorite is Andrew S. Tanenbaum’s (yes, the same guy who wrote
the Minix kernel on which Linux is ultimately based) book “Operating
Systems: Design and Implementation” (ISBN 971-8636-02-1). I like this
book because it discusses OS topics from a more practical standpoint
rather than the dull theory of most other books I’ve seen. There’s
even a listing of the Minix kernel there.

If I make all graphics in 800x600x16 and want others depths and
resolutions. Should I do this by scaling and
converting the pictures, or is better include pictures on others res?

Doing the former is all right, but your graphic quality will definitely
suffer, most especially if you want to support a resolution higher than
the one you originally start with. Scaling graphics is NOT a trivial
task, not if you want as little degradation in image quality as
possible. Your best bet really would be to go with the latter and make
graphics tuned to the different resolution. But if you’re scaling down
in size, I think it would be fine to go with the first strategy. You’ll
probably need to use some kind of filter so that your rescaling doesn’t
look so ugly. The theory behind this falls under some complex digital
signal processing, so if you need a hint on what to do email me
privately. And graphic scaling is a slow process, so it would be best
to do this at install time rather than at runtime…–

| Rafael R. Sevilla @Rafael_R_Sevilla |
| Instrumentation, Robotics, and Control Laboratory |

College of Engineering, University of the Philippines, Diliman

Christian Biesinger wrote:

Datum: Mittwoch, 15. Dezember 1999 03:36

What SDL supports is the creation of threads and handling of shared data
through mutexes. Windows supports these ideas as well, so it’s not just a

What exactly is a mutex?

A mutex is a particular type of interprocess communication (IPC)
primitive, that’s used to keep processes/threads from fighting over a
resource (such as the screen) and causing things like race conditions.
Without these things, chaos results when threads try to interact.
Tanenbaum’s book which I’ve described in another posting on this same
topic explains these entities in great detail.> Von: Paul Braman

An: Librerma SDL mail-list
Betreff: Re: [SDL] Threads for beginers

| Rafael R. Sevilla @Rafael_R_Sevilla |
| Instrumentation, Robotics, and Control Laboratory |

College of Engineering, University of the Philippines, Diliman

“Rafael R. Sevilla” wrote:

Any good OS book should have a chapter or two on threads and
interprocess communication (IPC). The latter is a far more important
topic, you’re going to find, once you start programming threads in
earnest, because they’re the means by which you control the threads. My
personal favorite is Andrew S. Tanenbaum’s (yes, the same guy who wrote
the Minix kernel on which Linux is ultimately based) book “Operating
Systems: Design and Implementation” (ISBN 971-8636-02-1). I like this
book because it discusses OS topics from a more practical standpoint
rather than the dull theory of most other books I’ve seen. There’s
even a listing of the Minix kernel there.

I’ve also liked Doug Lea’s Concurrent Programming in Java. It uses Java
as an implementation language but really is a book on concurrent
programming. There is a second edition out, which I haven’t seen yet.–
Marc Lepage
Software Developer
Molecular Mining Corporation
http://www.molecularmining.com/