The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
October 03, 2024, 03:13:36 pm
Home Help Search Login Register
News: Celebrating 30 years of Star Control 2 - The Ur-Quan Masters

+  The Ur-Quan Masters Discussion Forum
|-+  The Ur-Quan Masters Re-Release
| |-+  Technical Issues (Moderator: Death 999)
| | |-+  threads questions
« previous next »
Pages: [1] Print
Author Topic: threads questions  (Read 1666 times)
Rib Rdb
Frungy champion
**
Offline Offline

Gender: Male
Posts: 85



View Profile WWW
threads questions
« on: November 09, 2003, 12:35:57 pm »

Am I correct in understanding that the threads use cooperative multitasking?  Is there a list of the different tasks/threads and what they do?  Do the tasks use pointers to stack variables (I'm wondering if it would be possible to use something like what's described in the may or november 1995 Dr. Dobb's Journal for the task switching)
Logged
Michael Martin
Core Team
*Smell* controller
*****
Offline Offline

Posts: 387



View Profile
Re: threads questions
« Reply #1 on: November 10, 2003, 12:24:03 am »

No.  The *original* code used cooperative multitasking, but SDL threads are pre-emptive or (on OS 9) nonexistent.

We add a little bit of thread-local heap data (see /doc/devel/threads) but the raw mechanics of thread implementation are closest to a kernel-threads implementation of pthreads.  (This matches what Win32 and Linux do.)  BSD is messier; see below.

We just made "TaskSwitch" be "sleep for a millisecond", which generally signals that you're willing to give up your timeslice if anyone's waiting.

We've had to code almost as if we were using cooperative multitasking, though, because BSD's thread model is entirely in user space, and there have been cases of deadlocks that appear only in BSD that I believe have to do with the priority inversion problem (e.g., the thread is waiting on another one, but that other one never gets a chance to run because the waiting thread blocks the entire process.)

I say "almost as if" because I don't have the slightest clue whether there are sufficient TaskSwitch()es to make it work under cooperative threading conditions.

But if there are, then we could make this run under OS 9 too.

An ongoing long-term project is to diminish the number of threads the program uses, possibly to collapse them entirely.  There are some high-level decisions about that that still need to be made, though.
Logged
Rib Rdb
Frungy champion
**
Offline Offline

Gender: Male
Posts: 85



View Profile WWW
Re: threads questions
« Reply #2 on: November 10, 2003, 09:40:34 pm »

I just got word that eCos will run on an unmodified GBA, so I guess I'll try to get that working.  It supports preempting, and is probably going to be a lot better than anything I could write.  The recursive mutexes will have to be emulated though.  Are these only used by the graphics code? If so I'll probably wait on them until I have a better idea of how the graphics will work to see if the recursive mutexes will still be necessary on the GBA.
Logged
Michael Martin
Core Team
*Smell* controller
*****
Offline Offline

Posts: 387



View Profile
Re: threads questions
« Reply #3 on: November 11, 2003, 12:45:15 am »

The recursive mutexes are emulated already (in terms of normal mutexes).  The graphics code and the audio code both use them.
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!